Skip to content

Commit 9854c55

Browse files
committed
test/datatype: add test for short unpack on heteregeneous cluster
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 8d5cb08 commit 9854c55

File tree

2 files changed

+112
-2
lines changed

2 files changed

+112
-2
lines changed

test/datatype/Makefile.am

Lines changed: 9 additions & 2 deletions
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

@@ -48,7 +48,9 @@ ddt_pack_LDADD = \
4848

4949
ddt_pack_hetero_SOURCES = ddt_pack_hetero.c
5050
ddt_pack_hetero_LDFLAGS = $(WRAPPER_EXTRA_LDFLAGS)
51-
ddt_pack_hetero_LDADD = $(top_builddir)/ompi/libmpi.la
51+
ddt_pack_hetero_LDADD = \
52+
$(top_builddir)/ompi/lib@[email protected] \
53+
$(top_builddir)/opal/lib@[email protected]
5254

5355
checksum_SOURCES = checksum.c
5456
checksum_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
@@ -83,5 +85,10 @@ external32_LDADD = \
8385
$(top_builddir)/ompi/lib@[email protected] \
8486
$(top_builddir)/opal/lib@[email protected]
8587

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

test/datatype/unpack_hetero.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; -*- */
2+
/*
3+
* Copyright (c) 2014-2017 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+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
43+
opal_datatype_init();
44+
45+
/**
46+
* By default simulate homogeneous architectures.
47+
*/
48+
remote_arch = opal_local_arch ^ OPAL_ARCH_ISBIGENDIAN;
49+
50+
opal_convertor_t * pConv;
51+
int sbuf[2], rbuf[2];
52+
size_t max_data;
53+
struct iovec a;
54+
uint32_t iov_count;
55+
56+
sbuf[0] = 0x01000000; sbuf[1] = 0x02000000;
57+
58+
printf( "\n\n#\n * TEST UNPACKING 1 int out of 1\n#\n\n" );
59+
60+
pConv = opal_convertor_create( remote_arch, 0 );
61+
rbuf[0] = -1; rbuf[1] = -1;
62+
if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 1, rbuf ) ) {
63+
printf( "Cannot attach the datatype to a convertor\n" );
64+
return OPAL_ERROR;
65+
}
66+
67+
a.iov_base = sbuf;
68+
a.iov_len = 4;
69+
iov_count = 1;
70+
max_data = 4;
71+
opal_unpack_general( pConv, &a, &iov_count, &max_data );
72+
73+
assert(1 == rbuf[0]);
74+
assert(-1 == rbuf[1]);
75+
OBJ_RELEASE(pConv);
76+
77+
printf( "\n\n#\n * TEST UNPACKING 1 int out of 2\n#\n\n" );
78+
pConv = opal_convertor_create( remote_arch, 0 );
79+
rbuf[0] = -1; rbuf[1] = -1;
80+
if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 2, rbuf ) ) {
81+
printf( "Cannot attach the datatype to a convertor\n" );
82+
return OPAL_ERROR;
83+
}
84+
85+
86+
a.iov_base = sbuf;
87+
a.iov_len = 4;
88+
iov_count = 1;
89+
max_data = 4;
90+
opal_unpack_general( pConv, &a, &iov_count, &max_data );
91+
92+
assert(1 == rbuf[0]);
93+
assert(-1 == rbuf[1]);
94+
OBJ_RELEASE(pConv);
95+
96+
/* clean-ups all data allocations */
97+
opal_datatype_finalize();
98+
opal_finalize();
99+
return OPAL_SUCCESS;
100+
#else
101+
return 77;
102+
#endif
103+
}

0 commit comments

Comments
 (0)