1
1
Some cleanups.

This commit was SVN r5485.
Этот коммит содержится в:
George Bosilca 2005-04-22 04:47:55 +00:00
родитель 6f92675c56
Коммит 72502a5d17
6 изменённых файлов: 51 добавлений и 44 удалений

Просмотреть файл

@ -180,6 +180,8 @@ extern conversion_fct_t ompi_ddt_copy_functions[DT_MAX_PREDEFINED];
extern int32_t ompi_ddt_external32_init( void ); extern int32_t ompi_ddt_external32_init( void );
extern void ompi_ddt_dump_stack( const dt_stack_t* pStack, int stack_pos, extern void ompi_ddt_dump_stack( const dt_stack_t* pStack, int stack_pos,
const dt_elem_desc_t* pDesc, const char* name ); const dt_elem_desc_t* pDesc, const char* name );
extern void ompi_convertor_dump( ompi_convertor_t* convertor );
#define SAVE_STACK( PSTACK, INDEX, COUNT, DISP, END_LOOP) \ #define SAVE_STACK( PSTACK, INDEX, COUNT, DISP, END_LOOP) \
do { \ do { \
(PSTACK)->index = (INDEX); \ (PSTACK)->index = (INDEX); \
@ -196,9 +198,11 @@ do { \
(PSTACK) = pTempStack; \ (PSTACK) = pTempStack; \
} while(0) } while(0)
#define MEMCPY( DST, SRC, BLENGTH ) { \ #define MEMCPY( DST, SRC, BLENGTH ) \
do { \
/*printf( "memcpy dest = %p src = %p length = %d\n", (void*)(DST), (void*)(SRC), (int)(BLENGTH) );*/ \ /*printf( "memcpy dest = %p src = %p length = %d\n", (void*)(DST), (void*)(SRC), (int)(BLENGTH) );*/ \
memcpy( (DST), (SRC), (BLENGTH) ); } memcpy( (DST), (SRC), (BLENGTH) ); \
} while (0)
#if OMPI_ENABLE_DEBUG #if OMPI_ENABLE_DEBUG
#define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) \ #define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) \
@ -373,14 +377,14 @@ int ompi_convertor_create_stack_at_begining( ompi_convertor_t* pConvertor, const
} }
static inline void static inline void
convertor_init_generic( ompi_convertor_t* pConv, const dt_desc_t* datatype, int count, convertor_init_generic( ompi_convertor_t* pConv, const ompi_datatype_t* datatype, int count,
const void* pUserBuf ) const void* pUserBuf )
{ {
uint32_t required_stack_length = datatype->btypes[DT_LOOP] + 3; uint32_t required_stack_length = datatype->btypes[DT_LOOP] + 3;
OBJ_RETAIN( datatype ); OBJ_RETAIN( datatype );
if( pConv->pDesc != datatype ) { if( pConv->pDesc != datatype ) {
pConv->pDesc = (dt_desc_t*)datatype; pConv->pDesc = (ompi_datatype_t*)datatype;
if( pConv->pStack != NULL ) { if( pConv->pStack != NULL ) {
if( pConv->stack_size > DT_STATIC_STACK_SIZE ) if( pConv->stack_size > DT_STATIC_STACK_SIZE )
free( pConv->pStack ); free( pConv->pStack );

Просмотреть файл

@ -19,12 +19,12 @@
#include "datatype/datatype.h" #include "datatype/datatype.h"
#include "datatype/datatype_internal.h" #include "datatype/datatype_internal.h"
int32_t ompi_ddt_duplicate( const dt_desc_t* oldType, dt_desc_t** newType ) int32_t ompi_ddt_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{ {
dt_desc_t* pdt = ompi_ddt_create( oldType->desc.used ); ompi_datatype_t* pdt = ompi_ddt_create( oldType->desc.used );
void* temp = pdt->desc.desc; /* temporary copy of the desc pointer */ void* temp = pdt->desc.desc; /* temporary copy of the desc pointer */
memcpy( pdt, oldType, sizeof(dt_desc_t) ); memcpy( pdt, oldType, sizeof(ompi_datatype_t) );
pdt->desc.desc = temp; pdt->desc.desc = temp;
memcpy( pdt->desc.desc, oldType->desc.desc, sizeof(dt_elem_desc_t) * oldType->desc.used ); memcpy( pdt->desc.desc, oldType->desc.desc, sizeof(dt_elem_desc_t) * oldType->desc.used );
pdt->id = 0; pdt->id = 0;
@ -40,10 +40,10 @@ int32_t ompi_ddt_duplicate( const dt_desc_t* oldType, dt_desc_t** newType )
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int32_t ompi_ddt_create_contiguous( int count, const dt_desc_t* oldType, int32_t ompi_ddt_create_contiguous( int count, const ompi_datatype_t* oldType,
dt_desc_t** newType ) ompi_datatype_t** newType )
{ {
dt_desc_t* pdt = ompi_ddt_create( oldType->desc.used + 2 ); ompi_datatype_t* pdt = ompi_ddt_create( oldType->desc.used + 2 );
ompi_ddt_add( pdt, oldType, count, 0, (oldType->ub - oldType->lb) ); ompi_ddt_add( pdt, oldType, count, 0, (oldType->ub - oldType->lb) );
*newType = pdt; *newType = pdt;
return OMPI_SUCCESS; return OMPI_SUCCESS;

Просмотреть файл

@ -19,12 +19,12 @@
#include "datatype/datatype.h" #include "datatype/datatype.h"
int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp, int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp,
const dt_desc_t ** pTypes, dt_desc_t** newType ) ompi_datatype_t* const * pTypes, ompi_datatype_t** newType )
{ {
int i; int i;
long disp = 0, endto, lastExtent, lastDisp; long disp = 0, endto, lastExtent, lastDisp;
int lastBlock; int lastBlock;
dt_desc_t *pdt, *lastType; ompi_datatype_t *pdt, *lastType;
if( 0 == count ) { if( 0 == count ) {
*newType = ompi_ddt_create( disp ); *newType = ompi_ddt_create( disp );
@ -38,7 +38,7 @@ int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long*
disp += pTypes[i]->desc.used; disp += pTypes[i]->desc.used;
if( pBlockLength[i] != 1 ) disp += 2; if( pBlockLength[i] != 1 ) disp += 2;
} }
lastType = (dt_desc_t*)pTypes[0]; lastType = (ompi_datatype_t*)pTypes[0];
lastBlock = pBlockLength[0]; lastBlock = pBlockLength[0];
lastExtent = lastType->ub - lastType->lb; lastExtent = lastType->ub - lastType->lb;
lastDisp = pDisp[0]; lastDisp = pDisp[0];
@ -51,7 +51,7 @@ int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long*
} else { } else {
disp += lastType->desc.used; disp += lastType->desc.used;
if( lastBlock > 1 ) disp += 2; if( lastBlock > 1 ) disp += 2;
lastType = (dt_desc_t*)pTypes[i]; lastType = (ompi_datatype_t*)pTypes[i];
lastExtent = lastType->ub - lastType->lb; lastExtent = lastType->ub - lastType->lb;
lastBlock = pBlockLength[i]; lastBlock = pBlockLength[i];
lastDisp = pDisp[i]; lastDisp = pDisp[i];
@ -61,7 +61,7 @@ int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long*
disp += lastType->desc.used; disp += lastType->desc.used;
if( lastBlock != 1 ) disp += 2; if( lastBlock != 1 ) disp += 2;
lastType = (dt_desc_t*)pTypes[0]; lastType = (ompi_datatype_t*)pTypes[0];
lastBlock = pBlockLength[0]; lastBlock = pBlockLength[0];
lastExtent = lastType->ub - lastType->lb; lastExtent = lastType->ub - lastType->lb;
lastDisp = pDisp[0]; lastDisp = pDisp[0];
@ -76,7 +76,7 @@ int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long*
endto = lastDisp + lastBlock * lastExtent; endto = lastDisp + lastBlock * lastExtent;
} else { } else {
ompi_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent ); ompi_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
lastType = (dt_desc_t*)pTypes[i]; lastType = (ompi_datatype_t*)pTypes[i];
lastExtent = lastType->ub - lastType->lb; lastExtent = lastType->ub - lastType->lb;
lastBlock = pBlockLength[i]; lastBlock = pBlockLength[i];
lastDisp = pDisp[i]; lastDisp = pDisp[i];

Просмотреть файл

@ -25,10 +25,10 @@
*/ */
int32_t ompi_ddt_create_vector( int count, int bLength, long stride, int32_t ompi_ddt_create_vector( int count, int bLength, long stride,
const dt_desc_t* oldType, dt_desc_t** newType ) const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{ {
long extent = oldType->ub - oldType->lb; long extent = oldType->ub - oldType->lb;
dt_desc_t *pTempData, *pData; ompi_datatype_t *pTempData, *pData;
pTempData = ompi_ddt_create( oldType->desc.used + 2 ); pTempData = ompi_ddt_create( oldType->desc.used + 2 );
if( (bLength == stride) || (1 >= count) ) { /* the elements are contiguous */ if( (bLength == stride) || (1 >= count) ) { /* the elements are contiguous */
@ -53,10 +53,10 @@ int32_t ompi_ddt_create_vector( int count, int bLength, long stride,
} }
int32_t ompi_ddt_create_hvector( int count, int bLength, long stride, int32_t ompi_ddt_create_hvector( int count, int bLength, long stride,
const dt_desc_t* oldType, dt_desc_t** newType ) const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{ {
long extent = oldType->ub - oldType->lb; long extent = oldType->ub - oldType->lb;
dt_desc_t *pTempData, *pData; ompi_datatype_t *pTempData, *pData;
pTempData = ompi_ddt_create( oldType->desc.used + 2 ); pTempData = ompi_ddt_create( oldType->desc.used + 2 );
if( ((extent * bLength) == stride) || (1 >= count) ) { /* contiguous */ if( ((extent * bLength) == stride) || (1 >= count) ) { /* contiguous */

Просмотреть файл

@ -230,13 +230,13 @@ int ompi_ddt_local_sizes[DT_MAX_PREDEFINED];
#define DECLARE_MPI2_COMPOSED_STRUCT_DDT( PDATA, MPIDDT, MPIDDTNAME, type1, type2, MPIType1, MPIType2 ) \ #define DECLARE_MPI2_COMPOSED_STRUCT_DDT( PDATA, MPIDDT, MPIDDTNAME, type1, type2, MPIType1, MPIType2 ) \
do { \ do { \
struct { type1 v1; type2 v2; } s[2]; \ struct { type1 v1; type2 v2; } s[2]; \
const dt_desc_t* types[2]; \ ompi_datatype_t* types[2]; \
dt_desc_t* ptype; \ ompi_datatype_t* ptype; \
int bLength[2] = {1, 1}; \ int bLength[2] = {1, 1}; \
long base, displ[2]; \ long base, displ[2]; \
\ \
types[0] = (dt_desc_t*)ompi_ddt_basicDatatypes[MPIType1]; \ types[0] = (ompi_datatype_t*)ompi_ddt_basicDatatypes[MPIType1]; \
types[1] = (dt_desc_t*)ompi_ddt_basicDatatypes[MPIType2]; \ types[1] = (ompi_datatype_t*)ompi_ddt_basicDatatypes[MPIType2]; \
base = (long)(&(s[0])); \ base = (long)(&(s[0])); \
displ[0] = (long)(&(s[0].v1)); \ displ[0] = (long)(&(s[0].v1)); \
displ[0] -= base; \ displ[0] -= base; \
@ -284,7 +284,7 @@ int32_t ompi_ddt_init( void )
int i; int i;
for( i = DT_CHAR; i < DT_MAX_PREDEFINED; i++ ) { for( i = DT_CHAR; i < DT_MAX_PREDEFINED; i++ ) {
dt_desc_t* datatype = (dt_desc_t*)ompi_ddt_basicDatatypes[i]; ompi_datatype_t* datatype = (ompi_datatype_t*)ompi_ddt_basicDatatypes[i];
datatype->desc.desc = (dt_elem_desc_t*)malloc(2*sizeof(dt_elem_desc_t)); datatype->desc.desc = (dt_elem_desc_t*)malloc(2*sizeof(dt_elem_desc_t));
datatype->desc.desc[0].flags = DT_FLAG_BASIC | DT_FLAG_CONTIGUOUS | DT_FLAG_DATA; datatype->desc.desc[0].flags = DT_FLAG_BASIC | DT_FLAG_CONTIGUOUS | DT_FLAG_DATA;
@ -561,7 +561,7 @@ static int __dump_data_desc( dt_elem_desc_t* pDesc, int nbElems, char* ptr )
return index; return index;
} }
static inline int __dt_contain_basic_datatypes( const dt_desc_t* pData, char* ptr ) static inline int __dt_contain_basic_datatypes( const ompi_datatype_t* pData, char* ptr )
{ {
int i, index = 0; int i, index = 0;
unsigned long long mask = 1; unsigned long long mask = 1;
@ -576,7 +576,7 @@ static inline int __dt_contain_basic_datatypes( const dt_desc_t* pData, char* pt
return index; return index;
} }
void ompi_ddt_dump( const dt_desc_t* pData ) void ompi_ddt_dump( const ompi_datatype_t* pData )
{ {
char buffer[1024*10]; char buffer[1024*10];
int index = 0; int index = 0;

Просмотреть файл

@ -24,13 +24,13 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#define SAVE_DESC( PELEM, DISP, COUNT ) \ #define SAVE_DESC( PELEM, DISP, COUNT, EXTENT ) \
do { \ do { \
(PELEM)->flags = DT_FLAG_BASIC | DT_FLAG_DATA; \ (PELEM)->flags = DT_FLAG_BASIC | DT_FLAG_DATA; \
(PELEM)->type = DT_BYTE; \ (PELEM)->type = DT_BYTE; \
(PELEM)->count = (COUNT); \ (PELEM)->count = (COUNT); \
(PELEM)->disp = (DISP); \ (PELEM)->disp = (DISP); \
(PELEM)->extent = 1; \ (PELEM)->extent = (EXTENT); \
(PELEM)++; \ (PELEM)++; \
nbElems++; \ nbElems++; \
} while(0) } while(0)
@ -46,15 +46,15 @@ do { \
nbElems++; \ nbElems++; \
} while(0) } while(0)
int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count, int32_t ompi_ddt_optimize_short( ompi_datatype_t* pData, int32_t count,
dt_type_desc_t* pTypeDesc ) dt_type_desc_t* pTypeDesc )
{ {
dt_elem_desc_t* pElemDesc; dt_elem_desc_t* pElemDesc;
long lastDisp = 0; long lastDisp = 0;
dt_stack_t* pStack; /* pointer to the position on the stack */ dt_stack_t* pStack; /* pointer to the position on the stack */
int pos_desc; /* actual position in the description of the derived datatype */ int32_t pos_desc; /* actual position in the description of the derived datatype */
int stack_pos = 0; int32_t stack_pos = 0;
int type, lastLength = 0, nbElems = 0, changes = 0; int32_t type, lastLength = 0, nbElems = 0, changes = 0, lastExtent = 1;
long totalDisp; long totalDisp;
pTypeDesc->length = 2 * pData->desc.used + 1 /* for the fake DT_END_LOOP at the end */; pTypeDesc->length = 2 * pData->desc.used + 1 /* for the fake DT_END_LOOP at the end */;
@ -75,7 +75,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
if( pData->desc.desc[pos_desc].type == DT_END_LOOP ) { /* end of the current loop */ if( pData->desc.desc[pos_desc].type == DT_END_LOOP ) { /* end of the current loop */
dt_loop_desc_t* pStartLoop; dt_loop_desc_t* pStartLoop;
if( lastLength != 0 ) { if( lastLength != 0 ) {
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
lastDisp += lastLength; lastDisp += lastLength;
lastLength = 0; lastLength = 0;
} }
@ -103,7 +103,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
if( loop->extent == end_loop->size ) { if( loop->extent == end_loop->size ) {
/* the whole loop is contiguous */ /* the whole loop is contiguous */
if( (lastDisp + lastLength) != (totalDisp + loop_disp) ) { if( (lastDisp + lastLength) != (totalDisp + loop_disp) ) {
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
lastLength = 0; lastLength = 0;
lastDisp = totalDisp + loop_disp; lastDisp = totalDisp + loop_disp;
} }
@ -116,7 +116,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
lastLength += end_loop->size; lastLength += end_loop->size;
counter--; counter--;
} }
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
lastDisp += lastLength; lastDisp += lastLength;
lastLength = 0; lastLength = 0;
} }
@ -125,7 +125,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
*/ */
SAVE_ELEM( pElemDesc, DT_LOOP, pData->desc.desc[pos_desc].flags, SAVE_ELEM( pElemDesc, DT_LOOP, pData->desc.desc[pos_desc].flags,
counter, (long)2, pData->desc.desc[pos_desc].extent ); counter, (long)2, pData->desc.desc[pos_desc].extent );
SAVE_DESC( pElemDesc, loop_disp, end_loop->size ); SAVE_DESC( pElemDesc, loop_disp, end_loop->size, lastExtent );
SAVE_ELEM( pElemDesc, DT_END_LOOP, end_loop->flags, SAVE_ELEM( pElemDesc, DT_END_LOOP, end_loop->flags,
2, end_loop->total_extent, end_loop->size ); 2, end_loop->total_extent, end_loop->size );
} }
@ -133,7 +133,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
changes++; changes++;
} else { } else {
if( lastLength != 0 ) { if( lastLength != 0 ) {
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
lastDisp += lastLength; lastDisp += lastLength;
lastLength = 0; lastLength = 0;
} }
@ -151,20 +151,23 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
while( pData->desc.desc[pos_desc].flags & DT_FLAG_DATA ) { /* keep doing it until we reach a non datatype element */ while( pData->desc.desc[pos_desc].flags & DT_FLAG_DATA ) { /* keep doing it until we reach a non datatype element */
/* now here we have a basic datatype */ /* now here we have a basic datatype */
type = pData->desc.desc[pos_desc].type; type = pData->desc.desc[pos_desc].type;
if( (lastDisp + lastLength) == (totalDisp + pData->desc.desc[pos_desc].disp) ) { if( (pData->desc.desc[pos_desc].flags & DT_FLAG_CONTIGUOUS) &&
(lastDisp + lastLength) == (totalDisp + pData->desc.desc[pos_desc].disp) ) {
lastLength += pData->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size; lastLength += pData->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size;
lastExtent = 1;
} else { } else {
if( lastLength != 0 ) if( lastLength != 0 )
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
lastDisp = totalDisp + pData->desc.desc[pos_desc].disp; lastDisp = totalDisp + pData->desc.desc[pos_desc].disp;
lastLength = pData->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size; lastLength = pData->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size;
lastExtent = 1;
} }
pos_desc++; /* advance to the next data */ pos_desc++; /* advance to the next data */
} }
} }
if( lastLength != 0 ) if( lastLength != 0 )
SAVE_DESC( pElemDesc, lastDisp, lastLength ); SAVE_DESC( pElemDesc, lastDisp, lastLength, lastExtent );
/* cleanup the stack */ /* cleanup the stack */
pTypeDesc->used = nbElems - 1; /* except the last fake END_LOOP */ pTypeDesc->used = nbElems - 1; /* except the last fake END_LOOP */
return OMPI_SUCCESS; return OMPI_SUCCESS;
@ -178,7 +181,7 @@ int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count,
} }
#if defined(COMPILE_USELSS_CODE) #if defined(COMPILE_USELSS_CODE)
static int ompi_ddt_unroll( dt_desc_t* pData, int count ) static int ompi_ddt_unroll( ompi_datatype_t* pData, int count )
{ {
dt_stack_t* pStack; /* pointer to the position on the stack */ dt_stack_t* pStack; /* pointer to the position on the stack */
int pos_desc; /* actual position in the description of the derived datatype */ int pos_desc; /* actual position in the description of the derived datatype */
@ -292,9 +295,9 @@ static int ompi_ddt_unroll( dt_desc_t* pData, int count )
} }
#endif /* COMPILE_USELSS_CODE */ #endif /* COMPILE_USELSS_CODE */
int32_t ompi_ddt_commit( dt_desc_t** data ) int32_t ompi_ddt_commit( ompi_datatype_t** data )
{ {
dt_desc_t* pData = (dt_desc_t*)*data; ompi_datatype_t* pData = *data;
dt_endloop_desc_t* pLast = (dt_endloop_desc_t*)&(pData->desc.desc[pData->desc.used]); dt_endloop_desc_t* pLast = (dt_endloop_desc_t*)&(pData->desc.desc[pData->desc.used]);
if( pData->flags & DT_FLAG_COMMITED ) return OMPI_SUCCESS; if( pData->flags & DT_FLAG_COMMITED ) return OMPI_SUCCESS;