相关疑难解决方法(0)

mpi4py Scatterv 函数沿哪个轴拆分 numpy 数组?

我使用以下 MWEcomm.Scatterv并将comm.Gatherv其分布在给定数量的内核 ( size)

import numpy as np
from mpi4py import MPI
import matplotlib.pyplot as plt

comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()

if rank == 0:
    test = np.random.rand(411,48,52,40) #Create array of random numbers
    outputData = np.zeros(np.shape(test))
    split = np.array_split(test,size,axis = 0) #Split input array by the number of available cores

    split_sizes = []

    for i in range(0,len(split),1):
        split_sizes = np.append(split_sizes, len(split[i]))

    displacements = np.insert(np.cumsum(split_sizes),0,0)[0:-1]

    plt.imshow(test[0,0,:,:])
    plt.show()

else:
#Create variables on other …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy mpi4py

1
推荐指数
1
解决办法
4622
查看次数

标签 统计

arrays ×1

mpi4py ×1

numpy ×1

python ×1