/** * Main function. Call several tests and print-out the results. It try to stress the convertor * using difficult data-type constructions as well as strange segment sizes for the conversion. * Usually, it is able to detect most of the data-type and convertor problems. Any modifications * on the data-type engine should first pass all the tests from this file, before going into other * tests. */ int main( int argc, char* argv[] ) { opal_datatype_init(); /** * By default simulate homogeneous architectures. */ remote_arch = opal_local_arch ^ OPAL_ARCH_ISBIGENDIAN; opal_convertor_t * pConv; int sbuf[2], rbuf[2]; size_t max_data; struct iovec a; uint32_t iov_count; sbuf[0] = 0x01000000; sbuf[1] = 0x02000000; printf( "\n\n#\n * TEST UNPACKING 1 int out of 1\n#\n\n" ); pConv = opal_convertor_create( remote_arch, 0 ); rbuf[0] = -1; rbuf[1] = -1; if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 1, rbuf ) ) { printf( "Cannot attach the datatype to a convertor\n" ); return OPAL_ERROR; } a.iov_base = sbuf; a.iov_len = 4; iov_count = 1; max_data = 4; opal_unpack_general( pConv, &a, &iov_count, &max_data ); assert(1 == rbuf[0]); assert(-1 == rbuf[1]); OBJ_RELEASE(pConv); printf( "\n\n#\n * TEST UNPACKING 1 int out of 2\n#\n\n" ); pConv = opal_convertor_create( remote_arch, 0 ); rbuf[0] = -1; rbuf[1] = -1; if( OPAL_SUCCESS != opal_convertor_prepare_for_recv( pConv, &opal_datatype_int4, 2, rbuf ) ) { printf( "Cannot attach the datatype to a convertor\n" ); return OPAL_ERROR; } a.iov_base = sbuf; a.iov_len = 4; iov_count = 1; max_data = 4; opal_unpack_general( pConv, &a, &iov_count, &max_data ); assert(1 == rbuf[0]); assert(-1 == rbuf[1]); OBJ_RELEASE(pConv); /* clean-ups all data allocations */ opal_datatype_finalize(); opal_finalize(); return OPAL_SUCCESS; }
/** * Main function. Call several tests and print-out the results. It try to stress the convertor * using difficult data-type constructions as well as strange segment sizes for the conversion. * Usually, it is able to detect most of the data-type and convertor problems. Any modifications * on the data-type engine should first pass all the tests from this file, before going into other * tests. */ int main( int argc, char* argv[] ) { opal_datatype_t *pdt, *pdt1, *pdt2, *pdt3; int rc, length = 500; opal_datatype_init(); /** * By default simulate homogeneous architectures. */ remote_arch = opal_local_arch; printf( "\n\n#\n * TEST CREATE CONTIGUOUS\n #\n\n" ); pdt = create_contiguous_type( &opal_datatype_int1, 10 ); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 100); local_copy_with_convertor(pdt, 100, 956); } OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "\n\n#\n * TEST STRANGE DATATYPE\n #\n\n" ); pdt = create_strange_dt(); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 1); local_copy_with_convertor(pdt, 1, 956); } OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "\n\n#\n * TEST UPPER TRIANGULAR MATRIX (size 100)\n #\n\n" ); pdt = upper_matrix(100); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 1); local_copy_with_convertor(pdt, 1, 48); } OBJ_RELEASE( pdt ); assert( pdt == NULL ); mpich_typeub(); mpich_typeub2(); mpich_typeub3(); printf( "\n\n#\n * TEST UPPER MATRIX\n #\n\n" ); rc = test_upper( length ); if( rc == 0 ) printf( "decode [PASSED]\n" ); else printf( "decode [NOT PASSED]\n" ); printf( "\n\n#\n * TEST MATRIX BORDERS\n #\n\n" ); pdt = test_matrix_borders( length, 100 ); if( outputFlags & DUMP_DATA_AFTER_COMMIT ) { opal_datatype_dump( pdt ); } OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "\n\n#\n * TEST CONTIGUOUS\n #\n\n" ); pdt = test_contiguous(); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "\n\n#\n * TEST STRUCT\n #\n\n" ); pdt = test_struct(); OBJ_RELEASE( pdt ); assert( pdt == NULL ); opal_datatype_create_contiguous(0, &opal_datatype_empty, &pdt1); opal_datatype_create_contiguous(0, &opal_datatype_empty, &pdt2); opal_datatype_create_contiguous(0, &opal_datatype_empty, &pdt3); opal_datatype_add( pdt3, &opal_datatype_int4, 10, 0, -1 ); opal_datatype_add( pdt3, &opal_datatype_float4, 5, 10 * sizeof(int), -1 ); opal_datatype_add( pdt2, &opal_datatype_float4, 1, 0, -1 ); opal_datatype_add( pdt2, pdt3, 3, sizeof(int) * 1, -1 ); opal_datatype_add( pdt1, &opal_datatype_int8, 5, 0, -1 ); opal_datatype_add( pdt1, &opal_datatype_float16, 2, sizeof(long long) * 5, -1 ); printf( ">>--------------------------------------------<<\n" ); if( outputFlags & DUMP_DATA_AFTER_COMMIT ) { opal_datatype_dump( pdt1 ); } printf( ">>--------------------------------------------<<\n" ); if( outputFlags & DUMP_DATA_AFTER_COMMIT ) { opal_datatype_dump( pdt2 ); } printf( ">>--------------------------------------------<<\n" ); if( outputFlags & DUMP_DATA_AFTER_COMMIT ) { opal_datatype_dump( pdt3 ); } OBJ_RELEASE( pdt1 ); assert( pdt1 == NULL ); OBJ_RELEASE( pdt2 ); assert( pdt2 == NULL ); OBJ_RELEASE( pdt3 ); assert( pdt3 == NULL ); printf( ">>--------------------------------------------<<\n" ); printf( " Contiguous data-type (opal_datatype_float8)\n" ); if( outputFlags & CHECK_PACK_UNPACK ) { const opal_datatype_t const* ddt = &opal_datatype_float8; local_copy_ddt_count( ddt, 4500); local_copy_with_convertor( ddt, 4500, 12 ); local_copy_with_convertor_2datatypes( ddt, 4500, ddt, 4500, 12 ); } printf( ">>--------------------------------------------<<\n" ); printf( ">>--------------------------------------------<<\n" ); if( outputFlags & CHECK_PACK_UNPACK ) { printf( "Contiguous multiple data-type (4500*1)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 4500 ); local_copy_ddt_count(pdt, 1); local_copy_with_convertor( pdt, 1, 12 ); local_copy_with_convertor_2datatypes( pdt, 1, pdt, 1, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "Contiguous multiple data-type (450*10)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 450 ); local_copy_ddt_count(pdt, 10); local_copy_with_convertor( pdt, 10, 12 ); local_copy_with_convertor_2datatypes( pdt, 10, pdt, 10, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "Contiguous multiple data-type (45*100)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 45 ); local_copy_ddt_count(pdt, 100); local_copy_with_convertor( pdt, 100, 12 ); local_copy_with_convertor_2datatypes( pdt, 100, pdt, 100, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "Contiguous multiple data-type (100*45)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 100 ); local_copy_ddt_count(pdt, 45); local_copy_with_convertor( pdt, 45, 12 ); local_copy_with_convertor_2datatypes( pdt, 45, pdt, 45, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "Contiguous multiple data-type (10*450)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 10 ); local_copy_ddt_count(pdt, 450); local_copy_with_convertor( pdt, 450, 12 ); local_copy_with_convertor_2datatypes( pdt, 450, pdt, 450, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( "Contiguous multiple data-type (1*4500)\n" ); pdt = create_contiguous_type( &opal_datatype_float8, 1 ); local_copy_ddt_count(pdt, 4500); local_copy_with_convertor( pdt, 4500, 12 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 12 ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); } printf( ">>--------------------------------------------<<\n" ); printf( ">>--------------------------------------------<<\n" ); printf( "Vector data-type (450 times 10 double stride 11)\n" ); pdt = create_vector_type( &opal_datatype_float8, 450, 10, 11 ); opal_datatype_dump( pdt ); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 1); local_copy_with_convertor( pdt, 1, 12 ); local_copy_with_convertor_2datatypes( pdt, 1, pdt, 1, 12 ); local_copy_with_convertor( pdt, 1, 82 ); local_copy_with_convertor_2datatypes( pdt, 1, pdt, 1, 82 ); local_copy_with_convertor( pdt, 1, 6000 ); local_copy_with_convertor_2datatypes( pdt, 1, pdt, 1, 6000 ); local_copy_with_convertor( pdt, 1, 36000 ); local_copy_with_convertor_2datatypes( pdt, 1, pdt, 1, 36000 ); } printf( ">>--------------------------------------------<<\n" ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( ">>--------------------------------------------<<\n" ); pdt = test_struct_char_double(); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 4500); local_copy_with_convertor( pdt, 4500, 12 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 12 ); } printf( ">>--------------------------------------------<<\n" ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( ">>--------------------------------------------<<\n" ); pdt = test_create_twice_two_doubles(); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_ddt_count(pdt, 4500); local_copy_with_convertor( pdt, 4500, 12 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 12 ); } printf( ">>--------------------------------------------<<\n" ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( ">>--------------------------------------------<<\n" ); pdt = test_create_blacs_type(); if( outputFlags & CHECK_PACK_UNPACK ) { opal_datatype_dump( pdt ); local_copy_ddt_count(pdt, 4500); local_copy_with_convertor( pdt, 4500, 956 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 956 ); local_copy_with_convertor( pdt, 4500, 16*1024 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 16*1024 ); local_copy_with_convertor( pdt, 4500, 64*1024 ); local_copy_with_convertor_2datatypes( pdt, 4500, pdt, 4500, 64*1024 ); } printf( ">>--------------------------------------------<<\n" ); OBJ_RELEASE( pdt ); assert( pdt == NULL ); printf( ">>--------------------------------------------<<\n" ); pdt1 = test_create_blacs_type1( &opal_datatype_int4 ); pdt2 = test_create_blacs_type2( &opal_datatype_int4 ); if( outputFlags & CHECK_PACK_UNPACK ) { local_copy_with_convertor_2datatypes( pdt1, 1, pdt2, 1, 100 ); } printf( ">>--------------------------------------------<<\n" ); OBJ_RELEASE( pdt1 ); assert( pdt1 == NULL ); OBJ_RELEASE( pdt2 ); assert( pdt2 == NULL ); /* clean-ups all data allocations */ opal_datatype_finalize(); return OPAL_SUCCESS; }
int opal_init_util(int* pargc, char*** pargv) { int ret; char *error = NULL; if( ++opal_util_initialized != 1 ) { if( opal_util_initialized < 1 ) { return OPAL_ERROR; } return OPAL_SUCCESS; } /* JMS See note in runtime/opal.h -- this is temporary; to be replaced with real hwloc information soon (in trunk/v1.5 and beyond, only). This *used* to be a #define, so it's important to define it very early. */ opal_cache_line_size = 128; /* initialize the memory allocator */ opal_malloc_init(); /* initialize the output system */ opal_output_init(); /* initialize install dirs code */ if (OPAL_SUCCESS != (ret = opal_installdirs_base_open())) { fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_INIT)\n", __FILE__, __LINE__, ret); return ret; } /* initialize the help system */ opal_show_help_init(); /* register handler for errnum -> string converstion */ if (OPAL_SUCCESS != (ret = opal_error_register("OPAL", OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) { error = "opal_error_register"; goto return_error; } /* init the trace function */ opal_trace_init(); /* keyval lex-based parser */ if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) { error = "opal_util_keyval_parse_init"; goto return_error; } if (OPAL_SUCCESS != (ret = opal_net_init())) { error = "opal_net_init"; goto return_error; } /* Setup the parameter system */ if (OPAL_SUCCESS != (ret = mca_base_param_init())) { error = "mca_base_param_init"; goto return_error; } /* register params for opal */ if (OPAL_SUCCESS != (ret = opal_register_params())) { error = "opal_register_params"; goto return_error; } /* pretty-print stack handlers */ if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) { error = "opal_util_register_stackhandlers"; goto return_error; } if (OPAL_SUCCESS != (ret = opal_util_init_sys_limits())) { error = "opal_util_init_sys_limits"; goto return_error; } /* initialize the datatype engine */ if (OPAL_SUCCESS != (ret = opal_datatype_init ())) { error = "opal_datatype_init"; goto return_error; } /* Initialize the data storage service. */ if (OPAL_SUCCESS != (ret = opal_dss_open())) { error = "opal_dss_open"; goto return_error; } return OPAL_SUCCESS; return_error: opal_show_help( "help-opal-runtime.txt", "opal_init:startup:internal-failure", true, error, ret ); return ret; }
int opal_init_util(int* pargc, char*** pargv) { int ret; char *error = NULL; if( ++opal_util_initialized != 1 ) { if( opal_util_initialized < 1 ) { return OPAL_ERROR; } return OPAL_SUCCESS; } /* initialize the memory allocator */ opal_malloc_init(); /* initialize the output system */ opal_output_init(); /* initialize install dirs code */ if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_installdirs_base_framework, 0))) { fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_SUCCESS)\n", __FILE__, __LINE__, ret); return ret; } /* initialize the help system */ opal_show_help_init(); /* register handler for errnum -> string converstion */ if (OPAL_SUCCESS != (ret = opal_error_register("OPAL", OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) { error = "opal_error_register"; goto return_error; } /* keyval lex-based parser */ if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) { error = "opal_util_keyval_parse_init"; goto return_error; } if (OPAL_SUCCESS != (ret = opal_net_init())) { error = "opal_net_init"; goto return_error; } /* Setup the parameter system */ if (OPAL_SUCCESS != (ret = mca_base_var_init())) { error = "mca_base_var_init"; goto return_error; } /* register params for opal */ if (OPAL_SUCCESS != (ret = opal_register_params())) { error = "opal_register_params"; goto return_error; } /* pretty-print stack handlers */ if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) { error = "opal_util_register_stackhandlers"; goto return_error; } /* set system resource limits - internally protected against * doing so twice in cases where the launch agent did it for us */ if (OPAL_SUCCESS != (ret = opal_util_init_sys_limits(&error))) { opal_show_help("help-opal-runtime.txt", "opal_init:syslimit", false, error); return OPAL_ERR_SILENT; } /* initialize the arch string */ if (OPAL_SUCCESS != (ret = opal_arch_init ())) { error = "opal_arch_init"; goto return_error; } /* initialize the datatype engine */ if (OPAL_SUCCESS != (ret = opal_datatype_init ())) { error = "opal_datatype_init"; goto return_error; } /* Initialize the data storage service. */ if (OPAL_SUCCESS != (ret = opal_dss_open())) { error = "opal_dss_open"; goto return_error; } return OPAL_SUCCESS; return_error: if (OPAL_ERR_SILENT != ret) { opal_show_help( "help-opal-runtime.txt", "opal_init:startup:internal-failure", true, error, ret ); } return ret; }
int opal_init_util(int* pargc, char*** pargv) { int ret; char *error = NULL; char hostname[512]; if( ++opal_util_initialized != 1 ) { if( opal_util_initialized < 1 ) { return OPAL_ERROR; } return OPAL_SUCCESS; } #if OPAL_NO_LIB_DESTRUCTOR if (opal_init_called) { /* can't use show_help here */ fprintf (stderr, "opal_init_util: attempted to initialize after finalize without compiler " "support for either __attribute__(destructor) or linker support for -fini -- process " "will likely abort\n"); return OPAL_ERR_NOT_SUPPORTED; } #endif opal_init_called = true; /* set the nodename right away so anyone who needs it has it. Note * that we don't bother with fqdn and prefix issues here - we let * the RTE later replace this with a modified name if the user * requests it */ gethostname(hostname, 512); opal_process_info.nodename = strdup(hostname); /* initialize the memory allocator */ opal_malloc_init(); /* initialize the output system */ opal_output_init(); /* initialize install dirs code */ if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_installdirs_base_framework, 0))) { fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_SUCCESS)\n", __FILE__, __LINE__, ret); return ret; } /* initialize the help system */ opal_show_help_init(); /* register handler for errnum -> string converstion */ if (OPAL_SUCCESS != (ret = opal_error_register("OPAL", OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) { error = "opal_error_register"; goto return_error; } /* keyval lex-based parser */ if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) { error = "opal_util_keyval_parse_init"; goto return_error; } /* Setup the parameter system */ if (OPAL_SUCCESS != (ret = mca_base_var_init())) { error = "mca_base_var_init"; goto return_error; } /* register params for opal */ if (OPAL_SUCCESS != (ret = opal_register_params())) { error = "opal_register_params"; goto return_error; } if (OPAL_SUCCESS != (ret = opal_net_init())) { error = "opal_net_init"; goto return_error; } /* pretty-print stack handlers */ if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) { error = "opal_util_register_stackhandlers"; goto return_error; } /* set system resource limits - internally protected against * doing so twice in cases where the launch agent did it for us */ if (OPAL_SUCCESS != (ret = opal_util_init_sys_limits(&error))) { opal_show_help("help-opal-runtime.txt", "opal_init:syslimit", false, error); return OPAL_ERR_SILENT; } /* initialize the arch string */ if (OPAL_SUCCESS != (ret = opal_arch_init ())) { error = "opal_arch_init"; goto return_error; } /* initialize the datatype engine */ if (OPAL_SUCCESS != (ret = opal_datatype_init ())) { error = "opal_datatype_init"; goto return_error; } /* Initialize the data storage service. */ if (OPAL_SUCCESS != (ret = opal_dss_open())) { error = "opal_dss_open"; goto return_error; } /* initialize the mca */ if (OPAL_SUCCESS != (ret = mca_base_open())) { error = "mca_base_open"; goto return_error; } return OPAL_SUCCESS; return_error: if (OPAL_ERR_SILENT != ret) { opal_show_help( "help-opal-runtime.txt", "opal_init:startup:internal-failure", true, error, ret ); } return ret; }
int32_t ompi_datatype_init( void ) { int32_t i; opal_datatype_init(); /* Create the f2c translation table */ OBJ_CONSTRUCT(&ompi_datatype_f_to_c_table, opal_pointer_array_t); if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_datatype_f_to_c_table, 0, OMPI_FORTRAN_HANDLE_MAX, 64)) { return OMPI_ERROR; } /* All temporary datatypes created on the following statement will get registered * on the f2c table. But as they get destroyed they will (hopefully) get unregistered * so later when we start registering the real datatypes they will get the index * in mpif.h */ /* Now the predefined MPI2 datatypes (they should last forever!) */ DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2int.dt, OMPI_DATATYPE_2INT, "MPI_2INT", OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_INT ); DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2integer.dt, OMPI_DATATYPE_2INTEGER, "MPI_2INTEGER", OMPI_DATATYPE_MPI_INTEGER, OMPI_DATATYPE_FLAG_DATA_FORTRAN | OMPI_DATATYPE_FLAG_DATA_INT); DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2real.dt, OMPI_DATATYPE_2REAL, "MPI_2REAL", OMPI_DATATYPE_MPI_FLOAT, OMPI_DATATYPE_FLAG_DATA_FORTRAN | OMPI_DATATYPE_FLAG_DATA_FLOAT ); DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2dblprec.dt, OMPI_DATATYPE_2DBLPREC, "MPI_2DOUBLE_PRECISION", OMPI_DATATYPE_MPI_DOUBLE, OMPI_DATATYPE_FLAG_DATA_FORTRAN | OMPI_DATATYPE_FLAG_DATA_FLOAT ); DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2cplex.dt, OMPI_DATATYPE_2COMPLEX, "MPI_2COMPLEX", OMPI_DATATYPE_MPI_COMPLEX, OMPI_DATATYPE_FLAG_DATA_FORTRAN | OMPI_DATATYPE_FLAG_DATA_COMPLEX ); DECLARE_MPI2_COMPOSED_BLOCK_DDT( &ompi_mpi_2dblcplex.dt, OMPI_DATATYPE_2DOUBLE_COMPLEX, "MPI_2DOUBLE_COMPLEX", OMPI_DATATYPE_MPI_DOUBLE_COMPLEX, OMPI_DATATYPE_FLAG_DATA_FORTRAN | OMPI_DATATYPE_FLAG_DATA_COMPLEX ); DECLARE_MPI2_COMPOSED_STRUCT_DDT( &ompi_mpi_float_int.dt, OMPI_DATATYPE_FLOAT_INT, "MPI_FLOAT_INT", float, int, OMPI_DATATYPE_MPI_FLOAT, OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C ); DECLARE_MPI2_COMPOSED_STRUCT_DDT( &ompi_mpi_double_int.dt, OMPI_DATATYPE_DOUBLE_INT, "MPI_DOUBLE_INT", double, int, OMPI_DATATYPE_MPI_DOUBLE, OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C ); DECLARE_MPI2_COMPOSED_STRUCT_DDT( &ompi_mpi_long_int.dt, OMPI_DATATYPE_LONG_INT, "MPI_LONG_INT", long, int, OMPI_DATATYPE_MPI_LONG, OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_INT ); DECLARE_MPI2_COMPOSED_STRUCT_DDT( &ompi_mpi_short_int.dt, OMPI_DATATYPE_SHORT_INT, "MPI_SHORT_INT", short, int, OMPI_DATATYPE_MPI_SHORT, OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_INT ); DECLARE_MPI2_COMPOSED_STRUCT_DDT( &ompi_mpi_longdbl_int.dt, OMPI_DATATYPE_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT", long double, int, OMPI_DATATYPE_MPI_LONG_DOUBLE, OMPI_DATATYPE_MPI_INT, OMPI_DATATYPE_FLAG_DATA_C ); /* Copy the desc pointer from the <OMPI_DATATYPE_MPI_MAX_PREDEFINED datatypes to the synonym types */ /* Start to populate the f2c index translation table */ /* The order of the data registration should be the same as the * one in the mpif.h file. Any modification here should be * reflected there !!! Do the Fortran types first so that mpif.h * can have consecutive, dense numbers. */ /* This macro makes everything significantly easier to read below. All hail the moog! :-) */ #define MOOG(name, index) \ { \ ompi_mpi_##name.dt.d_f_to_c_index = \ opal_pointer_array_add(&ompi_datatype_f_to_c_table, &ompi_mpi_##name); \ if( ompi_datatype_number_of_predefined_data < (ompi_mpi_##name).dt.d_f_to_c_index ) \ ompi_datatype_number_of_predefined_data = (ompi_mpi_##name).dt.d_f_to_c_index; \ assert( (index) == ompi_mpi_##name.dt.d_f_to_c_index ); \ } /* * This MUST match the order of ompi/include/mpif-common.h * Any change will break binary compatibility of Fortran programs. */ MOOG(datatype_null, 0); MOOG(byte, 1); MOOG(packed, 2); MOOG(ub, 3); MOOG(lb, 4); MOOG(character, 5); MOOG(logical, 6); MOOG(integer, 7); MOOG(integer1, 8); MOOG(integer2, 9); MOOG(integer4, 10); MOOG(integer8, 11); MOOG(integer16, 12); MOOG(real, 13); MOOG(real4, 14); MOOG(real8, 15); MOOG(real16, 16); MOOG(dblprec, 17); MOOG(cplex, 18); MOOG(complex8, 19); MOOG(complex16, 20); MOOG(complex32, 21); MOOG(dblcplex, 22); MOOG(2real, 23); MOOG(2dblprec, 24); MOOG(2integer, 25); MOOG(2cplex, 26); MOOG(2dblcplex, 27); MOOG(real2, 28); MOOG(logical1, 29); MOOG(logical2, 30); MOOG(logical4, 31); MOOG(logical8, 32); /* Now the C types */ MOOG(wchar, 33); MOOG(char, 34); MOOG(unsigned_char, 35); MOOG(signed_char, 36); MOOG(short, 37); MOOG(unsigned_short, 38); MOOG(int, 39); MOOG(unsigned, 40); MOOG(long, 41); MOOG(unsigned_long, 42); MOOG(long_long_int, 43); MOOG(unsigned_long_long, 44); MOOG(float, 45); MOOG(double, 46); MOOG(long_double, 47); MOOG(float_int, 48); MOOG(double_int, 49); MOOG(longdbl_int, 50); MOOG(long_int, 51); MOOG(2int, 52); MOOG(short_int, 53); /* C++ types */ MOOG(cxx_bool, 54); MOOG(cxx_cplex, 55); MOOG(cxx_dblcplex, 56); MOOG(cxx_ldblcplex, 57); /* MPI 2.2 types */ MOOG(int8_t, 58); MOOG(uint8_t, 59); MOOG(int16_t, 60); MOOG(uint16_t, 61); MOOG(int32_t, 62); MOOG(uint32_t, 63); MOOG(int64_t, 64); MOOG(uint64_t, 65); MOOG(aint, 66); MOOG(offset, 67); MOOG(c_complex, 68); MOOG(c_float_complex, 69); MOOG(c_double_complex, 70); MOOG(c_long_double_complex, 71); /* MPI 3.0 types */ MOOG(count, 72); /** * Now make sure all non-contiguous types are marked as such. */ for( i = 0; i < ompi_mpi_count.dt.d_f_to_c_index; i++ ) { opal_datatype_t* datatype = (opal_datatype_t*)opal_pointer_array_get_item(&ompi_datatype_f_to_c_table, i ); if( (datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size ) { datatype->flags |= OPAL_DATATYPE_FLAG_NO_GAPS; } else { datatype->flags &= ~OPAL_DATATYPE_FLAG_NO_GAPS; } } ompi_datatype_default_convertors_init(); return OMPI_SUCCESS; }
int main( int argc, char* argv[] ) { ddt_segment_t* segments; ddt_ldi_t *send_buffer, *recv_buffer; int i, seg_count, errors; int show_only_first_error = 1; ompi_datatype_t* datatype = MPI_LONG_DOUBLE_INT; send_buffer = malloc( sizeof(ddt_ldi_t) * data_count ); recv_buffer = malloc( sizeof(ddt_ldi_t) * data_count ); for( i = 0; i < data_count; i++ ) { send_buffer[i].ld = (long double)i + (long double)i / 100000.0; send_buffer[i].i = i; } memcpy(recv_buffer, send_buffer, sizeof(ddt_ldi_t) * data_count ); opal_datatype_init(); ompi_datatype_init(); #if (OPAL_ENABLE_DEBUG == 1) && (OPAL_C_HAVE_VISIBILITY == 0) opal_unpack_debug = false; opal_pack_debug = false; opal_position_debug = false; #endif /* OPAL_ENABLE_DEBUG */ create_segments( datatype, data_count, fragment_size, &segments, &seg_count ); /* shuffle the segments */ shuffle_segments( segments, seg_count ); /* pack the data */ pack_segments( datatype, data_count, fragment_size, segments, seg_count, send_buffer ); /* unpack the data back in the user space (recv buffer) */ unpack_segments( datatype, data_count, fragment_size, segments, seg_count, recv_buffer ); /* And now check the data */ for( errors = i = 0; i < data_count; i++ ) { /*if( !bytes_equal(&send_buffer[i].ld, &recv_buffer[i].ld, sizeof(long double)) ||*/ if( (send_buffer[i].ld != recv_buffer[i].ld) || (send_buffer[i].i != recv_buffer[i].i) ) { if( (show_only_first_error && (0 == errors)) || !show_only_first_error ) { printf( "error at %4d [*(%s,%d)\n" " != (%s,%d)\n", i, bytes_dump( &send_buffer[i].ld, sizeof(long double)), send_buffer[i].i, bytes_dump( &recv_buffer[i].ld, sizeof(long double)), recv_buffer[i].i ); } errors++; } } printf( "Found %d errors\n", errors ); free(send_buffer); free(recv_buffer); for( i = 0; i < seg_count; i++ ) { free( segments[i].buffer ); } free(segments); ompi_datatype_finalize(); return (0 == errors ? 0 : -1); }
int opal_init_util(int* pargc, char*** pargv) { int ret; char *error = NULL; char hostname[OPAL_MAXHOSTNAMELEN]; OPAL_TIMING_ENV_INIT(otmng); if( ++opal_util_initialized != 1 ) { if( opal_util_initialized < 1 ) { return OPAL_ERROR; } return OPAL_SUCCESS; } OBJ_CONSTRUCT(&opal_init_util_domain, opal_finalize_domain_t); (void) opal_finalize_domain_init (&opal_init_util_domain, "opal_init_util"); opal_finalize_set_domain (&opal_init_util_domain); opal_thread_set_main(); opal_init_called = true; /* register for */ opal_finalize_register_cleanup_arg (mca_base_framework_close_list, opal_init_util_frameworks); /* set the nodename right away so anyone who needs it has it. Note * that we don't bother with fqdn and prefix issues here - we let * the RTE later replace this with a modified name if the user * requests it */ gethostname(hostname, sizeof(hostname)); opal_process_info.nodename = strdup(hostname); /* initialize the memory allocator */ opal_malloc_init(); OPAL_TIMING_ENV_NEXT(otmng, "opal_malloc_init"); /* initialize the output system */ opal_output_init(); /* initialize install dirs code */ if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_installdirs_base_framework, 0))) { fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_SUCCESS)\n", __FILE__, __LINE__, ret); return ret; } /* initialize the help system */ opal_show_help_init(); OPAL_TIMING_ENV_NEXT(otmng, "opal_show_help_init"); /* register handler for errnum -> string converstion */ if (OPAL_SUCCESS != (ret = opal_error_register("OPAL", OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) { return opal_init_error ("opal_error_register", ret); } /* keyval lex-based parser */ if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) { return opal_init_error ("opal_util_keyval_parse_init", ret); } // Disable PSM signal hijacking (see comment in function for more // details) opal_init_psm(); OPAL_TIMING_ENV_NEXT(otmng, "opal_init_psm"); /* Setup the parameter system */ if (OPAL_SUCCESS != (ret = mca_base_var_init())) { return opal_init_error ("mca_base_var_init", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_var_init"); /* read any param files that were provided */ if (OPAL_SUCCESS != (ret = mca_base_var_cache_files(false))) { return opal_init_error ("failed to cache files", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_var_cache"); /* register params for opal */ if (OPAL_SUCCESS != (ret = opal_register_params())) { return opal_init_error ("opal_register_params", ret); } if (OPAL_SUCCESS != (ret = opal_net_init())) { return opal_init_error ("opal_net_init", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_net_init"); /* pretty-print stack handlers */ if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) { return opal_init_error ("opal_util_register_stackhandlers", ret); } /* set system resource limits - internally protected against * doing so twice in cases where the launch agent did it for us */ if (OPAL_SUCCESS != (ret = opal_util_init_sys_limits(&error))) { opal_show_help("help-opal-runtime.txt", "opal_init:syslimit", false, error); return OPAL_ERR_SILENT; } /* initialize the arch string */ if (OPAL_SUCCESS != (ret = opal_arch_init ())) { return opal_init_error ("opal_arch_init", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_arch_init"); /* initialize the datatype engine */ if (OPAL_SUCCESS != (ret = opal_datatype_init ())) { return opal_init_error ("opal_datatype_init", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_datatype_init"); /* Initialize the data storage service. */ if (OPAL_SUCCESS != (ret = opal_dss_open())) { return opal_init_error ("opal_dss_open", ret); } OPAL_TIMING_ENV_NEXT(otmng, "opal_dss_open"); /* initialize the mca */ if (OPAL_SUCCESS != (ret = mca_base_open())) { return opal_init_error ("mca_base_open", ret); } OPAL_TIMING_ENV_NEXT(otmng, "mca_base_open"); /* initialize if framework */ if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_if_base_framework, 0))) { fprintf(stderr, "opal_if_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_SUCCESS)\n", __FILE__, __LINE__, ret); return ret; } OPAL_TIMING_ENV_NEXT(otmng, "opal_if_init"); return OPAL_SUCCESS; }