Exemple #1
0
inline static void
personal_save(char *fname, struct account *account)
{
    struct csv_header *header;
    struct csv_row *row;
    FILE *stream;

    if ((stream = fopen(fname, "w")) == NULL)
        ERROR("write personal: %s", fname);

    header = csv_read_header_from_string(DEFAULT_HEADER);
    prepare_header(header);
    row = csv_create_row(header);
    prepare_row(row, account);

    csv_write_header(stream, header);
    csv_write_row(stream, row);

    csv_destory_row(row);
    csv_destory_header(header);
    fclose(stream);
}
Exemple #2
0
void
prb_stopwatch_write_csv(prb_stopwatch_t* sw, const char* filepath,
                        int noperations, char** operation_names,
                        MPI_Comm comm, int mpi_master)
{
    int rank, size;
    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

    int tag=0;

    if (rank==mpi_master) {
        FILE* csv = fopen(filepath, "w");
        double* other_durations = malloc(sizeof(double)*noperations);
        MPI_Status status;

        csv_write_header(csv, operation_names, noperations);

        // For each rank, write on one line operation durations.
        int other_rank;
        for (other_rank = 0 ; other_rank < size ; other_rank++) {
            if (other_rank == rank) {
                csv_write_durations(csv, sw->durations, noperations);
            } else {
                MPI_Recv(other_durations, noperations, MPI_DOUBLE,
                         other_rank, tag, comm, &status);
                csv_write_durations(csv, other_durations, noperations);
            }
        }

        fclose(csv);
        free(other_durations);
    } else {
        MPI_Send(sw->durations, noperations, MPI_DOUBLE, mpi_master, tag, comm);
    }
};