3232#include <string.h>
3333#endif
3434
35- static int get_extents (MPI_Datatype type , MPI_Aint * lb , MPI_Aint * extent , MPI_Aint * true_lb , MPI_Aint * true_extent ) {
35+ #include <poll.h>
36+
37+ static int get_extents (ompi_datatype_t * type , OPAL_PTRDIFF_TYPE * lb , OPAL_PTRDIFF_TYPE * extent , OPAL_PTRDIFF_TYPE * true_lb , OPAL_PTRDIFF_TYPE * true_extent ) {
3638 int ret ;
3739
38- ret = MPI_Type_get_extent (type , lb , extent );
40+ ret = ompi_datatype_get_extent (type , lb , extent );
3941 if (MPI_SUCCESS != ret ) return ret ;
40- ret = MPI_Type_get_true_extent (type , true_lb , true_extent );
42+ ret = ompi_datatype_get_true_extent (type , true_lb , true_extent );
4143 if (MPI_SUCCESS != ret ) return ret ;
4244
4345 return 0 ;
@@ -52,12 +54,20 @@ main(int argc, char* argv[])
5254 struct ompi_datatype_t * unpacked_dt ;
5355 int ret = 0 ;
5456 int blen [4 ];
55- MPI_Aint disp [4 ];
56- MPI_Datatype newType , types [4 ], struct_type , vec_type ;
57- MPI_Aint old_lb , old_extent , old_true_lb , old_true_extent ;
58- MPI_Aint lb , extent , true_lb , true_extent ;
57+ OPAL_PTRDIFF_TYPE disp [4 ];
58+ ompi_datatype_t * newType , * types [4 ], * struct_type , * vec_type ;
59+ OPAL_PTRDIFF_TYPE old_lb , old_extent , old_true_lb , old_true_extent ;
60+ OPAL_PTRDIFF_TYPE lb , extent , true_lb , true_extent ;
61+
62+ /* make ompi_proc_local () work ... */
63+ struct ompi_proc_t dummy_proc ;
64+ ompi_proc_local_proc = & dummy_proc ;
65+
66+
67+ int _dbg = 0 ;
68+ while (_dbg ) poll (NULL , 0 , 1 );
5969
60- MPI_Init ( & argc , & argv );
70+ ompi_datatype_init ( );
6171
6272 /**
6373 *
@@ -68,16 +78,16 @@ main(int argc, char* argv[])
6878 /* Basic test... */
6979 printf ("---> Basic test with MPI_INT\n" );
7080
71- packed_ddt_len = ompi_datatype_pack_description_length (MPI_INT );
81+ packed_ddt_len = ompi_datatype_pack_description_length (& ompi_mpi_int . dt );
7282 ptr = payload = malloc (packed_ddt_len );
73- ret = ompi_datatype_get_pack_description (MPI_INT , & packed_ddt );
83+ ret = ompi_datatype_get_pack_description (& ompi_mpi_int . dt , & packed_ddt );
7484 if (ret != 0 ) goto cleanup ;
7585
7686 memcpy (payload , packed_ddt , packed_ddt_len );
7787 unpacked_dt = ompi_datatype_create_from_packed_description (& payload ,
7888 ompi_proc_local ());
7989 free (ptr );
80- if (unpacked_dt == MPI_INT32_T ) {
90+ if (unpacked_dt == & ompi_mpi_int32_t . dt ) {
8191 printf ("\tPASSED\n" );
8292 } else {
8393 printf ("\tFAILED: datatypes don't match\n" );
@@ -94,11 +104,19 @@ main(int argc, char* argv[])
94104 printf ("---> Simple test using a struct and few predefined datatype (4 * MPI_INT).\n" );
95105 blen [0 ] = 1 ; blen [1 ] = 2 ; blen [2 ] = 3 ; blen [3 ] = 4 ;
96106 disp [0 ] = 0 ; disp [1 ] = 4 ; disp [2 ] = 8 ; disp [3 ] = 12 ;
97- types [0 ] = MPI_INT ; types [1 ] = MPI_INT ; types [2 ] = MPI_INT ; types [3 ] = MPI_INT ;
98- ret = MPI_Type_create_struct ( 4 , blen , disp , types , & struct_type );
107+ types [0 ] = & ompi_mpi_int . dt ; types [1 ] = & ompi_mpi_int . dt ; types [2 ] = & ompi_mpi_int . dt ; types [3 ] = & ompi_mpi_int . dt ;
108+ ret = ompi_datatype_create_struct ( 4 , blen , disp , types , & struct_type );
99109 if (ret != 0 ) goto cleanup ;
100110
101- ret = MPI_Type_commit (& struct_type );
111+ {
112+ int count = 4 ;
113+ const int * a_i [2 ] = {& count , blen };
114+ ret = ompi_datatype_set_args ( struct_type , count + 1 , a_i , count , disp ,
115+ count , types , MPI_COMBINER_STRUCT );
116+ if (ret != 0 ) goto cleanup ;
117+ }
118+
119+ ret = ompi_datatype_commit (& struct_type );
102120 if (ret != 0 ) goto cleanup ;
103121
104122 ret = get_extents (struct_type , & old_lb , & old_extent , & old_true_lb , & old_true_extent );
@@ -129,10 +147,10 @@ main(int argc, char* argv[])
129147 }
130148 printf ("\tPASSED\n" );
131149 }
132- ret = MPI_Type_free (& struct_type );
150+ ret = ompi_datatype_destroy (& struct_type );
133151 if (ret != 0 ) goto cleanup ;
134152
135- ret = MPI_Type_free (& unpacked_dt );
153+ ret = ompi_datatype_destroy (& unpacked_dt );
136154 if (ret != 0 ) goto cleanup ;
137155
138156 /**
@@ -143,10 +161,20 @@ main(int argc, char* argv[])
143161
144162 printf ("---> Less Basic test with MPI_Type_vector\n" );
145163
146- ret = MPI_Type_vector (2 , 1 , 1 , MPI_INT , & vec_type );
164+ ret = ompi_datatype_create_vector (2 , 1 , 1 , & ompi_mpi_int . dt , & vec_type );
147165 if (ret != 0 ) goto cleanup ;
148166
149- ret = MPI_Type_commit (& vec_type );
167+ {
168+ int count = 2 ;
169+ int blocklength = 1 ;
170+ int stride = 1 ;
171+ const int * a_i [3 ] = {& count , & blocklength , & stride };
172+ ompi_datatype_t * type = & ompi_mpi_int .dt ;
173+ ret = ompi_datatype_set_args (vec_type , 3 , a_i , 0 , NULL , 1 , & type , MPI_COMBINER_VECTOR );
174+ if (ret != 0 ) goto cleanup ;
175+ }
176+
177+ ret = ompi_datatype_commit (& vec_type );
150178 if (ret != 0 ) goto cleanup ;
151179
152180 ret = get_extents (vec_type , & old_lb , & old_extent , & old_true_lb , & old_true_extent );
@@ -178,10 +206,10 @@ main(int argc, char* argv[])
178206 }
179207 printf ("\tPASSED\n" );
180208 }
181- ret = MPI_Type_free (& vec_type );
209+ ret = ompi_datatype_destroy (& vec_type );
182210 if (ret != 0 ) goto cleanup ;
183211
184- ret = MPI_Type_free (& unpacked_dt );
212+ ret = ompi_datatype_destroy (& unpacked_dt );
185213 if (ret != 0 ) goto cleanup ;
186214
187215 /**
@@ -195,10 +223,20 @@ main(int argc, char* argv[])
195223 blen [0 ] = 0 ;
196224 blen [1 ] = 20 * sizeof (double );
197225
198- ret = MPI_Type_create_indexed_block (2 , 10 , blen , MPI_DOUBLE , & newType );
226+ ret = ompi_datatype_create_indexed_block (2 , 10 , blen , & ompi_mpi_double . dt , & newType );
199227 if (ret != 0 ) goto cleanup ;
200228
201- ret = MPI_Type_commit (& newType );
229+ {
230+ int count = 2 ;
231+ int blocklength = 10 ;
232+ const int * a_i [3 ] = {& count , & blocklength , blen };
233+ ompi_datatype_t * oldtype = & ompi_mpi_double .dt ;
234+ ompi_datatype_set_args ( newType , 2 + count , a_i , 0 , NULL , 1 , & oldtype ,
235+ MPI_COMBINER_INDEXED_BLOCK );
236+ if (ret != 0 ) goto cleanup ;
237+ }
238+
239+ ret = ompi_datatype_commit (& newType );
202240 if (ret != 0 ) goto cleanup ;
203241
204242 ret = get_extents (newType , & old_lb , & old_extent , & old_true_lb , & old_true_extent );
@@ -230,10 +268,10 @@ main(int argc, char* argv[])
230268 }
231269 printf ("\tPASSED\n" );
232270 }
233- ret = MPI_Type_free (& newType );
271+ ret = ompi_datatype_destroy (& newType );
234272 if (ret != 0 ) goto cleanup ;
235273
236- ret = MPI_Type_free (& unpacked_dt );
274+ ret = ompi_datatype_destroy (& unpacked_dt );
237275 if (ret != 0 ) goto cleanup ;
238276
239277 /**
@@ -249,10 +287,19 @@ main(int argc, char* argv[])
249287 disp [0 ] = 0 ;
250288 disp [1 ] = 20 * sizeof (double );
251289
252- ret = MPI_Type_create_hindexed (2 , blen , disp , MPI_DOUBLE , & newType );
290+ ret = ompi_datatype_create_hindexed (2 , blen , disp , & ompi_mpi_double . dt , & newType );
253291 if (ret != 0 ) goto cleanup ;
254292
255- ret = MPI_Type_commit (& newType );
293+ {
294+ int count = 2 ;
295+ const int * a_i [2 ] = {& count , blen };
296+ ompi_datatype_t * oldtype = & ompi_mpi_double .dt ;
297+ ret = ompi_datatype_set_args ( newType , count + 1 , a_i , count , disp ,
298+ 1 , & oldtype , MPI_COMBINER_HINDEXED );
299+ if (ret != 0 ) goto cleanup ;
300+ }
301+
302+ ret = ompi_datatype_commit (& newType );
256303 if (ret != 0 ) goto cleanup ;
257304
258305 ret = get_extents (newType , & old_lb , & old_extent , & old_true_lb , & old_true_extent );
@@ -282,7 +329,7 @@ main(int argc, char* argv[])
282329 }
283330 printf ("\tPASSED\n" );
284331 }
285- ret = MPI_Type_free (& newType );
332+ ret = ompi_datatype_destroy (& newType );
286333 if (ret != 0 ) goto cleanup ;
287334
288335 newType = unpacked_dt ; /* save it for later */
@@ -298,15 +345,23 @@ main(int argc, char* argv[])
298345 blen [1 ] = 2 ;
299346 disp [0 ] = 0 ;
300347 disp [1 ] = 64 ;
301- types [0 ] = MPI_INT ;
348+ types [0 ] = & ompi_mpi_int . dt ;
302349 types [1 ] = newType ;
303- ret = MPI_Type_create_struct ( 2 , blen , disp , types , & struct_type );
350+ ret = ompi_datatype_create_struct ( 2 , blen , disp , types , & struct_type );
304351 if (ret != 0 ) goto cleanup ;
305352
306- ret = MPI_Type_commit (& struct_type );
353+ {
354+ int count = 2 ;
355+ const int * a_i [2 ] = {& count , blen };
356+ ret = ompi_datatype_set_args ( struct_type , count + 1 , a_i , count , disp ,
357+ count , types , MPI_COMBINER_STRUCT );
358+ if (ret != 0 ) goto cleanup ;
359+ }
360+
361+ ret = ompi_datatype_commit (& struct_type );
307362 if (ret != 0 ) goto cleanup ;
308363
309- ret = MPI_Type_free (& newType );
364+ ret = ompi_datatype_destroy (& newType );
310365 if (ret != 0 ) goto cleanup ;
311366
312367 ret = get_extents (struct_type , & old_lb , & old_extent , & old_true_lb , & old_true_extent );
@@ -337,15 +392,15 @@ main(int argc, char* argv[])
337392 }
338393 printf ("\tPASSED\n" );
339394 }
340- ret = MPI_Type_free (& struct_type );
395+ ret = ompi_datatype_destroy (& struct_type );
341396 if (ret != 0 ) goto cleanup ;
342397
343- ret = MPI_Type_free (& unpacked_dt );
398+ ret = ompi_datatype_destroy (& unpacked_dt );
344399 if (ret != 0 ) goto cleanup ;
345400
346401
347402 cleanup :
348- MPI_Finalize ();
403+ ompi_datatype_finalize ();
349404
350405 return ret ;
351406}
0 commit comments