-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#define ENABLE_FORCED_FAILURES
using namespace std;
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
-void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess * mpi_access ) {
+void chksts( int sts , int myrank , MEDCoupling::MPIAccess * mpi_access ) {
char msgerr[MPI_MAX_ERROR_STRING] ;
int lenerr ;
if ( sts != MPI_SUCCESS ) {
mpi_access->errorString(sts, msgerr, &lenerr) ;
- cout << "test" << myrank << " lenerr " << lenerr << " "
+ debugStream << "test" << myrank << " lenerr " << lenerr << " "
<< msgerr << endl ;
ostringstream strstream ;
strstream << "==========================================================="
<< "test" << myrank << " KO"
<< "==========================================================="
<< endl ;
- cout << strstream.str() << endl ;
+ debugStream << strstream.str() << endl ;
CPPUNIT_FAIL( strstream.str() ) ;
}
return ;
void MPIAccessTest::test_MPI_Access_Time_0() {
- cout << "test_MPI_Access_Time_0" << endl ;
+ debugStream << "test_MPI_Access_Time_0" << endl ;
// MPI_Init(&argc, &argv) ;
strstream << "usage :" << endl
<< "mpirun -np <nbprocs> test_MPI_Access_Time_0" <<endl
<< " nbprocs =2" << endl
- << "test must be runned with 2 procs" << endl ;
- cout << strstream.str() << endl ;
- CPPUNIT_FAIL( strstream.str() ) ;
+ << "test must be run with 2 procs" << endl ;
+ cerr << strstream.str() << endl ;
+ //CPPUNIT_FAIL( strstream.str() ) ;
+ return;
}
#define maxreq 100
double dt[2] = {2., 1.} ;
double maxt = maxreq/dt[myrank] ;
- cout << "test_MPI_Access_Time_0 rank" << myrank << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << endl ;
- ParaMEDMEM::CommInterface interface ;
+ MEDCoupling::CommInterface interface ;
- ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ;
+ MEDCoupling::MPIProcessorGroup* group = new MEDCoupling::MPIProcessorGroup(interface) ;
- ParaMEDMEM::MPIAccess * mpi_access = new ParaMEDMEM::MPIAccess( group ) ;
+ MEDCoupling::MPIAccess * mpi_access = new MEDCoupling::MPIAccess( group ) ;
if ( myrank >= 2 ) {
- cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
mpi_access->barrier() ;
- cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
- cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
mpi_access->barrier() ;
- cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
delete group ;
delete mpi_access ;
- cout << "test_MPI_Access_Time" << myrank << " OK" << endl ;
+ debugStream << "test_MPI_Access_Time" << myrank << " OK" << endl ;
return ;
}
int RecvTimeRequestId[maxreq] ;
int SendRequestId[maxreq] ;
int RecvRequestId[maxreq] ;
- int sts ;
+ int sts = 0;
int sendbuf[maxreq] ;
int recvbuf[maxreq] ;
- ParaMEDMEM::TimeMessage aSendTimeMsg[maxreq] ;
+ MEDCoupling::TimeMessage aSendTimeMsg[maxreq] ;
int lasttime = -1 ;
- ParaMEDMEM::TimeMessage RecvTimeMessages[maxreq+1] ;
- ParaMEDMEM::TimeMessage *aRecvTimeMsg = &RecvTimeMessages[1] ;
+ MEDCoupling::TimeMessage RecvTimeMessages[maxreq+1] ;
+ MEDCoupling::TimeMessage *aRecvTimeMsg = &RecvTimeMessages[1] ;
// mpi_access->Trace() ;
int istep = 0 ;
for ( t = 0 ; t < maxt ; t = t+dt[myrank] ) {
- cout << "test" << myrank << " ==========================TIME " << t
+ debugStream << "test" << myrank << " ==========================TIME " << t
<< " ==========================" << endl ;
if ( myrank == 0 ) {
aSendTimeMsg[istep].time = t ;
sts = mpi_access->ISend( &aSendTimeMsg[istep] , 1 ,
mpi_access->timeType() , target ,
SendTimeRequestId[istep]) ;
- cout << "test" << myrank << " ISend TimeRequestId " << SendTimeRequestId[istep]
+ debugStream << "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]
+ debugStream << "test" << myrank << " ISend Data RequestId " << SendRequestId[istep]
<< " tag " << mpi_access->MPITag(SendRequestId[istep]) << endl ;
chksts( sts , myrank , mpi_access ) ;
//CheckSent
chksts( sts , myrank , mpi_access ) ;
if ( flag ) {
mpi_access->deleteRequest( sendrequests[j] ) ;
- cout << "test" << myrank << " " << j << ". " << sendrequests[j]
+ debugStream << "test" << myrank << " " << j << ". " << sendrequests[j]
<< " sendrequest deleted" << endl ;
}
}
sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 ,
mpi_access->timeType() ,
target , RecvTimeRequestId[lasttime+1]) ;
- cout << "test" << myrank << " t == 0 IRecv TimeRequestId "
+ debugStream << "test" << myrank << " t == 0 IRecv TimeRequestId "
<< RecvTimeRequestId[lasttime+1]
<< " MPITag " << mpi_access->MPITag( RecvTimeRequestId[lasttime+1] )
<< " MPICompleted "
chksts( sts , myrank , mpi_access ) ;
}
else {
- cout << "test" << myrank << " t # 0 lasttime " << lasttime << endl ;
+ debugStream << "test" << myrank << " t # 0 lasttime " << lasttime << endl ;
//InitialOutTime
//==============
bool outtime = false ;
<< aRecvTimeMsg[lasttime-1].time << " KO" << endl
<< "==========================================================="
<< endl ;
- cout << strstream.str() << endl ;
+ debugStream << strstream.str() << endl ;
CPPUNIT_FAIL( strstream.str() ) ;
}
else {
- cout << "==========================================================="
+ debugStream << "==========================================================="
<< endl << "test" << myrank << " t " << t << " > "
<< "aRecvTimeMsg[ " << lasttime << "-1 ].time "
<< aRecvTimeMsg[lasttime-1].time << " OK" << endl
if ( t <= aRecvTimeMsg[lasttime].time ) {
outtime = false ;
}
- cout << "test" << myrank << " while outtime( " << outtime << " && t " << t
+ debugStream << "test" << myrank << " while outtime( " << outtime << " && t " << t
<< " > aRecvTimeMsg[ " << lasttime << " ] "
<< aRecvTimeMsg[lasttime].time << " )" << endl ;
while ( !outtime && (t > aRecvTimeMsg[lasttime].time) ) {
//===========
sts = mpi_access->wait( RecvTimeRequestId[lasttime] ) ;
chksts( sts , myrank , mpi_access ) ;
- cout << "test" << myrank << " Wait done RecvTimeRequestId "
+ debugStream << "test" << myrank << " Wait done RecvTimeRequestId "
<< RecvTimeRequestId[lasttime] << " lasttime " << lasttime
<< " tag " << mpi_access->MPITag(RecvTimeRequestId[lasttime])
<< aRecvTimeMsg[lasttime] << endl ;
double deltatime = aRecvTimeMsg[lasttime].deltatime ;
//double maxtime = aRecvTimeMsg[lasttime].maxtime ;
double nexttime = aRecvTimeMsg[lasttime].time + deltatime ;
- cout << "test" << myrank << " t " << t << " lasttime " << lasttime
+ debugStream << "test" << myrank << " t " << t << " lasttime " << lasttime
<< " deltatime " << deltatime
<< " nexttime " << nexttime << endl ;
//if ( nexttime < maxtime && t > nexttime ) {
//sts = mpi_access->cancel( source, datatype, outcount ,
//RecvRequestId[lasttime] ,
cancelflag ) ;
- cout << "test" << myrank << " Recv TO CANCEL RequestId "
+ debugStream << "test" << myrank << " Recv TO CANCEL RequestId "
<< RecvRequestId[lasttime]
<< " tag " << mpi_access->recvMPITag( target )
<< " cancelflag " << cancelflag << endl ;
//sts = mpi_access->cancel( source, datatype, outcount ,
//RecvRequestId[lasttime] ,
cancelflag ) ;
- cout << "test" << myrank << " Time TO CANCEL RequestId "
+ debugStream << "test" << myrank << " Time TO CANCEL RequestId "
<< RecvRequestId[lasttime]
<< " tag " << mpi_access->recvMPITag( target )
<< " cancelflag " << cancelflag << endl ;
else {
//DoRecv
//======
- cout << "test" << myrank << " Recv target " << target
+ debugStream << "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 "
+ debugStream << "test" << myrank << " Recv RequestId "
<< RecvRequestId[lasttime]
<< " tag " << mpi_access->recvMPITag( target )
<< endl ;
sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 ,
mpi_access->timeType() , target ,
RecvTimeRequestId[lasttime+1]) ;
- cout << "test" << myrank << " IRecv TimeRequestId "
+ debugStream << "test" << myrank << " IRecv TimeRequestId "
<< RecvTimeRequestId[lasttime+1] << " MPITag "
<< mpi_access->MPITag( RecvTimeRequestId[lasttime+1] )
<< " MPICompleted "
<< RecvRequestId[lasttime-1] << " " << RecvRequestId[lasttime] << endl
<< "==========================================================="
<< endl ;
- cout << strstream.str() << endl ;
+ debugStream << strstream.str() << endl ;
CPPUNIT_FAIL( strstream.str() ) ;
}
else {
- cout << "==========================================================="
+ debugStream << "==========================================================="
<< endl << "test" << myrank
<< " aRecvTimeMsg[ " << lasttime << "-1 ].time "
<< aRecvTimeMsg[lasttime-1].time << " < t " << t << " <= "
istep = istep + 1 ;
}
- cout << "test" << myrank << " Barrier :" << endl ;
+ debugStream << "test" << myrank << " Barrier :" << endl ;
mpi_access->barrier() ;
- mpi_access->check() ;
+ if (MPI_ACCESS_VERBOSE) mpi_access->check() ;
if ( myrank == 0 ) {
//CheckFinalSent
//==============
- cout << "test" << myrank << " CheckFinalSent :" << endl ;
+ debugStream << "test" << myrank << " CheckFinalSent :" << endl ;
int sendrequests[2*maxreq] ;
int sendreqsize = mpi_access->sendRequestIds( target , 2*maxreq , sendrequests ) ;
int j ;
sts = mpi_access->wait( sendrequests[j] ) ;
chksts( sts , myrank , mpi_access ) ;
mpi_access->deleteRequest( sendrequests[j] ) ;
- cout << "test" << myrank << " " << j << ". " << sendrequests[j] << " deleted"
+ debugStream << "test" << myrank << " " << j << ". " << sendrequests[j] << " deleted"
<< endl ;
}
}
else {
- cout << "test" << myrank << " CheckFinalRecv :" << endl ;
+ debugStream << "test" << myrank << " CheckFinalRecv :" << endl ;
int recvrequests[2*maxreq] ;
int recvreqsize = mpi_access->recvRequestIds( target , 2*maxreq , recvrequests ) ;
int cancelflag ;
sts = mpi_access->cancel( recvrequests[j] , cancelflag ) ;
chksts( sts , myrank , mpi_access ) ;
mpi_access->deleteRequest( recvrequests[j] ) ;
- cout << "test" << myrank << " " << j << ". " << recvrequests[j] << " deleted"
+ debugStream << "test" << myrank << " " << j << ". " << recvrequests[j] << " deleted"
<< " cancelflag " << cancelflag << endl ;
}
int source, MPITag, outcount , flag ;
//sts = mpi_access->cancel( source, datatype, outcount ,
//RecvRequestId[lasttime] ,
cancelflag ) ;
- cout << "test" << myrank << " TO CANCEL RequestId "
+ debugStream << "test" << myrank << " TO CANCEL RequestId "
<< RecvRequestId[lasttime]
<< " tag " << mpi_access->recvMPITag( target )
<< " cancelflag " << cancelflag << endl ;
chksts( sts , myrank , mpi_access ) ;
}
}
- mpi_access->check() ;
+ if(MPI_ACCESS_VERBOSE) mpi_access->check() ;
if ( myrank == 0 ) {
int sendrequests[2*maxreq] ;
strstream << "=========================================================" << endl
<< "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
<< "=========================================================" << endl ;
- cout << strstream.str() << endl ;
+ debugStream << strstream.str() << endl ;
CPPUNIT_FAIL( strstream.str() ) ;
}
else {
- cout << "=========================================================" << endl
+ debugStream << "=========================================================" << endl
<< "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
<< "=========================================================" << endl ;
}
strstream << "=========================================================" << endl
<< "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
<< "=========================================================" << endl ;
- cout << strstream.str() << endl ;
+ debugStream << strstream.str() << endl ;
CPPUNIT_FAIL( strstream.str() ) ;
}
else {
- cout << "=========================================================" << endl
+ debugStream << "=========================================================" << endl
<< "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
<< "=========================================================" << endl ;
}
int i ;
for ( i = 0 ; i <= lasttime ; i++ ) {
- cout << "test" << myrank << " " << i << ". RecvTimeMsg "
+ debugStream << "test" << myrank << " " << i << ". RecvTimeMsg "
<< aRecvTimeMsg[i].time << " recvbuf " << recvbuf[i] << endl ;
}
- cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ;
mpi_access->barrier() ;
- cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
+ debugStream << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ;
delete group ;
delete mpi_access ;
// MPI_Finalize();
- cout << "test" << myrank << " OK" << endl ;
+ debugStream << "test" << myrank << " OK" << endl ;
return ;
}