From b6ddded1fa3e89b651eb02d3b093ed63d6e9e58f Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Sat, 25 Mar 2006 02:53:41 +0000 Subject: [PATCH] * Fix bug in determining size of C++ bool when creating the predefined datatype MPI::BOOL. * Add first round of support for heterogeneous platforms. This includes endianness and size difference for C++ bool and Fortran LOGICAL. It does not include differences in sizes for any other datatype or for different representations of floating point numbers. This commit was SVN r9422. --- ompi/datatype/Makefile.am | 4 +- ompi/datatype/convertor.c | 12 + ompi/datatype/convertor.h | 11 +- ompi/datatype/copy_functions.c | 12 +- ompi/datatype/copy_functions_heterogeneous.c | 398 +++++++++++++++++++ ompi/datatype/datatype_pack.c | 5 +- ompi/datatype/datatype_unpack.c | 5 +- ompi/datatype/dt_arch.c | 18 + ompi/datatype/dt_arch.h | 24 +- ompi/datatype/dt_module.c | 2 +- 10 files changed, 471 insertions(+), 20 deletions(-) create mode 100644 ompi/datatype/copy_functions_heterogeneous.c diff --git a/ompi/datatype/Makefile.am b/ompi/datatype/Makefile.am index 8b99df9da7..1047cbf43d 100644 --- a/ompi/datatype/Makefile.am +++ b/ompi/datatype/Makefile.am @@ -57,7 +57,9 @@ libdatatype_la_SOURCES = \ dt_external32.c \ dt_match_size.c \ convertor.c position.c \ - copy_functions.c get_count.c + copy_functions.c \ + copy_functions_heterogeneous.c \ + get_count.c libdatatype_la_LIBADD = libdatatype_reliable.la diff --git a/ompi/datatype/convertor.c b/ompi/datatype/convertor.c index 6e6e7ca4ee..7ca34aaf5a 100644 --- a/ompi/datatype/convertor.c +++ b/ompi/datatype/convertor.c @@ -349,6 +349,12 @@ ompi_convertor_prepare_for_recv( ompi_convertor_t* convertor, convertor->memAlloc_fn = NULL; if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) { +#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT + if (convertor->remoteArch != ompi_mpi_local_arch) { + convertor->pFunctions = ompi_ddt_heterogeneous_copy_functions; + convertor->fAdvance = ompi_unpack_general_checksum; + } else +#endif if( convertor->pDesc->flags & DT_FLAG_CONTIGUOUS ) { assert( convertor->flags & DT_FLAG_CONTIGUOUS ); convertor->fAdvance = ompi_unpack_homogeneous_contig_checksum; @@ -356,6 +362,12 @@ ompi_convertor_prepare_for_recv( ompi_convertor_t* convertor, convertor->fAdvance = ompi_generic_simple_unpack_checksum; } } else { +#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT + if (convertor->remoteArch != ompi_mpi_local_arch) { + convertor->pFunctions = ompi_ddt_heterogeneous_copy_functions; + convertor->fAdvance = ompi_unpack_general; + } else +#endif if( convertor->pDesc->flags & DT_FLAG_CONTIGUOUS ) { assert( convertor->flags & DT_FLAG_CONTIGUOUS ); convertor->fAdvance = ompi_unpack_homogeneous_contig; diff --git a/ompi/datatype/convertor.h b/ompi/datatype/convertor.h index 36bb0da713..3262b93f4c 100644 --- a/ompi/datatype/convertor.h +++ b/ompi/datatype/convertor.h @@ -53,11 +53,13 @@ extern "C" { #define CONVERTOR_COMPLETED 0x08000000 #define CONVERTOR_COMPUTE_CRC 0x10000000 -typedef int32_t (*conversion_fct_t)( uint32_t count, - const void* from, uint32_t from_len, long from_extent, - void* to, uint32_t to_length, long to_extent ); - typedef struct ompi_convertor_t ompi_convertor_t; + +typedef int32_t (*conversion_fct_t)( ompi_convertor_t* pConvertor, uint32_t count, + const void* from, uint32_t from_len, long from_extent, + void* to, uint32_t to_length, long to_extent, + uint32_t *advance ); + typedef int32_t (*convertor_advance_fct_t)( ompi_convertor_t* pConvertor, struct iovec* iov, uint32_t* out_size, @@ -109,6 +111,7 @@ OMPI_DECLSPEC extern ompi_convertor_t* ompi_mpi_local_convertor; OMPI_DECLSPEC extern uint32_t ompi_mpi_local_arch; extern conversion_fct_t ompi_ddt_copy_functions[]; +extern conversion_fct_t ompi_ddt_heterogeneous_copy_functions[]; /* * diff --git a/ompi/datatype/copy_functions.c b/ompi/datatype/copy_functions.c index 441fe22b93..d0914e04ad 100644 --- a/ompi/datatype/copy_functions.c +++ b/ompi/datatype/copy_functions.c @@ -31,9 +31,10 @@ * Return value: Number of elements of type TYPE copied */ #define COPY_TYPE( TYPENAME, TYPE, COUNT ) \ -static int copy_##TYPENAME( uint32_t count, \ +static int copy_##TYPENAME( ompi_convertor_t *pConvertor, uint32_t count, \ char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_len, long to_extent ) \ + char* to, uint32_t to_len, long to_extent, \ + uint32_t *advance) \ { \ uint32_t i; \ uint32_t remote_TYPE_size = sizeof(TYPE) * (COUNT); /* TODO */ \ @@ -64,6 +65,7 @@ static int copy_##TYPENAME( uint32_t count, \ from += from_extent; \ } \ } \ + *advance = count * from_extent; \ return count; \ } @@ -82,9 +84,10 @@ static int copy_##TYPENAME( uint32_t count, \ * Return value: Number of elements of type TYPE copied */ #define COPY_CONTIGUOUS_BYTES( TYPENAME, COUNT ) \ -static int copy_##TYPENAME##_##COUNT( uint32_t count, \ +static int copy_##TYPENAME##_##COUNT( ompi_convertor_t *pConvertor, uint32_t count, \ char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_len, long to_extent) \ + char* to, uint32_t to_len, long to_extent, \ + uint32_t *advance) \ { \ uint32_t i; \ uint32_t remote_TYPE_size = (COUNT); /* TODO */ \ @@ -112,6 +115,7 @@ static int copy_##TYPENAME##_##COUNT( uint32_t count, \ from += from_extent; \ } \ } \ + *advance = count * from_extent; \ return count; \ } diff --git a/ompi/datatype/copy_functions_heterogeneous.c b/ompi/datatype/copy_functions_heterogeneous.c new file mode 100644 index 0000000000..c910284b9c --- /dev/null +++ b/ompi/datatype/copy_functions_heterogeneous.c @@ -0,0 +1,398 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (c) 2004-2006 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include "opal/util/output.h" + +#include "opal/types.h" +#include "ompi/datatype/dt_arch.h" +#include "ompi/datatype/datatype.h" +#include "ompi/datatype/convertor.h" +#include "ompi/datatype/datatype_internal.h" +#include "ompi/datatype/datatype_checksum.h" + + +static inline void +ompi_dt_swap_bytes(void *to_p, const void *from_p, const long size) +{ + int i; + uint8_t *to = (uint8_t*) to_p, *from = (uint8_t*) from_p; + for (i = 0 ; i < size ; i++) { + to[size - 1 - i] = from[i]; + } +} + + +#define COPY_TYPE_HETEROGENEOUS( TYPENAME, TYPE ) \ +static int32_t \ +copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ + const char* from, uint32_t from_len, long from_extent, \ + char* to, uint32_t to_length, long to_extent, \ + uint32_t *advance) \ +{ \ + uint32_t i; \ + \ + datatype_check( #TYPE, sizeof(TYPE), sizeof(TYPE), count, \ + from, from_len, from_extent, \ + to, to_length, to_extent); \ + \ + if ((pConvertor->remoteArch & OMPI_ARCH_ISBIGENDIAN) != \ + (ompi_mpi_local_arch & OMPI_ARCH_ISBIGENDIAN)) { \ + for( i = 0; i < count; i++ ) { \ + ompi_dt_swap_bytes(to, from, sizeof(TYPE)); \ + to += to_extent; \ + from += from_extent; \ + } \ + } else if (sizeof(TYPE) == to_extent && \ + sizeof(TYPE) == from_extent) { \ + MEMCPY( to, from, count * sizeof(TYPE) ); \ + } else { \ + /* source or destination are non-contigous */ \ + for( i = 0; i < count; i++ ) { \ + MEMCPY( to, from, sizeof(TYPE) ); \ + to += to_extent; \ + from += from_extent; \ + } \ + } \ + *advance = count * from_extent; \ + return count; \ +} + + +#define COPY_2TYPE_HETEROGENEOUS( TYPENAME, TYPE1, TYPE2 ) \ +static int32_t \ +copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ + const char* from, uint32_t from_len, long from_extent, \ + char* to, uint32_t to_length, long to_extent, \ + uint32_t *advance) \ +{ \ + uint32_t i; \ + \ + datatype_check( #TYPENAME, sizeof(TYPE1) + sizeof(TYPE2), \ + sizeof(TYPE1) + sizeof(TYPE2), count, \ + from, from_len, from_extent, \ + to, to_length, to_extent); \ + \ + if ((pConvertor->remoteArch & OMPI_ARCH_ISBIGENDIAN) != \ + (ompi_mpi_local_arch & OMPI_ARCH_ISBIGENDIAN)) { \ + /* source and destination are different endianness */ \ + for( i = 0; i < count; i++ ) { \ + TYPE1* to_1, *from_1; \ + TYPE2* to_2, *from_2; \ + to_1 = (TYPE1*) to; from_1 = (TYPE1*) from; \ + ompi_dt_swap_bytes(to_1, from_1, sizeof(TYPE1)); \ + to_2 = (TYPE2*) (to_1 + 1); from_2 = (TYPE2*) (from_1 + 1); \ + ompi_dt_move_bytes(to_2, from_2, sizeof(TYPE2)); \ + to += to_extent; \ + from += from_extent; \ + } \ + } else if (sizeof(TYPE1) + sizeof(TYPE2) == to_extent && \ + sizeof(TYPE1) + sizeof(TYPE2) == from_extent) { \ + /* source and destination are contigous */ \ + MEMCPY( to, from, count * (sizeof(TYPE1) + sizeof(TYPE2)) ); \ + } else { \ + /* source or destination are non-contigous */ \ + for( i = 0; i < count; i++ ) { \ + MEMCPY( to, from, sizeof(TYPE1) + sizeof(TYPE2) ); \ + to += to_extent; \ + from += from_extent; \ + } \ + } \ + *advance = count * from_extent; \ + return count; \ +} + + +#define COPY_COMPLEX_HETEROGENEOUS( TYPENAME, TYPE ) \ + COPY_2TYPE_HETEROGENEOUS(complex_##TYPENAME, TYPE, TYPE) + + +#define COPY_2COMPLEX_HETEROGENEOUS( TYPENAME, TYPE ) \ +static int32_t \ +copy_2complex_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ + const char* from, uint32_t from_len, long from_extent, \ + char* to, uint32_t to_length, long to_extent, \ + uint32_t *advance) \ +{ \ + uint32_t i; \ + \ + datatype_check( #TYPENAME, sizeof(TYPE) * 2, sizeof(TYPE) * 2, count, \ + from, from_len, from_extent, \ + to, to_length, to_extent); \ + \ + if ((pConvertor->remoteArch & OMPI_ARCH_ISBIGENDIAN) != \ + (ompi_mpi_local_arch & OMPI_ARCH_ISBIGENDIAN)) { \ + /* source and destination are different endianness */ \ + for( i = 0; i < count; i++ ) { \ + TYPE *to_p = (TYPE*) to, *from_p = (TYPE*) from; \ + ompi_dt_swap_bytes(&(to_p->r), &(from_p->r), sizeof(to_p->r)); \ + ompi_dt_swap_bytes(&(to_p->i), &(from_p->i), sizeof(to_p->i)); \ + to_p++; from_p++; \ + ompi_dt_swap_bytes(&(to_p->r), &(from_p->r), sizeof(to_p->r)); \ + ompi_dt_swap_bytes(&(to_p->i), &(from_p->i), sizeof(to_p->i)); \ + to += to_extent; \ + from += from_extent; \ + } \ + } else if (sizeof(TYPE) * 2 == to_extent && \ + sizeof(TYPE) * 2 == from_extent) { \ + /* source and destination are contigous */ \ + MEMCPY( to, from, count * (sizeof(TYPE) * 2) ); \ + } else { \ + /* source or destination are non-contigous */ \ + for( i = 0; i < count; i++ ) { \ + MEMCPY( to, from, sizeof(TYPE) * 2 ); \ + to += to_extent; \ + from += from_extent; \ + } \ + } \ + *advance = count * from_extent; \ + return count; \ +} + + +static inline void +datatype_check(char *type, uint32_t local_size, uint32_t remote_size, uint32_t count, + const char* from, uint32_t from_len, long from_extent, + char* to, uint32_t to_len, long to_extent) +{ + /* make sure the remote buffer is large enough to hold the data */ + if( (remote_size * count) > from_len ) { + count = from_len / remote_size; + if( (count * remote_size) != from_len ) { + DUMP( "oops should I keep this data somewhere (excedent %d bytes)?\n", + from_len - (count * remote_size) ); + } + DUMP( "correct: copy %s count %d from buffer %p with length %d to %p space %d\n", + "char", count, from, from_len, to, to_len ); + } else { + DUMP( " copy %s count %d from buffer %p with length %d to %p space %d\n", + "char", count, from, from_len, to, to_len ); + } +} + + +/* char has no endian issues, so don't really worry about it */ +static int32_t +copy_char_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, + const char* from, uint32_t from_len, long from_extent, + char* to, uint32_t to_length, long to_extent, + uint32_t *advance) +{ + uint32_t i; + + datatype_check("char", sizeof(char), sizeof(char), count, + from, from_len, from_extent, + to, to_length, to_extent); + + if( (from_extent == sizeof(char)) && + (to_extent == sizeof(char)) ) { + /* copy of contigous data at both source and destination */ + MEMCPY( to, from, count * sizeof(char) ); + } else { + /* source or destination are non-contigous */ + for( i = 0; i < count; i++ ) { + MEMCPY( to, from, sizeof(char) ); + to += to_extent; + from += from_extent; + } + } + *advance = count * from_extent; + return count; +} + + +#define CXX_BOOL_COPY_LOOP(TYPE) \ + for( i = 0; i < count; i++ ) { \ + bool *to_real = (bool*) to; \ + *to_real = *((TYPE*) from) == 0 ? false : true; \ + to += to_extent; \ + from += from_extent; \ + } +static int32_t +copy_cxx_bool_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, + const char* from, uint32_t from_len, long from_extent, + char* to, uint32_t to_length, long to_extent, + uint32_t *advance) +{ + uint32_t i; + + /* fix up the from extent */ + if ((pConvertor->remoteArch & OMPI_ARCH_BOOLISxx) != + (ompi_mpi_local_arch & OMPI_ARCH_BOOLISxx)) { + switch (pConvertor->remoteArch & OMPI_ARCH_BOOLISxx) { + case OMPI_ARCH_BOOLIS8: + from_extent = 1; + break; + case OMPI_ARCH_BOOLIS16: + from_extent = 2; + break; + case OMPI_ARCH_BOOLIS32: + from_extent = 4; + break; + } + } + + datatype_check( "bool", sizeof(bool), sizeof(bool), count, + from, from_len, from_extent, + to, to_length, to_extent); + + if ((to_extent != sizeof(bool) || from_extent != sizeof(bool)) || + ((pConvertor->remoteArch & OMPI_ARCH_BOOLISxx) != + (ompi_mpi_local_arch & OMPI_ARCH_BOOLISxx))) { + switch (pConvertor->remoteArch & OMPI_ARCH_BOOLISxx) { + case OMPI_ARCH_BOOLIS8: + CXX_BOOL_COPY_LOOP(int8_t); + break; + case OMPI_ARCH_BOOLIS16: + CXX_BOOL_COPY_LOOP(int16_t); + break; + case OMPI_ARCH_BOOLIS32: + CXX_BOOL_COPY_LOOP(int32_t); + break; + } + } else { + MEMCPY( to, from, count * sizeof(bool) ); + } + + *advance = count * from_extent; + return count; +} + +#define FORTRAN_LOGICAL_COPY_LOOP(TYPE) \ + for( i = 0; i < count; i++ ) { \ + ompi_fortran_logical_t *to_real = (ompi_fortran_logical_t*) to; \ + *to_real = *((TYPE*) from) == 0 ? 0 : OMPI_FORTRAN_VALUE_TRUE; \ + to += to_extent; \ + from += from_extent; \ + } +static int32_t +copy_fortran_logical_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, + const char* from, uint32_t from_len, long from_extent, + char* to, uint32_t to_length, long to_extent, + uint32_t *advance) +{ + uint32_t i; + + /* fix up the from extent */ + if ((pConvertor->remoteArch & OMPI_ARCH_LOGICALISxx) != + (ompi_mpi_local_arch & OMPI_ARCH_LOGICALISxx)) { + switch (pConvertor->remoteArch & OMPI_ARCH_LOGICALISxx) { + case OMPI_ARCH_LOGICALIS8: + from_extent = 1; + break; + case OMPI_ARCH_LOGICALIS16: + from_extent = 2; + break; + case OMPI_ARCH_LOGICALIS32: + from_extent = 4; + break; + } + } + + datatype_check( "logical", sizeof(ompi_fortran_logical_t), + sizeof(ompi_fortran_logical_t), count, + from, from_len, from_extent, + to, to_length, to_extent); + + if ((to_extent != sizeof(ompi_fortran_logical_t) || + from_extent != sizeof(ompi_fortran_logical_t)) || + ((pConvertor->remoteArch & OMPI_ARCH_LOGICALISxx) != + (ompi_mpi_local_arch & OMPI_ARCH_LOGICALISxx))) { + switch (pConvertor->remoteArch & OMPI_ARCH_LOGICALISxx) { + case OMPI_ARCH_LOGICALIS8: + FORTRAN_LOGICAL_COPY_LOOP(int8_t); + break; + case OMPI_ARCH_LOGICALIS16: + FORTRAN_LOGICAL_COPY_LOOP(int16_t); + break; + case OMPI_ARCH_LOGICALIS32: + FORTRAN_LOGICAL_COPY_LOOP(int32_t); + break; + } + } else { + MEMCPY( to, from, count * sizeof(ompi_fortran_logical_t) ); + } + + *advance = count * from_extent; + return count; +} + + +COPY_TYPE_HETEROGENEOUS(short, short) +COPY_TYPE_HETEROGENEOUS(int, int) +COPY_TYPE_HETEROGENEOUS(long, long) +COPY_TYPE_HETEROGENEOUS(long_long, long long) +COPY_TYPE_HETEROGENEOUS(float, float) +COPY_TYPE_HETEROGENEOUS(double, double) +COPY_TYPE_HETEROGENEOUS(long_double, long double) +COPY_COMPLEX_HETEROGENEOUS(float, float) +COPY_COMPLEX_HETEROGENEOUS(double, double) +COPY_COMPLEX_HETEROGENEOUS(long_double, long double) +COPY_2TYPE_HETEROGENEOUS(float_int, float, int) +COPY_2TYPE_HETEROGENEOUS(double_int, double, int) +COPY_2TYPE_HETEROGENEOUS(long_double_int, long double, int) +COPY_2TYPE_HETEROGENEOUS(long_int, long, int) +COPY_2TYPE_HETEROGENEOUS(2int, int, int) +COPY_2TYPE_HETEROGENEOUS(2float, float, float) +COPY_2TYPE_HETEROGENEOUS(2double, double, double) +COPY_TYPE_HETEROGENEOUS(wchar, wchar_t) +COPY_2COMPLEX_HETEROGENEOUS(float, ompi_complex_float_t) +COPY_2COMPLEX_HETEROGENEOUS(double, ompi_complex_double_t) + + +/* table of predefined copy functions - one for each MPI type */ +conversion_fct_t ompi_ddt_heterogeneous_copy_functions[DT_MAX_PREDEFINED] = { + NULL, /* DT_LOOP */ + NULL, /* DT_END_LOOP */ + NULL, /* DT_LB */ + NULL, /* DT_UB */ + (conversion_fct_t) copy_char_heterogeneous, /* DT_CHAR */ + (conversion_fct_t) copy_char_heterogeneous, /* DT_CHARACTER */ + (conversion_fct_t) copy_char_heterogeneous, /* DT_UNSIGNED_CHAR */ + (conversion_fct_t) copy_char_heterogeneous, /* DT_SIGNED_CHAR */ + (conversion_fct_t) copy_char_heterogeneous, /* DT_BYTE */ + (conversion_fct_t) copy_short_heterogeneous, /* DT_SHORT */ + (conversion_fct_t) copy_short_heterogeneous, /* DT_UNSIGNED_SHORT */ + (conversion_fct_t) copy_int_heterogeneous, /* DT_INT */ + (conversion_fct_t) copy_int_heterogeneous, /* DT_UNSIGNED_INT */ + (conversion_fct_t) copy_long_heterogeneous, /* DT_LONG */ + (conversion_fct_t) copy_long_heterogeneous, /* DT_UNSIGNED_LONG */ + (conversion_fct_t) copy_long_long_heterogeneous, /* DT_LONG_LONG */ + (conversion_fct_t) copy_long_long_heterogeneous, /* DT_LONG_LONG_INT */ + (conversion_fct_t) copy_long_long_heterogeneous, /* DT_UNSIGNED_LONG_LONG */ + (conversion_fct_t) copy_float_heterogeneous, /* DT_FLOAT */ + (conversion_fct_t) copy_double_heterogeneous, /* DT_DOUBLE */ + (conversion_fct_t) copy_long_double_heterogeneous, /* DT_LONG_DOUBLE */ + NULL, /* DT_PACKED */ + (conversion_fct_t) copy_wchar_heterogeneous, /* DT_WCHAR */ + (conversion_fct_t) copy_cxx_bool_heterogeneous, /* DT_CXX_BOOL */ + (conversion_fct_t) copy_fortran_logical_heterogeneous, /* DT_LOGIC */ + (conversion_fct_t) copy_int_heterogeneous, /* DT_INTEGER */ + (conversion_fct_t) copy_float_heterogeneous, /* DT_REAL */ + (conversion_fct_t) copy_double_heterogeneous, /* DT_DBLPREC */ + (conversion_fct_t) copy_complex_float_heterogeneous, /* DT_COMPLEX_FLOAT */ + (conversion_fct_t) copy_complex_double_heterogeneous, /* DT_COMPLEX_DOUBLE */ + (conversion_fct_t) copy_complex_long_double_heterogeneous,/* DT_COMPLEX_LONG_DOUBLE */ + (conversion_fct_t) copy_2int_heterogeneous, /* DT_2INT */ + (conversion_fct_t) copy_2int_heterogeneous, /* DT_2INTEGER */ + (conversion_fct_t) copy_2float_heterogeneous, /* DT_2REAL */ + (conversion_fct_t) copy_2double_heterogeneous, /* DT_2DBLPREC */ + (conversion_fct_t) copy_2complex_float_heterogeneous, /* DT_2COMPLEX */ + (conversion_fct_t) copy_2complex_double_heterogeneous, /* DT_2DOUBLE_COMPLEX */ + (conversion_fct_t) copy_float_int_heterogeneous, /* DT_FLOAT_INT */ + (conversion_fct_t) copy_double_int_heterogeneous, /* DT_DOUBLE_INT */ + (conversion_fct_t) copy_long_double_int_heterogeneous, /* DT_LONG_DOUBLE_INT */ + (conversion_fct_t) copy_long_int_heterogeneous, /* DT_LONG_INT */ + NULL, /* DT_SHORT_INT */ + NULL, /* DT_UNAVAILABLE */ +}; diff --git a/ompi/datatype/datatype_pack.c b/ompi/datatype/datatype_pack.c index 9197af9799..60215dcb71 100644 --- a/ompi/datatype/datatype_pack.c +++ b/ompi/datatype/datatype_pack.c @@ -137,11 +137,10 @@ ompi_pack_general_function( ompi_convertor_t* pConvertor, while( pElem[pos_desc].elem.common.flags & DT_FLAG_DATA ) { /* now here we have a basic datatype */ type = pElem[pos_desc].elem.common.type; - rc = pConvertor->pFunctions[type]( count_desc, + rc = pConvertor->pFunctions[type]( pConvertor, count_desc, pOutput + pStack->disp + disp_desc, iCount, pElem[pos_desc].elem.extent, - pInput, iCount, BASIC_DDT_FROM_ELEM(pElem[pos_desc])->size ); - advance = rc * BASIC_DDT_FROM_ELEM(pElem[pos_desc])->size; + pInput, iCount, BASIC_DDT_FROM_ELEM(pElem[pos_desc])->size, &advance ); iCount -= advance; /* decrease the available space in the buffer */ pInput += advance; /* increase the pointer to the buffer */ bConverted += advance; diff --git a/ompi/datatype/datatype_unpack.c b/ompi/datatype/datatype_unpack.c index ac6fb1e9a4..603348e499 100644 --- a/ompi/datatype/datatype_unpack.c +++ b/ompi/datatype/datatype_unpack.c @@ -131,11 +131,10 @@ ompi_unpack_general_function( ompi_convertor_t* pConvertor, while( pElems[pos_desc].elem.common.flags & DT_FLAG_DATA ) { /* now here we have a basic datatype */ type = pElems[pos_desc].elem.common.type; - rc = pConvertor->pFunctions[type]( count_desc, + rc = pConvertor->pFunctions[type]( pConvertor, count_desc, pInput, iCount, ompi_ddt_basicDatatypes[type]->size, pConvertor->pBaseBuf + pStack->disp + disp_desc, - oCount, pElems[pos_desc].elem.extent ); - advance = rc * ompi_ddt_basicDatatypes[type]->size; + oCount, pElems[pos_desc].elem.extent, &advance ); iCount -= advance; /* decrease the available space in the buffer */ pInput += advance; /* increase the pointer to the buffer */ bConverted += advance; diff --git a/ompi/datatype/dt_arch.c b/ompi/datatype/dt_arch.c index 3104c1bc85..7c86f38bfa 100644 --- a/ompi/datatype/dt_arch.c +++ b/ompi/datatype/dt_arch.c @@ -26,6 +26,24 @@ int32_t ompi_arch_compute_local_id( uint32_t *me ) if( 8 == sizeof(long) ) ompi_arch_setmask( me, OMPI_ARCH_LONGIS64 ); + /* sizeof bool */ + if (1 == sizeof(bool) ) { + ompi_arch_setmask( me, OMPI_ARCH_BOOLIS8); + } else if (2 == sizeof(bool)) { + ompi_arch_setmask( me, OMPI_ARCH_BOOLIS16); + } else if (4 == sizeof(bool)) { + ompi_arch_setmask( me, OMPI_ARCH_BOOLIS32); + } + + /* sizeof fortran logical */ + if (1 == sizeof(ompi_fortran_logical_t) ) { + ompi_arch_setmask( me, OMPI_ARCH_LOGICALIS8); + } else if (2 == sizeof(ompi_fortran_logical_t)) { + ompi_arch_setmask( me, OMPI_ARCH_LOGICALIS16); + } else if (4 == sizeof(ompi_fortran_logical_t)) { + ompi_arch_setmask( me, OMPI_ARCH_LOGICALIS32); + } + /* Initialize the information regarding the long double */ if( 12 == sizeof(long double) ) ompi_arch_setmask( me, OMPI_ARCH_LONGDOUBLEIS96 ); diff --git a/ompi/datatype/dt_arch.h b/ompi/datatype/dt_arch.h index 172e1bee7d..54191de04f 100644 --- a/ompi/datatype/dt_arch.h +++ b/ompi/datatype/dt_arch.h @@ -173,8 +173,8 @@ ** 2. Byte: ** bits 1 & 2: length of long: 00 = 32, 01 = 64 ** bits 3 & 4: lenght of long long (not used currently, set to 00). -** bits 5 & 6: reserved for later use. currently set to 00 -** bits 7 & 8: reserved for later use. currently set to 00 +** bits 5 & 6: length of C/C++ bool (00 = 8, 01 = 16, 10 = 32) +** bits 7 & 8: length of Fortran Logical (00 = 8, 01 = 16, 10 = 32) ** 3. Byte: ** bits 1 & 2: length of long double: 00=64, 01=96,10 = 128 ** bits 3 & 4: no. of rel. bits in the exponent: 00 = 10, 01 = 14) @@ -195,9 +195,25 @@ #define OMPI_ARCH_HEADERMASK2 0x00000003 /* other end, needed for checks */ #define OMPI_ARCH_UNUSEDMASK 0xfc000000 /* mark the unused fields */ +/* BYTE 1 */ #define OMPI_ARCH_ISBIGENDIAN 0x00000008 -#define OMPI_ARCH_LONGIS64 0x00000200 -#define OMPI_ARCH_LONGLONGISxx 0x0000F000 /* the size of the long long */ + +/* BYTE 2 */ +#define OMPI_ARCH_LONGISxx 0x0000c000 /* mask for sizeof long */ +#define OMPI_ARCH_LONGIS64 0x00001000 +#define OMPI_ARCH_LONGLONGISxx 0x00003000 /* mask for sizeof long long */ + +#define OMPI_ARCH_BOOLISxx 0x00000c00 /* mask for sizeof bool */ +#define OMPI_ARCH_BOOLIS8 0x00000000 /* bool is 8 bits */ +#define OMPI_ARCH_BOOLIS16 0x00000400 /* bool is 16 bits */ +#define OMPI_ARCH_BOOLIS32 0x00000800 /* bool is 32 bits */ + +#define OMPI_ARCH_LOGICALISxx 0x00000300 /* mask for sizeof Fortran logical */ +#define OMPI_ARCH_LOGICALIS8 0x00000000 /* logical is 8 bits */ +#define OMPI_ARCH_LOGICALIS16 0x00000100 /* logical is 16 bits */ +#define OMPI_ARCH_LOGICALIS32 0x00000200 /* logical is 32 bits */ + +/* BYTE 3 */ #define OMPI_ARCH_LONGDOUBLEIS96 0x00020000 #define OMPI_ARCH_LONGDOUBLEIS128 0x00010000 diff --git a/ompi/datatype/dt_module.c b/ompi/datatype/dt_module.c index 3149332b33..a364185b6b 100644 --- a/ompi/datatype/dt_module.c +++ b/ompi/datatype/dt_module.c @@ -118,7 +118,7 @@ OMPI_DECLSPEC ompi_datatype_t ompi_mpi_wchar = INIT_BASIC_DATA( wchar_t, OMPI_AL OMPI_DECLSPEC ompi_datatype_t ompi_mpi_wchar = INIT_UNAVAILABLE_DATA( WCHAR ); #endif /* FTMPI_HAVE_WCHAR_T */ -OMPI_DECLSPEC ompi_datatype_t ompi_mpi_cxx_bool = INIT_BASIC_DATA( SIZEOF_BOOL, OMPI_ALIGNMENT_CXX_BOOL, CXX_BOOL, DT_FLAG_DATA_CPP ); +OMPI_DECLSPEC ompi_datatype_t ompi_mpi_cxx_bool = INIT_BASIC_DATA( bool, OMPI_ALIGNMENT_CXX_BOOL, CXX_BOOL, DT_FLAG_DATA_CPP ); OMPI_DECLSPEC ompi_datatype_t ompi_mpi_logic = INIT_BASIC_FORTRAN_TYPE( DT_LOGIC, LOGIC, OMPI_SIZEOF_FORTRAN_LOGICAL, OMPI_ALIGNMENT_FORTRAN_LOGICAL, 0 ); OMPI_DECLSPEC ompi_datatype_t ompi_mpi_integer = INIT_BASIC_FORTRAN_TYPE( DT_INTEGER, INTEGER, OMPI_SIZEOF_FORTRAN_INTEGER, OMPI_ALIGNMENT_FORTRAN_INTEGER, DT_FLAG_DATA_INT ); OMPI_DECLSPEC ompi_datatype_t ompi_mpi_real = INIT_BASIC_FORTRAN_TYPE( DT_REAL, REAL, OMPI_SIZEOF_FORTRAN_REAL, OMPI_ALIGNMENT_FORTRAN_REAL, DT_FLAG_DATA_FLOAT );