Skip to content

External32 fix #7919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ompi/datatype/ompi_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BEGIN_C_DECLS
#define OMPI_DATATYPE_FLAG_DATA_FORTRAN 0xC000
#define OMPI_DATATYPE_FLAG_DATA_LANGUAGE 0xC000

#define OMPI_DATATYPE_MAX_PREDEFINED 50
#define OMPI_DATATYPE_MAX_PREDEFINED 80

#if OMPI_DATATYPE_MAX_PREDEFINED > OPAL_DATATYPE_MAX_SUPPORTED
#error Need to increase the number of supported dataypes by OPAL (value OPAL_DATATYPE_MAX_SUPPORTED).
Expand Down
62 changes: 62 additions & 0 deletions ompi/datatype/ompi_datatype_external32.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Copyright (c) 2004-2006 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2020 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -23,6 +24,7 @@
#include "opal/datatype/opal_convertor.h"
#include "opal/util/arch.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/datatype/ompi_datatype_internal.h"

/* From the MPI standard. external32 use the following types:
* Type Length
Expand Down Expand Up @@ -76,10 +78,13 @@ uint32_t ompi_datatype_external32_arch_id = OPAL_ARCH_LDEXPSIZEIS15 | OPAL_ARCH_
opal_convertor_t* ompi_mpi_external32_convertor = NULL;
opal_convertor_t* ompi_mpi_local_convertor = NULL;

static void set_external32_sizes(opal_convertor_t *convertor);

int32_t ompi_datatype_default_convertors_init( void )
{
/* create the extern32 convertor */
ompi_mpi_external32_convertor = opal_convertor_create( ompi_datatype_external32_arch_id, 0 );
set_external32_sizes(ompi_mpi_external32_convertor);

/* create the local convertor */
ompi_mpi_local_convertor = opal_convertor_create( opal_local_arch, 0 );
Expand All @@ -95,3 +100,60 @@ int32_t ompi_datatype_default_convertors_fini( void )

return OMPI_SUCCESS;
}

static void
set_external32_sizes(opal_convertor_t *convertor)
{
int i;

/* We have to give every predefined datatype a size, initialize as */
/* the default sizes, then change whatever is specified in the standard */
for (i=OMPI_DATATYPE_MPI_EMPTY+1; i<OMPI_DATATYPE_MPI_MAX_PREDEFINED; ++i) {
if (i != OMPI_DATATYPE_MPI_LB && i != OMPI_DATATYPE_MPI_UB) {
opal_convertor_set_ompi_remote_size(convertor,
i, ompi_datatype_basicDatatypes[i]->super.size);
}
}

opal_convertor_set_ompi_remote_size(convertor, MPI_PACKED->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_BYTE->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_CHAR->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_UNSIGNED_CHAR->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_SIGNED_CHAR->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_WCHAR->super.ompi_id, 2);
opal_convertor_set_ompi_remote_size(convertor, MPI_SHORT->super.ompi_id, 2);
opal_convertor_set_ompi_remote_size(convertor, MPI_UNSIGNED_SHORT->super.ompi_id, 2);
opal_convertor_set_ompi_remote_size(convertor, MPI_INT->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_UNSIGNED->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_LONG->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_UNSIGNED_LONG->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_LONG_LONG_INT->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_UNSIGNED_LONG_LONG->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_FLOAT->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_DOUBLE->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_LONG_DOUBLE->super.ompi_id, 16);

opal_convertor_set_ompi_remote_size(convertor, MPI_C_BOOL->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_AINT->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_COUNT->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_OFFSET->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_C_COMPLEX->super.ompi_id, 2*4);
opal_convertor_set_ompi_remote_size(convertor, MPI_C_FLOAT_COMPLEX->super.ompi_id, 2*4);
opal_convertor_set_ompi_remote_size(convertor, MPI_C_DOUBLE_COMPLEX->super.ompi_id, 2*8);
opal_convertor_set_ompi_remote_size(convertor, MPI_C_LONG_DOUBLE_COMPLEX->super.ompi_id, 2*16);

opal_convertor_set_ompi_remote_size(convertor, MPI_CHARACTER->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_LOGICAL->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_INTEGER->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_REAL->super.ompi_id, 4);
opal_convertor_set_ompi_remote_size(convertor, MPI_DOUBLE_PRECISION->super.ompi_id, 8);
opal_convertor_set_ompi_remote_size(convertor, MPI_COMPLEX->super.ompi_id, 2*4);
opal_convertor_set_ompi_remote_size(convertor, MPI_DOUBLE_COMPLEX->super.ompi_id, 2*8);

opal_convertor_set_ompi_remote_size(convertor, MPI_CXX_BOOL->super.ompi_id, 1);
opal_convertor_set_ompi_remote_size(convertor, MPI_CXX_FLOAT_COMPLEX->super.ompi_id, 2*4);
opal_convertor_set_ompi_remote_size(convertor, MPI_CXX_DOUBLE_COMPLEX->super.ompi_id, 2*8);
opal_convertor_set_ompi_remote_size(convertor, MPI_CXX_LONG_DOUBLE_COMPLEX->super.ompi_id, 2*16);

opal_convertor_ompi_remote_size_is_ready(convertor);
}
2 changes: 1 addition & 1 deletion ompi/datatype/ompi_datatype_get_elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int ompi_datatype_get_elements (ompi_datatype_t *datatype, size_t ucount, size_t
opal_datatype_compute_ptypes(&datatype->super);
/* count the basic elements in the datatype */
for (i = OPAL_DATATYPE_FIRST_TYPE, total = 0 ; i < OPAL_DATATYPE_MAX_PREDEFINED ; ++i) {
total += datatype->super.ptypes[i];
total += datatype->super.ptypes->bdt_count[i];
}
internal_count = total * internal_count;
}
Expand Down
Loading