发送数据:MPI_Type_contiguous vs 原始类型 [英] sending data: MPI_Type_contiguous vs primitive types

查看:142
本文介绍了发送数据:MPI_Type_contiguous vs 原始类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过两个进程交换数据(30 个字符)以将 MPI_Type_contiguous API 理解为:

I am trying to exchange data (30 chars) b/w two processes to understand the MPI_Type_contiguous API as:

char data[30];
MPI_Type_contiguous(10,MPI_CHAR,&mytype);
MPI_Type_commit(&mytype);
MPI_Send(data, 3,mytype,1, 99,MPI_COMM_WORLD);

但是可以通过以下方式完成类似的任务:

But the similar task could have been accomplished via :

MPI_Send(data, 30,MPI_CHAR,1, 99,MPI_COMM_WORLD);

我想没有延迟因素优势,因为我在两种情况下都只使用单个函数调用(或者是吗?).

I guess there is no latency factor advantage as i am using only single function call in both cases(or is it?).

谁能分享一个用例,其中 MPI_Type_contiguous 优于 原始类型(在性能/完成任务的难易度方面)?

Can anyone share a use case where MPI_Type_contiguous is advantageous over primitive types(in terms of performance/ease of accomplishing a task)?

推荐答案

立即想到的一种用途是发送非常大的消息.由于 MPI_Sendcount 参数属于 int 类型,因此在典型的 LP64(类 Unix 操作系统)或 LLP64(Windows)64 位操作系统不可能直接发送超过 231-1 个元素,即使 MPI 实现在内部使用 64 位长度.随着现代计算节点拥有数百 GiB 的 RAM,这变得很麻烦.解决方案是创建一个长度为 m 的新数据类型并发送新类型的 n 个元素,总共 n*m 个数据元素,其中 n*m 现在可以达到 262-232+1.该方法是面向未来的,也可以在 128 位机器上使用,因为 MPI 数据类型可以进一步嵌套.这种变通方法以及注册数据类型的成本(在执行时间上)比如此大的消息遍历网络所花费的时间要便宜得多这一事实被 MPI 论坛用来拒绝添加新的大计数 API 或修改现有参数类型.Jeff Hammond (@Jeff) 编写了一个来简化流程.

One use that immediately comes to mind is sending very large messages. Since the count argument to MPI_Send is of type int, on a typical LP64 (Unix-like OSes) or LLP64 (Windows) 64-bit OS it is not possible to directly send more than 231-1 elements, even if the MPI implementation is using internally 64-bit lengths. With modern compute nodes having hundreds of GiBs of RAM, this is becoming a nuisance. The solution is to create a new datatype of length m and send n elements of the new type for a total of n*m data elements, where n*m can now be up to 262-232+1. The method is future-proof and can also be used on 128-bit machines as MPI datatypes can be nested even further. This workaround and the fact that registering a datatype is way cheaper (in execution time) compared to the time it takes such large messages to traverse the network was used by the MPI Forum to reject the proposal for adding new large-count APIs or modifying the argument types of the existing ones. Jeff Hammond (@Jeff) has written a library to simplify the process.

另一个用途是在 MPI-IO 中.当使用MPI_File_set_view 设置文件视图时,可以提供一个连续的数据类型作为基本数据类型.它允许一个人例如在没有内置复数数据类型的语言(如早期版本的 C)中,以更简单的方式处理复数的二进制文件.

Another use is in MPI-IO. When setting the view of file with MPI_File_set_view, a contiguous datatype can be provided as the elementary datatype. It allows one to e.g. treat in a simpler way binary files of complex numbers in languages that do not have a built-in complex datatype (like the earlier versions of C).

这篇关于发送数据:MPI_Type_contiguous vs 原始类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆