This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12 #include "opal_config.h"
13 #include "opal/runtime/opal.h"
14 #include "opal/datatype/opal_datatype.h"
15 #include "opal/datatype/opal_datatype_internal.h"
16 #include "opal/datatype/opal_convertor.h"
17 #include "opal/datatype/opal_datatype_prototypes.h"
18 #include "opal/util/arch.h"
19 #include <time.h>
20 #include <stdlib.h>
21 #ifdef HAVE_SYS_TIME_H
22 #include <sys/time.h>
23 #endif
24 #include <stdio.h>
25 #include <string.h>
26
27
28
29
30
31 uint32_t remote_arch = 0xffffffff;
32
33
34
35
36
37
38
39
40 int main( int argc, char* argv[] )
41 {
42 opal_init_util (NULL, NULL);
43
44
45
46
47 remote_arch = opal_local_arch ^ OPAL_ARCH_ISBIGENDIAN;
48
49 opal_convertor_t * pConv;
50 int sbuf[2], rbuf[2];
51 size_t max_data;
52 struct iovec a;
53 uint32_t iov_count;
54
55 sbuf[0] = 0x01000000; sbuf[1] = 0x02000000;
56
57 printf( "\n\n#\n * TEST UNPACKING 1 int out of 1\n#\n\n" );
58
59 pConv = opal_convertor_create( remote_arch, 0 );
60 rbuf[0] = -1; rbuf[1] = -1;
61 if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 1, rbuf ) ) {
62 printf( "Cannot attach the datatype to a convertor\n" );
63 return OPAL_ERROR;
64 }
65
66 a.iov_base = sbuf;
67 a.iov_len = 4;
68 iov_count = 1;
69 max_data = 4;
70 opal_unpack_general( pConv, &a, &iov_count, &max_data );
71
72 assert(1 == rbuf[0]);
73 assert(-1 == rbuf[1]);
74 OBJ_RELEASE(pConv);
75
76 printf( "\n\n#\n * TEST UNPACKING 1 int out of 2\n#\n\n" );
77 pConv = opal_convertor_create( remote_arch, 0 );
78 rbuf[0] = -1; rbuf[1] = -1;
79 if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 2, rbuf ) ) {
80 printf( "Cannot attach the datatype to a convertor\n" );
81 return OPAL_ERROR;
82 }
83
84
85 a.iov_base = sbuf;
86 a.iov_len = 4;
87 iov_count = 1;
88 max_data = 4;
89 opal_unpack_general( pConv, &a, &iov_count, &max_data );
90
91 assert(1 == rbuf[0]);
92 assert(-1 == rbuf[1]);
93 OBJ_RELEASE(pConv);
94
95
96 opal_finalize_util ();
97
98 return OPAL_SUCCESS;
99 }