Remove the (only two) fortran constants from OPAL. The only places that
actually care if opal_pointer_array is limited to handle_max already passes that in as the max_size during init, so don't need it there. The arch constant was a bit more difficult, so pass that in during MPI init and leave empty otherwise. This is to help with the effort to allow building ompi against an external opal or orte. This commit was SVN r27817.
Этот коммит содержится в:
родитель
5b8de0b9f4
Коммит
fc3df11e08
@ -576,13 +576,7 @@ OPAL_CONFIG_ASM
|
||||
# Fortran
|
||||
##################################
|
||||
|
||||
# OPAL uses opal_fortran_logical_t and OMPI_FORTRAN_HANDLE_MAX (long
|
||||
# story; yes, it's an intentional abstraction break). So ensure to
|
||||
# define it to a valid C type if we're not building the OMPI project.
|
||||
m4_ifdef([project_ompi], [OMPI_SETUP_MPI_FORTRAN],
|
||||
[AC_DEFINE([ompi_fortran_logical_t], [int], [Bogus type for OPAL])
|
||||
AC_DEFINE([OMPI_FORTRAN_HANDLE_MAX], [128], [Bogus type for OPAL])
|
||||
])
|
||||
OMPI_SETUP_MPI_FORTRAN
|
||||
|
||||
# checkpoint results
|
||||
AC_CACHE_SAVE
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "opal/mca/hwloc/base/base.h"
|
||||
#include "opal/runtime/opal_progress.h"
|
||||
#include "opal/threads/threads.h"
|
||||
#include "opal/util/arch.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/error.h"
|
||||
#include "opal/util/stacktrace.h"
|
||||
@ -342,6 +343,11 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = opal_arch_set_fortran_logical_size(sizeof(ompi_fortran_logical_t)))) {
|
||||
error = "ompi_mpi_init: opal_arch_set_fortran_logical_size failed";
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* _After_ opal_init_util() but _before_ orte_init(), we need to
|
||||
set an MCA param that tells libevent that it's ok to use any
|
||||
mechanism in libevent that is available on this platform (e.g.,
|
||||
|
@ -116,7 +116,7 @@ int opal_pointer_array_add(opal_pointer_array_t *table, void *ptr)
|
||||
/* need to grow table */
|
||||
if (!grow_table(table,
|
||||
(NULL == table->addr ? TABLE_INIT : table->size * TABLE_GROW),
|
||||
OMPI_FORTRAN_HANDLE_MAX)) {
|
||||
INT_MAX)) {
|
||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -329,9 +329,6 @@ static bool grow_table(opal_pointer_array_t *table, int soft, int hard)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* We've already established (above) that the arithmetic
|
||||
below will be less than OMPI_FORTRAN_HANDLE_MAX */
|
||||
|
||||
new_size_int = (int) new_size;
|
||||
table->number_free += new_size_int - table->size;
|
||||
table->addr = (void**)p;
|
||||
|
@ -37,7 +37,6 @@ int opal_pack_debug = 0;
|
||||
int opal_position_debug = 0;
|
||||
int opal_copy_debug = 0;
|
||||
|
||||
uint32_t opal_local_arch = 0xFFFFFFFF;
|
||||
|
||||
/* Using this macro implies that at this point _all_ informations needed
|
||||
* to fill up the datatype are known.
|
||||
@ -166,8 +165,6 @@ 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];
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/util/malloc.h"
|
||||
#include "opal/util/arch.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/trace.h"
|
||||
#include "opal/util/show_help.h"
|
||||
@ -297,6 +298,12 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* 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";
|
||||
|
120
opal/util/arch.c
120
opal/util/arch.c
@ -21,71 +21,109 @@
|
||||
#include "opal/constants.h"
|
||||
#include "opal/util/arch.h"
|
||||
|
||||
int32_t opal_arch_compute_local_id( uint32_t *me )
|
||||
uint32_t opal_local_arch = 0xFFFFFFFF;
|
||||
|
||||
static inline int32_t opal_arch_isbigendian ( void )
|
||||
{
|
||||
*me = (OPAL_ARCH_HEADERMASK | OPAL_ARCH_UNUSEDMASK);
|
||||
const uint32_t value = 0x12345678;
|
||||
const char *ptr = (char*)&value;
|
||||
int x = 0;
|
||||
|
||||
/* if( sizeof(int) == 8 ) x = 4; */
|
||||
if( ptr[x] == 0x12) return 1; /* big endian, true */
|
||||
if( ptr[x] == 0x78 ) return 0; /* little endian, false */
|
||||
assert( 0 ); /* unknown architecture not little nor big endian */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we must find which representation of long double is used
|
||||
* intel or sparc. Both of them represent the long doubles using a close to
|
||||
* IEEE representation (seeeeeee..emmm...m) where the mantissa look like
|
||||
* 1.????. For the intel representaion the 1 is explicit, and for the sparc
|
||||
* the first one is implicit. If we take the number 2.0 the exponent is 1
|
||||
* and the mantissa is 1.0 (the sign of course should be 0). So if we check
|
||||
* for the first one in the binary representation of the number, we will
|
||||
* find the bit from the exponent, so the next one should be the begining
|
||||
* of the mantissa. If it's 1 then we have an intel representaion, if not
|
||||
* we have a sparc one. QED
|
||||
*/
|
||||
static inline int32_t opal_arch_ldisintel( void )
|
||||
{
|
||||
long double ld = 2.0;
|
||||
int i, j;
|
||||
uint32_t* pui = (uint32_t*)(void*)&ld;
|
||||
|
||||
j = LDBL_MANT_DIG / 32;
|
||||
i = (LDBL_MANT_DIG % 32) - 1;
|
||||
if( opal_arch_isbigendian() ) { /* big endian */
|
||||
j = (sizeof(long double) / sizeof(unsigned int)) - j;
|
||||
if( i < 0 ) {
|
||||
i = 31;
|
||||
j = j+1;
|
||||
}
|
||||
} else {
|
||||
if( i < 0 ) {
|
||||
i = 31;
|
||||
j = j-1;
|
||||
}
|
||||
}
|
||||
return (pui[j] & (1 << i) ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void opal_arch_setmask ( uint32_t *var, uint32_t mask)
|
||||
{
|
||||
*var |= mask;
|
||||
}
|
||||
|
||||
int opal_arch_init(void)
|
||||
{
|
||||
opal_local_arch = (OPAL_ARCH_HEADERMASK | OPAL_ARCH_UNUSEDMASK);
|
||||
|
||||
/* Handle the size of long (can hold a pointer) */
|
||||
if( 8 == sizeof(long) )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LONGIS64 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LONGIS64 );
|
||||
|
||||
/* sizeof bool */
|
||||
if (1 == sizeof(bool) ) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_BOOLIS8);
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_BOOLIS8);
|
||||
} else if (2 == sizeof(bool)) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_BOOLIS16);
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_BOOLIS16);
|
||||
} else if (4 == sizeof(bool)) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_BOOLIS32);
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_BOOLIS32);
|
||||
}
|
||||
|
||||
/* sizeof fortran logical
|
||||
*
|
||||
* RHC: technically, use of the ompi_ prefix is
|
||||
* an abstraction violation. However, this is actually
|
||||
* an error in our configure scripts that transcends
|
||||
* all the data types and eventually should be fixed.
|
||||
* The guilty part is f77_check.m4. Fixing it right
|
||||
* now is beyond a reasonable scope - this comment is
|
||||
* placed here to explain the abstraction break and
|
||||
* indicate that it will eventually be fixed
|
||||
*/
|
||||
if (1 == sizeof(ompi_fortran_logical_t) ) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_LOGICALIS8);
|
||||
} else if (2 == sizeof(ompi_fortran_logical_t)) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_LOGICALIS16);
|
||||
} else if (4 == sizeof(ompi_fortran_logical_t)) {
|
||||
opal_arch_setmask( me, OPAL_ARCH_LOGICALIS32);
|
||||
}
|
||||
/* Note that fortran logical size is set later, to make
|
||||
abstractions a little less painful... */
|
||||
|
||||
/* Initialize the information regarding the long double */
|
||||
if( 12 == sizeof(long double) )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LONGDOUBLEIS96 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LONGDOUBLEIS96 );
|
||||
else if( 16 == sizeof(long double) )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LONGDOUBLEIS128 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LONGDOUBLEIS128 );
|
||||
|
||||
/* Big endian or little endian ? That's the question */
|
||||
if( opal_arch_isbigendian() )
|
||||
opal_arch_setmask( me, OPAL_ARCH_ISBIGENDIAN );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_ISBIGENDIAN );
|
||||
|
||||
/* What's the maximum exponent ? */
|
||||
if ( LDBL_MAX_EXP == 16384 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDEXPSIZEIS15 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDEXPSIZEIS15 );
|
||||
|
||||
/* How about the length in bits of the mantissa */
|
||||
if ( LDBL_MANT_DIG == 64 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDMANTDIGIS64 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDMANTDIGIS64 );
|
||||
else if ( LDBL_MANT_DIG == 105 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDMANTDIGIS105 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDMANTDIGIS105 );
|
||||
else if ( LDBL_MANT_DIG == 106 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDMANTDIGIS106 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDMANTDIGIS106 );
|
||||
else if ( LDBL_MANT_DIG == 107 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDMANTDIGIS107 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDMANTDIGIS107 );
|
||||
else if ( LDBL_MANT_DIG == 113 )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDMANTDIGIS113 );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDMANTDIGIS113 );
|
||||
|
||||
/* Intel data representation or Sparc ? */
|
||||
if( opal_arch_ldisintel() )
|
||||
opal_arch_setmask( me, OPAL_ARCH_LDISINTEL );
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LDISINTEL );
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
@ -123,3 +161,17 @@ int32_t opal_arch_checkmask ( uint32_t *var, uint32_t mask )
|
||||
/* Here is the real evaluation of the bitmask */
|
||||
return ( ((*var) & mask) == mask );
|
||||
}
|
||||
|
||||
int
|
||||
opal_arch_set_fortran_logical_size(uint32_t size)
|
||||
{
|
||||
if (1 == size) {
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LOGICALIS8);
|
||||
} else if (2 == size) {
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LOGICALIS16);
|
||||
} else if (4 == size) {
|
||||
opal_arch_setmask( &opal_local_arch, OPAL_ARCH_LOGICALIS32);
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -231,61 +231,16 @@
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
OPAL_DECLSPEC int32_t opal_arch_compute_local_id( uint32_t *var);
|
||||
/* Local Architecture */
|
||||
OPAL_DECLSPEC extern uint32_t opal_local_arch;
|
||||
|
||||
/* Initialize architecture and determine all but fortran logical fields */
|
||||
OPAL_DECLSPEC int opal_arch_init(void);
|
||||
|
||||
OPAL_DECLSPEC int32_t opal_arch_checkmask ( uint32_t *var, uint32_t mask );
|
||||
|
||||
static inline int32_t opal_arch_isbigendian ( void )
|
||||
{
|
||||
const uint32_t value = 0x12345678;
|
||||
const char *ptr = (char*)&value;
|
||||
int x = 0;
|
||||
|
||||
/* if( sizeof(int) == 8 ) x = 4; */
|
||||
if( ptr[x] == 0x12) return 1; /* big endian, true */
|
||||
if( ptr[x] == 0x78 ) return 0; /* little endian, false */
|
||||
assert( 0 ); /* unknown architecture not little nor big endian */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we must find which representation of long double is used
|
||||
* intel or sparc. Both of them represent the long doubles using a close to
|
||||
* IEEE representation (seeeeeee..emmm...m) where the mantissa look like
|
||||
* 1.????. For the intel representaion the 1 is explicit, and for the sparc
|
||||
* the first one is implicit. If we take the number 2.0 the exponent is 1
|
||||
* and the mantissa is 1.0 (the sign of course should be 0). So if we check
|
||||
* for the first one in the binary representation of the number, we will
|
||||
* find the bit from the exponent, so the next one should be the begining
|
||||
* of the mantissa. If it's 1 then we have an intel representaion, if not
|
||||
* we have a sparc one. QED
|
||||
*/
|
||||
static inline int32_t opal_arch_ldisintel( void )
|
||||
{
|
||||
long double ld = 2.0;
|
||||
int i, j;
|
||||
uint32_t* pui = (uint32_t*)(void*)&ld;
|
||||
|
||||
j = LDBL_MANT_DIG / 32;
|
||||
i = (LDBL_MANT_DIG % 32) - 1;
|
||||
if( opal_arch_isbigendian() ) { /* big endian */
|
||||
j = (sizeof(long double) / sizeof(unsigned int)) - j;
|
||||
if( i < 0 ) {
|
||||
i = 31;
|
||||
j = j+1;
|
||||
}
|
||||
} else {
|
||||
if( i < 0 ) {
|
||||
i = 31;
|
||||
j = j-1;
|
||||
}
|
||||
}
|
||||
return (pui[j] & (1 << i) ? 1 : 0);
|
||||
}
|
||||
|
||||
static inline void opal_arch_setmask ( uint32_t *var, uint32_t mask)
|
||||
{
|
||||
*var |= mask;
|
||||
}
|
||||
/* Set fortran logical fields after init, to keep fortran out of opal... */
|
||||
OPAL_DECLSPEC int opal_arch_set_fortran_logical_size(uint32_t size);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user