Skip to content

Commit 88a693b

Browse files
bosilcaggouaillardet
authored andcommitted
Add a test for very large data.
Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
1 parent fbb5bb8 commit 88a693b

File tree

4 files changed

+105
-3
lines changed

4 files changed

+105
-3
lines changed

opal/datatype/opal_convertor.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,22 @@ struct opal_convertor_t {
9494
const opal_datatype_t* pDesc; /**< the datatype description associated with the convertor */
9595
const dt_type_desc_t* use_desc; /**< the version used by the convertor (normal or optimized) */
9696
opal_datatype_count_t count; /**< the total number of full datatype elements */
97-
uint32_t stack_size; /**< size of the allocated stack */
9897

9998
/* --- cacheline boundary (64 bytes - if 64bits arch and !OPAL_ENABLE_DEBUG) --- */
99+
uint32_t stack_size; /**< size of the allocated stack */
100100
unsigned char* pBaseBuf; /**< initial buffer as supplied by the user */
101101
dt_stack_t* pStack; /**< the local stack for the actual conversion */
102102
convertor_advance_fct_t fAdvance; /**< pointer to the pack/unpack functions */
103+
104+
/* --- cacheline boundary (96 bytes - if 64bits arch and !OPAL_ENABLE_DEBUG) --- */
103105
struct opal_convertor_master_t* master; /**< the master convertor */
104106

105107
/* All others fields get modified for every call to pack/unpack functions */
106108
uint32_t stack_pos; /**< the actual position on the stack */
107109
size_t partial_length; /**< amount of data left over from the last unpack */
108110
size_t bConverted; /**< # of bytes already converted */
111+
112+
/* --- cacheline boundary (128 bytes - if 64bits arch and !OPAL_ENABLE_DEBUG) --- */
109113
uint32_t checksum; /**< checksum computed by pack/unpack operation */
110114
uint32_t csum_ui1; /**< partial checksum computed by pack/unpack operation */
111115
size_t csum_ui2; /**< partial checksum computed by pack/unpack operation */

opal/datatype/opal_datatype.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ struct opal_datatype_t {
119119

120120
/* Attribute fields */
121121
char name[OPAL_MAX_OBJECT_NAME]; /**< name of the datatype */
122-
/* --- cacheline 2 boundary (128 bytes) was 8-12 bytes ago --- */
123122
dt_type_desc_t desc; /**< the data description */
124123
dt_type_desc_t opt_desc; /**< short description of the data used when conversion is useless
125124
or in the send case (without conversion) */

test/datatype/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
if PROJECT_OMPI
18-
MPI_TESTS = checksum position position_noncontig ddt_test ddt_raw unpack_ooo ddt_pack external32
18+
MPI_TESTS = checksum position position_noncontig ddt_test ddt_raw unpack_ooo ddt_pack external32 large_data
1919
MPI_CHECKS = to_self
2020
endif
2121
TESTS = opal_datatype_test unpack_hetero $(MPI_TESTS)
@@ -68,6 +68,12 @@ to_self_SOURCES = to_self.c
6868
to_self_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
6969
to_self_LDADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la
7070

71+
large_data_SOURCES = large_data.c
72+
large_data_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
73+
large_data_LDADD = \
74+
$(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \
75+
$(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la
76+
7177
opal_datatype_test_SOURCES = opal_datatype_test.c opal_ddt_lib.c opal_ddt_lib.h
7278
opal_datatype_test_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
7379
opal_datatype_test_LDADD = \

test/datatype/large_data.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#include <mpi.h>
2+
#include <stdio.h>
3+
#include <stddef.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
7+
#include "ompi_config.h"
8+
#include "ompi/datatype/ompi_datatype.h"
9+
#include "opal/runtime/opal.h"
10+
#include "opal/datatype/opal_convertor.h"
11+
#include "opal/datatype/opal_datatype_internal.h"
12+
13+
#define MAX_IOVEC 10
14+
#define MAX_CHUNK (1024*1024*1024) /* 1GB */
15+
16+
static size_t
17+
count_length_via_convertor_raw(MPI_Datatype dtype, int count)
18+
{
19+
opal_convertor_t* pconv;
20+
struct iovec iov[MAX_IOVEC];
21+
uint32_t iov_count = MAX_IOVEC, i;
22+
size_t length = MAX_CHUNK, packed_iovec = 0, packed = 0;
23+
24+
pconv = opal_convertor_create( opal_local_arch, 0 );
25+
opal_convertor_prepare_for_send(pconv, (const struct opal_datatype_t *)dtype, 1, NULL);
26+
while( 0 == opal_convertor_raw(pconv, iov, &iov_count, &length) ) {
27+
printf("iov_count = %d packed_iovec = %"PRIsize_t"\n", iov_count, packed_iovec);
28+
packed += length;
29+
for( i = 0; i < iov_count; i++ ) {
30+
packed_iovec += iov[i].iov_len;
31+
}
32+
if( packed != packed_iovec ) {
33+
printf( "Packed send amount diverges %"PRIsize_t" != %"PRIsize_t"\n", packed, packed_iovec);
34+
exit(-1);
35+
}
36+
iov_count = MAX_IOVEC; /* number of available iov */
37+
length = MAX_CHUNK;
38+
}
39+
packed += length;
40+
for( i = 0; i < iov_count; i++ ) {
41+
packed_iovec += iov[i].iov_len;
42+
}
43+
if( packed != packed_iovec ) {
44+
printf( "Packed send amount diverges %"PRIsize_t" != %"PRIsize_t"\n", packed, packed_iovec);
45+
exit(-1);
46+
}
47+
return packed_iovec;
48+
}
49+
50+
int main(int argc, char * argv[])
51+
{
52+
53+
int const per_process = 192;
54+
int const per_type = 20000000;
55+
56+
int scounts[2] = {per_process, per_process};
57+
int sdispls[2] = {3*per_process, 0*per_process};
58+
int rcounts[2] = {per_process, per_process};
59+
int rdispls[2] = {1*per_process, 2*per_process};
60+
61+
MPI_Datatype ddt, stype, rtype;
62+
63+
opal_init_util(&argc, &argv);
64+
ompi_datatype_init();
65+
66+
ompi_datatype_create_contiguous( per_type, MPI_FLOAT, &ddt);
67+
ompi_datatype_create_indexed(2, scounts, sdispls, ddt, &stype);
68+
ompi_datatype_commit(&stype);
69+
ompi_datatype_create_indexed(2, rcounts, rdispls, ddt, &rtype);
70+
ompi_datatype_commit(&rtype);
71+
72+
size_t packed = count_length_via_convertor_raw(stype, 1);
73+
size_t length;
74+
opal_datatype_type_size(&stype->super, &length);
75+
if( length != packed ) {
76+
printf("Mismatched length of packed data to datatype size (%"PRIsize_t" != %"PRIsize_t")\n",
77+
packed, length);
78+
exit(-2);
79+
}
80+
81+
packed = count_length_via_convertor_raw(rtype, 1);
82+
opal_datatype_type_size(&rtype->super, &length);
83+
if( length != packed ) {
84+
printf("Mismatched length of packed data to datatype size (%"PRIsize_t" != %"PRIsize_t")\n",
85+
packed, length);
86+
exit(-2);
87+
}
88+
89+
ompi_datatype_destroy(&stype);
90+
ompi_datatype_destroy(&rtype);
91+
92+
return 0;
93+
}

0 commit comments

Comments
 (0)