Salome HOME
b53312cc00e3b9e07f1c5318fa1feb3101ba510a
[tools/medcoupling.git] / src / ParaMEDMEMTest / MPIAccess / MPIAccessTest.hxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _MPIACCESSTEST_HXX_
21 #define _MPIACCESSTEST_HXX_
22
23 #include <cppunit/extensions/HelperMacros.h>
24
25 #include <set>
26 #include <string>
27 #include <iostream>
28 #include "mpi.h"
29
30 // (ABN]: too many text output in the MPIAccesTest - this renders
31 // the analysis complicated:
32 #define MPI_ACCESS_VERBOSE 0
33 #define debugStream \
34     if (!MPI_ACCESS_VERBOSE) {} \
35     else std::cout
36
37 class MPIAccessTest : public CppUnit::TestFixture
38 {
39   CPPUNIT_TEST_SUITE( MPIAccessTest );
40   CPPUNIT_TEST( test_MPI_Access_Send_Recv ) ;
41   CPPUNIT_TEST( test_MPI_Access_Cyclic_Send_Recv ) ;
42   CPPUNIT_TEST( test_MPI_Access_SendRecv ) ;
43   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv ) ;
44   CPPUNIT_TEST( test_MPI_Access_Cyclic_ISend_IRecv ) ;
45   CPPUNIT_TEST( test_MPI_Access_ISendRecv ) ;
46   CPPUNIT_TEST( test_MPI_Access_Probe ) ;
47   CPPUNIT_TEST( test_MPI_Access_IProbe ) ;
48   CPPUNIT_TEST( test_MPI_Access_Cancel ) ;
49   CPPUNIT_TEST( test_MPI_Access_Send_Recv_Length ) ;
50   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length ) ;
51   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length_1 ) ;
52   CPPUNIT_TEST( test_MPI_Access_Time ) ;
53   CPPUNIT_TEST( test_MPI_Access_Time_0 ) ;
54   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_BottleNeck ) ;
55   CPPUNIT_TEST_SUITE_END();
56   
57
58 public:
59  
60   MPIAccessTest():CppUnit::TestFixture(){}
61   ~MPIAccessTest(){}  
62   void setUp(){}
63   void tearDown(){}
64   void test_MPI_Access_Send_Recv() ;
65   void test_MPI_Access_Cyclic_Send_Recv() ;
66   void test_MPI_Access_SendRecv() ;
67   void test_MPI_Access_ISend_IRecv() ;
68   void test_MPI_Access_Cyclic_ISend_IRecv() ;
69   void test_MPI_Access_ISendRecv() ;
70   void test_MPI_Access_Probe() ;
71   void test_MPI_Access_IProbe() ;
72   void test_MPI_Access_Cancel() ;
73   void test_MPI_Access_Send_Recv_Length() ;
74   void test_MPI_Access_ISend_IRecv_Length() ;
75   void test_MPI_Access_ISend_IRecv_Length_1() ;
76   void test_MPI_Access_Time() ;
77   void test_MPI_Access_Time_0() ;
78   void test_MPI_Access_ISend_IRecv_BottleNeck() ;
79
80 private:
81   };
82
83 // to automatically remove temporary files from disk
84 class MPIAccessTest_TmpFilesRemover
85 {
86 public:
87   MPIAccessTest_TmpFilesRemover() {}
88   ~MPIAccessTest_TmpFilesRemover();
89   bool Register(const std::string theTmpFile);
90
91 private:
92   std::set<std::string> myTmpFiles;
93 };
94
95 /*!
96  *  Tool to print array to stream.
97  */
98 template<class T>
99 void MPIAccessTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
100 {
101   stream << text << ": {";
102   if (length > 0) {
103     stream << array[0];
104     for (int i = 1; i < length; i++) {
105       stream << ", " << array[i];
106     }
107   }
108   stream << "}" << std::endl;
109 }
110
111 #endif