Skip to content

Commit 3bfdb11

Browse files
committed
test/datatype: add test for short unpack on heteregeneous cluster
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 3166c44 commit 3bfdb11

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

test/datatype/Makefile.am

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if PROJECT_OMPI
1818
MPI_TESTS = checksum position position_noncontig ddt_test ddt_raw unpack_ooo ddt_pack external32
1919
MPI_CHECKS = to_self ddt_pack_hetero
2020
endif
21-
TESTS = opal_datatype_test $(MPI_TESTS)
21+
TESTS = opal_datatype_test unpack_hetero $(MPI_TESTS)
2222

2323
check_PROGRAMS = $(TESTS) $(MPI_CHECKS)
2424

@@ -83,5 +83,10 @@ external32_LDADD = \
8383
$(top_builddir)/ompi/lib@[email protected] \
8484
$(top_builddir)/opal/lib@[email protected]
8585

86+
unpack_hetero_SOURCES = unpack_hetero.c
87+
unpack_hetero_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
88+
unpack_hetero_LDADD = \
89+
$(top_builddir)/opal/lib@[email protected]
90+
8691
distclean:
8792
rm -rf *.dSYM .deps .libs *.log *.o *.trs $(check_PROGRAMS) Makefile

test/datatype/unpack_hetero.c

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; -*- */
2+
/*
3+
* Copyright (c) 2014-2016 Research Organization for Information Science
4+
* and Technology (RIST). All rights reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
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+
/* Compile with:
28+
gcc -DHAVE_CONFIG_H -I. -I../../include -I../.. -I../../include -I../../../ompi-trunk/opal -I../../../ompi-trunk/orte -g opal_datatype_test.c -o opal_datatype_test
29+
*/
30+
31+
uint32_t remote_arch = 0xffffffff;
32+
33+
/**
34+
* Main function. Call several tests and print-out the results. It try to stress the convertor
35+
* using difficult data-type constructions as well as strange segment sizes for the conversion.
36+
* Usually, it is able to detect most of the data-type and convertor problems. Any modifications
37+
* on the data-type engine should first pass all the tests from this file, before going into other
38+
* tests.
39+
*/
40+
int main( int argc, char* argv[] )
41+
{
42+
opal_datatype_init();
43+
44+
/**
45+
* By default simulate homogeneous architectures.
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+
/* clean-ups all data allocations */
96+
opal_datatype_finalize();
97+
opal_finalize();
98+
return OPAL_SUCCESS;
99+
}

0 commit comments

Comments
 (0)