Skip to content

Commit

Permalink
Fixing bug in reorder_in; placing P3DFFT++ classes inside a scope to …
Browse files Browse the repository at this point in the history
…avoid interaction with MPI_Finalize
  • Loading branch information
Dmitry Pekurovsky committed Oct 22, 2020
1 parent 3b5b24c commit 707dc63
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build/exec.C
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ template <class Type> void reorder_in(Type *in,int mo1[3],int mo2[3],int dims[3]
for(j=0;j < d1[1];j+=nb23) {
j2 = min(j+nb23,d1[1]);
for(kk=k; kk < k2; kk++){
pin1 = tmp +kk*d1[0]*d1[1] +j*d1[0];
pin1 = tmp +kk*(d1[0]+1)*d1[1] +j*(d1[0]+1);
pout1 = in +kk +j*d1[0]*d1[2];
for(jj=j; jj < j2; jj++) {
pin = pin1;
Expand Down
48 changes: 24 additions & 24 deletions build/plan.C
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
else
printf("Error in init_trans_MPIplan: neither input %d nor output %d has current dimension as leading\n",gr1.mem_order[trans_dim_],gr2.mem_order[trans_dim_]);
// (p->trplan)->libplan = p->trplan->find_plan(p->trplan->trans_type);
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand All @@ -194,8 +194,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
else
printf("Error in init_trans_MPIplan: neither input %d nor output %d has current dimension as leading\n",gr1.mem_order[trans_dim_],gr2.mem_order[trans_dim_]);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand Down Expand Up @@ -229,8 +229,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int

// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
delete tmpgrid;
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand All @@ -244,8 +244,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
trans_MPIplan<double,complex_double> *p= new trans_MPIplan<double,complex_double>(gr1,*tmpgrid,gr2,mpicomm,d1,d2,type,trans_dim_);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
delete tmpgrid;
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand Down Expand Up @@ -283,8 +283,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
trans_MPIplan<mycomplex,float> *p = new trans_MPIplan<mycomplex,float>(gr1,*tmpgrid,gr2,mpicomm,d1,d2,type,trans_dim_);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
delete tmpgrid;
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand All @@ -298,8 +298,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
trans_MPIplan<complex_double,double> *p= new trans_MPIplan<complex_double,double>(gr1,*tmpgrid,gr2,mpicomm,d1,d2,type,trans_dim_);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
delete tmpgrid;
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand All @@ -324,8 +324,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
else
printf("Error in init_trans_MPIplan: neither input %d nor output %d has current dimension as leading\n",gr1.mem_order[trans_dim_],gr2.mem_order[trans_dim_]);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand All @@ -348,8 +348,8 @@ stage *init_trans_MPIplan(const grid &gr1,const grid &gr2,int mpicomm,int d1,int
else
printf("Error in init_trans_MPIplan: neither input %d nor output %d has current dimension as leading\n",gr1.mem_order[trans_dim_],gr2.mem_order[trans_dim_]);
// p->trplan->libplan = p->trplan->find_plan(p->trplan->trans_type);
if(p->trplan->plan == NULL) {
cout << "Error in trans_plan: null plan" << endl;
if(p->trplan->plan == NULL && !p->trplan->is_empty) {
cout << "Error in trans_MPIplan: null plan" << endl;
return(NULL);
}
else {
Expand Down Expand Up @@ -381,7 +381,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type

if(!p->trans_type->is_empty) {
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -397,7 +397,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
transplan<double,double> *p =new transplan<double,double>(gr1,gr2,type,d);
if(!p->trans_type->is_empty) {
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -414,7 +414,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
if(prec == 4) {
transplan<float,mycomplex> *p=new transplan<float,mycomplex>(gr1,gr2,type,d);
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -428,7 +428,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
else if(prec == 8) {
transplan<double,complex_double> *p=new transplan<double,complex_double>(gr1,gr2,type,d);
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -450,7 +450,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
if(prec == 4) {
transplan<mycomplex,float> *p=new transplan<mycomplex,float>(gr1,gr2,type,d);
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -464,7 +464,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
else if(prec == 8) {
transplan<complex_double,double> *p=new transplan<complex_double,double>(gr1,gr2,type,d);
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -481,7 +481,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
transplan<mycomplex,mycomplex> *p=new transplan<mycomplex,mycomplex>(gr1,gr2,type,d);
if(!p->trans_type->is_empty) {
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand All @@ -497,7 +497,7 @@ stage *init_transplan(const grid &gr1,const grid &gr2,const gen_trans_type *type
transplan<complex_double,complex_double> *p=new transplan<complex_double,complex_double>(gr1,gr2,type,d);
if(!p->trans_type->is_empty) {
// p->libplan = p->find_plan(p->trans_type);
if(p->plan == NULL) {
if(p->plan == NULL && !p->is_empty) {
cout << "Error in trans_plan: null plan" << endl;
return(NULL);
}
Expand Down
3 changes: 3 additions & 0 deletions sample/C++/test1D_cos.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ using namespace p3dfft;
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

// Read input parameters

if(myid == 0) {
Expand Down Expand Up @@ -247,6 +249,7 @@ using namespace p3dfft;

p3dfft_cleanup();

}
MPI_Finalize();
}

Expand Down
4 changes: 4 additions & 0 deletions sample/C++/test1D_cos_complex.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ using namespace p3dfft;
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

// Read input parameters

if(myid == 0) {
Expand Down Expand Up @@ -246,6 +248,8 @@ using namespace p3dfft;

p3dfft_cleanup();

}

MPI_Finalize();
}

Expand Down
3 changes: 3 additions & 0 deletions sample/C++/test1D_sin.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ using namespace p3dfft;
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{
// Read input parameters

if(myid == 0) {
Expand Down Expand Up @@ -245,6 +246,8 @@ using namespace p3dfft;

p3dfft_cleanup();

}

MPI_Finalize();
}

Expand Down
4 changes: 4 additions & 0 deletions sample/C++/test3D_c2c.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C++ test program. Running on %d cores\n",nprocs);
printf("GitVersion = %s\n", GIT_VERSION);
Expand Down Expand Up @@ -257,6 +259,8 @@ int main(int argc,char **argv)


cleanup();
}

MPI_Finalize();

}
Expand Down
3 changes: 3 additions & 0 deletions sample/C++/test3D_c2c_inplace.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C++ test program. Running on %d cores\n",nprocs);
printf("GitVersion = %s\n", GIT_VERSION);
Expand Down Expand Up @@ -258,6 +260,7 @@ int main(int argc,char **argv)


cleanup();
}
MPI_Finalize();

}
Expand Down
4 changes: 3 additions & 1 deletion sample/C++/test3D_r2c.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C++ test program. Running on %d cores\n",nprocs);
printf("GitVersion = %s\n", GIT_VERSION);
Expand Down Expand Up @@ -263,8 +265,8 @@ int main(int argc,char **argv)

// Clean up P3DFFT++ structures


cleanup();
}
MPI_Finalize();

}
Expand Down
4 changes: 4 additions & 0 deletions sample/C++/test3D_r2c_single.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C++ test program. Running on %d cores\n",nprocs);
printf("GitVersion = %s\n", GIT_VERSION);
Expand Down Expand Up @@ -261,6 +263,8 @@ int main(int argc,char **argv)


cleanup();

}
MPI_Finalize();

}
Expand Down
3 changes: 3 additions & 0 deletions sample/C++/test_deriv.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C test program. Running on %d cores\n",nprocs);
Expand Down Expand Up @@ -271,6 +272,8 @@ int main(int argc,char **argv)

cleanup();

}

MPI_Finalize();
}

Expand Down
3 changes: 3 additions & 0 deletions sample/C++/test_deriv2.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

if(myid == 0) {
printf("P3DFFT++ C test program. Running on %d cores\n",nprocs);
Expand Down Expand Up @@ -271,6 +272,8 @@ int main(int argc,char **argv)

cleanup();

}

MPI_Finalize();
}

Expand Down
4 changes: 4 additions & 0 deletions sample/C++/test_transplan.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ int main(int argc,char **argv)
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);

{

// Read input parameters

if(myid == 0) {
Expand Down Expand Up @@ -246,6 +248,8 @@ int main(int argc,char **argv)

p3dfft_cleanup();

}

MPI_Finalize();
}

Expand Down

0 comments on commit 707dc63

Please sign in to comment.