我正在使用 mpi4py 将处理任务分布在一组内核上。我的代码如下所示:
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
'''Perform processing operations with each processor returning
two arrays of equal size, array1 and array2'''
all_data1 = comm.gather(array1, root = 0)
all_data2 = comm.gather(array2, root = 0)
这将返回以下错误:
SystemError: Negative size passed to PyString_FromStringAndSize
我相信这个错误意味着存储的数据数组all_data1
超过了Python中数组的最大大小,这是很有可能的。
我尝试将其分成较小的部分,如下所示:
comm.isend(array1, dest = 0, tag = rank+1)
comm.isend(array2, dest = 0, tag = rank+2)
if rank == 0:
for proc in xrange(size):
partial_array1 = comm.irecv(source = proc, tag = proc+1)
partial_array2 = comm.irecv(source = proc, tag = proc+2)
但这会返回以下错误。
[node10:20210] *** Process received signal ***
[node10:20210] Signal: Segmentation fault (11)
[node10:20210] Signal code: Address not mapped (1)
[node10:20210] Failing at address: 0x2319982b
接下来是一大堆难以理解的类似路径的信息和最后一条消息:
mpirun noticed that process rank 0 with PID 0 on node node10 exited on signal 11 (Segmentation fault).
无论我使用多少个处理器,这似乎都会发生。
对于 C 中的类似问题,解决方案似乎巧妙地改变了recv
调用中参数的解析方式。使用 Python 的语法是不同的,所以如果有人能说明为什么会出现这个错误以及如何修复它,我将不胜感激。