@@ -50,39 +50,34 @@ namespace MPI_Wrapper
5050
5151
5252 // MPI_Type_Contiguous_Pool(ie) = MPI_Type_contiguous(2^ie, Type_Base);
53- template <MPI_Datatype Type_Base>
5453 class MPI_Type_Contiguous_Pool
5554 {
5655 public:
5756 MPI_Datatype operator ()(const std::size_t exponent)
5857 {
59- if (type_pool.size ()<exponent+1 )
58+ if (this -> type_pool .size ()<exponent+1 )
6059 {
61- const std::size_t size_old = type_pool.size ();
62- type_pool.resize (exponent+1 );
63- for (std::size_t ie=size_old; ie<type_pool.size (); ++ie)
60+ const std::size_t size_old = this -> type_pool .size ();
61+ this -> type_pool .resize (exponent+1 );
62+ for (std::size_t ie=size_old; ie<this -> type_pool .size (); ++ie)
6463 {
65- if (!ie)
66- {
67- type_pool[ie] = Type_Base;
68- }
69- else
70- {
71- MPI_Type_contiguous ( 1 <<ie, Type_Base, &type_pool[ie] );
72- MPI_Type_commit ( &type_pool[ie] );
73- }
64+ MPI_CHECK ( MPI_Type_contiguous ( 1 <<ie, this ->Type_Base , &this ->type_pool [ie] ) );
65+ MPI_CHECK ( MPI_Type_commit ( &this ->type_pool [ie] ) );
7466 }
7567 }
76- return type_pool[exponent];
68+ return this -> type_pool [exponent];
7769 }
70+ MPI_Type_Contiguous_Pool (const MPI_Datatype &Type_Base_in)
71+ :Type_Base(Type_Base_in){}
7872 ~MPI_Type_Contiguous_Pool ()
7973 {
80- for (std::size_t ie=1 ; ie<type_pool.size (); ++ie)
81- MPI_Type_free ( &type_pool[ie] );
74+ for (std::size_t ie=0 ; ie<this -> type_pool .size (); ++ie)
75+ MPI_Type_free ( &this -> type_pool [ie] );
8276 }
8377 std::vector<MPI_Datatype> type_pool;
78+ const MPI_Datatype Type_Base;
8479 };
85- static MPI_Type_Contiguous_Pool<MPI_CHAR> char_contiguous;
80+ static MPI_Type_Contiguous_Pool char_contiguous (MPI_CHAR) ;
8681}
8782
8883}
0 commit comments