简体   繁体   中英

In MPI, what is non-blocking I/O used for?

What I assumed: non-blocking I/O is used to leverage the gap between data loading and computation. In another word, while loading the data, we can do some computations at the same time. Accordingly, the following program

MPI_File_read_at_all_begin(...);
... // do some computations
MPI_File_read_at_all_end(...);

should perform better than

MPI_File_read_at_all(...);
... // the same computations of the previous program

However, I didn't witness the expected result. Why? Did I misunderstand?

I fixed it by something like

{ // run with a thread
    MPI_File_read_at_all_begin(...);
    MPI_File_read_at_all_end(...);
}
... // do some computations

Non-blocking I/O or communication is used for efficiency. The problem with blocking calls is that you need to wait till the operation has completed. With non-blocking calls, you can issue some request (send, write, read,..) and test or wait later for the completion of the request (MPI_WAIT, MPI_TESt, MPI_WAITALL,..). Having said that, nonblocking operations usually start with an 'i' eg MPI_File_ i write_.. or MPI_File_ i read_..

Having said that, non-blocking are not always more effective. If you have a long computation phase, non-blocking operations are great as they can be hidden behind the computational phase (eg checkpointing). However, you need to make sure that the buffer used (eg for writing data to the disk) is not changed inside the computational phase until the writing operation compelets.

Looking into your code, you can see that you are using an blocking I/O operation. You function is described here

Take a look at the Manual at Section 6.12. There you can see how to use non-blocking collective MPI calls. Note that:

"Unlike point-to-point operations, nonblocking collective operations do not match with blocking collective operations,.."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM