示例#1
0
int32_t opal_datatype_init( void )
{
    const opal_datatype_t* datatype;
    int32_t i;

    opal_arch_compute_local_id( &opal_local_arch );

    /**
     * Force he initialization of the opal_datatype_t class. This will allow us to
     * call OBJ_DESTRUCT without going too deep in the initialization process.
     */
    opal_class_initialize(OBJ_CLASS(opal_datatype_t));
    for( i = OPAL_DATATYPE_FIRST_TYPE; i < OPAL_DATATYPE_MAX_PREDEFINED; i++ ) {
        datatype = opal_datatype_basicDatatypes[i];

        /* All of the predefined OPAL types don't have any GAPS! */
        datatype->desc.desc[0].elem.common.flags = OPAL_DATATYPE_FLAG_PREDEFINED |
                                                   OPAL_DATATYPE_FLAG_DATA |
                                                   OPAL_DATATYPE_FLAG_CONTIGUOUS |
                                                   OPAL_DATATYPE_FLAG_NO_GAPS;
        datatype->desc.desc[0].elem.common.type  = i;
        /* datatype->desc.desc[0].elem.blocklen XXX not set at the moment, it will be needed later */
        datatype->desc.desc[0].elem.count        = 1;
        datatype->desc.desc[0].elem.disp         = 0;
        datatype->desc.desc[0].elem.extent       = datatype->size;

        datatype->desc.desc[1].end_loop.common.flags    = 0;
        datatype->desc.desc[1].end_loop.common.type     = OPAL_DATATYPE_END_LOOP;
        datatype->desc.desc[1].end_loop.items           = 1;
        datatype->desc.desc[1].end_loop.first_elem_disp = datatype->desc.desc[0].elem.disp;
        datatype->desc.desc[1].end_loop.size            = datatype->size;
    }

    return OPAL_SUCCESS;
}
int32_t opal_datatype_init( void )
{
    const opal_datatype_t* datatype;
    int32_t i;

    opal_arch_compute_local_id( &opal_local_arch );

    for( i = OPAL_DATATYPE_FIRST_TYPE; i < OPAL_DATATYPE_MAX_PREDEFINED; i++ ) {
        datatype = opal_datatype_basicDatatypes[i];

        /* All of the predefined OPAL types don't have any GAPS! */
        datatype->desc.desc[0].elem.common.flags = OPAL_DATATYPE_FLAG_PREDEFINED |
                                                   OPAL_DATATYPE_FLAG_DATA |
                                                   OPAL_DATATYPE_FLAG_CONTIGUOUS |
                                                   OPAL_DATATYPE_FLAG_NO_GAPS;
        datatype->desc.desc[0].elem.common.type  = i;
        /* datatype->desc.desc[0].elem.blocklen XXX not set at the moment, it will be needed later */
        datatype->desc.desc[0].elem.count        = 1;
        datatype->desc.desc[0].elem.disp         = 0;
        datatype->desc.desc[0].elem.extent       = datatype->size;

        datatype->desc.desc[1].end_loop.common.flags    = 0;
        datatype->desc.desc[1].end_loop.common.type     = OPAL_DATATYPE_END_LOOP;
        datatype->desc.desc[1].end_loop.items           = 1;
        datatype->desc.desc[1].end_loop.first_elem_disp = datatype->desc.desc[0].elem.disp;
        datatype->desc.desc[1].end_loop.size            = datatype->size;
    }

#if !(OPAL_USE_FLOAT__COMPLEX && (SIZEOF_FLOAT__COMPLEX == 8)) && (SIZEOF_FLOAT == 4)
    datatype = opal_datatype_basicDatatypes[OPAL_DATATYPE_COMPLEX8];

    datatype->desc.desc[0].elem.common.type  = OPAL_DATATYPE_FLOAT4;
    datatype->desc.desc[0].elem.count        = 2;
    datatype->desc.desc[0].elem.extent       = SIZEOF_FLOAT;
#endif

#if !(OPAL_USE_DOUBLE__COMPLEX && (SIZEOF_DOUBLE__COMPLEX == 16)) && (SIZEOF_DOUBLE == 8)
    datatype = opal_datatype_basicDatatypes[OPAL_DATATYPE_COMPLEX16];

    datatype->desc.desc[0].elem.common.type  = OPAL_DATATYPE_FLOAT8;
    datatype->desc.desc[0].elem.count        = 2;
    datatype->desc.desc[0].elem.extent       = SIZEOF_DOUBLE;
#endif

#if !(OPAL_USE_LONG_DOUBLE__COMPLEX && (SIZEOF_LONG_DOUBLE__COMPLEX == 32)) && (HAVE_LONG_DOUBLE && (SIZEOF_LONG_DOUBLE == 16))
    datatype = opal_datatype_basicDatatypes[OPAL_DATATYPE_COMPLEX32];

    datatype->desc.desc[0].elem.common.type  = OPAL_DATATYPE_FLOAT16;
    datatype->desc.desc[0].elem.count        = 2;
    datatype->desc.desc[0].elem.extent       = SIZEOF_LONG_DOUBLE;
#endif

    return OPAL_SUCCESS;
}