接收3D陣列我有需要傳遞一些陣列發送/ MPI中
int main()
{
//...
//..Allocating many 3D,1D arrays and initializing fixed-value arrays
//..Initializing named constants here at compile time
//..initializing other constants at run time (not changed during the program runtime)
//...
for(int n=0;n<=1000;n++){
func1(); //Needs some 3D arrays to modify, some fixed-value arrays and lots of constants
func2(); //Same here
func3(); //Same here
}
//.. Data saving routines
return 0;
}
我正在考慮拆分它分爲MPI程序,像這樣
//Allocate all of the arrays
MPI_Comm_rank(MPI_Comm_World,&rank);
if(rank==0){
//Initialize all of the arrays and named constants
MPI_Bcast(); //Broadcasting all the constants and fixed-value arrays needed
MPI_ISend();//Send 3D arrays needed by func1()
MPI_ISend();//Send 3D arrays needed by func2()
MPI_ISend();//Send 3D arrays needed by func3()
MPI_IRecv();//Receive modified 3D arrays from func1()
MPI_IRecv();//Receive modified 3D arrays from func2()
MPI_IRecv();//Receive modified 3D arrays from func3()
MPI_Wait(); //For all responses to come in
}
for(int n=0;n<=1000;n++){
if(rank==1){
MPI_Recv();//Receive broadcast of constants and fixed value arraysfrom master
MPI_IRecv(); //Receive 3D arrays from master
func1(); //Modify 3D arrays
MPI_ISend(); //Send modified arrays back to master
}
else if(rank==2){
//Similar code
}
else if(rank==3){
//Similar code
}
}
MPI_Finalize();
我有一個計算程序兩個問題:
1)我繞過300x300x300 3D陣列除了30個常數
和多個被在運行時初始化的固定值的3D陣列的初始廣播。 這樣的設計是否會起作用?
2)如何去使用經過3D MPI_Datatypes陣列? C不支持3D陣列作爲 第一類語言構造
謝謝。問題是,我是一名初學者,對於根據進程數量分發數組片是不太自信的。循環運行的基本設計是否將工作的不同部分分配給不同的過程聲音? –