⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dt_module.c

📁 MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising
💻 C
📖 第 1 页 / 共 3 页
字号:
#elif (OMPI_SIZEOF_FORTRAN_COMPLEX16 == 2*SIZEOF_DOUBLE)    DECLARE_MPI_SYNONYM_DDT( &ompi_mpi_complex16, "MPI_COMPLEX16", &ompi_mpi_dblcplex );#else#   warning "No proper C type found for COMPLEX16"    DECLARE_MPI_SYNONYM_DDT( &ompi_mpi_complex16, "MPI_COMPLEX16", &ompi_mpi_unavailable );#endif    ompi_mpi_complex16.flags |= DT_FLAG_DATA_FORTRAN | DT_FLAG_DATA_COMPLEX;#endif /* OMPI_HAVE_FORTRAN_COMPLEX16 */#if OMPI_HAVE_FORTRAN_COMPLEX32#if (OMPI_SIZEOF_FORTRAN_COMPLEX32 == 2*SIZEOF_LONG_DOUBLE)    DECLARE_MPI_SYNONYM_DDT( &ompi_mpi_complex32, "MPI_COMPLEX32", &ompi_mpi_ldblcplex );#else#   warning "No proper C type found for COMPLEX32"    DECLARE_MPI_SYNONYM_DDT( &ompi_mpi_complex32, "MPI_COMPLEX32", &ompi_mpi_unavailable );#endif    ompi_mpi_complex32.flags |= DT_FLAG_DATA_FORTRAN | DT_FLAG_DATA_COMPLEX;#endif /* OMPI_HAVE_FORTRAN_COMPLEX32 */    /* 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)                                                      \    {                                                                   \        ompi_mpi_##name.d_f_to_c_index =                                \            ompi_pointer_array_add(ompi_datatype_f_to_c_table, &ompi_mpi_##name); \        if( ompi_ddt_number_of_predefined_data < (ompi_mpi_##name).d_f_to_c_index ) \            ompi_ddt_number_of_predefined_data = (ompi_mpi_##name).d_f_to_c_index; \    }    MOOG(datatype_null);    MOOG(byte);    MOOG(packed);    MOOG(ub);    MOOG(lb);    MOOG(character);    MOOG(logic);    MOOG(integer);    MOOG(integer1);    MOOG(integer2);    MOOG(integer4);    MOOG(integer8);    MOOG(integer16);    MOOG(real);    MOOG(real4);    MOOG(real8);    MOOG(real16);    MOOG(dblprec);    MOOG(cplex);    MOOG(complex8);    MOOG(complex16);    MOOG(complex32);    MOOG(dblcplex);    MOOG(2real);    MOOG(2dblprec);    MOOG(2integer);    MOOG(2cplex);    MOOG(2dblcplex);    /* Now the C types */    MOOG(wchar);    MOOG(char);    MOOG(unsigned_char);    MOOG(signed_char);    MOOG(short);    MOOG(unsigned_short);    MOOG(int);    MOOG(unsigned);    MOOG(long);    MOOG(unsigned_long);    MOOG(long_long_int);    MOOG(unsigned_long_long);    MOOG(float);    MOOG(double);    MOOG(long_double);    MOOG(float_int);    MOOG(double_int);    MOOG(longdbl_int);    MOOG(long_int);    MOOG(2int);    MOOG(short_int);    /* C++ types */    MOOG(cxx_bool);    MOOG(cxx_cplex);    MOOG(cxx_dblcplex);    MOOG(cxx_ldblcplex);    for( i = 0; i < ompi_mpi_cxx_ldblcplex.d_f_to_c_index; i++ ) {        ompi_datatype_t* datatype = (ompi_datatype_t*)ompi_pointer_array_get_item( ompi_datatype_f_to_c_table, i );        if( (datatype->ub - datatype->lb) == (ptrdiff_t)datatype->size ) {            datatype->flags |= DT_FLAG_NO_GAPS;        } else {            datatype->flags &= ~DT_FLAG_NO_GAPS;        }    }    ompi_ddt_default_convertors_init();    return OMPI_SUCCESS;}int32_t ompi_ddt_finalize( void ){    int i;    /* As the synonyms are just copies of the internal data we should not free them.     * Anyway they are over the limit of DT_MAX_PREDEFINED so they will never get freed.     */    /* As they are statically allocated they cannot be released. But we     * can call OBJ_DESTRUCT, just to free all internally allocated ressources.     */    for( i = 0; i < DT_MAX_PREDEFINED; i++ ) {        OBJ_DESTRUCT( ompi_ddt_basicDatatypes[i] );    }    /* Get rid of the Fortran2C translation table */    OBJ_RELEASE(ompi_datatype_f_to_c_table);#if defined(VERBOSE)    if( ompi_ddt_dfd != -1 )        opal_output_close( ompi_ddt_dfd );    ompi_ddt_dfd = -1;#endif  /* VERBOSE */    /* release the local convertors (external32 and local) */    ompi_ddt_default_convertors_fini();    /* clear all master convertors */    ompi_convertor_destroy_masters();    return OMPI_SUCCESS;}#if OMPI_ENABLE_DEBUG/* * Set a breakpoint to this function in your favorite debugger * to make it stopping on all pack and unpack errors. */int ompi_ddt_safeguard_pointer_debug_breakpoint( const void* actual_ptr, int length,                                                 const void* initial_ptr,                                                 const ompi_datatype_t* pData,                                                 int count ){    return 0;}#endif  /* OMPI_ENABLE_DEBUG *//******************************************************** * Data dumping functions ********************************************************/static int _dump_data_flags( unsigned short usflags, char* ptr, size_t length ){    if( length < 21 ) return 0;    sprintf( ptr, "-----------[---][---]" );  /* set everything to - */    if( usflags & DT_FLAG_DESTROYED )                ptr[0]  = 'd';    if( usflags & DT_FLAG_COMMITED )                 ptr[1]  = 'c';    if( usflags & DT_FLAG_CONTIGUOUS )               ptr[2]  = 'C';    if( usflags & DT_FLAG_OVERLAP )                  ptr[3]  = 'o';    if( usflags & DT_FLAG_USER_LB )                  ptr[4]  = 'l';    if( usflags & DT_FLAG_USER_UB )                  ptr[5]  = 'u';    if( usflags & DT_FLAG_PREDEFINED )               ptr[6]  = 'P';    if( !(usflags & DT_FLAG_NO_GAPS) )               ptr[7]  = 'G';    if( usflags & DT_FLAG_DATA )                     ptr[8]  = 'D';    if( (usflags & DT_FLAG_BASIC) == DT_FLAG_BASIC ) ptr[9]  = 'B';    /* Which kind of datatype is that */    switch( usflags & DT_FLAG_DATA_LANGUAGE ) {    case DT_FLAG_DATA_C:        ptr[12] = ' '; ptr[13] = 'C'; ptr[14] = ' '; break;    case DT_FLAG_DATA_CPP:        ptr[12] = 'C'; ptr[13] = 'P'; ptr[14] = 'P'; break;    case DT_FLAG_DATA_FORTRAN:        ptr[12] = 'F'; ptr[13] = '7'; ptr[14] = '7'; break;    default:        if( usflags & DT_FLAG_PREDEFINED ) {            ptr[12] = 'E'; ptr[13] = 'R'; ptr[14] = 'R'; break;        }    }    switch( usflags & DT_FLAG_DATA_TYPE ) {    case DT_FLAG_DATA_INT:        ptr[17] = 'I'; ptr[18] = 'N'; ptr[19] = 'T'; break;    case DT_FLAG_DATA_FLOAT:        ptr[17] = 'F'; ptr[18] = 'L'; ptr[19] = 'T'; break;    case DT_FLAG_DATA_COMPLEX:        ptr[17] = 'C'; ptr[18] = 'P'; ptr[19] = 'L'; break;    default:        if( usflags & DT_FLAG_PREDEFINED ) {            ptr[17] = 'E'; ptr[18] = 'R'; ptr[19] = 'R'; break;        }    }    return 21;}static int __dump_data_desc( dt_elem_desc_t* pDesc, int nbElems, char* ptr, size_t length ){    int i;    size_t index = 0;    for( i = 0; i < nbElems; i++ ) {        index += _dump_data_flags( pDesc->elem.common.flags, ptr + index, length );        if( length <= index ) break;        index += snprintf( ptr + index, length - index, "%15s ", ompi_ddt_basicDatatypes[pDesc->elem.common.type]->name );        if( length <= index ) break;        if( DT_LOOP == pDesc->elem.common.type )            index += snprintf( ptr + index, length - index, "%d times the next %d elements extent %d\n",                               (int)pDesc->loop.loops, (int)pDesc->loop.items,                               (int)pDesc->loop.extent );	else if( DT_END_LOOP == pDesc->elem.common.type )	    index += snprintf( ptr + index, length - index, "prev %d elements first elem displacement %ld size of data %d\n",                           (int)pDesc->end_loop.items, (long)pDesc->end_loop.first_elem_disp,                           (int)pDesc->end_loop.size );        else            index += snprintf( ptr + index, length - index, "count %d disp 0x%lx (%ld) extent %d (size %ld)\n",                               (int)pDesc->elem.count, (long)pDesc->elem.disp, (long)pDesc->elem.disp,                               (int)pDesc->elem.extent, (long)(pDesc->elem.count * ompi_ddt_basicDatatypes[pDesc->elem.common.type]->size) );        pDesc++;        if( length <= index ) break;    }    return index;}static inline int __dt_contain_basic_datatypes( const ompi_datatype_t* pData, char* ptr, size_t length ){    int i;    size_t index = 0;    uint64_t mask = 1;    if( pData->flags & DT_FLAG_USER_LB ) index += snprintf( ptr, length - index, "lb " );    if( pData->flags & DT_FLAG_USER_UB ) index += snprintf( ptr + index, length - index, "ub " );    for( i = 0; i < DT_MAX_PREDEFINED; i++ ) {        if( pData->bdt_used & mask )            index += snprintf( ptr + index, length - index, "%s ", ompi_ddt_basicDatatypes[i]->name );        mask <<= 1;        if( length <= index ) break;    }    return index;}void ompi_ddt_dump( const ompi_datatype_t* pData ){    size_t length;    int index = 0;    char* buffer;    length = pData->opt_desc.used + pData->desc.used;    length = length * 100 + 500;    buffer = (char*)malloc( length );    index += snprintf( buffer, length - index, "Datatype %p[%s] size %ld align %d id %d length %d used %d\n"                                               "true_lb %ld true_ub %ld (true_extent %ld) lb %ld ub %ld (extent %ld)\n"                                               "nbElems %d loops %d flags %X (",                     (void*)pData, pData->name, (long)pData->size, (int)pData->align, pData->id, (int)pData->desc.length, (int)pData->desc.used,                     (long)pData->true_lb, (long)pData->true_ub, (long)(pData->true_ub - pData->true_lb),                     (long)pData->lb, (long)pData->ub, (long)(pData->ub - pData->lb),                     (int)pData->nbElems, (int)pData->btypes[DT_LOOP], (int)pData->flags );    /* dump the flags */    if( pData->flags == DT_FLAG_PREDEFINED )        index += snprintf( buffer + index, length - index, "predefined " );    else {        if( pData->flags & DT_FLAG_DESTROYED ) index += snprintf( buffer + index, length - index, "destroyed " );        if( pData->flags & DT_FLAG_COMMITED ) index += snprintf( buffer + index, length - index, "commited " );        if( pData->flags & DT_FLAG_CONTIGUOUS) index += snprintf( buffer + index, length - index, "contiguous " );    }    index += snprintf( buffer + index, length - index, ")" );    index += _dump_data_flags( pData->flags, buffer + index, length - index );    {        index += snprintf( buffer + index, length - index, "\n   contain " );        index += __dt_contain_basic_datatypes( pData, buffer + index, length - index );        index += snprintf( buffer + index, length - index, "\n" );    }    if( (pData->opt_desc.desc != pData->desc.desc) && (NULL != pData->opt_desc.desc) ) {        /* If the data is already committed print everything including the last         * fake DT_END_LOOP entry.         */        index += __dump_data_desc( pData->desc.desc, pData->desc.used + 1, buffer + index, length - index );        index += snprintf( buffer + index, length - index, "Optimized description \n" );        index += __dump_data_desc( pData->opt_desc.desc, pData->opt_desc.used + 1, buffer + index, length - index );    } else {        index += __dump_data_desc( pData->desc.desc, pData->desc.used, buffer + index, length - index );        index += snprintf( buffer + index, length - index, "No optimized description\n" );    }    buffer[index] = '\0';  /* make sure we end the string with 0 */    opal_output( 0, "%s\n", buffer );    ompi_ddt_print_args( pData );    free(buffer);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -