简体   繁体   中英

What's the benefit of mpi derived datatypes

Let's suppose my 3d grid of procs needs to communicate 2d arrays with all nearest neighbors. I could simply store the 2d array as a 1d array to make the data contiguous and use send/recv. Can I expect any performance benefit if I used eg Mpi_type_vector instead?

Basically, you can manually pack/unpack the data to/from a contiguous buffer or used a derived datatype.

  • manual pack/unpack requires more code, more memory, but packing/unpacking time can be reduced by OpenMP for example.

  • a derived datatype requires less code, less memory, but data is generally packed/unpacked under the hood and this is generally performed by a single thread.

Bottome line, using a derived datatype saves you copying data to/from a buffer, but might not always be the fastest option.

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