Commit 2be21a13 authored by Marco Agnese's avatar Marco Agnese Committed by Steffen Müthing

use MPI_Get_address instead of MPI_Adress with MPI>=2

(cherry picked from commit 2125b283)
Signed-off-by: Steffen Müthing's avatarSteffen Müthing <muething@dune-project.org>
parent 9b55a240
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment