1

私は一連の異なるプロセスにマトリックスを持っていますが、必ずしもすべて同じサイズであるとは限らないため、 comm.gather() または同等のものを使用できるとは思いません。したがって、私は独自の関数を作成しましたが、次の行で本当に奇妙なエラーが発生します。

self.test_array_global[list_count:list_count+ count_symbol_list[count+1]] = temp_ar

この行は、何らかの理由で self.test_array_global インデックスに正しくアクセスしていないようですが、このエラーが発生したためにわかりません。上記の self.test_array_global の形状を手動で設定しようとしても、まだ動作しないようです..

Traceback (most recent call last):
  File "AudModMPI.py", line 183, in <module>
    aud.get_test_array()
  File "AudModMPI.py", line 149, in get_test_array
    self.test_array_global[list_count:list_count+ count_symbol_list[count+1]] = temp_ar
ValueError: could not broadcast input array from shape (82,300,50) into shape (0,300,50)

関数全体は次のとおりです。

def get_test_array(self, to_rank=0):
    if rank != to_rank:
                comm.send(self.test_symbol_list, dest=to_rank, tag=20)
    if (rank == to_rank):
        itera = range(num_proc)
        itera.remove(to_rank)
        self.test_symbol_list_global = []
        self.test_symbol_list_global.extend(self.test_symbol_list)
        count_symbol_list = [len(self.test_symbol_list)]
        temp_list = None
        for i in itera:
            temp_list = comm.recv(source=i, tag=20)
            count_symbol_list.append(len(temp_list))
            self.test_symbol_list_global.extend(temp_list)

    if rank != to_rank:
        comm.Send(self.test_array[0:len(self.test_symbol_list)], dest=to_rank, tag=21)
    if rank == to_rank and num_proc > 1:
        self.test_array_global = zeros((count_symbol_list[-1], self.test_array.shape[1], self.test_array.shape[2]))
        list_count = 0
        for count, i in enumerate(itera):
            list_count += count_symbol_list[count]
            temp_ar = empty((count_symbol_list[count+1], self.test_array.shape[1], self.test_array.shape[2]))
            comm.Recv(temp_ar, source=i, tag=21)
            print rank, list_count
            print rank, count_symbol_list[count+1]
            self.test_array_global[list_count:list_count+ count_symbol_list[count+1]] = temp_ar

        self.test_array_global[0:len(self.test_symbol_list)] = self.test_array[0:len(self.test_symbol_list)]
4

0 に答える 0