I want to use MPI IO to write files. The processes is in a while loop and it calls a function which generates random amount of data. I want to write this data to a single file. How can I accomplish this?
Asked
Active
Viewed 223 times
2 Answers
0
It might help you:
But maybe you ll need to pass a variable which contains the start point of every process..

user2076694
- 806
- 1
- 6
- 10
-
I have already checked that out. Actually I do not know how much offset or displacement is required. – vishesh Mar 17 '14 at 14:34
0
in each iteration of your while loop, each process knows how much data will be written. Use MPI_SCAN to share that data, then MPI_File_write_at_all to write collectively:
incr = generate_random_data();
MPI_Scan(&incr, &new_offset, 1, MPI_LONG_LONG_INT,
MPI_SUM, MPI_COMM_WORLD);
new_offset -= incr;
ret = MPI_File_write_at_all(mpi_fh, new_offset, buf, count,
datatype, status);

Rob Latham
- 5,085
- 3
- 27
- 44