2017-01-12 32 views
0

我正在嘗試爲2D子矩陣創建數據類型並使用MPI對其進行處理。我迄今發現的是this問題。對它的回答完全覆蓋了我的問題。我唯一無法理解的是如何計算子數組數據類型的範圍。任何解釋都會很有幫助。MPI中派生數據類型的範圍

這裏是代碼和答案複製到這個問題的聲明:

MPI_Datatype newtype; 
int sizes[2] = {6,6}; /* size of global array */ 
int subsizes[2] = {3,3}; /* size of sub-region */ 
int starts[2] = {0,0}; /* let's say we're looking at region "0", 
          which begins at index [0,0] */ 

MPI_Type_create_subarray(2, sizes, subsizes, starts, MPI_ORDER_C, MPI_INT, &newtype); 
MPI_Type_commit(&newtype); 

,我們不能只與這些類型的使用MPI_Scatter()(甚至scatterv),然而,因爲這些類型的有16個整數的範圍;

回答

0

事實上,我認爲這些有36個整數不是16的程度?無論如何,你認爲這個範圍意味着在Scatter或Scatterv操作中將子類型子類化並不容易。

您需要使用MPI_Type_create_resized將範圍修復爲更有用的範圍,例如,一個整數。

C - MPI - Send/Receive Subarrays to Array回答過類似的問題 - 一個更完整的解釋被張貼喬納森·德西在sending blocks of 2D array in C using MPI