Improuve the computation of the required space for MPI_Type_struct.
Change size_t to unsigned int, as I really need just a 32 bits integer here. This commit was SVN r1105.
Этот коммит содержится в:
родитель
daac7a1788
Коммит
152ac14685
@ -245,13 +245,13 @@ int mpich_typeub3( void )
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_double_mat( size_t N, double* mat )
|
void print_double_mat( unsigned int N, double* mat )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
double* pMat;
|
double* pMat;
|
||||||
|
|
||||||
for( i = 0; i < N; i++ ) {
|
for( i = 0; i < N; i++ ) {
|
||||||
printf( "(%4d) :", i * N * sizeof(double) );
|
printf( "(%4d) :", i * N * (int)sizeof(double) );
|
||||||
pMat = mat + i * N;
|
pMat = mat + i * N;
|
||||||
for( j = 0; j < N; j++ ) {
|
for( j = 0; j < N; j++ ) {
|
||||||
printf( "%5.1f ", *pMat );
|
printf( "%5.1f ", *pMat );
|
||||||
@ -261,7 +261,7 @@ void print_double_mat( size_t N, double* mat )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_random_upper_matrix( size_t N, double* mat )
|
int init_random_upper_matrix( unsigned int N, double* mat )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ int init_random_upper_matrix( size_t N, double* mat )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_diag_matrix( size_t N, double* mat1, double* mat2 )
|
int check_diag_matrix( unsigned int N, double* mat1, double* mat2 )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
@ -295,14 +295,14 @@ int check_diag_matrix( size_t N, double* mat1, double* mat2 )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt_desc_t* upper_matrix( size_t mat_size )
|
dt_desc_t* upper_matrix( unsigned int mat_size )
|
||||||
{
|
{
|
||||||
int *disp, i;
|
int *disp, i;
|
||||||
size_t *blocklen;
|
unsigned int *blocklen;
|
||||||
dt_desc_t* upper;
|
dt_desc_t* upper;
|
||||||
|
|
||||||
disp = (int*)malloc( sizeof(int) * mat_size );
|
disp = (int*)malloc( sizeof(int) * mat_size );
|
||||||
blocklen = (size_t*)malloc( sizeof(size_t) * mat_size );
|
blocklen = (unsigned int*)malloc( sizeof(unsigned int) * mat_size );
|
||||||
|
|
||||||
for( i = 0; i < mat_size; i++ ) {
|
for( i = 0; i < mat_size; i++ ) {
|
||||||
disp[i] = i * mat_size + i;
|
disp[i] = i * mat_size + i;
|
||||||
@ -316,14 +316,14 @@ dt_desc_t* upper_matrix( size_t mat_size )
|
|||||||
return upper;
|
return upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt_desc_t* lower_matrix( size_t mat_size )
|
dt_desc_t* lower_matrix( unsigned int mat_size )
|
||||||
{
|
{
|
||||||
int *disp, i;
|
int *disp, i;
|
||||||
size_t *blocklen;
|
unsigned int *blocklen;
|
||||||
dt_desc_t* upper;
|
dt_desc_t* upper;
|
||||||
|
|
||||||
disp = (int*)malloc( sizeof(int) * mat_size );
|
disp = (int*)malloc( sizeof(int) * mat_size );
|
||||||
blocklen = (size_t*)malloc( sizeof(size_t) * mat_size );
|
blocklen = (unsigned int*)malloc( sizeof(unsigned int) * mat_size );
|
||||||
|
|
||||||
for( i = 0; i < mat_size; i++ ) {
|
for( i = 0; i < mat_size; i++ ) {
|
||||||
disp[i] = i * mat_size;
|
disp[i] = i * mat_size;
|
||||||
@ -339,7 +339,7 @@ dt_desc_t* lower_matrix( size_t mat_size )
|
|||||||
|
|
||||||
extern long conversion_elapsed;
|
extern long conversion_elapsed;
|
||||||
|
|
||||||
int test_upper( size_t length )
|
int test_upper( unsigned int length )
|
||||||
{
|
{
|
||||||
double *mat1, *mat2, *inbuf;
|
double *mat1, *mat2, *inbuf;
|
||||||
dt_desc_t *pdt, *pdt1;
|
dt_desc_t *pdt, *pdt1;
|
||||||
@ -405,7 +405,7 @@ dt_desc_t* test_matrix_borders( unsigned int size, unsigned int width )
|
|||||||
{
|
{
|
||||||
dt_desc_t *pdt, *pdt_line;
|
dt_desc_t *pdt, *pdt_line;
|
||||||
int disp[2];
|
int disp[2];
|
||||||
size_t blocklen[2];
|
unsigned int blocklen[2];
|
||||||
|
|
||||||
disp[0] = 0;
|
disp[0] = 0;
|
||||||
blocklen[0] = width;
|
blocklen[0] = width;
|
||||||
|
@ -6,20 +6,31 @@ int lam_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
|
|||||||
dt_desc_t** pTypes, dt_desc_t** newType )
|
dt_desc_t** pTypes, dt_desc_t** newType )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long disp, endto, lastExtent, lastDisp;
|
long disp = 0, endto, lastExtent, lastDisp;
|
||||||
int lastBlock;
|
int lastBlock;
|
||||||
dt_desc_t *pdt, *lastType;
|
dt_desc_t *pdt, *lastType;
|
||||||
|
|
||||||
/* if we compute the total number of elements before we can
|
/* if we compute the total number of elements before we can
|
||||||
* avoid increasing the size of the desc array often.
|
* avoid increasing the size of the desc array often.
|
||||||
*/
|
*/
|
||||||
for( lastType = pTypes[0], lastBlock = 0, disp = 0, i = 0; i < count; i++ ) {
|
lastType = pTypes[0];
|
||||||
if( lastType == pTypes[i] ) {
|
lastBlock = pBlockLength[0];
|
||||||
|
lastExtent = lastType->ub - lastType->lb;
|
||||||
|
lastDisp = pDisp[0];
|
||||||
|
endto = pDisp[0] + lastExtent * lastBlock;
|
||||||
|
|
||||||
|
for( i = 1; i < count; i++ ) {
|
||||||
|
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
|
||||||
lastBlock += pBlockLength[i];
|
lastBlock += pBlockLength[i];
|
||||||
|
endto = lastDisp + lastBlock * lastExtent;
|
||||||
} else {
|
} else {
|
||||||
disp += lastType->desc.used;
|
disp += lastType->desc.used;
|
||||||
if( lastBlock != 1 ) disp += 2;
|
if( lastBlock > 1 ) disp += 2;
|
||||||
lastType = pTypes[i];
|
lastType = pTypes[i];
|
||||||
|
lastExtent = lastType->ub - lastType->lb;
|
||||||
lastBlock = pBlockLength[i];
|
lastBlock = pBlockLength[i];
|
||||||
|
lastDisp = pDisp[i];
|
||||||
|
endto = lastDisp + lastExtent * lastBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disp += lastType->desc.used;
|
disp += lastType->desc.used;
|
||||||
@ -33,6 +44,7 @@ int lam_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
|
|||||||
|
|
||||||
pdt = lam_ddt_create( disp );
|
pdt = lam_ddt_create( disp );
|
||||||
|
|
||||||
|
/* Do again the same loop but now add the elements */
|
||||||
for( i = 1; i < count; i++ ) {
|
for( i = 1; i < count; i++ ) {
|
||||||
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
|
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
|
||||||
lastBlock += pBlockLength[i];
|
lastBlock += pBlockLength[i];
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user