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