In my MPI program, I need to write the results of some computation to a single (shared) file, where each MPI process writes its portion of the data at different offsets. Simple enough. I have implemented it like:
offset = rank * sizeof(double) * N;
for (i = 0; i < N; i++) {
data = ...;
MPI_File_write_at(file, offset, &data, 1, MPI_DOUBLE, &status);
offset += sizeof(double);
}
This is a bit simplified, as data
is actually an array, but let's assume that it is a single value for brevity. All the processes call this routine at the same time, and it works correctly. However, I am not sure is this the most optimal way to perform IO with MPI. Would using MPI_File_write_at_all
or MPI_File_write_ordered
lead to better performance?
Unfortunately, I have very limited time on the cluster (which has Lustre) so I cannot test all possible implementations extensively, and testing on my laptop will obviously not give me a good measure of IO performance.