Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / ParaMEDMEMTest / MPIAccessTest.hxx
1 // Copyright (C) 2007-2012  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.
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
31 class MPIAccessTest : public CppUnit::TestFixture
32 {
33   CPPUNIT_TEST_SUITE( MPIAccessTest );
34   CPPUNIT_TEST( test_MPI_Access_Send_Recv ) ;
35   CPPUNIT_TEST( test_MPI_Access_Cyclic_Send_Recv ) ;
36   CPPUNIT_TEST( test_MPI_Access_SendRecv ) ;
37   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv ) ;
38   CPPUNIT_TEST( test_MPI_Access_Cyclic_ISend_IRecv ) ;
39   CPPUNIT_TEST( test_MPI_Access_ISendRecv ) ;
40   CPPUNIT_TEST( test_MPI_Access_Probe ) ;
41   CPPUNIT_TEST( test_MPI_Access_IProbe ) ;
42   CPPUNIT_TEST( test_MPI_Access_Cancel ) ;
43   CPPUNIT_TEST( test_MPI_Access_Send_Recv_Length ) ;
44   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length ) ;
45   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length_1 ) ;
46   CPPUNIT_TEST( test_MPI_Access_Time ) ;
47   CPPUNIT_TEST( test_MPI_Access_Time_0 ) ;
48   CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_BottleNeck ) ;
49   CPPUNIT_TEST_SUITE_END();
50   
51
52 public:
53  
54   MPIAccessTest():CppUnit::TestFixture(){}
55   ~MPIAccessTest(){}  
56   void setUp(){}
57   void tearDown(){}
58   void test_MPI_Access_Send_Recv() ;
59   void test_MPI_Access_Cyclic_Send_Recv() ;
60   void test_MPI_Access_SendRecv() ;
61   void test_MPI_Access_ISend_IRecv() ;
62   void test_MPI_Access_Cyclic_ISend_IRecv() ;
63   void test_MPI_Access_ISendRecv() ;
64   void test_MPI_Access_Probe() ;
65   void test_MPI_Access_IProbe() ;
66   void test_MPI_Access_Cancel() ;
67   void test_MPI_Access_Send_Recv_Length() ;
68   void test_MPI_Access_ISend_IRecv_Length() ;
69   void test_MPI_Access_ISend_IRecv_Length_1() ;
70   void test_MPI_Access_Time() ;
71   void test_MPI_Access_Time_0() ;
72   void test_MPI_Access_ISend_IRecv_BottleNeck() ;
73
74 private:
75   };
76
77 // to automatically remove temporary files from disk
78 class MPIAccessTest_TmpFilesRemover
79 {
80 public:
81   MPIAccessTest_TmpFilesRemover() {}
82   ~MPIAccessTest_TmpFilesRemover();
83   bool Register(const std::string theTmpFile);
84
85 private:
86   std::set<std::string> myTmpFiles;
87 };
88
89 /*!
90  *  Tool to print array to stream.
91  */
92 template<class T>
93 void MPIAccessTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
94 {
95   stream << text << ": {";
96   if (length > 0) {
97     stream << array[0];
98     for (int i = 1; i < length; i++) {
99       stream << ", " << array[i];
100     }
101   }
102   stream << "}" << std::endl;
103 }
104
105 #endif