Skip to content

Commit d411593

Browse files
authored
Merge pull request #2996 from ggouaillardet/topic/v2.x/external_support
v2.x: add support for 'external32' representation
2 parents 7161009 + fd29946 commit d411593

File tree

12 files changed

+658
-102
lines changed

12 files changed

+658
-102
lines changed

ompi/mpi/c/pack.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -45,7 +45,7 @@ static const char FUNC_NAME[] = "MPI_Pack";
4545
int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
4646
void *outbuf, int outsize, int *position, MPI_Comm comm)
4747
{
48-
int rc;
48+
int rc = MPI_SUCCESS;
4949
opal_convertor_t local_convertor;
5050
struct iovec invec;
5151
unsigned int iov_count;
@@ -67,9 +67,11 @@ int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
6767
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
6868
} else if (outsize < 0) {
6969
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
70-
} else if (MPI_DATATYPE_NULL == datatype || NULL == datatype) {
71-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
7270
}
71+
OMPI_CHECK_DATATYPE_FOR_SEND(rc, datatype, incount);
72+
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
73+
OMPI_CHECK_USER_BUFFER(rc, inbuf, datatype, incount);
74+
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
7375
}
7476

7577
OBJ_CONSTRUCT( &local_convertor, opal_convertor_t );

ompi/mpi/c/pack_external.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -46,7 +46,7 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount,
4646
MPI_Datatype datatype, void *outbuf,
4747
MPI_Aint outsize, MPI_Aint *position)
4848
{
49-
int rc;
49+
int rc = MPI_SUCCESS;
5050
opal_convertor_t local_convertor;
5151
struct iovec invec;
5252
unsigned int iov_count;
@@ -65,9 +65,11 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount,
6565
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
6666
} else if (outsize < 0) {
6767
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
68-
} else if (MPI_DATATYPE_NULL == datatype || NULL == datatype) {
69-
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);
7068
}
69+
OMPI_CHECK_DATATYPE_FOR_SEND(rc, datatype, incount);
70+
OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
71+
OMPI_CHECK_USER_BUFFER(rc, inbuf, datatype, incount);
72+
OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
7173
}
7274

7375
OBJ_CONSTRUCT(&local_convertor, opal_convertor_t);

ompi/mpi/c/unpack.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2005 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -43,7 +43,7 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
4343
void *outbuf, int outcount, MPI_Datatype datatype,
4444
MPI_Comm comm)
4545
{
46-
int rc = 1;
46+
int rc = MPI_SUCCESS;
4747
opal_convertor_t local_convertor;
4848
struct iovec outvec;
4949
unsigned int iov_count;
@@ -70,9 +70,10 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
7070
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
7171
}
7272

73-
if (MPI_DATATYPE_NULL == datatype || NULL == datatype) {
74-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
75-
}
73+
OMPI_CHECK_DATATYPE_FOR_RECV(rc, datatype, outcount);
74+
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
75+
OMPI_CHECK_USER_BUFFER(rc, outbuf, datatype, outcount);
76+
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
7677
}
7778

7879

@@ -101,10 +102,9 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
101102

102103
/* All done. Note that the convertor returns 1 upon success, not
103104
OMPI_SUCCESS. */
104-
105+
rc = (1 == rc) ? OMPI_SUCCESS : OMPI_ERROR;
105106
}
106107

107108
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
108109
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
109-
110110
}

ompi/mpi/c/unpack_external.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -45,7 +45,7 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz
4545
MPI_Aint *position, void *outbuf, int outcount,
4646
MPI_Datatype datatype)
4747
{
48-
int rc;
48+
int rc = MPI_SUCCESS;
4949
opal_convertor_t local_convertor;
5050
struct iovec outvec;
5151
unsigned int iov_count;
@@ -62,17 +62,21 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz
6262
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
6363
} else if (outcount < 0) {
6464
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
65-
} else if (MPI_DATATYPE_NULL == datatype || NULL == datatype) {
66-
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);
6765
}
66+
OMPI_CHECK_DATATYPE_FOR_RECV(rc, datatype, outcount);
67+
OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
68+
OMPI_CHECK_USER_BUFFER(rc, outbuf, datatype, outcount);
69+
OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
6870
}
6971

7072

7173
OBJ_CONSTRUCT(&local_convertor, opal_convertor_t);
7274

7375
/* the resulting convertor will be set to the position ZERO */
7476
opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor,
75-
&(datatype->super), outcount, outbuf, 0, &local_convertor );
77+
&(datatype->super), outcount, outbuf,
78+
0,
79+
&local_convertor );
7680

7781
/* Check for truncation */
7882
opal_convertor_get_packed_size( &local_convertor, &size );

opal/datatype/opal_convertor.c

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2014 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
1414
* Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
15-
* Copyright (c) 2013 Research Organization for Information Science
15+
* Copyright (c) 2013-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -449,16 +449,17 @@ int32_t opal_convertor_set_position_nocheck( opal_convertor_t* convertor,
449449

450450

451451
/**
452-
* Compute the remote size.
452+
* Compute the remote size. If necessary remove the homogeneous flag
453+
* and redirect the convertor description toward the non-optimized
454+
* datatype representation.
453455
*/
454-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
455456
#define OPAL_CONVERTOR_COMPUTE_REMOTE_SIZE(convertor, datatype, bdt_mask) \
456457
{ \
457458
if( OPAL_UNLIKELY(0 != (bdt_mask)) ) { \
458459
opal_convertor_master_t* master; \
459460
int i; \
460461
uint32_t mask = datatype->bdt_used; \
461-
convertor->flags ^= CONVERTOR_HOMOGENEOUS; \
462+
convertor->flags &= (~CONVERTOR_HOMOGENEOUS); \
462463
master = convertor->master; \
463464
convertor->remote_size = 0; \
464465
for( i = OPAL_DATATYPE_FIRST_TYPE; mask && (i < OPAL_DATATYPE_MAX_PREDEFINED); i++ ) { \
@@ -472,13 +473,6 @@ int32_t opal_convertor_set_position_nocheck( opal_convertor_t* convertor,
472473
convertor->use_desc = &(datatype->desc); \
473474
} \
474475
}
475-
#else
476-
#define OPAL_CONVERTOR_COMPUTE_REMOTE_SIZE(convertor, datatype, bdt_mask) \
477-
{ \
478-
assert(0 == (bdt_mask)); \
479-
(void)bdt_mask; /* silence compiler warning */ \
480-
}
481-
#endif /* OPAL_ENABLE_HETEROGENEOUS_SUPPORT */
482476

483477
/**
484478
* This macro will initialize a convertor based on a previously created
@@ -511,16 +505,13 @@ int32_t opal_convertor_set_position_nocheck( opal_convertor_t* convertor,
511505
convertor->flags |= (CONVERTOR_NO_OP | CONVERTOR_HOMOGENEOUS); \
512506
convertor->pDesc = (opal_datatype_t*)datatype; \
513507
convertor->bConverted = 0; \
514-
/* By default consider the optimized description */ \
515508
convertor->use_desc = &(datatype->opt_desc); \
516509
\
517510
convertor->remote_size = convertor->local_size; \
518511
if( OPAL_LIKELY(convertor->remoteArch == opal_local_arch) ) { \
519-
if( (convertor->flags & (CONVERTOR_WITH_CHECKSUM | OPAL_DATATYPE_FLAG_NO_GAPS)) == OPAL_DATATYPE_FLAG_NO_GAPS ) { \
520-
return OPAL_SUCCESS; \
521-
} \
522-
if( ((convertor->flags & (CONVERTOR_WITH_CHECKSUM | OPAL_DATATYPE_FLAG_CONTIGUOUS)) \
523-
== OPAL_DATATYPE_FLAG_CONTIGUOUS) && (1 == count) ) { \
512+
if( !(convertor->flags & CONVERTOR_WITH_CHECKSUM) && \
513+
((convertor->flags & OPAL_DATATYPE_FLAG_NO_GAPS) || \
514+
((convertor->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS) && (1 == count))) ) { \
524515
return OPAL_SUCCESS; \
525516
} \
526517
} \
@@ -532,8 +523,9 @@ int32_t opal_convertor_set_position_nocheck( opal_convertor_t* convertor,
532523
/* For predefined datatypes (contiguous) do nothing more */ \
533524
/* if checksum is enabled then always continue */ \
534525
if( ((convertor->flags & (CONVERTOR_WITH_CHECKSUM | OPAL_DATATYPE_FLAG_NO_GAPS)) \
535-
== OPAL_DATATYPE_FLAG_NO_GAPS) && \
536-
(convertor->flags & (CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS)) ) { \
526+
== OPAL_DATATYPE_FLAG_NO_GAPS) && \
527+
((convertor->flags & (CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS)) == \
528+
(CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS)) ) { \
537529
return OPAL_SUCCESS; \
538530
} \
539531
convertor->flags &= ~CONVERTOR_NO_OP; \
@@ -566,26 +558,24 @@ int32_t opal_convertor_prepare_for_recv( opal_convertor_t* convertor,
566558
OPAL_CONVERTOR_PREPARE( convertor, datatype, count, pUserBuf );
567559

568560
if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) {
569-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
570561
if( !(convertor->flags & CONVERTOR_HOMOGENEOUS) ) {
571562
convertor->fAdvance = opal_unpack_general_checksum;
572-
} else
573-
#endif
574-
if( convertor->pDesc->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
575-
convertor->fAdvance = opal_unpack_homogeneous_contig_checksum;
576563
} else {
577-
convertor->fAdvance = opal_generic_simple_unpack_checksum;
564+
if( convertor->pDesc->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
565+
convertor->fAdvance = opal_unpack_homogeneous_contig_checksum;
566+
} else {
567+
convertor->fAdvance = opal_generic_simple_unpack_checksum;
568+
}
578569
}
579570
} else {
580-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
581571
if( !(convertor->flags & CONVERTOR_HOMOGENEOUS) ) {
582572
convertor->fAdvance = opal_unpack_general;
583-
} else
584-
#endif
585-
if( convertor->pDesc->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
586-
convertor->fAdvance = opal_unpack_homogeneous_contig;
587573
} else {
588-
convertor->fAdvance = opal_generic_simple_unpack;
574+
if( convertor->pDesc->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
575+
convertor->fAdvance = opal_unpack_homogeneous_contig;
576+
} else {
577+
convertor->fAdvance = opal_generic_simple_unpack;
578+
}
589579
}
590580
}
591581
return OPAL_SUCCESS;
@@ -605,24 +595,32 @@ int32_t opal_convertor_prepare_for_send( opal_convertor_t* convertor,
605595
OPAL_CONVERTOR_PREPARE( convertor, datatype, count, pUserBuf );
606596

607597
if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) {
608-
if( datatype->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
609-
if( ((datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size)
610-
|| (1 >= convertor->count) )
611-
convertor->fAdvance = opal_pack_homogeneous_contig_checksum;
612-
else
613-
convertor->fAdvance = opal_pack_homogeneous_contig_with_gaps_checksum;
598+
if( CONVERTOR_SEND_CONVERSION == (convertor->flags & (CONVERTOR_SEND_CONVERSION|CONVERTOR_HOMOGENEOUS)) ) {
599+
convertor->fAdvance = opal_pack_general_checksum;
614600
} else {
615-
convertor->fAdvance = opal_generic_simple_pack_checksum;
601+
if( datatype->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
602+
if( ((datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size)
603+
|| (1 >= convertor->count) )
604+
convertor->fAdvance = opal_pack_homogeneous_contig_checksum;
605+
else
606+
convertor->fAdvance = opal_pack_homogeneous_contig_with_gaps_checksum;
607+
} else {
608+
convertor->fAdvance = opal_generic_simple_pack_checksum;
609+
}
616610
}
617611
} else {
618-
if( datatype->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
619-
if( ((datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size)
620-
|| (1 >= convertor->count) )
621-
convertor->fAdvance = opal_pack_homogeneous_contig;
622-
else
623-
convertor->fAdvance = opal_pack_homogeneous_contig_with_gaps;
612+
if( CONVERTOR_SEND_CONVERSION == (convertor->flags & (CONVERTOR_SEND_CONVERSION|CONVERTOR_HOMOGENEOUS)) ) {
613+
convertor->fAdvance = opal_pack_general;
624614
} else {
625-
convertor->fAdvance = opal_generic_simple_pack;
615+
if( datatype->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
616+
if( ((datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size)
617+
|| (1 >= convertor->count) )
618+
convertor->fAdvance = opal_pack_homogeneous_contig;
619+
else
620+
convertor->fAdvance = opal_pack_homogeneous_contig_with_gaps;
621+
} else {
622+
convertor->fAdvance = opal_generic_simple_pack;
623+
}
626624
}
627625
}
628626
return OPAL_SUCCESS;
@@ -678,15 +676,33 @@ int opal_convertor_clone( const opal_convertor_t* source,
678676

679677
void opal_convertor_dump( opal_convertor_t* convertor )
680678
{
681-
printf( "Convertor %p count %d stack position %d bConverted %ld\n", (void*)convertor,
682-
convertor->count, convertor->stack_pos, (unsigned long)convertor->bConverted );
683-
printf( "\tlocal_size %ld remote_size %ld flags %X stack_size %d pending_length %d\n",
684-
(unsigned long)convertor->local_size, (unsigned long)convertor->remote_size,
685-
convertor->flags, convertor->stack_size, convertor->partial_length );
679+
opal_output( 0, "Convertor %p count %d stack position %d bConverted %ld\n"
680+
"\tlocal_size %ld remote_size %ld flags %X stack_size %d pending_length %d\n"
681+
"\tremote_arch %u local_arch %u\n",
682+
(void*)convertor,
683+
convertor->count, convertor->stack_pos, (unsigned long)convertor->bConverted,
684+
(unsigned long)convertor->local_size, (unsigned long)convertor->remote_size,
685+
convertor->flags, convertor->stack_size, convertor->partial_length,
686+
convertor->remoteArch, opal_local_arch );
687+
if( convertor->flags & CONVERTOR_RECV ) opal_output( 0, "unpack ");
688+
if( convertor->flags & CONVERTOR_SEND ) opal_output( 0, "pack ");
689+
if( convertor->flags & CONVERTOR_SEND_CONVERSION ) opal_output( 0, "conversion ");
690+
if( convertor->flags & CONVERTOR_HOMOGENEOUS ) opal_output( 0, "homogeneous " );
691+
else opal_output( 0, "heterogeneous ");
692+
if( convertor->flags & CONVERTOR_NO_OP ) opal_output( 0, "no_op ");
693+
if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) opal_output( 0, "checksum ");
694+
if( convertor->flags & CONVERTOR_CUDA ) opal_output( 0, "CUDA ");
695+
if( convertor->flags & CONVERTOR_CUDA_ASYNC ) opal_output( 0, "CUDA Async ");
696+
if( convertor->flags & CONVERTOR_COMPLETED ) opal_output( 0, "COMPLETED ");
697+
686698
opal_datatype_dump( convertor->pDesc );
687-
printf( "Actual stack representation\n" );
688-
opal_datatype_dump_stack( convertor->pStack, convertor->stack_pos,
689-
convertor->pDesc->desc.desc, convertor->pDesc->name );
699+
if( !((0 == convertor->stack_pos) &&
700+
((size_t)convertor->pStack[convertor->stack_pos].index > convertor->pDesc->desc.length)) ) {
701+
/* only if the convertor is completely initialized */
702+
opal_output( 0, "Actual stack representation\n" );
703+
opal_datatype_dump_stack( convertor->pStack, convertor->stack_pos,
704+
convertor->pDesc->desc.desc, convertor->pDesc->name );
705+
}
690706
}
691707

692708

opal/datatype/opal_convertor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ static inline int opal_convertor_cleanup( opal_convertor_t* convertor )
175175
*/
176176
static inline int32_t opal_convertor_need_buffers( const opal_convertor_t* pConvertor )
177177
{
178-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
179178
if (OPAL_UNLIKELY(0 == (pConvertor->flags & CONVERTOR_HOMOGENEOUS))) return 1;
180-
#endif
181179
#if OPAL_CUDA_SUPPORT
182180
if( pConvertor->flags & (CONVERTOR_CUDA | CONVERTOR_CUDA_UNIFIED)) return 1;
183181
#endif

0 commit comments

Comments
 (0)