接收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阵列作为 第一类语言构造
谢谢。问题是,我是一名初学者,对于根据进程数量分发数组片是不太自信的。循环运行的基本设计是否将工作的不同部分分配给不同的过程声音? –