1
1

changes required for tcp testing

This commit was SVN r1086.
Этот коммит содержится в:
Tim Woodall 2004-04-23 20:53:32 +00:00
родитель ba91bcf530
Коммит b9a0e941b4
3 изменённых файлов: 283 добавлений и 258 удалений

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

@ -344,7 +344,6 @@ int lam_convertor_init_for_send( lam_convertor_t* pConv, unsigned int flags,
pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (dt->btypes[DT_LOOP] + 2) ); pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (dt->btypes[DT_LOOP] + 2) );
pConv->stack_pos = 0; /* just to be sure */ pConv->stack_pos = 0; /* just to be sure */
} }
lam_create_stack_with_pos( pConv, local_starting_point, local_sizes );
pConv->pBaseBuf = pUserBuf; pConv->pBaseBuf = pUserBuf;
pConv->available_space = count * (dt->ub - dt->lb); pConv->available_space = count * (dt->ub - dt->lb);
@ -364,6 +363,7 @@ int lam_convertor_init_for_send( lam_convertor_t* pConv, unsigned int flags,
free( pConv->freebuf ); free( pConv->freebuf );
pConv->freebuf = NULL; pConv->freebuf = NULL;
} }
lam_create_stack_with_pos( pConv, local_starting_point, local_sizes );
return 0; return 0;
} }

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

@ -471,7 +471,6 @@ int lam_convertor_init_for_recv( lam_convertor_t* pConv, unsigned int flags,
pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (pData->btypes[DT_LOOP] + 2) ); pConv->pStack = (dt_stack_t*)malloc(sizeof(dt_stack_t) * (pData->btypes[DT_LOOP] + 2) );
pConv->stack_pos = 0; pConv->stack_pos = 0;
} }
lam_create_stack_with_pos( pConv, starting_point, local_sizes );
pConv->pBaseBuf = pUserBuf; pConv->pBaseBuf = pUserBuf;
pConv->available_space = count * (pData->ub - pData->lb); pConv->available_space = count * (pData->ub - pData->lb);
@ -486,6 +485,7 @@ int lam_convertor_init_for_recv( lam_convertor_t* pConv, unsigned int flags,
} else { } else {
pConv->fAdvance = lam_convertor_unpack_homogeneous; pConv->fAdvance = lam_convertor_unpack_homogeneous;
} }
lam_create_stack_with_pos( pConv, starting_point, local_sizes );
return 0; return 0;
} }

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

@ -1,256 +1,281 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* -*- Mode: C; c-basic-offset:4 ; -*- */
#include "lam_config.h" #include "lam_config.h"
#include "datatype.h" #include "datatype.h"
#include "datatype_internal.h" #include "datatype_internal.h"
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> #include <alloca.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>
static inline long GET_LOOP_DISP( dt_elem_desc_t* _pElem ) static inline long GET_LOOP_DISP( dt_elem_desc_t* _pElem )
{ {
while( _pElem->type == DT_LOOP ) ++_pElem; while( _pElem->type == DT_LOOP ) ++_pElem;
return _pElem->disp; return _pElem->disp;
} }
int lam_create_stack_with_pos( lam_convertor_t* pConvertor, int lam_create_stack_with_pos( lam_convertor_t* pConvertor,
int starting_point, int* sizes ); int starting_point, int* sizes );
int lam_create_stack_with_pos_general( lam_convertor_t* pConvertor, int lam_create_stack_with_pos_general( lam_convertor_t* pConvertor,
int starting_point, int* sizes ); int starting_point, int* sizes );
int lam_create_stack_with_pos_general( lam_convertor_t* pConvertor, int lam_create_stack_with_pos_general( lam_convertor_t* pConvertor,
int starting_point, int* sizes ) int starting_point, 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 */
int type, lastLength = 0; int type, lastLength = 0;
long totalDisp; long totalDisp;
lam_datatype_t* pData = pConvertor->pDesc; lam_datatype_t* pData = pConvertor->pDesc;
int* remoteLength; int* remoteLength;
int loop_length; int loop_length;
int resting_place = starting_point; int resting_place = starting_point;
dt_elem_desc_t* pElems; dt_elem_desc_t* pElems;
if( starting_point == 0 ) { if( starting_point == 0 ) {
pConvertor->stack_pos = 1; pConvertor->stack_pos = 1;
pConvertor->pStack[0].index = 0; pConvertor->pStack[0].index = 0;
pConvertor->pStack[0].count = pConvertor->count; pConvertor->pStack[0].count = pConvertor->count;
pConvertor->pStack[0].disp = 0; pConvertor->pStack[0].disp = 0;
/* first here we should select which data representation will be used for /* first here we should select which data representation will be used for
* this operation: normal one or the optimized version ? */ * this operation: normal one or the optimized version ? */
if( pData->opt_desc.used > 0 ) { if( pData->opt_desc.used > 0 ) {
pElems = pData->opt_desc.desc; pElems = pData->opt_desc.desc;
pConvertor->pStack[0].end_loop = pData->opt_desc.used; pConvertor->pStack[0].end_loop = pData->opt_desc.used;
} else { } else {
pElems = pData->desc.desc; pElems = pData->desc.desc;
pConvertor->pStack[0].end_loop = pData->desc.used; pConvertor->pStack[0].end_loop = pData->desc.used;
} }
pConvertor->pStack[1].index = 0; pConvertor->pStack[1].index = 0;
pConvertor->pStack[1].count = pElems->count; pConvertor->pStack[1].count = pElems->count;
pConvertor->pStack[1].disp = pElems->disp; pConvertor->pStack[1].disp = pElems->disp;
pConvertor->pStack[1].end_loop = pConvertor->pStack[0].end_loop; pConvertor->pStack[1].end_loop = pConvertor->pStack[0].end_loop;
return 0; return 0;
} }
/* if the convertor continue from the last position /* if the convertor continue from the last position
* there is nothing to do. * there is nothing to do.
*/ */
if( pConvertor->bConverted == starting_point ) return 0; if( pConvertor->bConverted == starting_point ) return 0;
remoteLength = (int*)alloca( sizeof(int) * pConvertor->pDesc->btypes[DT_LOOP] ); remoteLength = (int*)alloca( sizeof(int) * pConvertor->pDesc->btypes[DT_LOOP] );
pStack = pConvertor->pStack; pStack = pConvertor->pStack;
pStack->count = pConvertor->count; pStack->count = pConvertor->count;
pStack->index = -1; pStack->index = -1;
pStack->end_loop = pData->desc.used - 1; pStack->end_loop = pData->desc.used - 1;
pStack->disp = 0; pStack->disp = 0;
pos_desc = 0; pos_desc = 0;
remoteLength[0] = 0; /* initial value set to ZERO */ remoteLength[0] = 0; /* initial value set to ZERO */
pConvertor->stack_pos = 0; pConvertor->stack_pos = 0;
pElems = &(pData->desc.desc[pos_desc]); pElems = &(pData->desc.desc[pos_desc]);
next_loop: next_loop:
totalDisp = pStack->disp; totalDisp = pStack->disp;
loop_length = remoteLength[pConvertor->stack_pos]; loop_length = remoteLength[pConvertor->stack_pos];
while( pConvertor->stack_pos >= 0 ) { while( pConvertor->stack_pos >= 0 ) {
if( pElems->type == DT_END_LOOP ) { /* end of the current loop */ if( pElems->type == DT_END_LOOP ) { /* end of the current loop */
/* now we know the length of the loop. We can compute /* now we know the length of the loop. We can compute
* if the the starting_position will happend in one of the * if the the starting_position will happend in one of the
* iterations of this loop. * iterations of this loop.
*/ */
remoteLength[pConvertor->stack_pos] = loop_length; remoteLength[pConvertor->stack_pos] = loop_length;
if( (loop_length * pStack->count) > resting_place ) { if( (loop_length * pStack->count) > resting_place ) {
/* OK here we stop in this loop. First save the loop /* OK here we stop in this loop. First save the loop
* on the stack, then save the position of the last * on the stack, then save the position of the last
* data */ * data */
int cnt = resting_place / loop_length; int cnt = resting_place / loop_length;
pStack->count -= cnt; pStack->count -= cnt;
resting_place -= cnt * loop_length; resting_place -= cnt * loop_length;
pStack->disp += cnt * pElems->extent; pStack->disp += cnt * pElems->extent;
pConvertor->bConverted += (cnt * loop_length); pConvertor->bConverted += (cnt * loop_length);
goto next_loop; goto next_loop;
} }
/* Not in this loop. Cleanup the stack and advance to the /* Not in this loop. Cleanup the stack and advance to the
* next data description. * next data description.
*/ */
pConvertor->stack_pos--; pConvertor->stack_pos--;
pStack--; pStack--;
pos_desc++; pos_desc++;
pElems++; pElems++;
goto next_loop; goto next_loop;
} }
if( pElems->type == DT_LOOP ) { if( pElems->type == DT_LOOP ) {
remoteLength[pConvertor->stack_pos + 1] = 0; remoteLength[pConvertor->stack_pos + 1] = 0;
totalDisp = pElems->disp; totalDisp = pElems->disp;
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc,
pData->desc.desc[pos_desc].count, pData->desc.desc[pos_desc].count,
totalDisp, pos_desc + pElems->disp ); totalDisp, pos_desc + pElems->disp );
pos_desc++; pos_desc++;
pElems++; pElems++;
loop_length = 0; /* starting a new loop */ loop_length = 0; /* starting a new loop */
goto next_loop; goto next_loop;
} }
/* now here we have a basic datatype */ /* now here we have a basic datatype */
type = pElems->type; type = pElems->type;
lastLength = pElems->count * basicDatatypes[type].size; lastLength = pElems->count * basicDatatypes[type].size;
if( resting_place > lastLength ) { if( resting_place > lastLength ) {
resting_place -= lastLength; resting_place -= lastLength;
loop_length += lastLength; loop_length += lastLength;
} else { } else {
int cnt = resting_place / basicDatatypes[type].size; int cnt = resting_place / basicDatatypes[type].size;
resting_place -= cnt * basicDatatypes[type].size; resting_place -= cnt * basicDatatypes[type].size;
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc,
pElems->count - cnt, pElems->count - cnt,
totalDisp + pElems->disp + cnt * pElems->extent, totalDisp + pElems->disp + cnt * pElems->extent,
pos_desc ); pos_desc );
pConvertor->bConverted += (starting_point - resting_place); pConvertor->bConverted += (starting_point - resting_place);
return 0; return 0;
} }
pos_desc++; /* advance to the next data */ pos_desc++; /* advance to the next data */
pElems++; pElems++;
} }
return 0; return 0;
} }
/* This function works for homogeneous architectures. As we keep /* This function works for homogeneous architectures. As we keep
* trace of the size inside the loop in the END_LOOP element * trace of the size inside the loop in the END_LOOP element
* we can easily jump directly where we need. It works only * we can easily jump directly where we need. It works only
* because we can split a basic data in the middle if we * because we can split a basic data in the middle if we
* have a optimized representation. * have a optimized representation.
*/ */
int lam_create_stack_with_pos( lam_convertor_t* pConvertor, int lam_create_stack_with_pos( lam_convertor_t* pConvertor,
int starting_point, int* sizes ) int starting_point, 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 */
int type, lastLength = 0; int type, lastLength = 0;
long totalDisp; long totalDisp;
lam_datatype_t* pData = pConvertor->pDesc; lam_datatype_t* pData = pConvertor->pDesc;
int* remoteLength; int* remoteLength;
int loop_length; int loop_length;
int resting_place = starting_point; int resting_place = starting_point;
dt_elem_desc_t* pElems; dt_elem_desc_t* pElems;
if( starting_point == 0 ) { if( starting_point == 0 ) {
pConvertor->stack_pos = 1;
pConvertor->stack_pos = 1; pConvertor->pStack[0].index = 0;
pConvertor->pStack[0].index = 0; pConvertor->pStack[0].count = pConvertor->count;
pConvertor->pStack[0].count = pConvertor->count; pConvertor->pStack[0].disp = 0;
pConvertor->pStack[0].disp = 0; /* first here we should select which data representation will be used for
/* first here we should select which data representation will be used for * this operation: normal one or the optimized version ? */
* this operation: normal one or the optimized version ? */ if( pData->opt_desc.used > 0 ) {
if( pData->opt_desc.used > 0 ) { pElems = pData->opt_desc.desc;
pElems = pData->opt_desc.desc; pConvertor->pStack[0].end_loop = pData->opt_desc.used;
pConvertor->pStack[0].end_loop = pData->opt_desc.used; } else {
} else { pElems = pData->desc.desc;
pElems = pData->desc.desc; pConvertor->pStack[0].end_loop = pData->desc.used;
pConvertor->pStack[0].end_loop = pData->desc.used; }
} pConvertor->pStack[1].index = 0;
pConvertor->pStack[1].index = 0; pConvertor->pStack[1].count = pElems->count;
pConvertor->pStack[1].count = pElems->count; pConvertor->pStack[1].disp = pElems->disp;
pConvertor->pStack[1].disp = pElems->disp; pConvertor->pStack[1].end_loop = pConvertor->pStack[0].end_loop;
pConvertor->pStack[1].end_loop = pConvertor->pStack[0].end_loop; pConvertor->converted = 0;
return 0; pConvertor->bConverted = 0;
} return 0;
/* if the convertor continue from the last position }
* there is nothing to do. /* if the convertor continue from the last position
*/ * there is nothing to do.
if( pConvertor->bConverted == starting_point ) return 0; */
if( pConvertor->bConverted == starting_point ) return 0;
remoteLength = (int*)alloca( sizeof(int) * pConvertor->pDesc->btypes[DT_LOOP] ); if( pConvertor->flags & DT_FLAG_CONTIGUOUS ) {
pStack = pConvertor->pStack; int cnt;
pStack->count = pConvertor->count;
pStack->index = -1; cnt = starting_point / pData->size;
pStack->end_loop = pData->desc.used - 1; pConvertor->stack_pos = 1;
pStack->disp = 0; pConvertor->pStack[0].index = 0;
pos_desc = 0; pConvertor->pStack[0].count = pConvertor->count - cnt;
remoteLength[0] = 0; /* initial value set to ZERO */ pConvertor->pStack[0].disp = 0;
pConvertor->stack_pos = 0; /* first here we should select which data representation will be used for
pElems = &(pData->desc.desc[pos_desc]); * this operation: normal one or the optimized version ? */
if( pData->opt_desc.used > 0 ) {
next_loop: pElems = pData->opt_desc.desc;
totalDisp = pStack->disp; pConvertor->pStack[0].end_loop = pData->opt_desc.used;
loop_length = remoteLength[pConvertor->stack_pos]; } else {
while( pConvertor->stack_pos >= 0 ) { pElems = pData->desc.desc;
if( pElems->type == DT_END_LOOP ) { /* end of the current loop */ pConvertor->pStack[0].end_loop = pData->desc.used;
/* now we know the length of the loop. We can compute }
* if the the starting_position will happend in one of the cnt = starting_point - cnt * pData->size;
* iterations of this loop. pConvertor->pStack[1].index = 0;
*/ pConvertor->pStack[1].count = pElems->count - cnt;
remoteLength[pConvertor->stack_pos] = loop_length; pConvertor->pStack[1].disp = pElems->disp + cnt;
if( (loop_length * pStack->count) > resting_place ) { pConvertor->pStack[1].end_loop = pConvertor->pStack[0].end_loop;
/* OK here we stop in this loop. First save the loop pConvertor->bConverted = starting_point;
* on the stack, then save the position of the last return 0;
* data */ }
int cnt = resting_place / loop_length; remoteLength = (int*)alloca( sizeof(int) * pConvertor->pDesc->btypes[DT_LOOP] );
pStack->count -= cnt; pStack = pConvertor->pStack;
resting_place -= cnt * loop_length; pStack->count = pConvertor->count;
pStack->disp += cnt * pElems->extent; pStack->index = -1;
pConvertor->bConverted += (cnt * loop_length); pStack->end_loop = pData->desc.used - 1;
goto next_loop; pStack->disp = 0;
} pos_desc = 0;
/* Not in this loop. Cleanup the stack and advance to the remoteLength[0] = 0; /* initial value set to ZERO */
* next data description. pConvertor->stack_pos = 0;
*/ pElems = &(pData->desc.desc[pos_desc]);
pConvertor->stack_pos--;
pStack--; next_loop:
pos_desc++; totalDisp = pStack->disp;
pElems++; loop_length = remoteLength[pConvertor->stack_pos];
goto next_loop; while( pos_desc <= pStack->end_loop ) {
} if( pElems->type == DT_END_LOOP ) { /* end of the current loop */
if( pElems->type == DT_LOOP ) { /* now we know the length of the loop. We can compute
remoteLength[pConvertor->stack_pos + 1] = 0; * if the the starting_position will happend in one of the
totalDisp = pElems->disp; * iterations of this loop.
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, */
pData->desc.desc[pos_desc].count, remoteLength[pConvertor->stack_pos] = loop_length;
totalDisp, pos_desc + pElems->disp ); if( (loop_length * pStack->count) > resting_place ) {
pos_desc++; /* OK here we stop in this loop. First save the loop
pElems++; * on the stack, then save the position of the last
loop_length = 0; /* starting a new loop */ * data */
goto next_loop; int cnt = resting_place / loop_length;
} pStack->count -= cnt;
/* now here we have a basic datatype */ resting_place -= cnt * loop_length;
type = pElems->type; pStack->disp += cnt * pElems->extent;
lastLength = pElems->count * basicDatatypes[type].size; pConvertor->bConverted += (cnt * loop_length);
if( resting_place > lastLength ) { goto next_loop;
resting_place -= lastLength; }
loop_length += lastLength; /* Not in this loop. Cleanup the stack and advance to the
} else { * next data description.
int cnt = resting_place / basicDatatypes[type].size; */
resting_place -= cnt * basicDatatypes[type].size; pConvertor->stack_pos--;
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, pStack--;
pElems->count - cnt, pos_desc++;
totalDisp + pElems->disp + cnt * pElems->extent, pElems++;
pos_desc ); goto next_loop;
pConvertor->bConverted += (starting_point - resting_place); }
return 0; if( pElems->type == DT_LOOP ) {
} remoteLength[pConvertor->stack_pos + 1] = 0;
pos_desc++; /* advance to the next data */ totalDisp = pElems->disp;
pElems++; PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc,
} pData->desc.desc[pos_desc].count,
totalDisp, pos_desc + pElems->disp );
return 0; pos_desc++;
} pElems++;
loop_length = 0; /* starting a new loop */
goto next_loop;
}
/* now here we have a basic datatype */
type = pElems->type;
lastLength = pElems->count * basicDatatypes[type].size;
if( resting_place > lastLength ) {
resting_place -= lastLength;
loop_length += lastLength;
} else {
int cnt = resting_place / basicDatatypes[type].size;
resting_place -= cnt * basicDatatypes[type].size;
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc,
pElems->count - cnt,
totalDisp + pElems->disp + cnt * pElems->extent,
pos_desc );
pConvertor->bConverted += (starting_point - resting_place);
return 0;
}
pos_desc++; /* advance to the next data */
pElems++;
}
return 0;
}