1
1

Mainly cleanups + some variable rename.

Help the compiler a little bit : add const to all arguments non modified inside the
functions.

This commit was SVN r3586.
Этот коммит содержится в:
George Bosilca 2004-11-16 23:50:31 +00:00
родитель b73c7ae6c9
Коммит 6c9f27a2f5
15 изменённых файлов: 230 добавлений и 227 удалений

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

@ -105,60 +105,60 @@ int ompi_ddt_finalize( void );
dt_desc_t* ompi_ddt_create( int expectedSize ); dt_desc_t* ompi_ddt_create( int expectedSize );
int ompi_ddt_commit( dt_desc_t** ); int ompi_ddt_commit( dt_desc_t** );
int ompi_ddt_destroy( dt_desc_t** ); int ompi_ddt_destroy( dt_desc_t** );
static inline int ompi_ddt_is_committed( ompi_datatype_t* type ) static inline int ompi_ddt_is_committed( const ompi_datatype_t* type )
{ return ((type->flags & DT_FLAG_COMMITED) == DT_FLAG_COMMITED); } { return ((type->flags & DT_FLAG_COMMITED) == DT_FLAG_COMMITED); }
static inline int ompi_ddt_is_overlapped( ompi_datatype_t* type ) static inline int ompi_ddt_is_overlapped( const ompi_datatype_t* type )
{ return ((type->flags & DT_FLAG_OVERLAP) == DT_FLAG_OVERLAP); } { return ((type->flags & DT_FLAG_OVERLAP) == DT_FLAG_OVERLAP); }
static inline int ompi_ddt_is_acceptable_for_one_sided( ompi_datatype_t* type ) static inline int ompi_ddt_is_acceptable_for_one_sided( const ompi_datatype_t* type )
{ return ((type->flags & DT_FLAG_ONE_SIDED) == DT_FLAG_ONE_SIDED); } { return ((type->flags & DT_FLAG_ONE_SIDED) == DT_FLAG_ONE_SIDED); }
void ompi_ddt_dump( dt_desc_t* pData ); void ompi_ddt_dump( const dt_desc_t* pData );
/* data creation functions */ /* data creation functions */
OMPI_DECLSPEC int ompi_ddt_duplicate( dt_desc_t* oldType, dt_desc_t** newType ); OMPI_DECLSPEC int ompi_ddt_duplicate( const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_contiguous( int count, dt_desc_t* oldType, dt_desc_t** newType ); OMPI_DECLSPEC int ompi_ddt_create_contiguous( int count, const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_vector( int count, int bLength, long stride, OMPI_DECLSPEC int ompi_ddt_create_vector( int count, int bLength, long stride,
dt_desc_t* oldType, dt_desc_t** newType ); const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_hvector( int count, int bLength, long stride, OMPI_DECLSPEC int ompi_ddt_create_hvector( int count, int bLength, long stride,
dt_desc_t* oldType, dt_desc_t** newType ); const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_indexed( int count, int* pBlockLength, int* pDisp, OMPI_DECLSPEC int ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ); const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_hindexed( int count, int* pBlockLength, long* pDisp, OMPI_DECLSPEC int ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ); const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_indexed_block( int count, int bLength, int* pDisp, OMPI_DECLSPEC int ompi_ddt_create_indexed_block( int count, int bLength, const int* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ); const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp, OMPI_DECLSPEC int ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp,
dt_desc_t** pTypes, dt_desc_t** newType ); const dt_desc_t** pTypes, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_resized( dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType ); OMPI_DECLSPEC int ompi_ddt_create_resized( const dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_subarray( int ndims, int* pSizes, int* pSubSizes, int* pStarts, OMPI_DECLSPEC int ompi_ddt_create_subarray( int ndims, const int* pSizes, const int* pSubSizes, const int* pStarts,
int order, dt_desc_t* oldType, dt_desc_t** newType ); int order, const dt_desc_t* oldType, dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_create_darray( int size, int rank, int ndims, int* pGSizes, int *pDistrib, OMPI_DECLSPEC int ompi_ddt_create_darray( int size, int rank, int ndims, const int* pGSizes, const int *pDistrib,
int* pDArgs, int* pPSizes, int order, dt_desc_t* oldType, const int* pDArgs, const int* pPSizes, int order, const dt_desc_t* oldType,
dt_desc_t** newType ); dt_desc_t** newType );
OMPI_DECLSPEC int ompi_ddt_add( dt_desc_t* pdtBase, dt_desc_t* pdtNew, unsigned int count, long disp, long extent ); OMPI_DECLSPEC int ompi_ddt_add( dt_desc_t* pdtBase, const dt_desc_t* pdtAdd, unsigned int count, long disp, long extent );
static inline int ompi_ddt_type_lb( dt_desc_t* pData, long* disp ) static inline int ompi_ddt_type_lb( const dt_desc_t* pData, long* disp )
{ *disp = pData->lb; return 0; } { *disp = pData->lb; return 0; }
static inline int ompi_ddt_type_ub( dt_desc_t* pData, long* disp ) static inline int ompi_ddt_type_ub( const dt_desc_t* pData, long* disp )
{ *disp = pData->ub; return 0; } { *disp = pData->ub; return 0; }
static inline int ompi_ddt_type_size ( dt_desc_t* pData, int *size ) static inline int ompi_ddt_type_size ( const dt_desc_t* pData, int *size )
{ *size = pData->size; return 0; } { *size = pData->size; return 0; }
static inline int ompi_ddt_type_extent( dt_desc_t* pData, long* extent ) static inline int ompi_ddt_type_extent( const dt_desc_t* pData, long* extent )
{ *extent = (pData->ub - pData->lb); return 0; } { *extent = (pData->ub - pData->lb); return 0; }
static inline int ompi_ddt_get_extent( dt_desc_t* pData, long* lb, long* extent) static inline int ompi_ddt_get_extent( const dt_desc_t* pData, long* lb, long* extent)
{ *lb = pData->lb; *extent = pData->ub - pData->lb; return 0; } { *lb = pData->lb; *extent = pData->ub - pData->lb; return 0; }
static inline int ompi_ddt_get_true_extent( dt_desc_t* pData, long* true_lb, long* true_extent) static inline int ompi_ddt_get_true_extent( const dt_desc_t* pData, long* true_lb, long* true_extent)
{ *true_lb = pData->true_lb; *true_extent = (pData->true_ub - pData->true_lb); return 0; } { *true_lb = pData->true_lb; *true_extent = (pData->true_ub - pData->true_lb); return 0; }
OMPI_DECLSPEC int ompi_ddt_get_element_count( dt_desc_t* pData, int iSize ); OMPI_DECLSPEC int ompi_ddt_get_element_count( const dt_desc_t* pData, int iSize );
OMPI_DECLSPEC int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count, char* pDestBuf, char* pSrcBuf ); OMPI_DECLSPEC int ompi_ddt_copy_content_same_ddt( const dt_desc_t* pData, int count, char* pDestBuf, const char* pSrcBuf );
OMPI_DECLSPEC int ompi_ddt_optimize_short( dt_desc_t* pData, int count, dt_type_desc_t* pTypeDesc ); OMPI_DECLSPEC int ompi_ddt_optimize_short( dt_desc_t* pData, int count, dt_type_desc_t* pTypeDesc );
/* flags for the datatypes */ /* flags for the datatypes */
typedef int (*conversion_fct_t)( unsigned int count, typedef int (*conversion_fct_t)( unsigned int count,
void* from, uint32_t from_len, long from_extent, const void* from, uint32_t from_len, long from_extent,
void* to, uint32_t in_length, long to_extent ); void* to, uint32_t in_length, long to_extent );
typedef struct __dt_stack dt_stack_t; typedef struct __dt_stack dt_stack_t;
@ -242,22 +242,22 @@ static inline int ompi_convertor_unpack( ompi_convertor_t* pConv,
/* and finally the convertor functions */ /* and finally the convertor functions */
OMPI_DECLSPEC ompi_convertor_t* ompi_convertor_create( int remote_arch, int mode ); OMPI_DECLSPEC ompi_convertor_t* ompi_convertor_create( int remote_arch, int mode );
OMPI_DECLSPEC ompi_convertor_t* ompi_convertor_get_copy( ompi_convertor_t* pConvertor ); OMPI_DECLSPEC ompi_convertor_t* ompi_convertor_get_copy( const ompi_convertor_t* pConvertor );
OMPI_DECLSPEC int ompi_convertor_copy( ompi_convertor_t* pSrcConv, ompi_convertor_t* pDestConv ); OMPI_DECLSPEC int ompi_convertor_copy( const ompi_convertor_t* pSrcConv, ompi_convertor_t* pDestConv );
OMPI_DECLSPEC int ompi_convertor_init_for_send( ompi_convertor_t* pConv, unsigned int flags, OMPI_DECLSPEC int ompi_convertor_init_for_send( ompi_convertor_t* pConv, unsigned int flags,
dt_desc_t* pData, int count, const dt_desc_t* pData, int count,
void* pUserBuf, int local_starting_point, const void* pUserBuf, int local_starting_point,
memalloc_fct_t allocfn ); memalloc_fct_t allocfn );
OMPI_DECLSPEC int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, unsigned int flags, OMPI_DECLSPEC int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, unsigned int flags,
dt_desc_t* pData, int count, const dt_desc_t* pData, int count,
void* pUserBuf, int remote_starting_point, const void* pUserBuf, int remote_starting_point,
memalloc_fct_t allocfn ); memalloc_fct_t allocfn );
OMPI_DECLSPEC int ompi_convertor_need_buffers( ompi_convertor_t* pConvertor ); OMPI_DECLSPEC int ompi_convertor_need_buffers( ompi_convertor_t* pConvertor );
OMPI_DECLSPEC int ompi_convertor_get_packed_size( ompi_convertor_t* pConv, unsigned int* pSize ); OMPI_DECLSPEC int ompi_convertor_get_packed_size( const ompi_convertor_t* pConv, unsigned int* pSize );
OMPI_DECLSPEC int ompi_convertor_get_unpacked_size( ompi_convertor_t* pConv, unsigned int* pSize ); OMPI_DECLSPEC int ompi_convertor_get_unpacked_size( const ompi_convertor_t* pConv, unsigned int* pSize );
/* temporary function prototypes. They should move in other place later. */ /* temporary function prototypes. They should move in other place later. */
OMPI_DECLSPEC int ompi_ddt_get_args( dt_desc_t* pData, int which, OMPI_DECLSPEC int ompi_ddt_get_args( const dt_desc_t* pData, int which,
int * ci, int * i, int * ci, int * i,
int * ca, long* a, int * ca, long* a,
int * cd, ompi_datatype_t** d, int * type); int * cd, ompi_datatype_t** d, int * type);
@ -265,11 +265,10 @@ OMPI_DECLSPEC int ompi_ddt_set_args( dt_desc_t* pData,
int ci, int ** i, int ci, int ** i,
int ca, long* a, int ca, long* a,
int cd, ompi_datatype_t** d,int type); int cd, ompi_datatype_t** d,int type);
OMPI_DECLSPEC int ompi_ddt_sndrcv( void *sbuf, int scount, ompi_datatype_t* sdtype, void *rbuf, OMPI_DECLSPEC int ompi_ddt_sndrcv( void *sbuf, int scount, const ompi_datatype_t* sdtype, void *rbuf,
int rcount, ompi_datatype_t* rdtype, int tag, MPI_Comm comm); int rcount, const ompi_datatype_t* rdtype, int tag, MPI_Comm comm);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif
#endif /* DATATYPE_H_HAS_BEEN_INCLUDED */ #endif /* DATATYPE_H_HAS_BEEN_INCLUDED */

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

@ -145,7 +145,7 @@ typedef struct {
long double i; long double i;
} ompi_complex_long_double_t; } ompi_complex_long_double_t;
extern ompi_datatype_t* ompi_ddt_basicDatatypes[]; extern const ompi_datatype_t* ompi_ddt_basicDatatypes[];
/* macros to play with the flags */ /* macros to play with the flags */
#define SWAP( INT_VALUE, FLAG ) (INT_VALUE) = (INT_VALUE) ^ (FLAG) #define SWAP( INT_VALUE, FLAG ) (INT_VALUE) = (INT_VALUE) ^ (FLAG)
@ -169,7 +169,8 @@ static inline int IMIN( int a, int b ) { return ( a < b ? a : b ); }
extern conversion_fct_t ompi_ddt_copy_functions[DT_MAX_PREDEFINED]; extern conversion_fct_t ompi_ddt_copy_functions[DT_MAX_PREDEFINED];
extern void ompi_ddt_dump_stack( dt_stack_t* pStack, int stack_pos, dt_elem_desc_t* pDesc, char* name ); extern void ompi_ddt_dump_stack( const dt_stack_t* pStack, int stack_pos,
const dt_elem_desc_t* pDesc, const char* name );
#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); \
@ -197,9 +198,9 @@ do { \
#define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) #define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT )
#endif /* OMPI_ENABLE_DEBUG */ #endif /* OMPI_ENABLE_DEBUG */
static inline void ompi_ddt_safeguard_pointer( void* actual_ptr, int length, static inline void ompi_ddt_safeguard_pointer( const void* actual_ptr, int length,
void* initial_ptr, const void* initial_ptr,
ompi_datatype_t* pData, const ompi_datatype_t* pData,
int count ) int count )
{ {
char* lower_bound = (char*)initial_ptr; char* lower_bound = (char*)initial_ptr;
@ -249,7 +250,7 @@ do { \
} while(0) } while(0)
#endif /* USELESS */ #endif /* USELESS */
static inline int GET_FIRST_NON_LOOP( dt_elem_desc_t* _pElem ) static inline int GET_FIRST_NON_LOOP( const dt_elem_desc_t* _pElem )
{ {
int index = 0; int index = 0;
@ -263,10 +264,10 @@ static inline int GET_FIRST_NON_LOOP( dt_elem_desc_t* _pElem )
} }
int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor,
int starting_point, int* sizes ); int starting_point, const int* sizes );
static inline static inline
int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor, int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor,
int starting_point, int* sizes ) int starting_point, const int* sizes )
{ {
dt_stack_t* pStack; /* pointer to the position on the stack */ dt_stack_t* pStack; /* pointer to the position on the stack */
ompi_datatype_t* pData = pConvertor->pDesc; ompi_datatype_t* pData = pConvertor->pDesc;
@ -313,7 +314,7 @@ int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor,
} }
static inline static inline
int ompi_convertor_create_stack_at_begining( ompi_convertor_t* pConvertor, int* sizes ) int ompi_convertor_create_stack_at_begining( ompi_convertor_t* pConvertor, const int* sizes )
{ {
ompi_datatype_t* pData = pConvertor->pDesc; ompi_datatype_t* pData = pConvertor->pDesc;
dt_stack_t* pStack; dt_stack_t* pStack;

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

@ -18,7 +18,7 @@
* be sure that the pdtBase datatype is correctly initialized with all fields * be sure that the pdtBase datatype is correctly initialized with all fields
* set to ZERO if it's a empty datatype. * set to ZERO if it's a empty datatype.
*/ */
int ompi_ddt_add( dt_desc_t* pdtBase, dt_desc_t* pdtAdd, int ompi_ddt_add( dt_desc_t* pdtBase, const dt_desc_t* pdtAdd,
unsigned int count, long disp, long extent ) unsigned int count, long disp, long extent )
{ {
uint32_t newLength, place_needed = 0, i; uint32_t newLength, place_needed = 0, i;
@ -72,8 +72,6 @@ int ompi_ddt_add( dt_desc_t* pdtBase, dt_desc_t* pdtAdd,
return 0; return 0;
} }
OBJ_RETAIN( pdtAdd );
/* compute the new memory alignement */ /* compute the new memory alignement */
pdtBase->align = IMAX( pdtBase->align, pdtAdd->align ); pdtBase->align = IMAX( pdtBase->align, pdtAdd->align );
@ -100,6 +98,14 @@ int ompi_ddt_add( dt_desc_t* pdtBase, dt_desc_t* pdtAdd,
if( extent == (int)pdtAdd->size ) if( extent == (int)pdtAdd->size )
pLast->flags |= DT_FLAG_CONTIGUOUS; pLast->flags |= DT_FLAG_CONTIGUOUS;
} else { } else {
/* We handle a user defined datatype. We should make sure that the user will not have the
* oportunity to destroy it before all datatypes derived are destroyed. As we keep pointers
* to every datatype (for MPI_Type_get_content and MPI_Type_get_envelope) we have to make
* sure that those datatype will be available if the user ask for them. However, there
* is no easy way to free them in this case ...
*/
OBJ_RETAIN( pdtAdd );
/* now we add a complex datatype */ /* now we add a complex datatype */
if( disp != pdtBase->true_ub ) { /* add the initial gap */ if( disp != pdtBase->true_ub ) { /* add the initial gap */
if( disp < pdtBase->true_ub ) pdtBase->flags |= DT_FLAG_OVERLAP; if( disp < pdtBase->true_ub ) pdtBase->flags |= DT_FLAG_OVERLAP;
@ -201,7 +207,5 @@ int ompi_ddt_add( dt_desc_t* pdtBase, dt_desc_t* pdtAdd,
!(pdtBase->flags & DT_FLAG_CONTIGUOUS) || !(pdtAdd->flags & DT_FLAG_CONTIGUOUS) ) !(pdtBase->flags & DT_FLAG_CONTIGUOUS) || !(pdtAdd->flags & DT_FLAG_CONTIGUOUS) )
UNSET_CONTIGUOUS_FLAG(pdtBase->flags); UNSET_CONTIGUOUS_FLAG(pdtBase->flags);
OBJ_RELEASE( pdtAdd );
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

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

@ -162,7 +162,7 @@ int ompi_ddt_set_args( ompi_datatype_t* pData,
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int ompi_ddt_get_args( ompi_datatype_t* pData, int which, int ompi_ddt_get_args( const ompi_datatype_t* pData, int which,
int * ci, int * i, int * ci, int * i,
int * ca, MPI_Aint * a, int * ca, MPI_Aint * a,
int * cd, MPI_Datatype * d, int * type) int * cd, MPI_Datatype * d, int * type)

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

@ -69,7 +69,7 @@ dt_desc_t* ompi_ddt_create( int expectedSize )
return pdt; return pdt;
} }
int ompi_ddt_create_resized( dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType ) int ompi_ddt_create_resized( const dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType )
{ {
ompi_ddt_duplicate( oldType, newType ); ompi_ddt_duplicate( oldType, newType );
(*newType)->lb = lb; (*newType)->lb = lb;

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

@ -3,15 +3,15 @@
#include "ompi_config.h" #include "ompi_config.h"
#include "datatype.h" #include "datatype.h"
int ompi_ddt_create_subarray( int ndims, int* pSizes, int* pSubSizes, int* pStarts, int ompi_ddt_create_subarray( int ndims, const int* pSizes, const int* pSubSizes, const int* pStarts,
int order, dt_desc_t* oldType, dt_desc_t** newType ) int order, const dt_desc_t* oldType, dt_desc_t** newType )
{ {
return OMPI_ERR_NOT_IMPLEMENTED; return OMPI_ERR_NOT_IMPLEMENTED;
} }
int ompi_ddt_create_darray( int size, int rank, int ndims, int* pGSizes, int *pDistrib, int ompi_ddt_create_darray( int size, int rank, int ndims, const int* pGSizes, const int *pDistrib,
int* pDArgs, int* pPSizes, int order, dt_desc_t* oldType, const int* pDArgs, const int* pPSizes, int order, const dt_desc_t* oldType,
dt_desc_t** newType ) dt_desc_t** newType )
{ {
return OMPI_ERR_NOT_IMPLEMENTED; return OMPI_ERR_NOT_IMPLEMENTED;
} }

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

@ -4,7 +4,7 @@
#include "datatype.h" #include "datatype.h"
#include "datatype_internal.h" #include "datatype_internal.h"
int ompi_ddt_duplicate( dt_desc_t* oldType, dt_desc_t** newType ) int ompi_ddt_duplicate( const dt_desc_t* oldType, dt_desc_t** newType )
{ {
dt_desc_t* pdt = ompi_ddt_create( oldType->desc.used ); dt_desc_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 */
@ -19,7 +19,7 @@ int ompi_ddt_duplicate( dt_desc_t* oldType, dt_desc_t** newType )
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_ddt_create_contiguous( int count, dt_desc_t* oldType, int ompi_ddt_create_contiguous( int count, const dt_desc_t* oldType,
dt_desc_t** newType ) dt_desc_t** newType )
{ {
dt_desc_t* pdt = ompi_ddt_create( oldType->desc.used + 2 ); dt_desc_t* pdt = ompi_ddt_create( oldType->desc.used + 2 );

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

@ -4,8 +4,8 @@
#include "datatype.h" #include "datatype.h"
/* We try to merge together data that are contiguous */ /* We try to merge together data that are contiguous */
int ompi_ddt_create_indexed( int count, int* pBlockLength, int* pDisp, int ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ) const dt_desc_t* oldType, dt_desc_t** newType )
{ {
dt_desc_t* pdt; dt_desc_t* pdt;
int i, dLength, endat, disp; int i, dLength, endat, disp;
@ -40,8 +40,8 @@ int ompi_ddt_create_indexed( int count, int* pBlockLength, int* pDisp,
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_ddt_create_hindexed( int count, int* pBlockLength, long* pDisp, int ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ) const dt_desc_t* oldType, dt_desc_t** newType )
{ {
dt_desc_t* pdt; dt_desc_t* pdt;
int i, dLength; int i, dLength;
@ -76,8 +76,8 @@ int ompi_ddt_create_hindexed( int count, int* pBlockLength, long* pDisp,
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_ddt_create_indexed_block( int count, int bLength, int* pDisp, int ompi_ddt_create_indexed_block( int count, int bLength, const int* pDisp,
dt_desc_t* oldType, dt_desc_t** newType ) const dt_desc_t* oldType, dt_desc_t** newType )
{ {
dt_desc_t* pdt; dt_desc_t* pdt;
int i, dLength, endat, disp; int i, dLength, endat, disp;

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

@ -3,8 +3,8 @@
#include "ompi_config.h" #include "ompi_config.h"
#include "datatype.h" #include "datatype.h"
int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp, int ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp,
dt_desc_t** pTypes, dt_desc_t** newType ) const dt_desc_t ** pTypes, dt_desc_t** newType )
{ {
int i; int i;
long disp = 0, endto, lastExtent, lastDisp; long disp = 0, endto, lastExtent, lastDisp;
@ -18,7 +18,7 @@ int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
disp += pTypes[i]->desc.used; disp += pTypes[i]->desc.used;
if( pBlockLength[i] != 1 ) disp += 2; if( pBlockLength[i] != 1 ) disp += 2;
} }
lastType = pTypes[0]; lastType = (dt_desc_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];
@ -31,7 +31,7 @@ int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
} else { } else {
disp += lastType->desc.used; disp += lastType->desc.used;
if( lastBlock > 1 ) disp += 2; if( lastBlock > 1 ) disp += 2;
lastType = pTypes[i]; lastType = (dt_desc_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];
@ -41,7 +41,7 @@ int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
disp += lastType->desc.used; disp += lastType->desc.used;
if( lastBlock != 1 ) disp += 2; if( lastBlock != 1 ) disp += 2;
lastType = pTypes[0]; lastType = (dt_desc_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];
@ -56,7 +56,7 @@ int ompi_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
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 = pTypes[i]; lastType = (dt_desc_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];

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

@ -10,7 +10,7 @@
*/ */
int ompi_ddt_create_vector( int count, int bLength, long stride, int ompi_ddt_create_vector( int count, int bLength, long stride,
dt_desc_t* oldType, dt_desc_t** newType ) const dt_desc_t* oldType, dt_desc_t** newType )
{ {
long extent = oldType->ub - oldType->lb; long extent = oldType->ub - oldType->lb;
dt_desc_t *pTempData, *pData; dt_desc_t *pTempData, *pData;
@ -22,12 +22,12 @@ int ompi_ddt_create_vector( int count, int bLength, long stride,
} else { } else {
if( 1 == bLength ) { if( 1 == bLength ) {
pData = pTempData; pData = pTempData;
pTempData = oldType; ompi_ddt_add( pData, oldType, count, 0, extent * stride );
} else { } else {
ompi_ddt_add( pTempData, oldType, bLength, 0, extent ); ompi_ddt_add( pTempData, oldType, bLength, 0, extent );
pData = ompi_ddt_create( oldType->desc.used + 2 + 2 ); pData = ompi_ddt_create( oldType->desc.used + 2 + 2 );
ompi_ddt_add( pData, pTempData, count, 0, extent * stride );
} }
ompi_ddt_add( pData, pTempData, count, 0, extent * stride );
if( 1 != bLength ) if( 1 != bLength )
OBJ_RELEASE( pTempData ); OBJ_RELEASE( pTempData );
/* correct the ub to remove the last stride */ /* correct the ub to remove the last stride */
@ -38,7 +38,7 @@ int ompi_ddt_create_vector( int count, int bLength, long stride,
} }
int ompi_ddt_create_hvector( int count, int bLength, long stride, int ompi_ddt_create_hvector( int count, int bLength, long stride,
dt_desc_t* oldType, dt_desc_t** newType ) const dt_desc_t* oldType, dt_desc_t** newType )
{ {
long extent = oldType->ub - oldType->lb; long extent = oldType->ub - oldType->lb;
dt_desc_t *pTempData, *pData; dt_desc_t *pTempData, *pData;
@ -50,12 +50,12 @@ int ompi_ddt_create_hvector( int count, int bLength, long stride,
} else { } else {
if( 1 == bLength ) { if( 1 == bLength ) {
pData = pTempData; pData = pTempData;
pTempData = oldType; ompi_ddt_add( pData, oldType, count, 0, stride );
} else { } else {
ompi_ddt_add( pTempData, oldType, bLength, 0, extent ); ompi_ddt_add( pTempData, oldType, bLength, 0, extent );
pData = ompi_ddt_create( oldType->desc.used + 2 + 2 ); pData = ompi_ddt_create( oldType->desc.used + 2 + 2 );
ompi_ddt_add( pData, pTempData, count, 0, stride );
} }
ompi_ddt_add( pData, pTempData, count, 0, stride );
if( 1 != bLength ) if( 1 != bLength )
OBJ_RELEASE( pTempData ); OBJ_RELEASE( pTempData );
/* correct the ub to remove the last stride */ /* correct the ub to remove the last stride */

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

@ -140,7 +140,7 @@ ompi_datatype_t ompi_mpi_complex32 = INIT_BASIC_TYPE( DT_UNAVAILABLE, COMPLEX32
* NOTE: The order of this array *MUST* match what is listed in * NOTE: The order of this array *MUST* match what is listed in
* datatype_internal.h * datatype_internal.h
*/ */
ompi_datatype_t* ompi_ddt_basicDatatypes[DT_MAX_PREDEFINED] = { const ompi_datatype_t* ompi_ddt_basicDatatypes[DT_MAX_PREDEFINED] = {
&ompi_mpi_loop, &ompi_mpi_loop,
&ompi_mpi_end_loop, &ompi_mpi_end_loop,
&ompi_mpi_lb, &ompi_mpi_lb,
@ -214,12 +214,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]; \
ompi_datatype_t *types[2], *ptype; \ const dt_desc_t* types[2]; \
dt_desc_t* ptype; \
int bLength[2] = {1, 1}; \ int bLength[2] = {1, 1}; \
long base, displ[2]; \ long base, displ[2]; \
\ \
types[0] = ompi_ddt_basicDatatypes[MPIType1]; \ types[0] = (dt_desc_t*)ompi_ddt_basicDatatypes[MPIType1]; \
types[1] = ompi_ddt_basicDatatypes[MPIType2]; \ types[1] = (dt_desc_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; \
@ -267,7 +268,7 @@ int 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++ ) {
ompi_datatype_t* datatype = ompi_ddt_basicDatatypes[i]; dt_desc_t* datatype = (dt_desc_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;
@ -499,7 +500,7 @@ static int __dump_data_desc( dt_elem_desc_t* pDesc, int nbElems )
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
static void __dt_contain_basic_datatypes( dt_desc_t* pData ) static inline void __dt_contain_basic_datatypes( const dt_desc_t* pData )
{ {
int i; int i;
unsigned long long mask = 1; unsigned long long mask = 1;
@ -513,12 +514,10 @@ static void __dt_contain_basic_datatypes( dt_desc_t* pData )
} }
} }
void ompi_ddt_dump( dt_desc_t* data ) void ompi_ddt_dump( const dt_desc_t* pData )
{ {
dt_desc_t* pData = (dt_desc_t*)data;
printf( "Datatype %p size %ld align %d id %d length %d used %d\n\ printf( "Datatype %p 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\ true_lb %ld true_ub %ld (true_extent %ld) lb %ld ub %ld (extent %ld)\n \
nbElems %d loops %d flags %X (", nbElems %d loops %d flags %X (",
(void*)pData, pData->size, pData->align, pData->id, pData->desc.length, pData->desc.used, (void*)pData, pData->size, pData->align, pData->id, pData->desc.length, pData->desc.used,
pData->true_lb, pData->true_ub, pData->true_ub - pData->true_lb, pData->true_lb, pData->true_ub, pData->true_ub - pData->true_lb,

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

@ -26,7 +26,6 @@ int ompi_convertor_pack_general( ompi_convertor_t* pConvertor,
dt_desc_t *pData = pConvertor->pDesc; dt_desc_t *pData = pConvertor->pDesc;
dt_elem_desc_t* pElem; dt_elem_desc_t* pElem;
char* pOutput = pConvertor->pBaseBuf; char* pOutput = pConvertor->pBaseBuf;
int oCount = (pData->ub - pData->lb) * pConvertor->count;
char* pInput; char* pInput;
int iCount, rc; int iCount, rc;
uint32_t iov_count, total_bytes_converted = 0; uint32_t iov_count, total_bytes_converted = 0;
@ -738,28 +737,28 @@ ompi_convertor_pack_no_conv_contig_with_gaps( ompi_convertor_t* pConv,
extern int ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; extern int ompi_ddt_local_sizes[DT_MAX_PREDEFINED];
int ompi_convertor_init_for_send( ompi_convertor_t* pConv, int ompi_convertor_init_for_send( ompi_convertor_t* pConv,
uint32_t flags, uint32_t flags,
dt_desc_t* dt, const dt_desc_t* datatype,
int count, int count,
void* pUserBuf, const void* pUserBuf,
int starting_pos, int starting_pos,
memalloc_fct_t allocfn ) memalloc_fct_t allocfn )
{ {
OBJ_RETAIN( dt ); OBJ_RETAIN( datatype );
if( pConv->pDesc != dt ) { if( pConv->pDesc != datatype ) {
pConv->pDesc = dt; pConv->pDesc = (dt_desc_t*)datatype;
if( pConv->pStack != NULL ) free( pConv->pStack ); if( pConv->pStack != NULL ) free( pConv->pStack );
pConv->pStack = NULL; pConv->pStack = NULL;
} }
if( pConv->pStack == NULL ) { if( pConv->pStack == NULL ) {
pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (dt->btypes[DT_LOOP] + 3) ); pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (datatype->btypes[DT_LOOP] + 3) );
pConv->stack_pos = 0; /* just to be sure */ pConv->stack_pos = 0; /* just to be sure */
} }
pConv->flags = CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS; /* by default set to homogeneous */ pConv->flags = CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS; /* by default set to homogeneous */
pConv->pBaseBuf = pUserBuf; pConv->pBaseBuf = (void*)pUserBuf;
pConv->available_space = count * (dt->ub - dt->lb); pConv->available_space = count * (datatype->ub - datatype->lb);
pConv->count = count; pConv->count = count;
pConv->pFunctions = ompi_ddt_copy_functions; pConv->pFunctions = ompi_ddt_copy_functions;
pConv->converted = 0; pConv->converted = 0;
@ -768,9 +767,9 @@ int ompi_convertor_init_for_send( ompi_convertor_t* pConv,
/* Just to avoid complaint from the compiler */ /* Just to avoid complaint from the compiler */
pConv->fAdvance = ompi_convertor_pack_general; pConv->fAdvance = ompi_convertor_pack_general;
pConv->fAdvance = ompi_convertor_pack_homogeneous_with_memcpy; pConv->fAdvance = ompi_convertor_pack_homogeneous_with_memcpy;
if( dt->flags & DT_FLAG_CONTIGUOUS ) { if( datatype->flags & DT_FLAG_CONTIGUOUS ) {
pConv->flags |= DT_FLAG_CONTIGUOUS; pConv->flags |= DT_FLAG_CONTIGUOUS;
if( (pConv->pDesc->ub - pConv->pDesc->lb) == (long)pConv->pDesc->size ) if( (datatype->ub - datatype->lb) == (long)datatype->size )
pConv->fAdvance = ompi_convertor_pack_no_conv_contig; pConv->fAdvance = ompi_convertor_pack_no_conv_contig;
else else
pConv->fAdvance = ompi_convertor_pack_no_conv_contig_with_gaps; pConv->fAdvance = ompi_convertor_pack_no_conv_contig_with_gaps;
@ -813,7 +812,7 @@ static void ompi_convertor_destruct( ompi_convertor_t* pConv )
OBJ_CLASS_INSTANCE(ompi_convertor_t, ompi_object_t, ompi_convertor_construct, ompi_convertor_destruct ); OBJ_CLASS_INSTANCE(ompi_convertor_t, ompi_object_t, ompi_convertor_construct, ompi_convertor_destruct );
inline int ompi_convertor_copy( ompi_convertor_t* pSrcConv, ompi_convertor_t* pDestConv ) inline int ompi_convertor_copy( const ompi_convertor_t* pSrcConv, ompi_convertor_t* pDestConv )
{ {
pDestConv->remoteArch = pSrcConv->remoteArch; pDestConv->remoteArch = pSrcConv->remoteArch;
pDestConv->flags = pSrcConv->flags; pDestConv->flags = pSrcConv->flags;
@ -830,7 +829,7 @@ inline int ompi_convertor_copy( ompi_convertor_t* pSrcConv, ompi_convertor_t* pD
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
ompi_convertor_t* ompi_convertor_get_copy( ompi_convertor_t* pConvertor ) ompi_convertor_t* ompi_convertor_get_copy( const ompi_convertor_t* pConvertor )
{ {
ompi_convertor_t* pDestConv = OBJ_NEW(ompi_convertor_t); ompi_convertor_t* pDestConv = OBJ_NEW(ompi_convertor_t);
(void)ompi_convertor_copy( pConvertor, pDestConv ); (void)ompi_convertor_copy( pConvertor, pDestConv );
@ -838,7 +837,7 @@ ompi_convertor_t* ompi_convertor_get_copy( ompi_convertor_t* pConvertor )
} }
/* Actually we suppose that we can only do receiver side conversion */ /* Actually we suppose that we can only do receiver side conversion */
int ompi_convertor_get_packed_size( ompi_convertor_t* pConv, uint32_t* pSize ) int ompi_convertor_get_packed_size( const ompi_convertor_t* pConv, uint32_t* pSize )
{ {
int ddt_size = 0; int ddt_size = 0;
@ -849,7 +848,7 @@ int ompi_convertor_get_packed_size( ompi_convertor_t* pConv, uint32_t* pSize )
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_convertor_get_unpacked_size( ompi_convertor_t* pConv, uint32_t* pSize ) int ompi_convertor_get_unpacked_size( const ompi_convertor_t* pConv, uint32_t* pSize )
{ {
int i; int i;
dt_desc_t* pData = pConv->pDesc; dt_desc_t* pData = pConv->pDesc;

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

@ -25,85 +25,86 @@
* - communicator * - communicator
* Returns: - MPI_SUCCESS or error code * Returns: - MPI_SUCCESS or error code
*/ */
int ompi_ddt_sndrcv(void *sbuf, int scount, MPI_Datatype sdtype, void *rbuf, int ompi_ddt_sndrcv( void *sbuf, int scount, const ompi_datatype_t* sdtype, void *rbuf,
int rcount, MPI_Datatype rdtype, int tag, MPI_Comm comm) int rcount, const ompi_datatype_t* rdtype, int tag, MPI_Comm comm )
{ {
int err; int err;
unsigned int size; ompi_convertor_t *send_convertor, *recv_convertor;
int rank; struct iovec iov;
int position = 0; int length, completed;
ompi_convertor_t *local_convertor; uint32_t max_data, iov_count;
ompi_request_t *req; int32_t freeAfter;
/* If same datatypes used, just copy. */ /* First check if we really have something to do */
if( 0 == (rcount * scount) ) {
if( (0 == rcount) && (0 != scount) )
return MPI_ERR_TRUNCATE;
return MPI_SUCCESS;
}
/* If same datatypes used, just copy. */
if (sdtype == rdtype) {
max_data = ( scount < rcount ? scount : rcount );
ompi_ddt_copy_content_same_ddt(rdtype, max_data, (char*)rbuf, (char*)sbuf);
if( scount > rcount )
return MPI_ERR_TRUNCATE;
return MPI_SUCCESS;
}
if (sdtype == rdtype) { /* If receive packed. */
if (scount <= rcount) {
ompi_ddt_copy_content_same_ddt(rdtype, scount, (char *) rbuf,
(char *) sbuf);
err = MPI_SUCCESS;
} else {
err = MPI_ERR_TRUNCATE;
}
}
/* If receive packed. */ else if (rdtype == MPI_PACKED) {
send_convertor = OBJ_NEW(ompi_convertor_t);
ompi_convertor_init_for_send( send_convertor, 0, sdtype, scount, sbuf, 0, NULL );
else if (rdtype == MPI_PACKED) { iov_count = 1;
local_convertor = OBJ_NEW(ompi_convertor_t); iov.iov_len = rcount;
ompi_convertor_init_for_send( local_convertor, 0, sdtype, iov.iov_base = rbuf;
scount, NULL, 0, NULL ); max_data = ( iov.iov_len > (scount * sdtype->size) ? (scount * sdtype->size) : iov.iov_len );
err = ompi_convertor_get_packed_size(local_convertor, &size);
OBJ_RELEASE(local_convertor);
if( OMPI_SUCCESS != err ) {
return err;
}
if( (int)size <= rcount ) { err = ompi_convertor_pack( send_convertor, &iov, &iov_count, &max_data, &freeAfter );
err = MPI_Pack(sbuf, scount, sdtype, if( max_data < (uint32_t)rcount )
rbuf, rcount, &position, MPI_COMM_WORLD); err = MPI_ERR_TRUNCATE;
} else { OBJ_RELEASE( send_convertor );
err = MPI_ERR_TRUNCATE; }
}
}
/* If send packed. */ /* If send packed. */
else if (sdtype == MPI_PACKED) { else if (sdtype == MPI_PACKED) {
local_convertor = OBJ_NEW(ompi_convertor_t); recv_convertor = OBJ_NEW(ompi_convertor_t);
ompi_convertor_init_for_send(local_convertor, 0, rdtype, ompi_convertor_init_for_recv( recv_convertor, 0, rdtype, rcount, rbuf, 0, NULL );
rcount, NULL, 0, NULL );
err = ompi_convertor_get_packed_size(local_convertor, &size);
OBJ_RELEASE(local_convertor);
if( OMPI_SUCCESS != err ) {
return err;
}
if( scount <= (int)size ) { iov_count = 1;
err = MPI_Unpack(sbuf, scount, &position, iov.iov_len = scount;
rbuf, rcount, rdtype, iov.iov_base = sbuf;
MPI_COMM_WORLD); max_data = ( iov.iov_len < (rcount * rdtype->size) ? iov.iov_len : (rcount * rdtype->size) );
} else {
err = MPI_ERR_TRUNCATE;
}
}
/* Let the PML handle it (i.e., do a normal send/recv) */ err = ompi_convertor_unpack( recv_convertor, &iov, &iov_count, &max_data, &freeAfter );
if( scount > (int32_t)(rcount * rdtype->size) )
err = MPI_ERR_TRUNCATE;
OBJ_RELEASE( recv_convertor );
}
else { iov.iov_len = length = 64 * 1024;
rank = ompi_comm_rank(comm); iov.iov_base = (void*)malloc( length * sizeof(char) );
err = mca_pml.pml_irecv(rbuf, rcount, rdtype, rank, tag, comm, &req);
if (MPI_SUCCESS != err) {
return err;
}
err = mca_pml.pml_send(sbuf, scount, sdtype, rank, tag,
MCA_PML_BASE_SEND_STANDARD, comm);
if (MPI_SUCCESS != err) {
return err;
}
err = ompi_request_wait(&req, MPI_STATUS_IGNORE);
}
return err; send_convertor = OBJ_NEW(ompi_convertor_t);
recv_convertor = OBJ_NEW(ompi_convertor_t);
ompi_convertor_init_for_send( send_convertor, 0, sdtype, scount, sbuf, 0, NULL );
ompi_convertor_init_for_recv( recv_convertor, 0, rdtype, rcount, rbuf, 0, NULL );
completed = 0;
while( !completed ) {
iov.iov_len = length;
iov_count = 1;
max_data = length;
completed |= ompi_convertor_pack( send_convertor, &iov, &iov_count, &max_data, &freeAfter );
completed |= ompi_convertor_unpack( recv_convertor, &iov, &iov_count, &max_data, &freeAfter );
}
free( iov.iov_base );
OBJ_RELEASE( send_convertor );
OBJ_RELEASE( recv_convertor );
return ( (scount * sdtype->size) <= (rcount * rdtype->size) ? MPI_SUCCESS : MPI_ERR_TRUNCATE );
} }

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

@ -9,7 +9,7 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
void ompi_ddt_dump_stack( dt_stack_t* pStack, int stack_pos, dt_elem_desc_t* pDesc, char* name ) void ompi_ddt_dump_stack( const dt_stack_t* pStack, int stack_pos, const dt_elem_desc_t* pDesc, const char* name )
{ {
printf( "\nStack %p stack_pos %d name %s\n", (void*)pStack, stack_pos, name ); printf( "\nStack %p stack_pos %d name %s\n", (void*)pStack, stack_pos, name );
for( ;stack_pos >= 0; stack_pos-- ) { for( ;stack_pos >= 0; stack_pos-- ) {
@ -592,25 +592,25 @@ int ompi_convertor_need_buffers( ompi_convertor_t* pConvertor )
extern int ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; extern int ompi_ddt_local_sizes[DT_MAX_PREDEFINED];
int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, uint32_t flags, int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, uint32_t flags,
dt_desc_t* pData, int count, const dt_desc_t* datatype, int count,
void* pUserBuf, int starting_point, const void* pUserBuf, int starting_point,
memalloc_fct_t allocfn ) memalloc_fct_t allocfn )
{ {
OBJ_RETAIN( pData ); OBJ_RETAIN( datatype );
if( pConv->pDesc != pData ) { if( pConv->pDesc != datatype ) {
pConv->pDesc = pData; pConv->pDesc = (dt_desc_t*)datatype;
pConv->flags = CONVERTOR_RECV; pConv->flags = CONVERTOR_RECV;
if( pConv->pStack != NULL ) free( pConv->pStack ); if( pConv->pStack != NULL ) free( pConv->pStack );
pConv->pStack = NULL; pConv->pStack = NULL;
} }
if( pConv->pStack == NULL ) { if( pConv->pStack == NULL ) {
pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (pData->btypes[DT_LOOP] + 3) ); pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (datatype->btypes[DT_LOOP] + 3) );
pConv->stack_pos = 0; pConv->stack_pos = 0;
} }
pConv->flags = CONVERTOR_RECV | CONVERTOR_HOMOGENEOUS; pConv->flags = CONVERTOR_RECV | CONVERTOR_HOMOGENEOUS;
pConv->pBaseBuf = pUserBuf; pConv->pBaseBuf = (void*)pUserBuf;
pConv->available_space = count * (pData->ub - pData->lb); pConv->available_space = count * (datatype->ub - datatype->lb);
pConv->count = count; pConv->count = count;
pConv->pFunctions = ompi_ddt_copy_functions; pConv->pFunctions = ompi_ddt_copy_functions;
pConv->converted = 0; pConv->converted = 0;
@ -620,7 +620,7 @@ int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, uint32_t flags,
pConv->memAlloc_fn = allocfn; pConv->memAlloc_fn = allocfn;
/* TODO: work only on homogeneous architectures */ /* TODO: work only on homogeneous architectures */
if( pData->flags & DT_FLAG_CONTIGUOUS ) { if( datatype->flags & DT_FLAG_CONTIGUOUS ) {
pConv->flags |= DT_FLAG_CONTIGUOUS; pConv->flags |= DT_FLAG_CONTIGUOUS;
pConv->fAdvance = ompi_convertor_unpack_homogeneous_contig; pConv->fAdvance = ompi_convertor_unpack_homogeneous_contig;
} }
@ -638,7 +638,7 @@ int ompi_convertor_init_for_recv( ompi_convertor_t* pConv, uint32_t flags,
* positive = number of basic elements inside * positive = number of basic elements inside
* negative = some error occurs * negative = some error occurs
*/ */
int ompi_ddt_get_element_count( dt_desc_t* pData, int iSize ) int ompi_ddt_get_element_count( const dt_desc_t* datatype, int iSize )
{ {
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 */
@ -646,22 +646,22 @@ int ompi_ddt_get_element_count( dt_desc_t* pData, int iSize )
int rc, nbElems = 0; int rc, nbElems = 0;
int stack_pos = 0; int stack_pos = 0;
DUMP( "dt_count_elements( %p, %d )\n", (void*)pData, iSize ); DUMP( "dt_count_elements( %p, %d )\n", (void*)datatype, iSize );
pStack = alloca( sizeof(pStack) * (pData->btypes[DT_LOOP] + 2) ); pStack = alloca( sizeof(pStack) * (datatype->btypes[DT_LOOP] + 2) );
pStack->count = 1; pStack->count = 1;
pStack->index = -1; pStack->index = -1;
pStack->end_loop = pData->desc.used; pStack->end_loop = datatype->desc.used;
pStack->disp = 0; pStack->disp = 0;
pos_desc = 0; pos_desc = 0;
DUMP_STACK( pStack, stack_pos, pData->desc.desc, "starting" ); DUMP_STACK( pStack, stack_pos, datatype->desc.desc, "starting" );
DUMP( "remember position on stack %d last_elem at %d\n", stack_pos, pos_desc ); DUMP( "remember position on stack %d last_elem at %d\n", stack_pos, pos_desc );
DUMP( "top stack info {index = %d, count = %d}\n", DUMP( "top stack info {index = %d, count = %d}\n",
pStack->index, pStack->count ); pStack->index, pStack->count );
next_loop: next_loop:
while( pos_desc >= 0 ) { while( pos_desc >= 0 ) {
if( pData->desc.desc[pos_desc].type == DT_END_LOOP ) { /* end of the current loop */ if( datatype->desc.desc[pos_desc].type == DT_END_LOOP ) { /* end of the current loop */
if( --(pStack->count) == 0 ) { /* end of loop */ if( --(pStack->count) == 0 ) { /* end of loop */
stack_pos--; stack_pos--;
pStack--; pStack--;
@ -670,29 +670,29 @@ int ompi_ddt_get_element_count( dt_desc_t* pData, int iSize )
} }
pos_desc = pStack->index; pos_desc = pStack->index;
if( pos_desc == -1 ) if( pos_desc == -1 )
pStack->disp += (pData->ub - pData->lb); pStack->disp += (datatype->ub - datatype->lb);
else else
pStack->disp += pData->desc.desc[pos_desc].extent; pStack->disp += datatype->desc.desc[pos_desc].extent;
pos_desc++; pos_desc++;
goto next_loop; goto next_loop;
} }
if( pData->desc.desc[pos_desc].type == DT_LOOP ) { if( datatype->desc.desc[pos_desc].type == DT_LOOP ) {
do { do {
PUSH_STACK( pStack, stack_pos, pos_desc, pData->desc.desc[pos_desc].count, PUSH_STACK( pStack, stack_pos, pos_desc, datatype->desc.desc[pos_desc].count,
0, pos_desc + pData->desc.desc[pos_desc].disp ); 0, pos_desc + datatype->desc.desc[pos_desc].disp );
pos_desc++; pos_desc++;
} while( pData->desc.desc[pos_desc].type == DT_LOOP ); /* let's start another loop */ } while( datatype->desc.desc[pos_desc].type == DT_LOOP ); /* let's start another loop */
DUMP_STACK( pStack, stack_pos, pData->desc.desc, "advance loops" ); DUMP_STACK( pStack, stack_pos, datatype->desc.desc, "advance loops" );
goto next_loop; goto next_loop;
} }
/* now here we have a basic datatype */ /* now here we have a basic datatype */
type = pData->desc.desc[pos_desc].type; type = datatype->desc.desc[pos_desc].type;
rc = pData->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size; rc = datatype->desc.desc[pos_desc].count * ompi_ddt_basicDatatypes[type]->size;
if( rc >= iSize ) { if( rc >= iSize ) {
nbElems += iSize / ompi_ddt_basicDatatypes[type]->size; nbElems += iSize / ompi_ddt_basicDatatypes[type]->size;
break; break;
} }
nbElems += pData->desc.desc[pos_desc].count; nbElems += datatype->desc.desc[pos_desc].count;
iSize -= rc; iSize -= rc;
pos_desc++; /* advance to the next data */ pos_desc++; /* advance to the next data */
@ -702,8 +702,8 @@ int ompi_ddt_get_element_count( dt_desc_t* pData, int iSize )
return nbElems; return nbElems;
} }
int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count, int ompi_ddt_copy_content_same_ddt( const dt_desc_t* datatype, int count,
char* pDestBuf, char* pSrcBuf ) char* pDestBuf, const char* pSrcBuf )
{ {
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 */
@ -720,15 +720,15 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
/* If we have to copy a contiguous datatype then simply /* If we have to copy a contiguous datatype then simply
* do a memcpy. * do a memcpy.
*/ */
if( (pData->flags & DT_FLAG_CONTIGUOUS) == DT_FLAG_CONTIGUOUS ) { if( (datatype->flags & DT_FLAG_CONTIGUOUS) == DT_FLAG_CONTIGUOUS ) {
long extent = (pData->ub - pData->lb); long extent = (datatype->ub - datatype->lb);
if( (long)pData->size == extent ) { /* all contiguous */ if( (long)datatype->size == extent ) { /* all contiguous */
int total_length = pData->size * count; int total_length = datatype->size * count;
lastLength = 128 * 1024; lastLength = 128 * 1024;
if( lastLength > total_length ) lastLength = total_length; if( lastLength > total_length ) lastLength = total_length;
while( total_length > 0 ) { while( total_length > 0 ) {
OMPI_DDT_SAFEGUARD_POINTER( pDestBuf, lastLength, OMPI_DDT_SAFEGUARD_POINTER( pDestBuf, lastLength,
pDestBuf, pData, count ); pDestBuf, datatype, count );
MEMCPY( pDestBuf, pSrcBuf, lastLength ); MEMCPY( pDestBuf, pSrcBuf, lastLength );
pDestBuf += lastLength; pDestBuf += lastLength;
pSrcBuf += lastLength; pSrcBuf += lastLength;
@ -737,9 +737,9 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
} }
} else { } else {
for( pos_desc = 0; pos_desc < count; pos_desc++ ) { for( pos_desc = 0; pos_desc < count; pos_desc++ ) {
OMPI_DDT_SAFEGUARD_POINTER( pDestBuf, pData->size, OMPI_DDT_SAFEGUARD_POINTER( pDestBuf, datatype->size,
pDestBuf, pData, count ); pDestBuf, datatype, count );
MEMCPY( pDestBuf, pSrcBuf, pData->size ); MEMCPY( pDestBuf, pSrcBuf, datatype->size );
pDestBuf += extent; pDestBuf += extent;
pSrcBuf += extent; pSrcBuf += extent;
} }
@ -747,18 +747,18 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
return 0; return 0;
} }
pStack = alloca( sizeof(pStack) * (pData->btypes[DT_LOOP] + 1) ); pStack = alloca( sizeof(pStack) * (datatype->btypes[DT_LOOP] + 1) );
pStack->count = count; pStack->count = count;
pStack->index = -1; pStack->index = -1;
pStack->disp = 0; pStack->disp = 0;
pos_desc = 0; pos_desc = 0;
if( pData->opt_desc.desc != NULL ) { if( datatype->opt_desc.desc != NULL ) {
pElems = pData->opt_desc.desc; pElems = datatype->opt_desc.desc;
pStack->end_loop = pData->opt_desc.used; pStack->end_loop = datatype->opt_desc.used;
} else { } else {
pElems = pData->desc.desc; pElems = datatype->desc.desc;
pStack->end_loop = pData->desc.used; pStack->end_loop = datatype->desc.used;
} }
DUMP_STACK( pStack, stack_pos, pElems, "starting" ); DUMP_STACK( pStack, stack_pos, pElems, "starting" );
@ -774,7 +774,7 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
} }
pos_desc = pStack->index; pos_desc = pStack->index;
if( pos_desc == -1 ) if( pos_desc == -1 )
pStack->disp += (pData->ub - pData->lb); pStack->disp += (datatype->ub - datatype->lb);
else else
pStack->disp += pElems[pos_desc].extent; pStack->disp += pElems[pos_desc].extent;
pos_desc++; pos_desc++;
@ -794,7 +794,7 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
lastLength += pElems[pos_desc].count * ompi_ddt_basicDatatypes[type]->size; lastLength += pElems[pos_desc].count * ompi_ddt_basicDatatypes[type]->size;
} else { } else {
OMPI_DDT_SAFEGUARD_POINTER( pDestBuf + lastDisp, lastLength, OMPI_DDT_SAFEGUARD_POINTER( pDestBuf + lastDisp, lastLength,
pDestBuf, pData, count ); pDestBuf, datatype, count );
MEMCPY( pDestBuf + lastDisp, pSrcBuf + lastDisp, lastLength ); MEMCPY( pDestBuf + lastDisp, pSrcBuf + lastDisp, lastLength );
lastDisp = pStack->disp + pElems[pos_desc].disp; lastDisp = pStack->disp + pElems[pos_desc].disp;
lastLength = pElems[pos_desc].count * ompi_ddt_basicDatatypes[type]->size; lastLength = pElems[pos_desc].count * ompi_ddt_basicDatatypes[type]->size;
@ -805,7 +805,7 @@ int ompi_ddt_copy_content_same_ddt( dt_desc_t* pData, int count,
end_loop: end_loop:
if( lastLength != 0 ) { if( lastLength != 0 ) {
OMPI_DDT_SAFEGUARD_POINTER( pDestBuf + lastDisp, lastLength, OMPI_DDT_SAFEGUARD_POINTER( pDestBuf + lastDisp, lastLength,
pDestBuf, pData, count ); pDestBuf, datatype, count );
MEMCPY( pDestBuf + lastDisp, pSrcBuf + lastDisp, lastLength ); MEMCPY( pDestBuf + lastDisp, pSrcBuf + lastDisp, lastLength );
} }
/* cleanup the stack */ /* cleanup the stack */

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

@ -11,10 +11,10 @@
#include <stdlib.h> #include <stdlib.h>
int ompi_convertor_create_stack_with_pos( ompi_convertor_t* pConvertor, int ompi_convertor_create_stack_with_pos( ompi_convertor_t* pConvertor,
int starting_point, int* sizes ); int starting_point, const int* sizes );
static inline size_t static inline size_t
ompi_convertor_compute_remote_size( ompi_datatype_t* pData, int* sizes ) ompi_convertor_compute_remote_size( const ompi_datatype_t* pData, const int* sizes )
{ {
uint32_t i; uint32_t i;
size_t length = 0; size_t length = 0;
@ -26,7 +26,7 @@ ompi_convertor_compute_remote_size( ompi_datatype_t* pData, int* sizes )
} }
int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor,
int starting_point, int* sizes ) int starting_point, const int* sizes )
{ {
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 */