diff --git a/dune/common/parallel/communicator.hh b/dune/common/parallel/communicator.hh index 2d5ac757a57d4f9119f2e7f6b4ced6879ad1ebfc..bcdebbbb701dfb143eaff07e551544716ad3b126 100644 --- a/dune/common/parallel/communicator.hh +++ b/dune/common/parallel/communicator.hh @@ -419,8 +419,13 @@ namespace Dune { IndexedTypeInformation& info=information_[proc]; assert((info.elements)<info.size); + #if MPI_2 + MPI_Get_address( const_cast<void*>(CommPolicy<V>::getAddress(data_, local)), + info.displ+info.elements); + #else MPI_Address( const_cast<void*>(CommPolicy<V>::getAddress(data_, local)), info.displ+info.elements); + #endif info.length[info.elements]=CommPolicy<V>::getSize(data_, local); info.elements++; } @@ -1006,7 +1011,11 @@ namespace Dune IndexedTypeInformation& info=dataInfo.information_[process->first]; // Shift the displacement MPI_Aint base; + #if MPI_2 + MPI_Get_address(const_cast<void *>(CommPolicy<V>::getAddress(data, 0)), &base); + #else MPI_Address(const_cast<void *>(CommPolicy<V>::getAddress(data, 0)), &base); + #endif for(int i=0; i< info.elements; i++) { info.displ[i]-=base; diff --git a/dune/common/parallel/indicessyncer.hh b/dune/common/parallel/indicessyncer.hh index 1d38ccb06ba8f7287e7b77bd466a7a38b234eb4f..178464e8617c2dc08f3feedc4f1d68cc24304e70 100644 --- a/dune/common/parallel/indicessyncer.hh +++ b/dune/common/parallel/indicessyncer.hh @@ -640,11 +640,20 @@ namespace Dune // Compute displacement MessageInformation message; + #if MPI_2 + MPI_Get_address( &(message.publish), displacement); + MPI_Get_address( &(message.pairs), displacement+1); + #else MPI_Address( &(message.publish), displacement); MPI_Address( &(message.pairs), displacement+1); + #endif // Make the displacement relative + #if MPI_2 + MPI_Get_address(&message, &base); + #else MPI_Address(&message, &base); + #endif displacement[0] -= base; displacement[1] -= base; diff --git a/dune/common/parallel/mpihelper.hh b/dune/common/parallel/mpihelper.hh index fd8822c6ffde84a447ccc724a48d0a51e967f568..bcbcd0992258d8ee599436d81ce0d54b8a3618c5 100644 --- a/dune/common/parallel/mpihelper.hh +++ b/dune/common/parallel/mpihelper.hh @@ -261,14 +261,14 @@ namespace Dune //! \brief calls MPI_Finalize ~MPIHelper() { -#ifdef MPI_2 +#if MPI_2 int wasFinalized = -1; MPI_Finalized( &wasFinalized ); if(!wasFinalized) { #endif MPI_Finalize(); dverb << "Called MPI_Finalize on p=" << rank_ << "!" <<std::endl; -#ifdef MPI_2 +#if MPI_2 } #endif diff --git a/dune/common/parallel/mpitraits.hh b/dune/common/parallel/mpitraits.hh index e22ce48b142f563ab86e8b9611ad08d2449e95a4..222e517ad39c95d240e820eb27131d3ff1674035 100644 --- a/dune/common/parallel/mpitraits.hh +++ b/dune/common/parallel/mpitraits.hh @@ -97,12 +97,21 @@ namespace Dune FieldVector<K,n> fvector; MPI_Aint base; MPI_Aint displ; + #if MPI_2 + MPI_Get_address(&fvector, &base); + MPI_Get_address(&(fvector[0]), &displ); + #else MPI_Address(&fvector, &base); MPI_Address(&(fvector[0]), &displ); + #endif displ -= base; int length[1]={1}; + #if MPI_2 + MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); + #else MPI_Type_struct(1, length, &displ, &vectortype, &datatype); + #endif MPI_Type_commit(&datatype); } return datatype; @@ -134,11 +143,20 @@ namespace Dune bigunsignedint<k> data; MPI_Aint base; MPI_Aint displ; + #if MPI_2 + MPI_Get_address(&data, &base); + MPI_Get_address(&(data.digit), &displ); + #else MPI_Address(&data, &base); MPI_Address(&(data.digit), &displ); + #endif displ -= base; int length[1]={1}; + #if MPI_2 + MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); + #else MPI_Type_struct(1, length, &displ, &vectortype, &datatype); + #endif MPI_Type_commit(&datatype); } return datatype; @@ -171,13 +189,24 @@ namespace Dune MPITraits<T2>::getType(), MPI_UB}; std::pair<T1,T2> rep[2]; length[0]=length[1]=length[2]=length[3]=1; + #if MPI_2 + MPI_Get_address(rep, disp); // lower bound of the datatype + MPI_Get_address(&(rep[0].first), disp+1); + MPI_Get_address(&(rep[0].second), disp+2); + MPI_Get_address(rep+1, disp+3); // upper bound of the datatype + #else MPI_Address(rep, disp); // lower bound of the datatype MPI_Address(&(rep[0].first), disp+1); MPI_Address(&(rep[0].second), disp+2); MPI_Address(rep+1, disp+3); // upper bound of the datatype + #endif for(int i=3; i >= 0; --i) disp[i] -= disp[0]; + #if MPI_2 + MPI_Type_create_struct(4, length, disp, types, &type); + #else MPI_Type_struct(4, length, disp, types, &type); + #endif MPI_Type_commit(&type); } return type; diff --git a/dune/common/parallel/plocalindex.hh b/dune/common/parallel/plocalindex.hh index 994cf4b0d45dfe1f81c70f77903e0b6f24557730..e371545d81d56c0eddf95d1439f63d651d162a99 100644 --- a/dune/common/parallel/plocalindex.hh +++ b/dune/common/parallel/plocalindex.hh @@ -294,9 +294,15 @@ namespace Dune MPI_Datatype types[3] = {MPI_LB, MPITraits<char>::getType(), MPI_UB}; ParallelLocalIndex<T> rep[2]; length[0]=length[1]=length[2]=1; + #if MPI_2 + MPI_Get_address(rep, disp); // lower bound of the datatype + MPI_Get_address(&(rep[0].attribute_), disp+1); + MPI_Get_address(rep+1, disp+2); // upper bound of the datatype + #else MPI_Address(rep, disp); // lower bound of the datatype MPI_Address(&(rep[0].attribute_), disp+1); MPI_Address(rep+1, disp+2); // upper bound of the datatype + #endif for(int i=2; i >= 0; --i) disp[i] -= disp[0]; MPI_Type_struct(3, length, disp, types, &type); diff --git a/dune/common/parallel/remoteindices.hh b/dune/common/parallel/remoteindices.hh index f224ba68516a968c712e82695dea26d6e712dd3e..fc0cd13c8c5656b43bba4a021bf9c173d41e605c 100644 --- a/dune/common/parallel/remoteindices.hh +++ b/dune/common/parallel/remoteindices.hh @@ -891,10 +891,17 @@ namespace Dune { MPITraits<ParallelLocalIndex<TA> >::getType(), MPI_UB}; IndexPair<TG,ParallelLocalIndex<TA> > rep[2]; length[0]=length[1]=length[2]=length[3]=1; + #if MPI_2 + MPI_Get_address(rep, disp); // lower bound of the datatype + MPI_Get_address(&(rep[0].global_), disp+1); + MPI_Get_address(&(rep[0].local_), disp+2); + MPI_Get_address(rep+1, disp+3); // upper bound of the datatype + #else MPI_Address(rep, disp); // lower bound of the datatype MPI_Address(&(rep[0].global_), disp+1); MPI_Address(&(rep[0].local_), disp+2); MPI_Address(rep+1, disp+3); // upper bound of the datatype + #endif for(int i=3; i >= 0; --i) disp[i] -= disp[0]; MPI_Type_struct(4, length, disp, types, &type);