做的方式,這是與MPI_TYPE_VECTOR
和MPI_TYPE_CREATE_HVECTOR
,但魔鬼在細節。現在
/* data[I][J][K] is I by J by K (stored in array 'dim_sizes[] = {I, J, K}'
and we want permuted[J][K][I] */
/* new innermost dimension is I items, strided across the old JK face*/
MPI_Type_vector(dim_sizes[0], 1, dim_sizes[1]*dim_sizes[2],
MPI_DOUBLE, &one_d);
MPI_Type_commit(&one_d);
/* new middle dimenson is K items, strided over the K row, which isn't
* actually a stride in this case. We use hvector here because we
* operate directly in terms of array items */
MPI_Type_create_hvector(dim_sizes[2], 1, sizeof(double), one_d, &two_d);
MPI_Type_commit(&two_d);
/* new outermost dimension is J items, strided over the old J row */
MPI_Type_create_hvector(dim_sizes[1], 1, dim_sizes[2]*sizeof(double), two_d,
&transposed_type);
MPI_Type_commit(&transposed_type);
可以喂transposed_type
您發送/接收來電或使您的MPI文件視圖。
您必須爲創建的每個數據類型調用'MPI_Type_commit'。 'MPI_Type_hvector'很長時間不推薦使用 - 應該使用'MPI_Type_create_hvector'來代替。我相應地編輯了你的答案。 –
在type_commit上很出色。我的個人偏好是提交最終類型而不是組成類型,因爲one_d和two_d將永遠不會用於發送/接收或file_set_view調用。還感謝您更新已棄用的type_hvector調用。 –
你是絕對正確的 - 沒有必要提交通信調用中未使用的類型,但是這樣做是一種很好的編程實踐,因爲稍後可能會決定使用其中一種中間類型。 –