Back to index

salome-med  6.5.0
Public Member Functions | Private Member Functions
MPIAccessDECTest Class Reference

#include <MPIAccessDECTest.hxx>

Inheritance diagram for MPIAccessDECTest:
Inheritance graph
[legend]
Collaboration diagram for MPIAccessDECTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MPIAccessDECTest ()
 ~MPIAccessDECTest ()
void setUp ()
void tearDown ()
void test_AllToAllDECSynchronousPointToPoint ()
void test_AllToAllDECAsynchronousPointToPoint ()
void test_AllToAllvDECSynchronousPointToPoint ()
void test_AllToAllvDECAsynchronousPointToPoint ()
void test_AllToAllTimeDECSynchronousPointToPoint ()
void test_AllToAllTimeDECAsynchronousPointToPoint ()
void test_AllToAllvTimeDECSynchronousNative ()
void test_AllToAllvTimeDECSynchronousPointToPoint ()
void test_AllToAllvTimeDECAsynchronousPointToPoint ()
void test_AllToAllvTimeDoubleDECSynchronousPointToPoint ()
void test_AllToAllvTimeDoubleDECAsynchronousPointToPoint ()

Private Member Functions

 CPPUNIT_TEST_SUITE (MPIAccessDECTest)
 CPPUNIT_TEST (test_AllToAllDECAsynchronousPointToPoint)
 CPPUNIT_TEST (test_AllToAllvDECAsynchronousPointToPoint)
 CPPUNIT_TEST (test_AllToAllTimeDECAsynchronousPointToPoint)
 CPPUNIT_TEST (test_AllToAllvTimeDECSynchronousNative)
 CPPUNIT_TEST (test_AllToAllvTimeDECAsynchronousPointToPoint)
 CPPUNIT_TEST (test_AllToAllvTimeDoubleDECAsynchronousPointToPoint)
 CPPUNIT_TEST_SUITE_END ()
void test_AllToAllDEC (bool Asynchronous)
void test_AllToAllvDEC (bool Asynchronous)
void test_AllToAllTimeDEC (bool Asynchronous)
void test_AllToAllvTimeDEC (bool Asynchronous, bool UseMPINative)
void test_AllToAllvTimeDoubleDEC (bool Asynchronous)

Detailed Description

Definition at line 31 of file MPIAccessDECTest.hxx.


Constructor & Destructor Documentation

Definition at line 50 of file MPIAccessDECTest.hxx.

:CppUnit::TestFixture(){}

Definition at line 51 of file MPIAccessDECTest.hxx.

{}  

Member Function Documentation

void MPIAccessDECTest::setUp ( ) [inline]

Definition at line 52 of file MPIAccessDECTest.hxx.

{}
void MPIAccessDECTest::tearDown ( ) [inline]

Definition at line 53 of file MPIAccessDECTest.hxx.

{}
void MPIAccessDECTest::test_AllToAllDEC ( bool  Asynchronous) [private]

Definition at line 64 of file test_AllToAllDEC.cxx.

                                                           {

  cout << "test_AllToAllDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "usage :" << endl
              << "mpirun -np <nbprocs> test_AllToAllDEC" << endl
              << " (nbprocs >=2)" << endl
              << "test must be runned with more than 1 proc and less than 12 procs"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  cout << "test_AllToAllDEC" << 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) ;

  MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup ,
                                                    Asynchronous ) ;
  
  MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ;

#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] ;
    int j ;
    for ( j = 0 ; j < datamsglength*size ; j++ ) {
      sendbuf[j] = myrank*1000000 + ireq*1000 + j ;
      recvbuf[j] = -1 ;
    }

    MyMPIAccessDEC->allToAll( sendbuf, sendcount , MPI_INT ,
                              recvbuf, recvcount , MPI_INT ) ;

    int nRecvReq = mpi_access->recvRequestIdsSize() ;
    int *ArrayOfRecvRequests = new int[nRecvReq] ;
    int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ;
    mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ;
    mpi_access->deleteRequests( nReq , ArrayOfRecvRequests ) ;
    delete [] ArrayOfRecvRequests ;
  }

  int nSendReq = mpi_access->sendRequestIdsSize() ;
  cout << "test_AllToAllDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "test_AllToAllDEC" << myrank << " final RecvRequestIds " << nRecvReq
              << " RecvRequests # 0 Error" << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }
  else {
    cout << "test_AllToAllDEC" << myrank << " final RecvRequestIds " << nRecvReq
         << " RecvRequests = 0 OK" << endl ;
  }

  mpi_access->barrier() ;

  delete sourcegroup ;
  delete targetgroup ;
  delete MyMPIAccessDEC ;
  delete [] recvbuf ;

  //  MPI_Finalize();

  cout << "test_AllToAllDEC" << myrank << " OK" << endl ;

  return ;
}

Here is the call graph for this function:

Definition at line 42 of file test_AllToAllDEC.cxx.

                                                                {
  test_AllToAllDEC( true ) ;
}

Definition at line 39 of file test_AllToAllDEC.cxx.

                                                               {
  test_AllToAllDEC( false ) ;
}
void MPIAccessDECTest::test_AllToAllTimeDEC ( bool  Asynchronous) [private]

Definition at line 69 of file test_AllToAllTimeDEC.cxx.

                                                               {

  cout << "test_AllToAllTimeDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "usage :" << endl
              << "mpirun -np <nbprocs> test_AllToAllTimeDEC" << endl
              << " (nbprocs >=2)" << endl
              << "test must be runned with more than 1 proc and less than 12 procs"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  //  int Asynchronous = atoi(argv[1]);

  cout << "test_AllToAllTimeDEC" << 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 ) ;
  MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup ,
                                                    Asynchronous ) ;
  //                                                    Asynchronous , LinearInterp , 0.5 ) ;
  MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp ) ;
  MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ;

  cout << "test_AllToAllTimeDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;
  cout << "test_AllToAllTimeDEC" << myrank << " Barrier done" << endl ;
  
#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] ;
  //  MyMPIAccessDEC->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 ;
      }
      //       MyMPIAccessDEC->NextTime( nextdeltatime ) ;
    }
    MyMPIAccessDEC->setTime( time , nextdeltatime ) ;
    cout << "test_AllToAllTimeDEC" << 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 = MyMPIAccessDEC->allToAllTime( sendbuf, sendcount , MPI_INT ,
                                            recvbuf, recvcount , MPI_INT ) ;
    chksts( sts , myrank , mpi_access ) ;

    //     cout << "test_AllToAllTimeDEC" << myrank << " recvbuf before CheckSent" ;
    //     for ( i = 0 ; i < datamsglength*size ; i++ ) {
    //        cout << " " << recvbuf[i] ;
    //     }
    //     cout << endl ;

    //     cout << "test_AllToAllTimeDEC" << myrank << " sendbuf " << sendbuf << endl ;
    //     MyMPIAccessDEC->CheckSent() ;

    int nRecvReq = mpi_access->recvRequestIdsSize() ;
    if ( nRecvReq != 0 ) {
      ostringstream strstream ;
      strstream << "=============================================================" << endl
                << "test_AllToAllTimeDEC" << 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 ;
      cout << strstream.str() << endl ;
      CPPUNIT_FAIL( strstream.str() ) ;
    }

    //     cout << "test_AllToAllTimeDEC" << 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_AllToAllTimeDEC" << myrank << " recvbuf[" << i << "] "
             << recvbuf[i] << " # " << (i/datamsglength)*1000000 + myrank*1000 +
          myrank*datamsglength+(i%datamsglength) << endl ;
      }
      else if ( badrecvbuf ) {
        cout << "test_AllToAllTimeDEC" << myrank << " recvbuf[" << i << "] "
             << recvbuf[i] << " == " << (i/datamsglength)*1000000 + myrank*1000 +
          myrank*datamsglength+(i%datamsglength) << endl ;
      }
    }
    if ( badrecvbuf ) {
      ostringstream strstream ;
      strstream << "==============================================================" << endl
                << "test_AllToAllTimeDEC" << myrank << " badrecvbuf"
                << endl << "============================================================="
                << endl ;
      cout << strstream.str() << endl ;
      CPPUNIT_FAIL( strstream.str() ) ;
    }
    delete [] recvbuf ;
  }

  cout << "test_AllToAllTimeDEC" << myrank << " final CheckSent" << endl ;
  sts = MyMPIAccessDEC->checkSent() ;
  if ( sts != MPI_SUCCESS ) {
    ostringstream strstream ;
    strstream << "================================================================" << endl
              << "test_AllToAllTimeDEC" << myrank << " final CheckSent ERROR"
              << endl << "================================================================"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  int nSendReq = mpi_access->sendRequestIdsSize() ;
  cout << "test_AllToAllTimeDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "===============================================================" << endl
              << "test_AllToAllTimeDEC" << myrank << " RecvRequestIds " << nRecvReq
              << " RecvRequests # 0 Error"
              << endl << "==============================================================="
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }
  else {
    cout << "test_AllToAllTimeDEC" << myrank << " RecvRequestIds " << nRecvReq
         << " RecvRequests = 0 OK" << endl ;
  }

  cout << "test_AllToAllTimeDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;
  cout << "test_AllToAllTimeDEC" << myrank << " Barrier done" << endl ;

  delete sourcegroup ;
  delete targetgroup ;
  //  delete aLinearInterpDEC ;
  delete MyMPIAccessDEC ;

  //  MPI_Finalize();

  cout << "test_AllToAllTimeDEC" << myrank << " OK" << endl ;

  return ;
}

Here is the call graph for this function:

Definition at line 47 of file test_AllToAllTimeDEC.cxx.

                                                                    {
  test_AllToAllTimeDEC( true ) ;
}

Definition at line 44 of file test_AllToAllTimeDEC.cxx.

                                                                   {
  test_AllToAllTimeDEC( false ) ;
}
void MPIAccessDECTest::test_AllToAllvDEC ( bool  Asynchronous) [private]

Definition at line 68 of file test_AllToAllvDEC.cxx.

                                                            {

  cout << "test_AllToAllvDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "usage :" << endl
              << "mpirun -np <nbprocs> test_AllToAllvDEC" << endl
              << " (nbprocs >=2)" << endl
              << "test must be runned with more than 1 proc and less than 12 procs"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  //  int Asynchronous = atoi(argv[1]);

  cout << "test_AllToAllvDEC" << 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) ;

  MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup ,
                                                    Asynchronous ) ;
  
  MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ;

#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 ;
    }

    MyMPIAccessDEC->allToAllv( sendbuf, sendcounts , sdispls , MPI_INT ,
                               recvbuf, recvcounts , rdispls , MPI_INT ) ;

    //    cout << "test_AllToAllvDEC" << myrank << " recvbuf before CheckSent" ;
    //    for ( i = 0 ; i < datamsglength*size ; i++ ) {
    //       cout << " " << recvbuf[i] ;
    //    }
    //    cout << endl ;

    //    cout << "test_AllToAllvDEC" << myrank << " sendbuf " << sendbuf << endl ;
    //    MyMPIAccessDEC->CheckSent() ;

    int nRecvReq = mpi_access->recvRequestIdsSize() ;
    //    cout << "test_AllToAllvDEC" << 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_AllToAllvDEC" << myrank << " recvbuf" ;
    //    for ( i = 0 ; i < datamsglength*size ; i++ ) {
    //       cout << " " << recvbuf[i] ;
    //    }
    //    cout << endl ;
  }

  //  cout << "test_AllToAllvDEC" << myrank << " final CheckSent" << endl ;
  //  MyMPIAccessDEC->CheckSent() ;

  int nSendReq = mpi_access->sendRequestIdsSize() ;
  cout << "test_AllToAllvDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "test_AllToAllvDEC" << myrank << " final RecvRequestIds " << nRecvReq
              << " RecvRequests # 0 Error" << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }
  else {
    cout << "test_AllToAllvDEC" << myrank << " final RecvRequestIds " << nRecvReq
         << " RecvRequests = 0 OK" << endl ;
  }

  mpi_access->barrier() ;

  delete sourcegroup ;
  delete targetgroup ;
  delete MyMPIAccessDEC ;
  delete [] sendcounts ;
  delete [] sdispls ;
  delete [] recvcounts ;
  delete [] rdispls ;
  delete [] recvbuf ;

  //  MPI_Finalize();

  cout << "test_AllToAllvDEC" << myrank << " OK" << endl ;

  return ;
}

Here is the call graph for this function:

Definition at line 46 of file test_AllToAllvDEC.cxx.

                                                                 {
  test_AllToAllvDEC( true ) ;
}

Definition at line 43 of file test_AllToAllvDEC.cxx.

                                                                {
  test_AllToAllvDEC( false ) ;
}
void MPIAccessDECTest::test_AllToAllvTimeDEC ( bool  Asynchronous,
bool  UseMPINative 
) [private]

Definition at line 73 of file test_AllToAllvTimeDEC.cxx.

                                                                                    {

  cout << "test_AllToAllvTimeDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "usage :" << endl
              << "mpirun -np <nbprocs> test_AllToAllTimeDEC" << endl
              << " (nbprocs >=2)" << endl
              << "test must be runned with more than 1 proc and less than 12 procs"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  //  int Asynchronous = atoi(argv[1]) ;
  int UseMPI_Alltoallv = UseMPINative ;
  //  if ( argc == 3 ) {
  //    UseMPI_Alltoallv = atoi(argv[2]) ;
  //  }

  cout << "test_AllToAllvTimeDEC" << 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 ) ;
  MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup ,
                                                    Asynchronous ) ;
  //                                                    Asynchronous , LinearInterp , 0.5 ) ;
  MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp , 0.5 ) ;
  MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ;

  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;
  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ;

#define maxproc 11
#define maxreq 10000
#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 timeLoc = 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 ;
    //    MyMPIAccessDEC->InitTime( time , nextdeltatime , maxtime ) ;
  }
  time_t begintime = time(NULL) ;
  //  for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) {
  for ( timeLoc = 0 ; timeLoc <= maxtime && nextdeltatime != 0 ; timeLoc+=nextdeltatime ) {
    nextdeltatime = deltatime[myrank] ;
    if ( timeLoc != 0 ) {
      nextdeltatime = deltatime[myrank] ;
      if ( timeLoc+nextdeltatime > maxtime ) {
        nextdeltatime = 0 ;
      }
      //       MyMPIAccessDEC->NextTime( nextdeltatime ) ;
    }
    MyMPIAccessDEC->setTime( timeLoc , nextdeltatime ) ;
    cout << "test_AllToAllvTimeDEC" << 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 = MyMPIAccessDEC->getComm();
      TimeMessage * aSendTimeMessage = new TimeMessage ;
      aSendTimeMessage->time = timeLoc ;
      //       aSendTimeMessage->deltatime = deltatime[myrank] ;
      aSendTimeMessage->deltatime = nextdeltatime ;
      //       aSendTimeMessage->maxtime = maxtime ;
      aSendTimeMessage->tag = (int ) (timeLoc/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_AllToAllvTimeDEC" << 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 = MyMPIAccessDEC->allToAllvTime( sendbuf, sendcounts , sdispls , MPI_INT ,
                                               recvbuf, recvcounts , rdispls , MPI_INT ) ;
      chksts( sts , myrank , mpi_access ) ;
    }

    //     cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf before CheckSent" ;
    //     for ( i = 0 ; i < datamsglength*size ; i++ ) {
    //        cout << " " << recvbuf[i] ;
    //     }
    //     cout << endl ;

    //     cout << "test_AllToAllvTimeDEC" << myrank << " sendbuf " << sendbuf << endl ;
    //     MyMPIAccessDEC->CheckSent() ;

    int nRecvReq = mpi_access->recvRequestIdsSize() ;
    if ( nRecvReq != 0 ) {
      ostringstream strstream ;
      strstream << "=============================================================" << endl
                << "test_AllToAllvTimeDEC" << 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 ;
      cout << strstream.str() << endl ;
      CPPUNIT_FAIL( strstream.str() ) ;
    }

    //     cout << "test_AllToAllvTimeDEC" << 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_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] "
                 << recvbuf[index] << " # " << (index/datamsglength)*1000000 +
              myrank*1000 +
              myrank*datamsglength+(index%datamsglength) << endl ;
          }
          else if ( badrecvbuf ) {
            cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] "
                 << recvbuf[index] << " == " << (index/datamsglength)*1000000 +
              myrank*1000 +
              myrank*datamsglength+(index%datamsglength) << endl ;
          }
        }
        else if ( recvbuf[index] != -1 ) {
          badrecvbuf = true ;
          cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] "
               << recvbuf[index] << " # -1" << endl ;
        }
      }
    }
    if ( badrecvbuf ) {
      ostringstream strstream ;
      strstream << "==============================================================" << endl
                << "test_AllToAllvTimeDEC" << myrank << " badrecvbuf"
                << endl << "============================================================="
                << endl ;
      cout << strstream.str() << endl ;
      CPPUNIT_FAIL( strstream.str() ) ;
    }
    delete [] recvbuf ;
  }

  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;
  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ;

  cout << "test_AllToAllvTimeDEC" << myrank << " CheckFinalSent" << endl ;
  sts = MyMPIAccessDEC->checkFinalSent() ;
  if ( sts != MPI_SUCCESS ) {
    ostringstream strstream ;
    strstream << "================================================================" << endl
              << "test_AllToAllvTimeDEC" << myrank << " final CheckSent ERROR"
              << endl << "================================================================"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  cout << "test_AllToAllvTimeDEC" << myrank << " CheckFinalRecv" << endl ;
  sts = MyMPIAccessDEC->checkFinalRecv() ;
  if ( sts != MPI_SUCCESS ) {
    ostringstream strstream ;
    strstream << "================================================================" << endl
              << "test_AllToAllvTimeDEC" << myrank << " CheckFinalRecv ERROR"
              << endl << "================================================================"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  int nRecvReq = mpi_access->recvRequestIdsSize() ;
  if ( nRecvReq ) {
    ostringstream strstream ;
    strstream << "===============================================================" << endl
              << "test_AllToAllvTimeDEC" << myrank << " RecvRequestIds " << nRecvReq
              << " RecvRequests # 0 Error"
              << endl << "==============================================================="
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }
  else {
    cout << "test_AllToAllvTimeDEC" << myrank << " RecvRequestIds " << nRecvReq
         << " RecvRequests = 0 OK" << endl ;
  }

  time_t endtime = time(NULL) ;
  cout << "test_AllToAllvTimeDEC" << myrank << " begintime " << begintime << " endtime " << endtime
       << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank]
       << " calls to AllToAll" << endl ;

  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;
  cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ;

  delete sourcegroup ;
  delete targetgroup ;
  delete MyMPIAccessDEC ;
  //  delete aLinearInterpDEC ;

  delete [] sendcounts ;
  delete [] sdispls ;
  delete [] recvcounts ;
  delete [] rdispls ;
  delete [] sendtimecounts ;
  delete [] stimedispls ;
  delete [] recvtimecounts ;
  delete [] rtimedispls ;

  //  MPI_Finalize();

  endtime = time(NULL) ;

  cout << "test_AllToAllvTimeDEC" << myrank << " OK begintime " << begintime << " endtime " << endtime
       << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank]
       << " calls to AllToAll" << endl ;

  return ;
}

Here is the call graph for this function:

Definition at line 51 of file test_AllToAllvTimeDEC.cxx.

                                                                     {
  test_AllToAllvTimeDEC( true , false ) ;
}

Definition at line 45 of file test_AllToAllvTimeDEC.cxx.

                                                              {
  test_AllToAllvTimeDEC( false , true ) ;
}

Definition at line 48 of file test_AllToAllvTimeDEC.cxx.

                                                                    {
  test_AllToAllvTimeDEC( false , false ) ;
}
void MPIAccessDECTest::test_AllToAllvTimeDoubleDEC ( bool  Asynchronous) [private]

Definition at line 71 of file test_AllToAllvTimeDoubleDEC.cxx.

                                                                      {

  cout << "test_AllToAllvTimeDoubleDEC" << 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 ) {
    ostringstream strstream ;
    strstream << "usage :" << endl
              << "mpirun -np <nbprocs> test_AllToAllTimeDEC" << endl
              << " (nbprocs >=2)" << endl
              << "test must be runned with more than 1 proc and less than 12 procs"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

//  int Asynchronous = atoi(argv[1]) ;

  cout << "test_AllToAllvTimeDoubleDEC" << 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 ) ;
  MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup ,
                                                    Asynchronous ) ;
//                                                    Asynchronous , LinearInterp , 0.5 ) ;
  MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp ) ;
  MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ;

  cout << "test_AllToAllvTimeDoubleDEC" << 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 timeLoc[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++ ) {
     timeLoc[i] = 0 ;
     maxtime[i] = maxreq ;
     nextdeltatime[i] = deltatime[i] ;
  }
  time_t begintime = time(NULL) ;
  for ( timeLoc[myrank] = 0 ; timeLoc[myrank] <= maxtime[myrank] && nextdeltatime[myrank] != 0 ;
        timeLoc[myrank]+=nextdeltatime[myrank] ) {
//local and target times
     int target ;
     for ( target = 0 ; target < size ; target++ ) {
        nextdeltatime[target] = deltatime[target] ;
        if ( timeLoc[target] != 0 ) {
          if ( timeLoc[target]+nextdeltatime[target] > maxtime[target] ) {
            nextdeltatime[target] = 0 ;
          }
        }
        if ( target != myrank ) {
          while ( timeLoc[myrank] >= timeLoc[target] ) {
               timeLoc[target] += deltatime[target] ;
          }
        }
     }
     MyMPIAccessDEC->setTime( timeLoc[myrank] , nextdeltatime[myrank] ) ;
     cout << "test" << myrank << "=====TIME " << timeLoc[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_AllToAllvTimeDoubleDEC" << 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 +
                                             (timeLoc[myrank]/deltatime[myrank])*100 + j ;
           //cout << " " << (int ) sendbuf[target*datamsglength+j] ;
           recvbuf[target*datamsglength+j] = -1 ;
        }
        //cout << endl ;
     }

     int sts = MyMPIAccessDEC->allToAllvTime( sendbuf, sendcounts , sdispls , MPI_DOUBLE ,
                                            recvbuf, recvcounts , rdispls , MPI_DOUBLE ) ;
     chksts( sts , myrank , mpi_access ) ;

//     cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf before CheckSent" ;
//     for ( i = 0 ; i < datamsglength*size ; i++ ) {
//        cout << " " << recvbuf[i] ;
//     }
//     cout << endl ;

     int nRecvReq = mpi_access->recvRequestIdsSize() ;
     if ( nRecvReq != 0 ) {
       ostringstream strstream ;
       strstream << "=============================================================" << endl
                 << "test_AllToAllvTimeDoubleDEC" << 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 ;
       cout << strstream.str() << endl ;
       CPPUNIT_FAIL( strstream.str() ) ;
     }

//     cout << "test_AllToAllvTimeDoubleDEC" << 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 +
                  (timeLoc[target]/deltatime[target])*100 + j)) > 101) {
               badrecvbuf = true ;
               cout << "test_AllToAllvTimeDoubleDEC" << myrank << " target " << target << " timeLoc[target] "
                    << timeLoc[target] << " recvbuf[" << index << "] " << (int ) recvbuf[index]
                    << " # " << (int ) (target*1000000 +
                       myrank*10000 + (timeLoc[target]/deltatime[target])*100 + j)
                    << endl ;
             }
             else if ( badrecvbuf ) {
               cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf[" << index << "] "
                    << recvbuf[index] << " ~= " << (int ) (target*1000000 +
                       myrank*10000 + (timeLoc[target]/deltatime[target])*100 + j) << endl ;
             }
           }
           else if ( recvbuf[index] != -1 ) {
             badrecvbuf = true ;
             cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf[" << index << "] "
                  << recvbuf[index] << " # -1" << endl ;
           }
        }
     }
     if ( badrecvbuf ) {
       ostringstream strstream ;
       strstream << "==================================================================" << endl
                 << "test_AllToAllvTimeDoubleDEC" << myrank << " badrecvbuf"
                 << endl << "=================================================================="
                 << endl ;
       cout << strstream.str() << endl ;
       CPPUNIT_FAIL( strstream.str() ) ;
     }
     delete [] recvbuf ;
  }

  cout << "test_AllToAllvTimeDoubleDEC" << myrank << " Barrier :" << endl ;
  mpi_access->barrier() ;

  cout << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalSent" << endl ;
  sts = MyMPIAccessDEC->checkFinalSent() ;
  if ( sts != MPI_SUCCESS ) {
    ostringstream strstream ;
    strstream << "=================================================================" << endl
              << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalSent ERROR"
              << endl << "================================================================="
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  cout << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalRecv" << endl ;
  sts = MyMPIAccessDEC->checkFinalRecv() ;
  if ( sts != MPI_SUCCESS ) {
    ostringstream strstream ;
    strstream << "=================================================================" << endl
              << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalRecv ERROR"
              << endl << "================================================================"
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }

  int nRecvReq = mpi_access->recvRequestIdsSize() ;
  if ( nRecvReq ) {
    ostringstream strstream ;
    strstream << "===============================================================" << endl
              << "test_AllToAllvTimeDoubleDEC" << myrank << " RecvRequestIds " << nRecvReq
              << " RecvRequests # 0 Error"
              << endl << "==============================================================="
              << endl ;
    cout << strstream.str() << endl ;
    CPPUNIT_FAIL( strstream.str() ) ;
  }
  else {
    cout << "test_AllToAllvTimeDoubleDEC" << myrank << " RecvRequestIds " << nRecvReq
         << " RecvRequests = 0 OK" << endl ;
  }

  time_t endtime = time(NULL) ;
  cout << "test_AllToAllvTimeDoubleDEC" << 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 MyMPIAccessDEC ;
//  delete aLinearInterpDEC ;

  delete [] sendcounts ;
  delete [] sdispls ;
  delete [] recvcounts ;
  delete [] rdispls ;
  delete [] sendtimecounts ;
  delete [] stimedispls ;
  delete [] recvtimecounts ;
  delete [] rtimedispls ;

//  MPI_Finalize();

  endtime = time(NULL) ;

  cout << "test_AllToAllvTimeDoubleDEC" << myrank << " OK begintime " << begintime << " endtime " << endtime
       << " elapse " << endtime-begintime << " " << maxtime[myrank]/deltatime[myrank]
       << " calls to AllToAll" << endl ;

  return ;
}

Here is the call graph for this function:

Definition at line 49 of file test_AllToAllvTimeDoubleDEC.cxx.

Definition at line 46 of file test_AllToAllvTimeDoubleDEC.cxx.


The documentation for this class was generated from the following files: