Skip to content

Commit 5809272

Browse files
committed
test: add fence to perf test
1 parent f2f6f7b commit 5809272

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/mpi/romio/test/perf.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,55 @@ int main(int argc, char **argv)
158158
}
159159
}
160160

161+
flag = 0;
162+
for (j = 0; j < ntimes; j++) {
163+
MPI_CHECK(MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
164+
MPI_MODE_RDWR, MPI_INFO_NULL, &fh));
165+
MPI_CHECK(MPI_File_seek(fh, mynod * SIZE, MPI_SEEK_SET));
166+
167+
MPI_Barrier(MPI_COMM_WORLD);
168+
stim = MPI_Wtime();
169+
MPI_CHECK(MPI_File_write(fh, buf, SIZE, MPI_BYTE, &status));
170+
err = MPI_File_fence(fh);
171+
write_tim = MPI_Wtime() - stim;
172+
if (err == MPI_ERR_UNKNOWN) {
173+
flag = 1;
174+
break;
175+
}
176+
177+
MPI_CHECK(MPI_File_close(&fh));
178+
179+
MPI_Barrier(MPI_COMM_WORLD);
180+
181+
MPI_CHECK(MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
182+
MPI_MODE_RDWR, MPI_INFO_NULL, &fh));
183+
MPI_CHECK(MPI_File_seek(fh, mynod * SIZE, MPI_SEEK_SET));
184+
185+
MPI_Barrier(MPI_COMM_WORLD);
186+
stim = MPI_Wtime();
187+
MPI_CHECK(MPI_File_read(fh, buf, SIZE, MPI_BYTE, &status));
188+
read_tim = MPI_Wtime() - stim;
189+
190+
MPI_CHECK(MPI_File_close(&fh));
191+
192+
MPI_Allreduce(&write_tim, &new_write_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
193+
MPI_Allreduce(&read_tim, &new_read_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
194+
195+
min_read_tim = (new_read_tim < min_read_tim) ? new_read_tim : min_read_tim;
196+
min_write_tim = (new_write_tim < min_write_tim) ? new_write_tim : min_write_tim;
197+
}
198+
199+
if (mynod == 0) {
200+
if (flag)
201+
fprintf(stderr, "MPI_File_sync returns error.\n");
202+
else {
203+
read_bw = (SIZE * nprocs) / (min_read_tim * 1024.0 * 1024.0);
204+
write_bw = (SIZE * nprocs) / (min_write_tim * 1024.0 * 1024.0);
205+
fprintf(stderr, "Write bandwidth including file fence = %f Mbytes/sec\n", write_bw);
206+
fprintf(stderr, "Read bandwidth after file fence = %f Mbytes/sec\n", read_bw);
207+
}
208+
}
209+
161210
free(buf);
162211
free(filename);
163212
MPI_Finalize();

0 commit comments

Comments
 (0)