简体   繁体   English

MPI衍生数据类型的好处是什么

[英]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. 假设我的proc 3d网格需要与所有最近的邻居通信2d数组。 I could simply store the 2d array as a 1d array to make the data contiguous and use send/recv. 我可以简单地将2d数组存储为1d数组,以使数据连续并使用send / recv。 Can I expect any performance benefit if I used eg Mpi_type_vector instead? 如果我改用例如Mpi_type_vector,可以期待任何性能提升吗?

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. 手动打包/解压缩需要更多代码,更多内存,但是例如, OpenMP可以减少打包/解压缩时间。

  • 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. 最重要的是,使用派生的数据类型可以节省将数据复制到缓冲区或从缓冲区复制数据的时间,但不一定总是最快的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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