UnstructuredParaSUPPORT.cxx\
ElementLocator.cxx\
ExplicitTopology.cxx\
-ICoCoMEDField.cxx
+ICoCoMEDField.cxx \
MPI_Access.cxx \
MPI_AccessDEC.cxx \
TimeInterpolator.cxx \
BIN_CLIENT_IDL =
TEST_PROGS = test_ProcessorGroup test_BlockTopology test_ParaStructuredSupport \
-test_ParaField test_DEC test_UnstructuredDEC test_ExplicitDEC test_IntersectionDEC test_SeqIntersectionDEC test_Seq3DsurfIntersection test_MEDMEMConstructor make_cylinder make_plane test_INTERPOL_2D test_IntersectionDEC3D test_ICoCoMEDField
+test_ParaField test_DEC test_UnstructuredDEC test_ExplicitDEC test_IntersectionDEC test_SeqIntersectionDEC test_Seq3DsurfIntersection test_MEDMEMConstructor make_cylinder make_plane test_INTERPOL_2D test_IntersectionDEC3D test_ICoCoMEDField test_MPI_Access_Send_Recv test_MPI_Access_Cyclic_Send_Recv test_MPI_Access_SendRecv test_MPI_Access_ISend_IRecv test_MPI_Access_Cyclic_ISend_IRecv test_MPI_Access_ISendRecv test_MPI_Access_Probe test_MPI_Access_IProbe test_MPI_Access_Cancel test_MPI_Access_Send_Recv_Length test_MPI_Access_ISend_IRecv_Length test_MPI_Access_ISend_IRecv_Length_1 test_MPI_Access_Time test_MPI_Access_Time_0 test_AllToAllDEC test_AllToAllvDEC test_AllToAllTimeDEC test_AllToAllvTimeDEC test_MPI_Access_ISend_IRecv_BottleNeck test_AllToAllvTimeDoubleDEC
LDFLAGS+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
LDFLAGSFORBIN+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
CPPUNIT_TEST(testBlockTopology_constructor);
CPPUNIT_TEST(testBlockTopology_serialize);
CPPUNIT_TEST(testIntersectionDEC_2D);
+ CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D);
CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpDEC_2D);
CPPUNIT_TEST(testSynchronousEqualIntersectionDEC_2D);
CPPUNIT_TEST(testSynchronousFasterSourceIntersectionDEC_2D);
void testIntersectionDEC_2D();
void testNonCoincidentDEC_2D();
void testNonCoincidentDEC_3D();
+ void testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D();
void testSynchronousEqualIntersectionWithoutInterpDEC_2D();
void testSynchronousEqualIntersectionDEC_2D();
void testSynchronousFasterSourceIntersectionDEC_2D();
const std::string& meshname2,
int nbprocsource);
void testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA,
- double dtB, double tmaxB, bool Asynchronous, bool WithInterp );
+ double dtB, double tmaxB,
+ bool WithPointToPoint, bool Asynchronous, bool WithInterp );
};
cout << "end of IntersectionDEC_2D test"<<endl;
}
+//Synchronous tests without interpolation with native mode (AllToAll(v) from lam/MPI:
+void ParaMEDMEMTest::testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,false,false,false);
+}
+
//Synchronous tests without interpolation :
void ParaMEDMEMTest::testSynchronousEqualIntersectionWithoutInterpDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,false,false);
+ testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,true,false,false);
}
//Synchronous tests with interpolation :
void ParaMEDMEMTest::testSynchronousEqualIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,false,true);
+ testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,true,false,true);
}
void ParaMEDMEMTest::testSynchronousFasterSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.09,1,0.1,1,false,true);
+ testAsynchronousIntersectionDEC_2D(0.09,1,0.1,1,true,false,true);
}
void ParaMEDMEMTest::testSynchronousSlowerSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.11,1,0.1,1,false,true);
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.1,1,true,false,true);
}
void ParaMEDMEMTest::testSynchronousSlowSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.11,1,0.01,1,false,true);
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.01,1,true,false,true);
}
void ParaMEDMEMTest::testSynchronousFastSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.01,1,0.11,1,false,true);
+ testAsynchronousIntersectionDEC_2D(0.01,1,0.11,1,true,false,true);
}
//Asynchronous tests with interpolation :
void ParaMEDMEMTest::testAsynchronousEqualIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,true,true);
+ testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1,true,true,true);
}
void ParaMEDMEMTest::testAsynchronousFasterSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.09,1,0.1,1,true,true);
+ testAsynchronousIntersectionDEC_2D(0.09,1,0.1,1,true,true,true);
}
void ParaMEDMEMTest::testAsynchronousSlowerSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.11,1,0.1,1,true,true);
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.1,1,true,true,true);
}
void ParaMEDMEMTest::testAsynchronousSlowSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.11,1,0.01,1,true,true);
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.01,1,true,true,true);
}
void ParaMEDMEMTest::testAsynchronousFastSourceIntersectionDEC_2D()
{
- testAsynchronousIntersectionDEC_2D(0.01,1,0.11,1,true,true);
+ testAsynchronousIntersectionDEC_2D(0.01,1,0.11,1,true,true,true);
}
/*!
* the other one receives with dtB as an interval, the max time being tmaxB
*/
void ParaMEDMEMTest::testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA,
- double dtB, double tmaxB, bool Asynchronous, bool WithInterp )
+ double dtB, double tmaxB, bool WithPointToPoint, bool Asynchronous,
+ bool WithInterp )
{
int size;
int rank;
if ( WithInterp ) {
dec.setOption("TimeInterpolation",LinearTimeInterp);
}
- dec.setOption("AllToAllMethod",PointToPoint);
+ if ( WithPointToPoint ) {
+ dec.setOption("AllToAllMethod",PointToPoint);
+ }
+ else {
+ dec.setOption("AllToAllMethod",Native);
+ }
dec.synchronize();
dec.setOption("ForcedRenormalization",false);
for (double time=0; time<tmaxA+1e-10; time+=dtA)
if ( WithInterp ) {
dec.setOption("TimeInterpolation",LinearTimeInterp);
}
- dec.setOption("AllToAllMethod",PointToPoint);
+ if ( WithPointToPoint ) {
+ dec.setOption("AllToAllMethod",PointToPoint);
+ }
+ else {
+ dec.setOption("AllToAllMethod",Native);
+ }
dec.synchronize();
dec.setOption("ForcedRenormalization",false);
vector<double> times;
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_AccessDEC.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size < 2 || size > 10 || argc != 2 ) {
+ cout << "usage :"<<endl;
+ cout << "mpirun -np <nbprocs> test_AllToAllTimeDEC <Asynchronous>"<<endl;
+ cout << " (nbprocs >=2)"<<endl;
+ cout << "test must be runned with more than 1 proc and less than 11 procs" << endl ;
+ return 1 ;
+ }
+
+ int Asynchronous = atoi(argv[1]);
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+ std::set<int> sourceprocs;
+ std::set<int> targetprocs;
+ int i ;
+ for ( i = 0 ; i < size/2 ; i++ ) {
+ sourceprocs.insert(i);
+ }
+ for ( i = size/2 ; i < size ; i++ ) {
+ targetprocs.insert(i);
+ }
+
+ ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ;
+ ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ;
+
+// MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+// NULL , Asynchronous ) ;
+ MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+ Asynchronous ) ;
+
+ MPI_Access * mpi_access = MPIAccessDEC->MPIAccess() ;
+
+#define maxreq 100
+#define datamsglength 10
+
+// int sts ;
+ int sendcount = datamsglength ;
+ int recvcount = datamsglength ;
+ int * recvbuf = new int[datamsglength*size] ;
+
+ int ireq ;
+ for ( ireq = 0 ; ireq < maxreq ; ireq++ ) {
+// int * sendbuf = new int[datamsglength*size] ;
+ cout << "test" << myrank << " ireq " << ireq << " RecvRequestIdsSize "
+ << mpi_access->RecvRequestIdsSize() << endl ;
+ int * sendbuf = (int *) malloc( sizeof(int)*datamsglength*size) ;
+ int j ;
+ for ( j = 0 ; j < datamsglength*size ; j++ ) {
+ sendbuf[j] = myrank*1000000 + ireq*1000 + j ;
+ recvbuf[j] = -1 ;
+ }
+
+ MPIAccessDEC->AllToAll( sendbuf, sendcount , MPI_INT ,
+ recvbuf, recvcount , MPI_INT ) ;
+
+ cout << "test" << myrank << " recvbuf before CheckSent" ;
+ for ( i = 0 ; i < datamsglength*size ; i++ ) {
+ cout << " " << recvbuf[i] ;
+ }
+ cout << endl ;
+
+ cout << "test" << myrank << " sendbuf " << sendbuf << endl ;
+ MPIAccessDEC->CheckSent() ;
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ cout << "test" << myrank << " WaitAllRecv " << nRecvReq << " Requests" << endl ;
+ int *ArrayOfRecvRequests = new int[nRecvReq] ;
+ int nReq = mpi_access->RecvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfRecvRequests ) ;
+ mpi_access->DeleteRequests( nReq , ArrayOfRecvRequests ) ;
+ delete [] ArrayOfRecvRequests ;
+ cout << "test" << myrank << " RecvRequestIdsSize " << mpi_access->RecvRequestIdsSize()
+ << " after WaitAll" << endl ;
+
+ cout << "test" << myrank << " recvbuf" ;
+ for ( i = 0 ; i < datamsglength*size ; i++ ) {
+ cout << " " << recvbuf[i] ;
+ }
+ cout << endl ;
+ }
+
+ cout << "test" << myrank << " final CheckSent" << endl ;
+ MPIAccessDEC->CheckSent() ;
+
+ int nSendReq = mpi_access->SendRequestIdsSize() ;
+ cout << "test" << myrank << " final SendRequestIds " << nSendReq << " SendRequests"
+ << endl ;
+ if ( nSendReq ) {
+ int *ArrayOfSendRequests = new int[nSendReq] ;
+ int nReq = mpi_access->SendRequestIds( nSendReq, ArrayOfSendRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfSendRequests ) ;
+ delete [] ArrayOfSendRequests ;
+ }
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq ) {
+ cout << "test" << myrank << " final RecvRequestIds " << nRecvReq
+ << " RecvRequests # 0 Error" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "test" << myrank << " final RecvRequestIds " << nRecvReq
+ << " RecvRequests = 0 OK" << endl ;
+ }
+
+ mpi_access->Barrier() ;
+
+ delete sourcegroup ;
+ delete targetgroup ;
+ delete MPIAccessDEC ;
+ delete [] recvbuf ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_AccessDEC.hxx"
+#include "LinearTimeInterpolator.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access * mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access->Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size < 2 || size > 11 || argc != 2 ) {
+ cout << "usage :" << endl;
+ cout << "mpirun -np <nbprocs> test_AllToAllTimeDEC <Asynchronous>"
+ <<endl;
+ cout << " (nbprocs >=2)" <<endl;
+ cout << "test must be runned with more than 1 proc and less than 12 procs" << endl ;
+ return 1 ;
+ }
+
+ int Asynchronous = atoi(argv[1]);
+
+ cout << "test" << myrank << " Asynchronous " << Asynchronous << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+ std::set<int> sourceprocs;
+ std::set<int> targetprocs;
+ int i ;
+ for ( i = 0 ; i < size/2 ; i++ ) {
+ sourceprocs.insert(i);
+ }
+ for ( i = size/2 ; i < size ; i++ ) {
+ targetprocs.insert(i);
+ }
+
+ ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ;
+ ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ;
+
+// LinearTimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0.5 ) ;
+ MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+ Asynchronous ) ;
+// Asynchronous , LinearInterp , 0.5 ) ;
+ MPIAccessDEC->SetTimeInterpolator( LinearTimeInterp ) ;
+ MPI_Access * mpi_access = MPIAccessDEC->MPIAccess() ;
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+#define maxproc 11
+#define maxreq 10000
+#define datamsglength 10
+
+ int sts ;
+ int sendcount = datamsglength ;
+ int recvcount = datamsglength ;
+
+ double time = 0 ;
+// double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ;
+ double deltatime[maxproc] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.} ;
+ double maxtime = maxreq ;
+ double nextdeltatime = deltatime[myrank] ;
+// MPIAccessDEC->InitTime( time , deltatime[myrank] , maxtime ) ;
+// for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) {
+ for ( time = 0 ; time <= maxtime && nextdeltatime != 0 ; time+=nextdeltatime ) {
+ if ( time != 0 ) {
+ nextdeltatime = deltatime[myrank] ;
+ if ( time+nextdeltatime > maxtime ) {
+ nextdeltatime = 0 ;
+ }
+// MPIAccessDEC->NextTime( nextdeltatime ) ;
+ }
+ MPIAccessDEC->SetTime( time , nextdeltatime ) ;
+ cout << "test" << myrank << "=====TIME " << time << "=====DELTATIME "
+ << nextdeltatime << "=====MAXTIME " << maxtime << " ======" << endl ;
+ int * sendbuf = new int[datamsglength*size] ;
+// int * sendbuf = (int *) malloc(sizeof(int)*datamsglength*size) ;
+ int * recvbuf = new int[datamsglength*size] ;
+ int j ;
+ for ( j = 0 ; j < datamsglength*size ; j++ ) {
+ sendbuf[j] = myrank*1000000 + (j/datamsglength)*1000 + j ;
+ recvbuf[j] = -1 ;
+ }
+
+ int sts = MPIAccessDEC->AllToAllTime( sendbuf, sendcount , MPI_INT ,
+ recvbuf, recvcount , MPI_INT ) ;
+ chksts( sts , myrank , mpi_access ) ;
+
+// cout << "test" << myrank << " recvbuf before CheckSent" ;
+// for ( i = 0 ; i < datamsglength*size ; i++ ) {
+// cout << " " << recvbuf[i] ;
+// }
+// cout << endl ;
+
+// cout << "test" << myrank << " sendbuf " << sendbuf << endl ;
+// MPIAccessDEC->CheckSent() ;
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq != 0 ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " WaitAllRecv " << nRecvReq << " Requests # 0 ERROR"
+ << endl << "==============================================================="
+ << endl ;
+ int *ArrayOfRecvRequests = new int[nRecvReq] ;
+ int nReq = mpi_access->RecvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfRecvRequests ) ;
+ delete [] ArrayOfRecvRequests ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << " recvbuf" << endl ;
+ bool badrecvbuf = false ;
+ for ( i = 0 ; i < datamsglength*size ; i++ ) {
+ if ( recvbuf[i] != (i/datamsglength)*1000000 + myrank*1000 +
+ myrank*datamsglength+(i%datamsglength) ) {
+ badrecvbuf = true ;
+ cout << "test" << myrank << " recvbuf[" << i << "] "
+ << recvbuf[i] << " # " << (i/datamsglength)*1000000 + myrank*1000 +
+ myrank*datamsglength+(i%datamsglength) << endl ;
+ }
+ else if ( badrecvbuf ) {
+ cout << "test" << myrank << " recvbuf[" << i << "] "
+ << recvbuf[i] << " == " << (i/datamsglength)*1000000 + myrank*1000 +
+ myrank*datamsglength+(i%datamsglength) << endl ;
+ }
+ }
+ if ( badrecvbuf ) {
+ cout << "==================================================================" << endl
+ << "test" << myrank << " badrecvbuf"
+ << endl << "=================================================================="
+ << endl ;
+ return 1 ;
+ }
+ delete [] recvbuf ;
+ }
+
+ cout << "test" << myrank << " final CheckSent" << endl ;
+ sts = MPIAccessDEC->CheckSent() ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "====================================================================" << endl
+ << "test" << myrank << " final CheckSent ERROR"
+ << endl << "===================================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ int nSendReq = mpi_access->SendRequestIdsSize() ;
+ cout << "test" << myrank << " final SendRequestIds " << nSendReq << " SendRequests"
+ << endl ;
+ if ( nSendReq ) {
+ int *ArrayOfSendRequests = new int[nSendReq] ;
+ int nReq = mpi_access->SendRequestIds( nSendReq, ArrayOfSendRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfSendRequests ) ;
+ delete [] ArrayOfSendRequests ;
+ }
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " RecvRequestIds " << nRecvReq << " RecvRequests # 0 Error"
+ << endl << "==============================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "test" << myrank << " RecvRequestIds " << nRecvReq
+ << " RecvRequests = 0 OK" << endl ;
+ }
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ delete sourcegroup ;
+ delete targetgroup ;
+// delete aLinearInterpDEC ;
+ delete MPIAccessDEC ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_AccessDEC.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size < 2 || size > 10 || argc != 2 ) {
+ cout << "usage :"<<endl;
+ cout << "mpirun -np <nbprocs> test_AllToAllTimeDEC <Asynchronous>"<<endl;
+ cout << " (nbprocs >=2)"<<endl;
+ cout << "test must be runned with more than 1 proc and less than 11 procs" << endl ;
+ return 1 ;
+ }
+
+ int Asynchronous = atoi(argv[1]);
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+ std::set<int> sourceprocs;
+ std::set<int> targetprocs;
+ int i ;
+ for ( i = 0 ; i < size/2 ; i++ ) {
+ sourceprocs.insert(i);
+ }
+ for ( i = size/2 ; i < size ; i++ ) {
+ targetprocs.insert(i);
+ }
+
+ ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ;
+ ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ;
+
+ MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+ Asynchronous ) ;
+
+ MPI_Access * mpi_access = MPIAccessDEC->MPIAccess() ;
+
+#define maxreq 100
+#define datamsglength 10
+
+// int sts ;
+ int *sendcounts = new int[size] ;
+ int *sdispls = new int[size] ;
+ int *recvcounts = new int[size] ;
+ int *rdispls = new int[size] ;
+ for ( i = 0 ; i < size ; i++ ) {
+ sendcounts[i] = datamsglength-i;
+ sdispls[i] = i*datamsglength ;
+ recvcounts[i] = datamsglength-myrank;
+ rdispls[i] = i*datamsglength ;
+ }
+ int * recvbuf = new int[datamsglength*size] ;
+
+ int ireq ;
+ for ( ireq = 0 ; ireq < maxreq ; ireq++ ) {
+// int * sendbuf = new int[datamsglength*size] ;
+ int * sendbuf = (int *) malloc( sizeof(int)*datamsglength*size) ;
+ int j ;
+ for ( j = 0 ; j < datamsglength*size ; j++ ) {
+ sendbuf[j] = myrank*1000000 + ireq*1000 + j ;
+ recvbuf[j] = -1 ;
+ }
+
+ MPIAccessDEC->AllToAllv( sendbuf, sendcounts , sdispls , MPI_INT ,
+ recvbuf, recvcounts , rdispls , MPI_INT ) ;
+
+ cout << "test" << myrank << " recvbuf before CheckSent" ;
+ for ( i = 0 ; i < datamsglength*size ; i++ ) {
+ cout << " " << recvbuf[i] ;
+ }
+ cout << endl ;
+
+ cout << "test" << myrank << " sendbuf " << sendbuf << endl ;
+ MPIAccessDEC->CheckSent() ;
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ cout << "test" << myrank << " WaitAllRecv " << nRecvReq << " Requests" << endl ;
+ int *ArrayOfRecvRequests = new int[nRecvReq] ;
+ int nReq = mpi_access->RecvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfRecvRequests ) ;
+ mpi_access->DeleteRequests( nReq , ArrayOfRecvRequests ) ;
+ delete [] ArrayOfRecvRequests ;
+
+ cout << "test" << myrank << " recvbuf" ;
+ for ( i = 0 ; i < datamsglength*size ; i++ ) {
+ cout << " " << recvbuf[i] ;
+ }
+ cout << endl ;
+ }
+
+ cout << "test" << myrank << " final CheckSent" << endl ;
+ MPIAccessDEC->CheckSent() ;
+
+ int nSendReq = mpi_access->SendRequestIdsSize() ;
+ cout << "test" << myrank << " final SendRequestIds " << nSendReq << " SendRequests"
+ << endl ;
+ if ( nSendReq ) {
+ int *ArrayOfSendRequests = new int[nSendReq] ;
+ int nReq = mpi_access->SendRequestIds( nSendReq, ArrayOfSendRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfSendRequests ) ;
+ delete [] ArrayOfSendRequests ;
+ }
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq ) {
+ cout << "test" << myrank << " final RecvRequestIds " << nRecvReq
+ << " RecvRequests # 0 Error" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "test" << myrank << " final RecvRequestIds " << nRecvReq
+ << " RecvRequests = 0 OK" << endl ;
+ }
+
+ mpi_access->Barrier() ;
+
+ delete sourcegroup ;
+ delete targetgroup ;
+ delete MPIAccessDEC ;
+ delete [] sendcounts ;
+ delete [] sdispls ;
+ delete [] recvcounts ;
+ delete [] rdispls ;
+ delete [] recvbuf ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+#include <time.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_AccessDEC.hxx"
+#include "LinearTimeInterpolator.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access * mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access->Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size < 2 || size > 11 || ( argc != 2 && argc != 3 ) ) {
+ cout << "usage :" << endl ;
+ cout << "mpirun -np <nbprocs> test_AllToAllvTimeDEC <Asynchronous> [MPI_Alltoallv]"
+ << endl ;
+ cout << "test must be runned with more than 1 proc and less than 12 procs" << endl ;
+ return 1 ;
+ }
+
+ int Asynchronous = atoi(argv[1]) ;
+ int UseMPI_Alltoallv = false ;
+ if ( argc == 3 ) {
+ UseMPI_Alltoallv = atoi(argv[2]) ;
+ }
+
+ cout << "test" << myrank << " Asynchronous " << Asynchronous << " UseMPI_Alltoallv "
+ << UseMPI_Alltoallv << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+ std::set<int> sourceprocs;
+ std::set<int> targetprocs;
+ int i ;
+ for ( i = 0 ; i < size/2 ; i++ ) {
+ sourceprocs.insert(i);
+ }
+ for ( i = size/2 ; i < size ; i++ ) {
+ targetprocs.insert(i);
+ }
+
+ ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ;
+ ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ;
+
+// TimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0.5 ) ;
+ MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+ Asynchronous ) ;
+// Asynchronous , LinearInterp , 0.5 ) ;
+ MPIAccessDEC->SetTimeInterpolator( LinearTimeInterp , 0.5 ) ;
+ MPI_Access * mpi_access = MPIAccessDEC->MPIAccess() ;
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+#define maxproc 11
+#define maxreq 1000
+#define datamsglength 10
+
+ int sts ;
+ int *sendcounts = new int[size] ;
+ int *sdispls = new int[size] ;
+ int *recvcounts = new int[size] ;
+ int *rdispls = new int[size] ;
+ int *sendtimecounts = new int[size] ;
+ int *stimedispls = new int[size] ;
+ int *recvtimecounts = new int[size] ;
+ int *rtimedispls = new int[size] ;
+ for ( i = 0 ; i < size ; i++ ) {
+ sendcounts[i] = datamsglength-i ;
+ sdispls[i] = i*datamsglength ;
+ recvcounts[i] = datamsglength-myrank ;
+ rdispls[i] = i*datamsglength ;
+ sendtimecounts[i] = 1 ;
+ stimedispls[i] = 0 ;
+ recvtimecounts[i] = 1 ;
+ rtimedispls[i] = i ;
+ //rtimedispls[i] = i*mpi_access->TimeExtent() ;
+ }
+
+ double time = 0 ;
+ double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ;
+ double maxtime ;
+ double nextdeltatime = deltatime[myrank] ;
+ if ( UseMPI_Alltoallv ) {
+ maxtime = maxreq*nextdeltatime - 0.1 ;
+ }
+ else {
+ maxtime = maxreq ;
+// MPIAccessDEC->InitTime( time , nextdeltatime , maxtime ) ;
+ }
+ time_t begintime = std::time(NULL) ;
+// for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) {
+ for ( time = 0 ; time <= maxtime && nextdeltatime != 0 ; time+=nextdeltatime ) {
+ nextdeltatime = deltatime[myrank] ;
+ if ( time != 0 ) {
+ nextdeltatime = deltatime[myrank] ;
+ if ( time+nextdeltatime > maxtime ) {
+ nextdeltatime = 0 ;
+ }
+// MPIAccessDEC->NextTime( nextdeltatime ) ;
+ }
+ MPIAccessDEC->SetTime( time , nextdeltatime ) ;
+ cout << "test" << myrank << "=====TIME " << time << "=====DELTATIME "
+ << nextdeltatime << "=====MAXTIME " << maxtime << " ======" << endl ;
+ int * sendbuf = new int[datamsglength*size] ;
+// int * sendbuf = (int *) malloc(sizeof(int)*datamsglength*size) ;
+ int * recvbuf = new int[datamsglength*size] ;
+ int j ;
+ for ( j = 0 ; j < datamsglength*size ; j++ ) {
+ sendbuf[j] = myrank*1000000 + (j/datamsglength)*1000 + j ;
+ recvbuf[j] = -1 ;
+ }
+
+ if ( UseMPI_Alltoallv ) {
+ const MPI_Comm* comm = MPIAccessDEC->GetComm();
+ TimeMessage * aSendTimeMessage = new TimeMessage ;
+ aSendTimeMessage->time = time ;
+// aSendTimeMessage->deltatime = deltatime[myrank] ;
+ aSendTimeMessage->deltatime = nextdeltatime ;
+// aSendTimeMessage->maxtime = maxtime ;
+ aSendTimeMessage->tag = (int ) (time/deltatime[myrank]) ;
+ TimeMessage * aRecvTimeMessage = new TimeMessage[size] ;
+ interface.allToAllV(aSendTimeMessage, sendtimecounts , stimedispls ,
+ mpi_access->TimeType() ,
+ aRecvTimeMessage, recvtimecounts , rtimedispls ,
+ mpi_access->TimeType() , *comm ) ;
+// for ( j = 0 ; j < size ; j++ ) {
+// cout << "test" << myrank << " TimeMessage received " << j << " "
+// << aRecvTimeMessage[j] << endl ;
+// }
+ delete aSendTimeMessage ;
+ delete [] aRecvTimeMessage ;
+ interface.allToAllV(sendbuf, sendcounts , sdispls , MPI_INT ,
+ recvbuf, recvcounts , rdispls , MPI_INT , *comm ) ;
+// free(sendbuf) ;
+ delete [] sendbuf ;
+ }
+ else {
+ int sts = MPIAccessDEC->AllToAllvTime( sendbuf, sendcounts , sdispls , MPI_INT ,
+ recvbuf, recvcounts , rdispls , MPI_INT ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+
+// cout << "test" << myrank << " recvbuf before CheckSent" ;
+// for ( i = 0 ; i < datamsglength*size ; i++ ) {
+// cout << " " << recvbuf[i] ;
+// }
+// cout << endl ;
+
+// cout << "test" << myrank << " sendbuf " << sendbuf << endl ;
+// MPIAccessDEC->CheckSent() ;
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq != 0 ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " WaitAllRecv " << nRecvReq << " Requests # 0 ERROR"
+ << endl << "==============================================================="
+ << endl ;
+ int *ArrayOfRecvRequests = new int[nRecvReq] ;
+ int nReq = mpi_access->RecvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfRecvRequests ) ;
+ delete [] ArrayOfRecvRequests ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << " check of recvbuf" << endl ;
+ bool badrecvbuf = false ;
+ for ( i = 0 ; i < size ; i++ ) {
+ int j ;
+ for ( j = 0 ; j < datamsglength ; j++ ) {
+ int index = i*datamsglength+j ;
+ if ( j < recvcounts[i] ) {
+ if ( recvbuf[index] != (index/datamsglength)*1000000 + myrank*1000 +
+ myrank*datamsglength+(index%datamsglength) ) {
+ badrecvbuf = true ;
+ cout << "test" << myrank << " recvbuf[" << index << "] "
+ << recvbuf[index] << " # " << (index/datamsglength)*1000000 +
+ myrank*1000 +
+ myrank*datamsglength+(index%datamsglength) << endl ;
+ }
+ else if ( badrecvbuf ) {
+ cout << "test" << myrank << " recvbuf[" << index << "] "
+ << recvbuf[index] << " == " << (index/datamsglength)*1000000 +
+ myrank*1000 +
+ myrank*datamsglength+(index%datamsglength) << endl ;
+ }
+ }
+ else if ( recvbuf[index] != -1 ) {
+ badrecvbuf = true ;
+ cout << "test" << myrank << " recvbuf[" << index << "] "
+ << recvbuf[index] << " # -1" << endl ;
+ }
+ }
+ }
+ if ( badrecvbuf ) {
+ cout << "==================================================================" << endl
+ << "test" << myrank << " badrecvbuf"
+ << endl << "=================================================================="
+ << endl ;
+ return 1 ;
+ }
+ delete [] recvbuf ;
+ }
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ cout << "test" << myrank << " CheckFinalSent" << endl ;
+ sts = MPIAccessDEC->CheckFinalSent() ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "====================================================================" << endl
+ << "test" << myrank << " CheckFinalSent ERROR"
+ << endl << "===================================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << " CheckFinalRecv" << endl ;
+ sts = MPIAccessDEC->CheckFinalRecv() ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "====================================================================" << endl
+ << "test" << myrank << " CheckFinalRecv ERROR"
+ << endl << "===================================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " RecvRequestIds " << nRecvReq << " RecvRequests # 0 Error"
+ << endl << "==============================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "test" << myrank << " RecvRequestIds " << nRecvReq
+ << " RecvRequests = 0 OK" << endl ;
+ }
+
+ time_t endtime = std::time(NULL) ;
+ cout << "test" << myrank << " begintime " << begintime << " endtime " << endtime
+ << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank]
+ << " calls to AllToAll" << endl ;
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ delete sourcegroup ;
+ delete targetgroup ;
+ delete MPIAccessDEC ;
+// delete aLinearInterpDEC ;
+
+ delete [] sendcounts ;
+ delete [] sdispls ;
+ delete [] recvcounts ;
+ delete [] rdispls ;
+ delete [] sendtimecounts ;
+ delete [] stimedispls ;
+ delete [] recvtimecounts ;
+ delete [] rtimedispls ;
+
+ MPI_Finalize();
+
+ endtime = std::time(NULL) ;
+
+ cout << "test" << myrank << " OK begintime " << begintime << " endtime " << endtime
+ << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank]
+ << " calls to AllToAll" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <math.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+#include <time.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_AccessDEC.hxx"
+#include "LinearTimeInterpolator.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access * mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access->Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size < 2 || size > 11 || argc != 2 ) {
+ cout << "usage :" << endl ;
+ cout << "mpirun -np <nbprocs> test_AllToAllvTimeDEC <Asynchronous>"
+ << endl ;
+ cout << "test must be runned with more than 1 proc and less than 12 procs" << endl ;
+ return 1 ;
+ }
+
+ int Asynchronous = atoi(argv[1]) ;
+
+ cout << "test" << myrank << " Asynchronous " << Asynchronous << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+ std::set<int> sourceprocs;
+ std::set<int> targetprocs;
+ int i ;
+ for ( i = 0 ; i < size/2 ; i++ ) {
+ sourceprocs.insert(i);
+ }
+ for ( i = size/2 ; i < size ; i++ ) {
+ targetprocs.insert(i);
+ }
+
+ ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ;
+ ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ;
+
+// TimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0 ) ;
+ MPI_AccessDEC * MPIAccessDEC = new MPI_AccessDEC( *sourcegroup , *targetgroup ,
+ Asynchronous ) ;
+// Asynchronous , LinearInterp , 0.5 ) ;
+ MPIAccessDEC->SetTimeInterpolator( LinearTimeInterp ) ;
+ MPI_Access * mpi_access = MPIAccessDEC->MPIAccess() ;
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+#define maxproc 11
+#define maxreq 100
+#define datamsglength 10
+
+ int sts ;
+ int *sendcounts = new int[size] ;
+ int *sdispls = new int[size] ;
+ int *recvcounts = new int[size] ;
+ int *rdispls = new int[size] ;
+ int *sendtimecounts = new int[size] ;
+ int *stimedispls = new int[size] ;
+ int *recvtimecounts = new int[size] ;
+ int *rtimedispls = new int[size] ;
+ for ( i = 0 ; i < size ; i++ ) {
+ sendcounts[i] = datamsglength-i ;
+ sdispls[i] = i*datamsglength ;
+ recvcounts[i] = datamsglength-myrank ;
+ rdispls[i] = i*datamsglength ;
+ sendtimecounts[i] = 1 ;
+ stimedispls[i] = 0 ;
+ recvtimecounts[i] = 1 ;
+ rtimedispls[i] = i ;
+ }
+
+ double time[maxproc] ;
+ double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ;
+ double maxtime[maxproc] ;
+ double nextdeltatime[maxproc] ;
+ for ( i = 0 ; i < size ; i++ ) {
+ time[i] = 0 ;
+ maxtime[i] = maxreq ;
+ nextdeltatime[i] = deltatime[i] ;
+ }
+ time_t begintime = std::time(NULL) ;
+ for ( time[myrank] = 0 ; time[myrank] <= maxtime[myrank] && nextdeltatime[myrank] != 0 ;
+ time[myrank]+=nextdeltatime[myrank] ) {
+//local and target times
+ int target ;
+ for ( target = 0 ; target < size ; target++ ) {
+ nextdeltatime[target] = deltatime[target] ;
+ if ( time[target] != 0 ) {
+ if ( time[target]+nextdeltatime[target] > maxtime[target] ) {
+ nextdeltatime[target] = 0 ;
+ }
+ }
+ if ( target != myrank ) {
+ while ( time[myrank] >= time[target] ) {
+ time[target] += deltatime[target] ;
+ }
+ }
+ }
+ MPIAccessDEC->SetTime( time[myrank] , nextdeltatime[myrank] ) ;
+ cout << "test" << myrank << "=====TIME " << time[myrank] << "=====DELTATIME "
+ << nextdeltatime[myrank] << "=====MAXTIME " << maxtime[myrank] << " ======"
+ << endl ;
+ double * sendbuf = new double[datamsglength*size] ;
+// double * sendbuf = (double *) malloc(sizeof(double)*datamsglength*size) ;
+ double * recvbuf = new double[datamsglength*size] ;
+ int j ;
+ //cout << "test" << myrank << " sendbuf" ;
+ for ( target = 0 ; target < size ; target++ ) {
+ for ( j = 0 ; j < datamsglength ; j++ ) {
+ //sendbuf[j] = myrank*10000 + (j/datamsglength)*100 + j ;
+ sendbuf[target*datamsglength+j] = myrank*1000000 + target*10000 +
+ (time[myrank]/deltatime[myrank])*100 + j ;
+ //cout << " " << (int ) sendbuf[target*datamsglength+j] ;
+ recvbuf[target*datamsglength+j] = -1 ;
+ }
+ //cout << endl ;
+ }
+
+ int sts = MPIAccessDEC->AllToAllvTime( sendbuf, sendcounts , sdispls , MPI_DOUBLE ,
+ recvbuf, recvcounts , rdispls , MPI_DOUBLE ) ;
+ chksts( sts , myrank , mpi_access ) ;
+
+// cout << "test" << myrank << " recvbuf before CheckSent" ;
+// for ( i = 0 ; i < datamsglength*size ; i++ ) {
+// cout << " " << recvbuf[i] ;
+// }
+// cout << endl ;
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq != 0 ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " WaitAllRecv " << nRecvReq << " Requests # 0 ERROR"
+ << endl << "==============================================================="
+ << endl ;
+ int *ArrayOfRecvRequests = new int[nRecvReq] ;
+ int nReq = mpi_access->RecvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
+ mpi_access->WaitAll( nReq , ArrayOfRecvRequests ) ;
+ delete [] ArrayOfRecvRequests ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << " check of recvbuf" << endl ;
+ bool badrecvbuf = false ;
+ for ( target = 0 ; target < size ; target++ ) {
+ int j ;
+ for ( j = 0 ; j < datamsglength ; j++ ) {
+ int index = target*datamsglength+j ;
+ if ( j < recvcounts[target] ) {
+ if ( fabs(recvbuf[index] - (target*1000000 + myrank*10000 +
+ (time[target]/deltatime[target])*100 + j)) > 101) {
+ badrecvbuf = true ;
+ cout << "test" << myrank << " target " << target << " time[target] "
+ << time[target] << " recvbuf[" << index << "] " << (int ) recvbuf[index]
+ << " # " << (int ) (target*1000000 +
+ myrank*10000 + (time[target]/deltatime[target])*100 + j)
+ << endl ;
+ }
+ else if ( badrecvbuf ) {
+ cout << "test" << myrank << " recvbuf[" << index << "] "
+ << recvbuf[index] << " ~= " << (int ) (target*1000000 +
+ myrank*10000 + (time[target]/deltatime[target])*100 + j) << endl ;
+ }
+ }
+ else if ( recvbuf[index] != -1 ) {
+ badrecvbuf = true ;
+ cout << "test" << myrank << " recvbuf[" << index << "] "
+ << recvbuf[index] << " # -1" << endl ;
+ }
+ }
+ }
+ if ( badrecvbuf ) {
+ cout << "==================================================================" << endl
+ << "test" << myrank << " badrecvbuf"
+ << endl << "=================================================================="
+ << endl ;
+ return 1 ;
+ }
+ delete [] recvbuf ;
+ }
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ cout << "test" << myrank << " CheckFinalSent" << endl ;
+ sts = MPIAccessDEC->CheckFinalSent() ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "====================================================================" << endl
+ << "test" << myrank << " CheckFinalSent ERROR"
+ << endl << "===================================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << " CheckFinalRecv" << endl ;
+ sts = MPIAccessDEC->CheckFinalRecv() ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "====================================================================" << endl
+ << "test" << myrank << " CheckFinalRecv ERROR"
+ << endl << "===================================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ int nRecvReq = mpi_access->RecvRequestIdsSize() ;
+ if ( nRecvReq ) {
+ cout << "===============================================================" << endl
+ << "test" << myrank << " RecvRequestIds " << nRecvReq << " RecvRequests # 0 Error"
+ << endl << "==============================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "test" << myrank << " RecvRequestIds " << nRecvReq
+ << " RecvRequests = 0 OK" << endl ;
+ }
+
+ time_t endtime = std::time(NULL) ;
+ cout << "test" << myrank << " begintime " << begintime << " endtime " << endtime
+ << " elapse " << endtime-begintime << " " << maxtime[myrank]/deltatime[myrank]
+ << " calls to AllToAll" << endl ;
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ delete sourcegroup ;
+ delete targetgroup ;
+ delete MPIAccessDEC ;
+// delete aLinearInterpDEC ;
+
+ delete [] sendcounts ;
+ delete [] sdispls ;
+ delete [] recvcounts ;
+ delete [] rdispls ;
+ delete [] sendtimecounts ;
+ delete [] stimedispls ;
+ delete [] recvtimecounts ;
+ delete [] rtimedispls ;
+
+ MPI_Finalize();
+
+ endtime = std::time(NULL) ;
+
+ cout << "test" << myrank << " OK begintime " << begintime << " endtime " << endtime
+ << " elapse " << endtime-begintime << " " << maxtime[myrank]/deltatime[myrank]
+ << " calls to AllToAll" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <time.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int intsendbuf[5] ;
+ double doublesendbuf[10] ;
+ int RequestId[10] ;
+ int sts ;
+ int i , j ;
+ for ( j = 0 ; j < 3 ; j++ ) {
+ for ( i = 0 ; i < 10 ; i++ ) {
+ cout << "test" << myrank << " ============================ i " << i
+ << "============================" << endl ;
+ if ( myrank == 0 ) {
+ if ( i < 5 ) {
+ intsendbuf[i] = i ;
+ sts = mpi_access.ISend(&intsendbuf[i],1,MPI_INT,target, RequestId[i]) ;
+ cout << "test" << myrank << " Send MPI_INT RequestId " << RequestId[i]
+ << endl ;
+ }
+ else {
+ doublesendbuf[i] = i ;
+ sts = mpi_access.ISend(&doublesendbuf[i],1,MPI_DOUBLE,target,
+ RequestId[i]) ;
+ cout << "test" << myrank << " Send MPI_DOUBLE RequestId " << RequestId[i]
+ << endl ;
+ }
+ }
+ else {
+ int flag = false ;
+ while ( !flag ) {
+ int source, tag, outcount ;
+ MPI_Datatype datatype ;
+ sts = mpi_access.IProbe(target, source, tag, datatype, outcount,
+ flag ) ;
+ if ( flag ) {
+ cout << "test" << myrank << " " << i << " IProbe target " << target
+ << " source " << source << " tag " << tag
+ << " outcount " << outcount << " flag " << flag << endl ;
+ }
+ else {
+ cout << "test" << myrank << " flag " << flag << endl ;
+ sleep( 1 ) ;
+ }
+ if ( flag ) {
+ int recvbuf ;
+ sts = mpi_access.IRecv(&recvbuf,outcount,MPI_INT,source,
+ RequestId[i] ) ;
+ if ( datatype == MPI_INT ) {
+ int source, tag, error, outcount ;
+ mpi_access.Wait( RequestId[i] ) ;
+ mpi_access.Status( RequestId[i], source, tag, error, outcount,
+ true ) ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "======================================================"
+ << endl << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO" << endl
+ << "======================================================"
+ << endl ;
+ return 1 ;
+ }
+ cout << "========================================================"
+ << endl << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " OK" << endl
+ << "========================================================"
+ << endl ;
+ }
+ }
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+
+ if ( myrank != 0 ) {
+ int iprobe ;
+ for ( iprobe = 5 ; iprobe < 10 ; iprobe++ ) {
+ cout << "test" << myrank << " ============================ iprobe "
+ << iprobe << "============================" << endl ;
+ int source, tag, outcount ;
+ MPI_Datatype datatype ;
+ int probeflag = false ;
+ while ( !probeflag ) {
+ sts = mpi_access.IProbe( target, source, tag, datatype, outcount,
+ probeflag ) ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " IProbe iprobe " << iprobe
+ << " target " << target << " probeflag " << probeflag
+ << " tag " << tag << " outcount " << outcount << " datatype "
+ << datatype << " lenerr " << lenerr << " " << msgerr << endl ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "=========================================================="
+ << endl << "test" << myrank << " IProbe KO iprobe " << iprobe
+ << endl
+ << "=========================================================="
+ << endl ;
+ return 1 ;
+ }
+ if ( !probeflag ) {
+ //cout << "========================================================"
+ // << endl << "test" << myrank << " IProbe KO(OK) iprobe " << iprobe
+ // << " probeflag " << probeflag << endl
+ // << "========================================================"
+ // << endl ;
+ }
+ else {
+ cout << "test" << myrank << " " << iprobe << " IProbe target "
+ << target << " source " << source << " tag " << tag
+ << " outcount " << outcount << " probeflag " << probeflag
+ << endl ;
+ if ( datatype != MPI_DOUBLE ) {
+ cout << "========================================================"
+ << endl << "test" << myrank << " MPI_DOUBLE KO" << endl
+ << "========================================================"
+ << endl ;
+ return 1 ;
+ }
+ else {
+ int flag ;
+ sts = mpi_access.Cancel( source, tag, datatype, outcount, flag ) ;
+ if ( sts != MPI_SUCCESS || !flag ) {
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "======================================================"
+ << endl << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl << "test" << myrank
+ << " Cancel PendingIrecv KO flag " << flag << " iprobe "
+ << iprobe << " Irecv completed" << endl
+ << "======================================================"
+ << endl ;
+ //return 1 ;
+ }
+ else {
+ cout << "======================================================"
+ << endl << "test" << myrank
+ << " Cancel PendingIrecv OK RequestId " << " flag "
+ << flag << " iprobe " << iprobe << endl
+ << "======================================================"
+ << endl ;
+ }
+ }
+ int Reqtarget, Reqtag, Reqerror, Reqoutcount ;
+ mpi_access.Status( RequestId[iprobe], Reqtarget, Reqtag, Reqerror,
+ Reqoutcount, true ) ;
+ cout << "test" << myrank << " Status Reqtarget "<< Reqtarget
+ << " Reqtag " << Reqtag << " Reqoutcount " << Reqoutcount
+ << endl ;
+ int Reqflag ;
+ sts = mpi_access.Cancel( RequestId[iprobe] , Reqflag ) ;
+ cout << "test" << myrank << " " << iprobe
+ << " Cancel Irecv done Reqtarget " << Reqtarget
+ << " Reqtag " << Reqtag << " Reqoutcount " << Reqoutcount
+ << " Reqflag " << Reqflag << endl ;
+ if ( sts != MPI_SUCCESS || !Reqflag ) {
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "========================================================"
+ << endl << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl << "test" << myrank
+ << " Cancel Irecv KO Reqflag " << Reqflag << " iprobe "
+ << iprobe << endl
+ << "========================================================"
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "========================================================"
+ << endl << "test" << myrank
+ << " Cancel Irecv OK RequestId " << RequestId[iprobe]
+ << " Reqflag " << Reqflag << " iprobe " << iprobe << endl
+ << "========================================================"
+ << endl ;
+ probeflag = Reqflag ;
+ }
+ }
+ }
+ }
+ }
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.DeleteRequests(10,RequestId) ;
+ }
+
+ int source, tag, outcount, flag ;
+ MPI_Datatype datatype ;
+ sts = mpi_access.IProbe(target, source, tag, datatype, outcount, flag ) ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ if ( sts != MPI_SUCCESS || flag ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " IProbe KO flag " << flag
+ << " remaining unread/cancelled message :" << endl
+ << " source " << source << " tag " << tag << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+
+ mpi_access.TestAll(10,RequestId,flag) ;
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.DeleteRequests(10,RequestId) ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 3 ) {
+ cout << "test_MPI_Access_Send_Recv must be runned with 3 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxsend 100
+
+ int alltarget[3] = {1 , 2 , 0 } ;
+ int allsource[3] = {2 , 0 , 1 } ;
+ int SendRequestId[maxsend] ;
+ int RecvRequestId[maxsend] ;
+ int sendbuf[maxsend] ;
+ int recvbuf[maxsend] ;
+ int sts ;
+ int i = 0 ;
+ if ( myrank == 0 ) {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,alltarget[myrank],
+ SendRequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ for ( i = 0 ; i < maxsend ; i++ ) {
+ recvbuf[i] = -1 ;
+ sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,allsource[myrank],
+ RecvRequestId[i]) ;
+ cout << "test" << myrank << " Recv RequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(allsource[myrank]) << endl ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr
+ << " " << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ int j ;
+ for (j = 0 ; j <= i ; j++) {
+ int flag ;
+ if ( j < i ) {
+ cout << "test" << myrank << " " << j << " -> Test-Send("<< SendRequestId[j]
+ << ")" << endl ;
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ if ( flag ) {
+ int target, tag, error, outcount ;
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Send RequestId " << SendRequestId[j]
+ << " target " << target << " tag " << tag << " error " << error
+ << endl ;
+ mpi_access.DeleteRequest( SendRequestId[j] ) ;
+ }
+ }
+ cout << "test" << myrank << " " << j << " -> Test-Recv("<< SendRequestId[j]
+ << ")" << endl ;
+ mpi_access.Test( RecvRequestId[j], flag ) ;
+ if ( flag ) {
+ int source, tag, error, outcount ;
+ mpi_access.Status( RecvRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Recv RequestId" << j << " "
+ << RecvRequestId[j] << " source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount << endl ;
+ if ( (outcount != 1) | (recvbuf[j] != j) ) {
+ cout << "====================================================="
+ << endl << "test" << myrank << " outcount "
+ << outcount << " recvbuf[ " << j << " ] " << recvbuf[j] << " KO"
+ << endl << "====================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+ }
+ if ( myrank == 0 ) {
+ if ( i != maxsend-1 ) {
+ sendbuf[i+1] = i + 1 ;
+ sts = mpi_access.ISend(&sendbuf[i+1],1,MPI_INT,alltarget[myrank],
+ SendRequestId[i+1]) ;
+ cout << "test" << myrank << " Send RequestId " << SendRequestId[i+1]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ }
+ else {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,alltarget[myrank],
+ SendRequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr
+ << " " << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+
+ int flag ;
+ mpi_access.TestAll(maxsend,SendRequestId,flag) ;
+ mpi_access.TestAll(maxsend,RecvRequestId,flag) ;
+ mpi_access.WaitAll(maxsend,SendRequestId) ;
+ mpi_access.DeleteRequests(maxsend,SendRequestId) ;
+ mpi_access.WaitAll(maxsend,RecvRequestId) ;
+ mpi_access.DeleteRequests(maxsend,RecvRequestId) ;
+ mpi_access.Check() ;
+ mpi_access.TestAll(maxsend,SendRequestId,flag) ;
+ if ( !flag ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " TestAllSendflag " << flag << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " TestAllSendflag " << flag << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ mpi_access.TestAll(maxsend,RecvRequestId,flag) ;
+ if ( !flag ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " TestAllRecvflag " << flag << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " TestAllRecvflag " << flag << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+
+ int sendrequests[maxsend] ;
+ int sendreqsize = mpi_access.SendRequestIds( alltarget[myrank] , maxsend ,
+ sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ int source, tag, error, outcount ;
+ mpi_access.Status(sendrequests[0], source, tag, error, outcount, true) ;
+ cout << "test" << myrank << " RequestId " << sendrequests[0]
+ << " source " << source << " tag " << tag << " error " << error
+ << " outcount " << outcount << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ int recvrequests[maxsend] ;
+ int recvreqsize = mpi_access.SendRequestIds( allsource[myrank] , maxsend ,
+ recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 3 ) {
+ cout << "test_MPI_Access_Send_Recv must be runned with 3 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int alltarget[3] = {1 , 2 , 0 } ;
+ int allsource[3] = {2 , 0 , 1 } ;
+ int RequestId[10] ;
+ int sts ;
+ int i = 0 ;
+ if ( myrank == 0 ) {
+ sts = mpi_access.Send(&i,1,MPI_INT,alltarget[myrank], RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ for ( i = 0 ; i < 10 ; i++ ) {
+ int recvbuf ;
+ int outcount ;
+ if ( i & 1 ) {
+ outcount = 0 ;
+ sts = mpi_access.Recv(&recvbuf,1,MPI_INT,allsource[myrank], RequestId[i],
+ &outcount) ;
+ }
+ else {
+ sts = mpi_access.Recv(&recvbuf,1,MPI_INT,allsource[myrank], RequestId[i]) ;
+ outcount = 1 ;
+ }
+ //int source, tag, error, outcount ;
+ //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ;
+ cout << "test" << myrank << " Recv RequestId " << RequestId[i]
+ << " tag " << mpi_access.RecvMPITag(allsource[myrank])
+ << " outcount " << outcount << endl ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "==========================================================="
+ << "test" << myrank << " outcount "
+ << outcount << " recvbuf " << recvbuf << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ if ( myrank == 0 ) {
+ if ( i != 9 ) {
+ int ii = i + 1 ;
+ sts = mpi_access.Send(&ii,1,MPI_INT,alltarget[myrank], RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ }
+ else {
+ sts = mpi_access.Send(&i,1,MPI_INT,alltarget[myrank], RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << " tag " << mpi_access.SendMPITag(alltarget[myrank]) << endl ;
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr
+ << " " << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+
+ int flag ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.Check() ;
+
+ int sendrequests[10] ;
+ int sendreqsize = mpi_access.SendRequestIds( alltarget[myrank] , 10 ,
+ sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ int recvrequests[10] ;
+ int recvreqsize = mpi_access.SendRequestIds( allsource[myrank] , 10 ,
+ recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <time.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int sendbuf[10] ;
+ int RequestId[10] ;
+ int sts ;
+ int i ;
+ for ( i = 0 ; i < 10 ; i++ ) {
+ if ( myrank == 0 ) {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << endl ;
+ }
+ else {
+ int flag = false ;
+ while ( !flag ) {
+ int source, tag, outcount ;
+ MPI_Datatype datatype ;
+ sts = mpi_access.IProbe(target, source, tag, datatype, outcount, flag ) ;
+ if ( flag ) {
+ cout << "test" << myrank << " " << i << " IProbe target " << target
+ << " source " << source << " tag " << tag
+ << " outcount " << outcount << " flag " << flag << endl ;
+ }
+ else {
+ cout << "test" << myrank << " IProbe flag " << flag << endl ;
+ sleep( 1 ) ;
+ }
+ if ( flag ) {
+ int recvbuf ;
+ sts = mpi_access.Recv(&recvbuf,outcount,datatype,source, RequestId[i],
+ &outcount) ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO" << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+ int flag ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.DeleteRequests(10,RequestId) ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test_MPI_Access_Send_Recv must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int SendRequestId[10] ;
+ int RecvRequestId[10] ;
+ int sendbuf[10] ;
+ int recvbuf[10] ;
+ int sts ;
+ int i ;
+ for ( i = 0 ; i < 10 ; i++ ) {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISendRecv(&sendbuf[i],1,MPI_INT,target, SendRequestId[i],
+ &recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ;
+ cout << "test" << myrank << " Send sendRequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target)
+ << " recvRequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr
+ << " " << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ int j ;
+ for (j = 0 ; j <= i ; j++) {
+ int flag ;
+ if ( j < i ) {
+ cout << "test" << myrank << " " << j << " -> Test-Send("<< SendRequestId[j]
+ << ")" << endl ;
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ if ( flag ) {
+ int target, tag, error, outcount ;
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Send RequestId " << SendRequestId[j]
+ << " target " << target << " tag " << tag << " error " << error
+ << endl ;
+ mpi_access.DeleteRequest( SendRequestId[j] ) ;
+ }
+ }
+ cout << "test" << myrank << " " << j << " -> Test-Recv("<< SendRequestId[j]
+ << ")" << endl ;
+ mpi_access.Test( RecvRequestId[j], flag ) ;
+ if ( flag ) {
+ int source, tag, error, outcount ;
+ mpi_access.Status( RecvRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Recv RequestId" << j << " "
+ << RecvRequestId[j] << " source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount << endl ;
+ if ( (outcount != 1) | (recvbuf[j] != j) ) {
+ cout << "==========================================================="
+ << "test" << myrank << " outcount "
+ << outcount << " recvbuf[ " << j << " ] " << recvbuf[j] << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+ }
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ mpi_access.Check() ;
+ }
+
+ int flag ;
+ mpi_access.TestAll(10,SendRequestId,flag) ;
+ mpi_access.WaitAll(10,SendRequestId) ;
+ mpi_access.DeleteRequests(10,SendRequestId) ;
+ mpi_access.TestAll(10,SendRequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+
+ mpi_access.TestAll(10,RecvRequestId,flag) ;
+ mpi_access.WaitAll(10,RecvRequestId) ;
+ mpi_access.DeleteRequests(10,RecvRequestId) ;
+ mpi_access.TestAll(10,RecvRequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+
+ int sendrequests[10] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , 10 , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ int recvrequests[10] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , 10 , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxreq 100
+
+ int target = 1 - myrank ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[maxreq] ;
+ int recvbuf[maxreq] ;
+ int i ;
+ for ( i = 0 ; i < maxreq ; i++ ) {
+ if ( myrank == 0 ) {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, SendRequestId[i]) ;
+ cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ;
+ cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ }
+ int j ;
+ for (j = 0 ; j <= i ; j++) {
+ int flag ;
+ if ( myrank == 0 ) {
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ }
+ else {
+ mpi_access.Test( RecvRequestId[j], flag ) ;
+ }
+ if ( flag ) {
+ int target,source, tag, error, outcount ;
+ if ( myrank == 0 ) {
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
+ << ") : target " << target << " tag " << tag << " error " << error
+ << " flag " << flag << endl ;
+ }
+ else {
+ mpi_access.Status( RecvRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Recv RequestId "
+ << RecvRequestId[j] << ") : source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount
+ << " flag " << flag << endl ;
+ if ( (outcount != 1) | (recvbuf[j] != j) ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount "
+ << outcount << " recvbuf " << recvbuf[j] << " KO" << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ //else {
+ // cout << "==========================================================="
+ // << endl << "test" << myrank << " outcount " << outcount
+ // << " RequestId " << RecvRequestId[j] << " recvbuf "
+ // << recvbuf[j] << " OK" << endl
+ // << "==========================================================="
+ // << endl ;
+ //}
+ }
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Check() ;
+ if ( myrank == 0 ) {
+ mpi_access.WaitAll(maxreq, SendRequestId) ;
+ mpi_access.DeleteRequests(maxreq, SendRequestId) ;
+ }
+ else {
+ mpi_access.WaitAll(maxreq, RecvRequestId) ;
+ mpi_access.DeleteRequests(maxreq, RecvRequestId) ;
+ }
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[maxreq] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ int i ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ for ( i = 0 ; i < sendreqsize ; i++ ) {
+ cout << "test" << myrank << " sendrequests[ " << i << " ] = "
+ << sendrequests[i] << endl ;
+ }
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[maxreq] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <time.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxreq 10000
+
+ int target = 1 - myrank ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[maxreq] ;
+ int recvbuf[maxreq] ;
+ int i ;
+ for ( i = 0 ; i < maxreq ; i++ ) {
+ if ( myrank == 0 ) {
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(sendbuf,i,MPI_INT,target, SendRequestId[i]) ;
+ cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ //sleep( 1 ) ;
+ sts = mpi_access.IRecv(recvbuf,i,MPI_INT,target, RecvRequestId[i]) ;
+ cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ int recvreqsize = mpi_access.RecvRequestIdsSize() ;
+ int * recvrequests = new int[ recvreqsize ] ;
+ recvreqsize = mpi_access.RecvRequestIds( target , recvreqsize , recvrequests ) ;
+ int j ;
+ for (j = 0 ; j < recvreqsize ; j++) {
+ int flag ;
+ mpi_access.Test( recvrequests[j], flag ) ;
+ if ( flag ) {
+ int source, tag, error, outcount ;
+ mpi_access.Status( recvrequests[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Recv RequestId "
+ << recvrequests[j] << ") : source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount
+ << " flag " << flag << " : DeleteRequest" << endl ;
+ mpi_access.DeleteRequest( recvrequests[j] ) ;
+ }
+ else {
+// cout << "test" << myrank << " Test(Recv RequestId "
+// << recvrequests[j] << ") flag " << flag << endl ;
+ }
+ }
+ delete [] recvrequests ;
+ }
+ if ( sts != MPI_SUCCESS ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ }
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Check() ;
+ if ( myrank == 0 ) {
+ int size = mpi_access.SendRequestIdsSize() ;
+ cout << "test" << myrank << " before WaitAll sendreqsize " << size << endl ;
+ mpi_access.WaitAll(maxreq, SendRequestId) ;
+ size = mpi_access.SendRequestIdsSize() ;
+ cout << "test" << myrank << " after WaitAll sendreqsize " << size << endl ;
+ int * ArrayOfSendRequests = new int[ size ] ;
+ int nSendRequest = mpi_access.SendRequestIds( size , ArrayOfSendRequests ) ;
+ int i ;
+ for ( i = 0 ; i < nSendRequest ; i++ ) {
+ mpi_access.DeleteRequest( ArrayOfSendRequests[i] ) ;
+ }
+ delete [] ArrayOfSendRequests ;
+ }
+ else {
+ int size = mpi_access.RecvRequestIdsSize() ;
+ cout << "test" << myrank << " before WaitAll recvreqsize " << size << endl ;
+ mpi_access.WaitAll(maxreq, RecvRequestId) ;
+ size = mpi_access.RecvRequestIdsSize() ;
+ cout << "test" << myrank << " after WaitAll recvreqsize " << size << endl ;
+ int * ArrayOfRecvRequests = new int[ size ] ;
+ int nRecvRequest = mpi_access.RecvRequestIds( size , ArrayOfRecvRequests ) ;
+ int i ;
+ for ( i = 0 ; i < nRecvRequest ; i++ ) {
+ mpi_access.DeleteRequest( ArrayOfRecvRequests[i] ) ;
+ }
+ delete [] ArrayOfRecvRequests ;
+ }
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[maxreq] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ int i ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ for ( i = 0 ; i < sendreqsize ; i++ ) {
+ cout << "test" << myrank << " sendrequests[ " << i << " ] = "
+ << sendrequests[i] << endl ;
+ }
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[maxreq] ;
+ int recvreqsize = mpi_access.RecvRequestIds( target , maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxreq 10
+
+ int target = 1 - myrank ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[1000*(maxreq-1)] ;
+ int recvbuf[maxreq-1][1000*(maxreq-1)] ;
+ int i ;
+ for ( i = 0 ; i < 1000*(maxreq-1) ; i++ ) {
+ sendbuf[i] = i ;
+ }
+ for ( i = 0 ; i < maxreq ; i++ ) {
+ if ( myrank == 0 ) {
+ sts = mpi_access.ISend( sendbuf, 1000*i, MPI_INT, target, SendRequestId[i] ) ;
+ cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ sts = mpi_access.IRecv( recvbuf[i], 1000*i, MPI_INT, target,
+ RecvRequestId[i] ) ;
+ cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ }
+ int j ;
+ for (j = 0 ; j <= i ; j++) {
+ int flag ;
+ if ( myrank == 0 ) {
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ }
+ else {
+ mpi_access.Test( RecvRequestId[j], flag ) ;
+ }
+ if ( flag ) {
+ int target,source, tag, error, outcount ;
+ if ( myrank == 0 ) {
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
+ << ") : target " << target << " tag " << tag << " error " << error
+ << " flag " << flag << endl ;
+ }
+ else {
+ mpi_access.Status( RecvRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Recv RequestId "
+ << RecvRequestId[j] << ") : source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount
+ << " flag " << flag << endl ;
+ if ( outcount != 0 ) {
+ if ( (outcount != 1000*j) |
+ (recvbuf[j][outcount-1] != (outcount-1)) ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount "
+ << outcount << " recvbuf " << recvbuf[j][outcount-1] << " KO"
+ << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " RequestId " << RecvRequestId[j] << " recvbuf "
+ << recvbuf[j][outcount-1] << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " RequestId " << RecvRequestId[j] << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Check() ;
+ cout << "test" << myrank << " WaitAll" << endl ;
+ if ( myrank == 0 ) {
+ mpi_access.WaitAll(maxreq, SendRequestId) ;
+ mpi_access.DeleteRequests(maxreq, SendRequestId) ;
+ }
+ else {
+ mpi_access.WaitAll(maxreq, RecvRequestId) ;
+ mpi_access.DeleteRequests(maxreq, RecvRequestId) ;
+ }
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[maxreq] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[maxreq] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxreq 10
+
+ int target = 1 - myrank ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[1000*(maxreq-1)] ;
+ int recvbuf[maxreq-1][1000*(maxreq-1)] ;
+ int maxirecv = 1 ;
+ int i ;
+ RecvRequestId[0] = -1 ;
+ for ( i = 0 ; i < 1000*(maxreq-1) ; i++ ) {
+ sendbuf[i] = i ;
+ }
+ for ( i = 0 ; i < maxreq ; i++ ) {
+ sts = MPI_SUCCESS ;
+ if ( myrank == 0 ) {
+ sts = mpi_access.ISend( sendbuf, 1000*i, MPI_INT, target, SendRequestId[i] ) ;
+ cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ int j ;
+ for (j = 1 ; j <= i ; j++) {
+ int source ;
+ MPI_Datatype datatype ;
+ int outcount ;
+ int flag ;
+ if ( myrank == 0 ) {
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ }
+ else {
+ int MPITag ;
+ sts = mpi_access.IProbe( target , source, MPITag, datatype,
+ outcount, flag) ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " IProbe lenerr " << lenerr << " "
+ << msgerr << endl ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " IProbe KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ cout << "test" << myrank << " IProbe i/j " << i << "/" << j
+ << " MPITag " << MPITag << " datatype " << datatype
+ << " outcount " << outcount << " flag " << flag << endl ;
+ }
+ if ( flag ) {
+ if ( myrank == 0 ) {
+ int target, tag, error, outcount ;
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
+ << ") : target " << target << " tag " << tag << " error " << error
+ << " flag " << flag << endl ;
+ }
+ else {
+ sts = mpi_access.IRecv( recvbuf[maxirecv], outcount, datatype, source,
+ RecvRequestId[maxirecv] ) ;
+ cout << "test" << myrank << " maxirecv " << maxirecv << " IRecv RequestId "
+ << RecvRequestId[maxirecv] << " source " << source
+ << " outcount " << outcount << " tag "
+ << mpi_access.RecvMPITag(target) << endl ;
+ maxirecv = maxirecv + 1 ;
+ }
+ }
+ else if ( myrank == 1 && i == maxreq-1 && j >= maxirecv ) {
+ sts = mpi_access.IRecv( recvbuf[j], 1000*j, MPI_INT, target,
+ RecvRequestId[j] ) ;
+ cout << "test" << myrank << " maxirecv " << maxirecv << " IRecv RequestId "
+ << RecvRequestId[j] << " target " << target << " length " << 1000*j
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ maxirecv = maxirecv + 1 ;
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " KO" << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Check() ;
+ int flag ;
+ if ( myrank == 0 ) {
+ mpi_access.TestAll( maxreq, SendRequestId, flag ) ;
+ cout << "test" << myrank << " TestAll SendRequest flag " << flag << endl ;
+ }
+ else {
+ int i ;
+ int source ;
+ int outcount ;
+ int flag ;
+ if ( maxirecv != maxreq ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " KO" << " maxirecv " << maxirecv
+ << " != maxreq " << maxreq << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ while ( maxirecv > 0 ) {
+ for ( i = 1 ; i < maxreq ; i++ ) {
+ cout << "test" << myrank << " IProbe : " << endl ;
+ sts = mpi_access.Test( RecvRequestId[i] , flag ) ;
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " flag " << flag << " lenerr "
+ << lenerr << " " << msgerr << " maxirecv " << maxirecv << endl ;
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ cout << "test" << myrank << " Test flag " << flag << endl ;
+ if ( flag ) {
+ int tag, error ;
+ mpi_access.Status( RecvRequestId[i] , source , tag , error ,
+ outcount ) ;
+ if ( i != 0 ) {
+ if ( outcount != 1000*i |
+ (recvbuf[i][outcount-1] != (outcount-1)) ) {
+ cout << "========================================================"
+ << endl << "test" << myrank << " outcount " << outcount
+ << " KO" << " i " << i
+ << " recvbuf " << recvbuf[i][outcount-1] << endl
+ << "========================================================"
+ << endl ;
+ return 1 ;
+ }
+ }
+ else if ( outcount != 0 ) {
+ cout << "========================================================"
+ << endl << "test" << myrank << " outcount " << outcount
+ << " KO" << " i " << i << endl
+ << "========================================================"
+ << endl ;
+ return 1 ;
+ }
+ maxirecv = maxirecv - 1 ;
+ }
+ }
+ }
+ mpi_access.TestAll( maxreq, RecvRequestId, flag ) ;
+ cout << "test" << myrank << " TestAll RecvRequest flag " << flag << endl ;
+ }
+ mpi_access.Check() ;
+ cout << "test" << myrank << " WaitAll :" << endl ;
+ if ( myrank == 0 ) {
+ mpi_access.WaitAll( maxreq, SendRequestId ) ;
+ mpi_access.DeleteRequests( maxreq, SendRequestId ) ;
+ }
+ else {
+ mpi_access.WaitAll( maxreq, RecvRequestId ) ;
+ mpi_access.DeleteRequests( maxreq, RecvRequestId ) ;
+ }
+
+ if ( myrank == 0 ) {
+ int sendrequests[maxreq] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ sendreqsize = mpi_access.SendRequestIds( target , maxreq , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[maxreq] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int RequestId[10] ;
+ int sts ;
+ int i ;
+ for ( i = 0 ; i < 10 ; i++ ) {
+ if ( myrank == 0 ) {
+ sts = mpi_access.Send(&i,1,MPI_INT,target, RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << endl ;
+ }
+ else {
+ int source, tag, outcount ;
+ MPI_Datatype datatype ;
+ sts = mpi_access.Probe(target, source, tag, datatype, outcount ) ;
+ cout << "test" << myrank << " Probe target " << target << " source " << source
+ << " tag " << tag << " outcount " << outcount << endl ;
+ int recvbuf ;
+ sts = mpi_access.Recv(&recvbuf,outcount,datatype,source, RequestId[i],
+ &outcount) ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "==========================================================="
+ << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+ int flag ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.Check() ;
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test_MPI_Access_Send_Recv must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int sendRequestId[10] ;
+ int recvRequestId[10] ;
+ int sts ;
+ int i ;
+ for ( i = 0 ; i < 10 ; i++ ) {
+ int recvbuf ;
+ int outcount ;
+ if ( i & 1 ) {
+ outcount = -1 ;
+ sts = mpi_access.SendRecv(&i,1,MPI_INT,target, sendRequestId[i],
+ &recvbuf,1,MPI_INT,target, recvRequestId[i],
+ &outcount) ;
+ }
+ else {
+ sts = mpi_access.SendRecv(&i,1,MPI_INT,target, sendRequestId[i],
+ &recvbuf,1,MPI_INT,target, recvRequestId[i]) ;
+// outcount = mpi_access.MPIOutCount( recvRequestId[i] ) ;
+ outcount = 1 ;
+ }
+ cout << "test" << myrank << " Send sendRequestId " << sendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target)
+ << " recvRequestId " << recvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target)
+ << " outcount " << outcount << " MPIOutCount "
+ << mpi_access.MPIOutCount( recvRequestId[i] ) << endl ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "==========================================================="
+ << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+
+ int flag ;
+ mpi_access.TestAll(10,sendRequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,sendRequestId) ;
+ mpi_access.TestAll(10,recvRequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,recvRequestId) ;
+ mpi_access.Check() ;
+
+ int sendrequests[10] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , 10 , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ int recvrequests[10] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , 10 , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int RequestId[10] ;
+ int sts ;
+ int i ;
+ for ( i = 0 ; i < 10 ; i++ ) {
+ if ( myrank == 0 ) {
+ sts = mpi_access.Send(&i,1,MPI_INT,target, RequestId[i]) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ int recvbuf ;
+ int outcount ;
+ sts = mpi_access.Recv(&recvbuf,1,MPI_INT,target, RequestId[i],&outcount) ;
+ //int source, tag, error, outcount ;
+ //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ;
+ cout << "test" << myrank << " Recv RequestId " << RequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target)
+ << " outcount " << outcount << endl ;
+ if ( (outcount != 1) | (recvbuf != i) ) {
+ cout << "==========================================================="
+ << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+ int flag ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[10] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , 10 , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ }
+ else {
+ int recvrequests[10] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , 10 , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+ int target = 1 - myrank ;
+ int RequestId[10] ;
+ int sendbuf[9000] ;
+ int recvbuf[9000] ;
+ bool recvbufok ;
+ int sts ;
+ int i , j ;
+ for ( i = 0 ; i < 9000 ; i++ ) {
+ sendbuf[i] = i ;
+ }
+ for ( i = 0 ; i < 10 ; i++ ) {
+ if ( myrank == 0 ) {
+ sts = mpi_access.Send( sendbuf, 1000*i, MPI_INT, target, RequestId[i] ) ;
+ cout << "test" << myrank << " Send RequestId " << RequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ sts = MPI_SUCCESS ;
+ RequestId[i] = -1 ;
+ int outcount = 0 ;
+ if ( i != 0 ) {
+ sts = mpi_access.Recv( recvbuf,1000*i+1,MPI_INT,target, RequestId[i],
+ &outcount ) ;
+ }
+ //int source, tag, error, outcount ;
+ //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ;
+ cout << "test" << myrank << " Recv RequestId " << RequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target)
+ << " outcount " << outcount << endl ;
+ recvbufok = true ;
+ for ( j = 0 ; j < outcount ; j++ ) {
+ if ( recvbuf[j] != j ) {
+ cout << "test" << myrank << " recvbuf[ " << j << " ] = " << recvbuf[j]
+ << endl ;
+ recvbufok = false ;
+ break ;
+ }
+ }
+ if ( (outcount != 1000*i) | !recvbufok ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " recvbuf " << recvbuf << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ mpi_access.Check() ;
+ }
+ int flag ;
+ mpi_access.TestAll(10,RequestId,flag) ;
+ if ( !flag ) {
+ cout << "test" << myrank << " flag " << flag << " KO" << endl ;
+ return 1 ;
+ }
+ mpi_access.WaitAll(10,RequestId) ;
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[10] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , 10 , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ }
+ else {
+ int recvrequests[10] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , 10 , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 ) {
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access mpi_access( group ) ;
+
+#define maxreq 10
+
+ int target = 1 - myrank ;
+ int SendTimeRequestId[maxreq] ;
+ int RecvTimeRequestId[maxreq] ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[maxreq] ;
+ int recvbuf[maxreq] ;
+ int i = 0 ;
+ ParaMEDMEM::TimeMessage aSendTimeMsg[maxreq] ;
+ ParaMEDMEM::TimeMessage aRecvTimeMsg[maxreq] ;
+ double t ;
+ double dt = 1. ;
+ double maxt = 10. ;
+ for ( t = 0 ; t < maxt ; t = t+dt ) {
+ if ( myrank == 0 ) {
+ aSendTimeMsg[i].time = t ;
+ aSendTimeMsg[i].deltatime = dt ;
+ //aSendTimeMsg[i].maxtime = maxt ;
+ //sts = mpi_access.ISend( &aSendTimeMsg , mpi_access.TimeExtent() ,
+ sts = mpi_access.ISend( &aSendTimeMsg[i] , 1 ,
+ mpi_access.TimeType() , target ,
+ SendTimeRequestId[i]) ;
+ cout << "test" << myrank << " ISend RequestId " << SendTimeRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ sendbuf[i] = i ;
+ sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, SendRequestId[i]) ;
+ cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+ << " tag " << mpi_access.SendMPITag(target) << endl ;
+ }
+ else {
+ //sts = mpi_access.IRecv( &aRecvTimeMsg , mpi_access.TimeExtent() ,
+ sts = mpi_access.IRecv( &aRecvTimeMsg[i] , 1 ,
+ mpi_access.TimeType() , target ,
+ RecvTimeRequestId[i]) ;
+ cout << "test" << myrank << " IRecv RequestId " << RecvTimeRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ;
+ cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
+ << " tag " << mpi_access.RecvMPITag(target) << endl ;
+ }
+ int j ;
+ for (j = 0 ; j <= i ; j++) {
+ int flag ;
+ if ( myrank == 0 ) {
+ mpi_access.Test( SendTimeRequestId[j], flag ) ;
+ }
+ else {
+ mpi_access.Test( RecvTimeRequestId[j], flag ) ;
+ }
+ if ( flag ) {
+ int target,source, tag, error, outcount ;
+ if ( myrank == 0 ) {
+ mpi_access.Status( SendTimeRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Send TimeRequestId " << SendTimeRequestId[j]
+ << ") : target " << target << " tag " << tag << " error " << error
+ << " flag " << flag << aSendTimeMsg[j] << endl ;
+ }
+ else {
+ mpi_access.Status( RecvTimeRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Recv TimeRequestId "
+ << RecvTimeRequestId[j] << ") : source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount
+ << " flag " << flag << aRecvTimeMsg[j] << endl ;
+ if ( (outcount != 1) | (aRecvTimeMsg[j].time != j) ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount << " KO"
+ << " RecvTimeRequestId " << RecvTimeRequestId[j] << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " RecvTimeRequestId " << RecvTimeRequestId[j] << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ }
+ if ( myrank == 0 ) {
+ mpi_access.Test( SendRequestId[j], flag ) ;
+ }
+ else {
+ mpi_access.Test( RecvRequestId[j], flag ) ;
+ }
+ if ( flag ) {
+ int target,source, tag, error, outcount ;
+ if ( myrank == 0 ) {
+ mpi_access.Status( SendRequestId[j], target, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
+ << ") : target " << target << " tag " << tag << " error " << error
+ << " flag " << flag << endl ;
+ }
+ else {
+ mpi_access.Status( RecvRequestId[j], source, tag, error, outcount,
+ true ) ;
+ cout << "test" << myrank << " Test(Recv RequestId "
+ << RecvRequestId[j] << ") : source " << source << " tag " << tag
+ << " error " << error << " outcount " << outcount
+ << " flag " << flag << endl ;
+ if ( (outcount != 1) | (recvbuf[j] != j) ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount "
+ << outcount << " recvbuf " << recvbuf[j] << " KO" << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " outcount " << outcount
+ << " RequestId " << RecvRequestId[j] << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ }
+ }
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ mpi_access.Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+
+ if ( sts != MPI_SUCCESS ) {
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ i = i + 1 ;
+ }
+
+ mpi_access.Check() ;
+ if ( myrank == 0 ) {
+ mpi_access.WaitAll(maxreq, SendTimeRequestId) ;
+ mpi_access.DeleteRequests(maxreq, SendTimeRequestId) ;
+ mpi_access.WaitAll(maxreq, SendRequestId) ;
+ mpi_access.DeleteRequests(maxreq, SendRequestId) ;
+ }
+ else {
+ mpi_access.WaitAll(maxreq, RecvTimeRequestId) ;
+ mpi_access.DeleteRequests(maxreq, RecvTimeRequestId) ;
+ mpi_access.WaitAll(maxreq, RecvRequestId) ;
+ mpi_access.DeleteRequests(maxreq, RecvRequestId) ;
+ }
+ mpi_access.Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[2*maxreq] ;
+ int sendreqsize = mpi_access.SendRequestIds( target , 2*maxreq , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[2*maxreq] ;
+ int recvreqsize = mpi_access.SendRequestIds( target , 2*maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ mpi_access.Barrier() ;
+
+ delete group ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+
--- /dev/null
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <mpi.h>
+//#include "CommInterface.hxx"
+//#include "ProcessorGroup.hxx"
+//#include "MPIProcessorGroup.hxx"
+#include "MPI_Access.hxx"
+
+using namespace std;
+using namespace ParaMEDMEM;
+
+void chksts( int sts , int myrank , ParaMEDMEM::MPI_Access * mpi_access ) {
+ char msgerr[MPI_MAX_ERROR_STRING] ;
+ int lenerr ;
+ if ( sts != MPI_SUCCESS ) {
+ mpi_access->Error_String(sts, msgerr, &lenerr) ;
+ cout << "test" << myrank << " lenerr " << lenerr << " "
+ << msgerr << endl ;
+ cout << "==========================================================="
+ << "test" << myrank << " KO"
+ << "==========================================================="
+ << endl ;
+ exit( 1 ) ;
+ }
+return ;
+}
+
+int main(int argc, char** argv) {
+
+ cout << "test" << endl ;
+
+ MPI_Init(&argc, &argv) ;
+
+ int size ;
+ int myrank ;
+ MPI_Comm_size(MPI_COMM_WORLD,&size) ;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
+
+ if ( size != 2 || argc != 3 ) {
+ cout << "usage :" << endl ;
+ cout << "mpirun -np <nbprocs> test_MPI_Access_Time_0 <deltatime0> <deltatime1>" <<endl ;
+ cout << " nbprocs =2 and deltatime0 >= deltatime1" << endl;
+ cout << "test must be runned with 2 procs" << endl ;
+ return 1 ;
+ }
+
+#define maxreq 100
+
+ double t ;
+ double dt[2] = {1., 1.} ;
+ double maxt = maxreq/dt[myrank] ;
+ dt[0] = atof(argv[1]);
+ dt[1] = atof(argv[2]);
+ if ( dt[0] < dt[1] ) {
+ cout << "usage :" << endl ;
+ cout << "mpirun -np <nbprocs> test_MPI_Access_Time_0 <deltatime0> <deltatime1>" <<endl ;
+ cout << "deltatime0 >= deltatime1" << endl;
+ return 1 ;
+ }
+
+ cout << "test" << myrank << endl ;
+
+ ParaMEDMEM::CommInterface interface ;
+
+ ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+
+ ParaMEDMEM::MPI_Access * mpi_access = new ParaMEDMEM::MPI_Access( group ) ;
+
+ int target = 1 - myrank ;
+ int SendTimeRequestId[maxreq] ;
+ int RecvTimeRequestId[maxreq] ;
+ int SendRequestId[maxreq] ;
+ int RecvRequestId[maxreq] ;
+ int sts ;
+ int sendbuf[maxreq] ;
+ int recvbuf[maxreq] ;
+ ParaMEDMEM::TimeMessage aSendTimeMsg[maxreq] ;
+ int lasttime = -1 ;
+ ParaMEDMEM::TimeMessage RecvTimeMessages[maxreq+1] ;
+ ParaMEDMEM::TimeMessage *aRecvTimeMsg = &RecvTimeMessages[1] ;
+// mpi_access->Trace() ;
+ int istep = 0 ;
+ for ( t = 0 ; t < maxt ; t = t+dt[myrank] ) {
+ cout << "test" << myrank << " ==========================TIME " << t
+ << " ==========================" << endl ;
+ if ( myrank == 0 ) {
+ aSendTimeMsg[istep].time = t ;
+ aSendTimeMsg[istep].deltatime = dt[myrank] ;
+ //aSendTimeMsg[istep].maxtime = maxt ;
+ if ( t+dt[myrank] >= maxt ) {
+ aSendTimeMsg[istep].deltatime = 0 ;
+ }
+ sts = mpi_access->ISend( &aSendTimeMsg[istep] , 1 ,
+ mpi_access->TimeType() , target ,
+ SendTimeRequestId[istep]) ;
+ cout << "test" << myrank << " ISend TimeRequestId " << SendTimeRequestId[istep]
+ << " tag " << mpi_access->MPITag(SendTimeRequestId[istep]) << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ sendbuf[istep] = istep ;
+ sts = mpi_access->ISend(&sendbuf[istep],1,MPI_INT,target, SendRequestId[istep]) ;
+ cout << "test" << myrank << " ISend Data RequestId " << SendRequestId[istep]
+ << " tag " << mpi_access->MPITag(SendRequestId[istep]) << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+//CheckSent
+//=========
+ int sendrequests[2*maxreq] ;
+ int sendreqsize = mpi_access->SendRequestIds( target , 2*maxreq ,
+ sendrequests ) ;
+ int j , flag ;
+ for ( j = 0 ; j < sendreqsize ; j++ ) {
+ sts = mpi_access->Test( sendrequests[j] , flag ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ if ( flag ) {
+ mpi_access->DeleteRequest( sendrequests[j] ) ;
+ cout << "test" << myrank << " " << j << ". " << sendrequests[j]
+ << " sendrequest deleted" << endl ;
+ }
+ }
+ }
+ else {
+//InitRecv
+//========
+ if ( t == 0 ) {
+ aRecvTimeMsg[lasttime].time = 0 ;
+ sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 ,
+ mpi_access->TimeType() ,
+ target , RecvTimeRequestId[lasttime+1]) ;
+ cout << "test" << myrank << " t == 0 IRecv TimeRequestId "
+ << RecvTimeRequestId[lasttime+1]
+ << " MPITag " << mpi_access->MPITag( RecvTimeRequestId[lasttime+1] )
+ << " MPICompleted "
+ << mpi_access->MPICompleted( RecvTimeRequestId[lasttime+1] ) << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+ else {
+ cout << "test" << myrank << " t # 0 lasttime " << lasttime << endl ;
+//InitialOutTime
+//==============
+ bool outtime = false ;
+ if ( lasttime != -1 ) {
+ if ( t <= aRecvTimeMsg[lasttime-1].time ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " t " << t << " <= "
+ << "aRecvTimeMsg[ " << lasttime << "-1 ].time "
+ << aRecvTimeMsg[lasttime-1].time << " KO" << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " t " << t << " > "
+ << "aRecvTimeMsg[ " << lasttime << "-1 ].time "
+ << aRecvTimeMsg[lasttime-1].time << " OK" << endl
+ << "==========================================================="
+ << endl ;
+ }
+ //outtime = ((aRecvTimeMsg[lasttime].time +
+ // aRecvTimeMsg[lasttime].deltatime) >=
+ // aRecvTimeMsg[lasttime].maxtime) ;
+ outtime = aRecvTimeMsg[lasttime].deltatime == 0 ;
+ }
+// CheckRecv - CheckTime
+// On a lasttime tel que :
+// aRecvTimeMsg[ lasttime-1 ].time < T(i-1) <= aRecvTimeMsg[ lasttime ].time
+// On cherche lasttime tel que :
+// aRecvTimeMsg[ lasttime-1 ].time < T(i) <= aRecvTimeMsg[ lasttime ].time
+ if ( t <= aRecvTimeMsg[lasttime].time ) {
+ outtime = false ;
+ }
+ cout << "test" << myrank << " while outtime( " << outtime << " && t " << t
+ << " > aRecvTimeMsg[ " << lasttime << " ] "
+ << aRecvTimeMsg[lasttime].time << " )" << endl ;
+ while ( !outtime && (t > aRecvTimeMsg[lasttime].time) ) {
+ lasttime += 1 ;
+//TimeMessage
+//===========
+ sts = mpi_access->Wait( RecvTimeRequestId[lasttime] ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ cout << "test" << myrank << " Wait done RecvTimeRequestId "
+ << RecvTimeRequestId[lasttime] << " lasttime " << lasttime
+ << " tag " << mpi_access->MPITag(RecvTimeRequestId[lasttime])
+ << aRecvTimeMsg[lasttime] << endl ;
+ if ( lasttime == 0 ) {
+ aRecvTimeMsg[lasttime-1] = aRecvTimeMsg[lasttime] ;
+ }
+ mpi_access->DeleteRequest( RecvTimeRequestId[lasttime] ) ;
+
+ double deltatime = aRecvTimeMsg[lasttime].deltatime ;
+ //double maxtime = aRecvTimeMsg[lasttime].maxtime ;
+ double nexttime = aRecvTimeMsg[lasttime].time + deltatime ;
+ cout << "test" << myrank << " t " << t << " lasttime " << lasttime
+ << " deltatime " << deltatime
+ << " nexttime " << nexttime << endl ;
+ //if ( nexttime < maxtime && t > nexttime ) {
+ if ( deltatime != 0 && t > nexttime ) {
+//CheckRecv :
+//=========
+ //while ( nexttime < maxtime && t > nexttime ) {
+ while ( deltatime != 0 && t > nexttime ) {
+ int source, MPITag, outcount ;
+ MPI_Datatype datatype ;
+ sts = mpi_access->Probe( target , source, MPITag, datatype,
+ outcount ) ;
+ chksts( sts , myrank , mpi_access ) ;
+// Cancel DataMessages jusqu'a un TimeMessage
+ int cancelflag ;
+ while ( !mpi_access->IsTimeMessage( MPITag ) ) {
+ sts = mpi_access->Cancel( source, MPITag, datatype, outcount ,
+ //sts = mpi_access->Cancel( source, datatype, outcount ,
+ //RecvRequestId[lasttime] ,
+ cancelflag ) ;
+ cout << "test" << myrank << " Recv TO CANCEL RequestId "
+ << RecvRequestId[lasttime]
+ << " tag " << mpi_access->RecvMPITag( target )
+ << " cancelflag " << cancelflag << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ sts = mpi_access->Probe( target , source, MPITag, datatype,
+ outcount ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+//On peut avancer en temps
+ nexttime += deltatime ;
+ //if ( nexttime < maxtime && t > nexttime ) {
+ if ( deltatime != 0 && t > nexttime ) {
+// Cancel du TimeMessage
+ sts = mpi_access->Cancel( source, MPITag, datatype, outcount ,
+ //sts = mpi_access->Cancel( source, datatype, outcount ,
+ //RecvRequestId[lasttime] ,
+ cancelflag ) ;
+ cout << "test" << myrank << " Time TO CANCEL RequestId "
+ << RecvRequestId[lasttime]
+ << " tag " << mpi_access->RecvMPITag( target )
+ << " cancelflag " << cancelflag << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+ }
+ }
+ else {
+//DoRecv
+//======
+ cout << "test" << myrank << " Recv target " << target
+ << " lasttime " << lasttime
+ << " lasttime-1 " << aRecvTimeMsg[lasttime-1]
+ << " lasttime " << aRecvTimeMsg[lasttime]
+ << endl ;
+ sts = mpi_access->Recv(&recvbuf[lasttime],1,MPI_INT,target,
+ RecvRequestId[lasttime]) ;
+ cout << "test" << myrank << " Recv RequestId "
+ << RecvRequestId[lasttime]
+ << " tag " << mpi_access->RecvMPITag( target )
+ << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+ //outtime = ((aRecvTimeMsg[lasttime].time +
+ // aRecvTimeMsg[lasttime].deltatime) >=
+ // aRecvTimeMsg[lasttime].maxtime) ;
+ outtime = aRecvTimeMsg[lasttime].deltatime == 0 ;
+ if ( !outtime ) {
+// Une lecture asynchrone d'un message temps a l'avance
+ sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 ,
+ mpi_access->TimeType() , target ,
+ RecvTimeRequestId[lasttime+1]) ;
+ cout << "test" << myrank << " IRecv TimeRequestId "
+ << RecvTimeRequestId[lasttime+1] << " MPITag "
+ << mpi_access->MPITag( RecvTimeRequestId[lasttime+1] )
+ << " MPICompleted "
+ << mpi_access->MPICompleted( RecvTimeRequestId[lasttime+1] )
+ << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+ else if ( t <= aRecvTimeMsg[lasttime].time ) {
+ outtime = false ;
+ }
+ }
+
+ //printf("DEBUG t %.15f Msg[lasttime-1] %.15f Msg[lasttime] %.15f \n",t,
+ // aRecvTimeMsg[lasttime-1].time,aRecvTimeMsg[lasttime].time) ;
+ if ( ((t <= aRecvTimeMsg[lasttime-1].time) ||
+ (t > aRecvTimeMsg[lasttime].time)) && !outtime ) {
+ cout << "==========================================================="
+ << endl << "test" << myrank << " t " << t << " <= "
+ << "aRecvTimeMsg[ " << lasttime << "-1 ].time "
+ << aRecvTimeMsg[lasttime-1].time << " ou t " << t << " > "
+ << "aRecvTimeMsg[ " << lasttime << " ].time "
+ << aRecvTimeMsg[lasttime].time << endl
+ << " ou bien outtime " << outtime << " KO RequestTimeIds "
+ << RecvTimeRequestId[lasttime-1] << " " << RecvTimeRequestId[lasttime]
+ << " RequestIds "
+ << RecvRequestId[lasttime-1] << " " << RecvRequestId[lasttime] << endl
+ << "==========================================================="
+ << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "==========================================================="
+ << endl << "test" << myrank
+ << " aRecvTimeMsg[ " << lasttime << "-1 ].time "
+ << aRecvTimeMsg[lasttime-1].time << " < t " << t << " <= "
+ << "aRecvTimeMsg[ " << lasttime << " ].time "
+ << aRecvTimeMsg[lasttime].time << endl
+ << " ou bien outtime " << outtime << " OK RequestTimeIds "
+ << RecvTimeRequestId[lasttime-1] << " " << RecvTimeRequestId[lasttime]
+ << " RequestIds "
+ << RecvRequestId[lasttime-1] << " " << RecvRequestId[lasttime] << endl
+ << "==========================================================="
+ << endl ;
+ }
+ }
+ }
+ chksts( sts , myrank , mpi_access ) ;
+ istep = istep + 1 ;
+ }
+
+ cout << "test" << myrank << " Barrier :" << endl ;
+ mpi_access->Barrier() ;
+
+ mpi_access->Check() ;
+
+ if ( myrank == 0 ) {
+//CheckFinalSent
+//==============
+ cout << "test" << myrank << " CheckFinalSent :" << endl ;
+ int sendrequests[2*maxreq] ;
+ int sendreqsize = mpi_access->SendRequestIds( target , 2*maxreq , sendrequests ) ;
+ int j ;
+ for ( j = 0 ; j < sendreqsize ; j++ ) {
+ sts = mpi_access->Wait( sendrequests[j] ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ mpi_access->DeleteRequest( sendrequests[j] ) ;
+ cout << "test" << myrank << " " << j << ". " << sendrequests[j] << " deleted"
+ << endl ;
+ }
+ }
+ else {
+ cout << "test" << myrank << " CheckFinalRecv :" << endl ;
+ int recvrequests[2*maxreq] ;
+ int recvreqsize = mpi_access->RecvRequestIds( target , 2*maxreq , recvrequests ) ;
+ int cancelflag ;
+ int j ;
+ for ( j = 0 ; j < recvreqsize ; j++ ) {
+ sts = mpi_access->Cancel( recvrequests[j] , cancelflag ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ mpi_access->DeleteRequest( recvrequests[j] ) ;
+ cout << "test" << myrank << " " << j << ". " << recvrequests[j] << " deleted"
+ << " cancelflag " << cancelflag << endl ;
+ }
+ int source, MPITag, outcount , flag ;
+ MPI_Datatype datatype ;
+ sts = mpi_access->IProbe( target , source, MPITag, datatype,
+ outcount , flag ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ while ( flag ) {
+ sts = mpi_access->Cancel( source, MPITag, datatype, outcount ,
+ //sts = mpi_access->Cancel( source, datatype, outcount ,
+ //RecvRequestId[lasttime] ,
+ cancelflag ) ;
+ cout << "test" << myrank << " TO CANCEL RequestId "
+ << RecvRequestId[lasttime]
+ << " tag " << mpi_access->RecvMPITag( target )
+ << " cancelflag " << cancelflag << endl ;
+ chksts( sts , myrank , mpi_access ) ;
+ sts = mpi_access->IProbe( target , source, MPITag, datatype,
+ outcount , flag ) ;
+ chksts( sts , myrank , mpi_access ) ;
+ }
+ }
+ mpi_access->Check() ;
+
+ if ( myrank == 0 ) {
+ int sendrequests[2*maxreq] ;
+ int sendreqsize = mpi_access->SendRequestIds( target , 2*maxreq , sendrequests ) ;
+ if ( sendreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+ else {
+ int recvrequests[2*maxreq] ;
+ int recvreqsize = mpi_access->RecvRequestIds( target , 2*maxreq , recvrequests ) ;
+ if ( recvreqsize != 0 ) {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
+ << "=========================================================" << endl ;
+ return 1 ;
+ }
+ else {
+ cout << "=========================================================" << endl
+ << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
+ << "=========================================================" << endl ;
+ }
+ }
+
+ int i ;
+ for ( i = 0 ; i <= lasttime ; i++ ) {
+ cout << "test" << myrank << " " << i << ". RecvTimeMsg "
+ << aRecvTimeMsg[i].time << " recvbuf " << recvbuf[i] << endl ;
+ }
+
+ mpi_access->Barrier() ;
+
+ delete group ;
+ delete mpi_access ;
+
+ MPI_Finalize();
+
+ cout << "test" << myrank << " OK" << endl ;
+
+ return 0;
+}
+
+
+
+