Commit e595d1ec authored by Min Si's avatar Min Si Committed by Pavan Balaji
Browse files

Added lower-bound tests in mtest datatype routine.



The original mtest routine only generated datatype tests with zero
lower-bound. This patch added a test for every derived datatype that
checks datatype structure with non-zero lower-bound.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 6155592f
......@@ -623,9 +623,10 @@ static int MTestTypeSubarrayCheckbuf(MTestDatatype * mtype)
* nblock: Number of blocks.
* blocklen: Number of elements in each block. The total number of elements in
* this datatype is set as (nblock * blocklen).
* lb: Lower bound of the new datatype (ignored).
* oldtype: Datatype of element.
*/
static int MTestTypeContiguousCreate(int nblock, int blocklen, int stride,
static int MTestTypeContiguousCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -667,9 +668,10 @@ static int MTestTypeContiguousCreate(int nblock, int blocklen, int stride,
* nblock: Number of blocks.
* blocklen: Number of elements in each block.
* stride: Strided number of elements between blocks.
* lb: Lower bound of the new datatype (ignored).
* oldtype: Datatype of element.
*/
static int MTestTypeVectorCreate(int nblock, int blocklen, int stride,
static int MTestTypeVectorCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -715,9 +717,10 @@ static int MTestTypeVectorCreate(int nblock, int blocklen, int stride,
* nblock: Number of blocks.
* blocklen: Number of elements in each block.
* stride: Strided number of elements between blocks.
* lb: Lower bound of the new datatype (ignored).
* oldtype: Datatype of element.
*/
static int MTestTypeHvectorCreate(int nblock, int blocklen, int stride,
static int MTestTypeHvectorCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -766,9 +769,10 @@ static int MTestTypeHvectorCreate(int nblock, int blocklen, int stride,
* blocklen: Number of elements in each block. Each block has the same length.
* stride: Strided number of elements between two adjacent blocks. The
* displacement of each block is set as (index of current block * stride).
* lb: Lower bound of the new datatype.
* oldtype: Datatype of element.
*/
static int MTestTypeIndexedCreate(int nblock, int blocklen, int stride,
static int MTestTypeIndexedCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -794,8 +798,8 @@ static int MTestTypeIndexedCreate(int nblock, int blocklen, int stride,
mtype->nblock = nblock;
for (i = 0; i < nblock; i++) {
mtype->index[i] = blocklen;
mtype->displs[i] = stride * i; /*stride between the start of two blocks */
mtype->displ_in_bytes[i] = stride * i * mtype->basesize;
mtype->displs[i] = lb + stride * i; /*stride between the start of two blocks */
mtype->displ_in_bytes[i] = (lb + stride * i) * mtype->basesize;
}
/* Indexed uses displacement in oldtypes */
......@@ -807,8 +811,8 @@ static int MTestTypeIndexedCreate(int nblock, int blocklen, int stride,
MTestPrintError(merr);
memset(type_name, 0, sizeof(type_name));
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride)", typename_prefix, "index", nblock,
blocklen, stride);
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride %d lb)", typename_prefix,
"index", nblock, blocklen, stride, lb);
merr = MPI_Type_set_name(mtype->datatype, (char *) type_name);
if (merr)
MTestPrintError(merr);
......@@ -828,9 +832,10 @@ static int MTestTypeIndexedCreate(int nblock, int blocklen, int stride,
* blocklen: Number of elements in each block. Each block has the same length.
* stride: Strided number of elements between two adjacent blocks. The byte
* displacement of each block is set as (index of current block * stride * size of oldtype).
* lb: Lower bound of the new datatype.
* oldtype: Datatype of element.
*/
static inline int MTestTypeHindexedCreate(int nblock, int blocklen, int stride,
static inline int MTestTypeHindexedCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -855,7 +860,7 @@ static inline int MTestTypeHindexedCreate(int nblock, int blocklen, int stride,
mtype->nblock = nblock;
for (i = 0; i < nblock; i++) {
mtype->index[i] = blocklen;
mtype->displ_in_bytes[i] = stride * i * mtype->basesize;
mtype->displ_in_bytes[i] = (lb + stride * i) * mtype->basesize;
}
/* Hindexed uses displacement in bytes */
......@@ -868,8 +873,8 @@ static inline int MTestTypeHindexedCreate(int nblock, int blocklen, int stride,
MTestPrintError(merr);
memset(type_name, 0, sizeof(type_name));
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride)", typename_prefix, "hindex", nblock,
blocklen, stride);
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride %d lb)", typename_prefix,
"hindex", nblock, blocklen, stride, lb);
merr = MPI_Type_set_name(mtype->datatype, (char *) type_name);
if (merr)
MTestPrintError(merr);
......@@ -891,9 +896,10 @@ static inline int MTestTypeHindexedCreate(int nblock, int blocklen, int stride,
* blocklen: Number of elements in each block.
* stride: Strided number of elements between two adjacent blocks. The
* displacement of each block is set as (index of current block * stride).
* lb: Lower bound of the new datatype.
* oldtype: Datatype of element.
*/
static int MTestTypeIndexedBlockCreate(int nblock, int blocklen, int stride,
static int MTestTypeIndexedBlockCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -918,8 +924,8 @@ static int MTestTypeIndexedBlockCreate(int nblock, int blocklen, int stride,
mtype->nblock = nblock;
mtype->blksize = blocklen * mtype->basesize;
for (i = 0; i < nblock; i++) {
mtype->displs[i] = stride * i;
mtype->displ_in_bytes[i] = stride * i * mtype->basesize;
mtype->displs[i] = lb + stride * i;
mtype->displ_in_bytes[i] = (lb + stride * i) * mtype->basesize;
}
/* Indexed-block uses displacement in oldtypes */
......@@ -932,8 +938,8 @@ static int MTestTypeIndexedBlockCreate(int nblock, int blocklen, int stride,
MTestPrintError(merr);
memset(type_name, 0, sizeof(type_name));
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride)", typename_prefix, "index_block",
nblock, blocklen, stride);
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride %d lb)", typename_prefix,
"index_block", nblock, blocklen, stride, lb);
merr = MPI_Type_set_name(mtype->datatype, (char *) type_name);
if (merr)
MTestPrintError(merr);
......@@ -953,9 +959,10 @@ static int MTestTypeIndexedBlockCreate(int nblock, int blocklen, int stride,
* blocklen: Number of elements in each block.
* stride: Strided number of elements between two adjacent blocks. The byte
* displacement of each block is set as (index of current block * stride * size of oldtype).
* lb: Lower bound of the new datatype.
* oldtype: Datatype of element.
*/
static int MTestTypeHindexedBlockCreate(int nblock, int blocklen, int stride,
static int MTestTypeHindexedBlockCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -979,7 +986,7 @@ static int MTestTypeHindexedBlockCreate(int nblock, int blocklen, int stride,
mtype->nblock = nblock;
mtype->blksize = blocklen * mtype->basesize;
for (i = 0; i < nblock; i++) {
mtype->displ_in_bytes[i] = stride * i * mtype->basesize;
mtype->displ_in_bytes[i] = (lb + stride * i) * mtype->basesize;
}
/* Hindexed-block uses displacement in bytes */
......@@ -992,8 +999,8 @@ static int MTestTypeHindexedBlockCreate(int nblock, int blocklen, int stride,
MTestPrintError(merr);
memset(type_name, 0, sizeof(type_name));
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride)", typename_prefix, "hindex_block",
nblock, blocklen, stride);
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride %d lb)", typename_prefix,
"hindex_block", nblock, blocklen, stride, lb);
merr = MPI_Type_set_name(mtype->datatype, (char *) type_name);
if (merr)
MTestPrintError(merr);
......@@ -1014,9 +1021,10 @@ static int MTestTypeHindexedBlockCreate(int nblock, int blocklen, int stride,
* blocklen: Number of elements in each block. Each block has the same length.
* stride: Strided number of elements between two adjacent blocks. The byte
* displacement of each block is set as (index of current block * stride * size of oldtype).
* lb: Lower bound of the new datatype.
* oldtype: Datatype of element. Each block has the same oldtype.
*/
static int MTestTypeStructCreate(int nblock, int blocklen, int stride,
static int MTestTypeStructCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -1042,7 +1050,7 @@ static int MTestTypeStructCreate(int nblock, int blocklen, int stride,
mtype->nblock = nblock;
mtype->blksize = blocklen * mtype->basesize;
for (i = 0; i < nblock; i++) {
mtype->displ_in_bytes[i] = stride * i * mtype->basesize;
mtype->displ_in_bytes[i] = (lb + stride * i) * mtype->basesize;
mtype->old_datatypes[i] = oldtype;
mtype->index[i] = blocklen;
}
......@@ -1057,8 +1065,8 @@ static int MTestTypeStructCreate(int nblock, int blocklen, int stride,
MTestPrintError(merr);
memset(type_name, 0, sizeof(type_name));
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride)", typename_prefix, "struct",
nblock, blocklen, stride);
sprintf(type_name, "%s %s (%d nblock %d blocklen %d stride %d lb)", typename_prefix,
"struct", nblock, blocklen, stride, lb);
merr = MPI_Type_set_name(mtype->datatype, (char *) type_name);
if (merr)
MTestPrintError(merr);
......@@ -1074,15 +1082,15 @@ static int MTestTypeStructCreate(int nblock, int blocklen, int stride,
/*
* Setup order-C subarray type info and handlers.
*
* A 2D-subarray datatype specified with order C and located in the left-middle
* A 2D-subarray datatype specified with order C and located in the right-bottom
* of the full array is created by using input parameters.
* Number of elements in the dimensions of the full array: {nblock + 2, stride}
* Number of elements in the dimensions of the full array: {nblock + lb, stride}
* Number of elements in the dimensions of the subarray: {nblock, blocklen}
* Starting of the subarray in each dimension: {1, stride - blocklen}
* order: MPI_ORDER_C
* oldtype: oldtype
*/
static int MTestTypeSubArrayOrderCCreate(int nblock, int blocklen, int stride,
static int MTestTypeSubArrayOrderCCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -1095,11 +1103,11 @@ static int MTestTypeSubArrayOrderCCreate(int nblock, int blocklen, int stride,
if (merr)
MTestPrintError(merr);
mtype->arr_sizes[0] = nblock + 2; /* {row, col} */
mtype->arr_sizes[0] = nblock + lb; /* {row, col} */
mtype->arr_sizes[1] = stride;
mtype->arr_subsizes[0] = nblock; /* {row, col} */
mtype->arr_subsizes[1] = blocklen;
mtype->arr_starts[0] = 1; /* {row, col} */
mtype->arr_starts[0] = lb; /* {row, col} */
mtype->arr_starts[1] = stride - blocklen;
mtype->order = MPI_ORDER_C;
......@@ -1131,15 +1139,15 @@ static int MTestTypeSubArrayOrderCCreate(int nblock, int blocklen, int stride,
/*
* Setup order-Fortran subarray type info and handlers.
*
* A 2D-subarray datatype specified with order Fortran and located in the middle
* A 2D-subarray datatype specified with order Fortran and located in the right
* bottom of the full array is created by using input parameters.
* Number of elements in the dimensions of the full array: {stride, nblock + 2}
* Number of elements in the dimensions of the full array: {stride, nblock + lb}
* Number of elements in the dimensions of the subarray: {blocklen, nblock}
* Starting of the subarray in each dimension: {stride - blocklen, 1}
* Starting of the subarray in each dimension: {stride - blocklen, lb}
* order: MPI_ORDER_FORTRAN
* oldtype: oldtype
*/
static int MTestTypeSubArrayOrderFortranCreate(int nblock, int blocklen, int stride,
static int MTestTypeSubArrayOrderFortranCreate(int nblock, int blocklen, int stride, int lb,
MPI_Datatype oldtype, const char *typename_prefix,
MTestDatatype * mtype)
{
......@@ -1154,11 +1162,11 @@ static int MTestTypeSubArrayOrderFortranCreate(int nblock, int blocklen, int str
/* use the same row and col as that of order-c subarray for buffer
* initialization and check because we access buffer in order-c */
mtype->arr_sizes[0] = nblock + 2; /* {row, col} */
mtype->arr_sizes[0] = nblock + lb; /* {row, col} */
mtype->arr_sizes[1] = stride;
mtype->arr_subsizes[0] = nblock; /* {row, col} */
mtype->arr_subsizes[1] = blocklen;
mtype->arr_starts[0] = 1; /* {row, col} */
mtype->arr_starts[0] = lb; /* {row, col} */
mtype->arr_starts[1] = stride - blocklen;
mtype->order = MPI_ORDER_FORTRAN;
......
......@@ -50,7 +50,7 @@ enum MTEST_MIN_DERIVED_DT {
MTEST_MIN_DDT_MAX
};
typedef int (*MTestDdtCreator) (int, int, int, MPI_Datatype, const char *, MTestDatatype *);
typedef int (*MTestDdtCreator) (int, int, int, int, MPI_Datatype, const char *, MTestDatatype *);
extern void MTestTypeCreatorInit(MTestDdtCreator * creators);
extern void MTestTypeMinCreatorInit(MTestDdtCreator * creators);
......
......@@ -53,6 +53,7 @@ static int verbose = 0; /* Message level (0 is none) */
* S count & L block length & S stride
* L count & S block length & L stride
* S count & L block length & L stride
* S count & L block length & S stride & S lower-bound
*
* How to add a new structure for each datatype:
* 1. Add structure definition in function MTestDdtStructDefine.
......@@ -95,7 +96,8 @@ static int datatype_index = 0;
/* ------------------------------------------------------------------------ */
/* Routine and internal parameters to define the range of datatype tests */
/* ------------------------------------------------------------------------ */
#define MTEST_DDT_NUM_SUBTESTS 4 /* 4 kinds of derived datatype structure */
#define MTEST_DDT_NUM_SUBTESTS 5 /* 5 kinds of derived datatype structure */
static MTestDdtCreator mtestDdtCreators[MTEST_DDT_MAX];
static int MTEST_BDT_START_IDX = -1;
......@@ -236,12 +238,15 @@ static inline void MTestInitDatatypeEnv()
/* Routine to define various sets of blocklen/count/stride for derived datatypes. */
/* ------------------------------------------------------------------------------ */
static inline int MTestDdtStructDefine(int ddt_index, MPI_Aint tot_count, MPI_Aint *count,
MPI_Aint *blen, MPI_Aint *stride, MPI_Aint *align_tot_count)
static inline int MTestDdtStructDefine(int ddt_index, MPI_Aint tot_count, MPI_Aint * count,
MPI_Aint * blen, MPI_Aint * stride,
MPI_Aint * align_tot_count, MPI_Aint * lb)
{
int merr = 0;
int ddt_c_st;
MPI_Aint _short = 0, _align_tot_count = 0, _count = 0, _blen = 0, _stride = 0;
MPI_Aint _lb = 0;
ddt_c_st = ddt_index % MTEST_DDT_NUM_SUBTESTS;
/* Get short value according to user specified tot_count.
......@@ -283,6 +288,13 @@ static inline int MTestDdtStructDefine(int ddt_index, MPI_Aint tot_count, MPI_Ai
_blen = _short;
_stride = _blen * 10;
break;
case 4:
/* Large block length with lb */
_count = _short;
_blen = _align_tot_count / _short;
_stride = _blen * 2;
_lb = _short / 2; /* make sure lb < blen */
break;
default:
/* Undefined index */
merr = 1;
......@@ -293,6 +305,7 @@ static inline int MTestDdtStructDefine(int ddt_index, MPI_Aint tot_count, MPI_Ai
*count = _count;
*blen = _blen;
*stride = _stride;
*lb = _lb;
return merr;
}
......@@ -366,7 +379,7 @@ static inline int MTestGetSendDerivedDatatypes(MTestDatatype * sendtype,
int merr = 0;
int ddt_datatype_index, ddt_c_dt;
MPI_Count tsize = 1;
MPI_Aint blen, stride, count, align_tot_count;;
MPI_Aint blen, stride, count, align_tot_count, lb;
MPI_Datatype old_type = MPI_DOUBLE;
/* Check index */
......@@ -381,7 +394,7 @@ static inline int MTestGetSendDerivedDatatypes(MTestDatatype * sendtype,
/* Set datatype structure */
merr = MTestDdtStructDefine(ddt_datatype_index, tot_count, &count, &blen,
&stride, &align_tot_count);
&stride, &align_tot_count, &lb);
if (merr) {
printf("Wrong index: global %d, send %d send-ddt %d, or undefined ddt structure in %s\n",
datatype_index, ddt_datatype_index, ddt_c_dt, __FUNCTION__);
......@@ -390,7 +403,7 @@ static inline int MTestGetSendDerivedDatatypes(MTestDatatype * sendtype,
}
/* Create send datatype */
merr = mtestDdtCreators[ddt_c_dt] (count, blen, stride, old_type, "send", sendtype);
merr = mtestDdtCreators[ddt_c_dt] (count, blen, stride, lb, old_type, "send", sendtype);
if (merr)
return merr;
......@@ -412,7 +425,7 @@ static inline int MTestGetRecvDerivedDatatypes(MTestDatatype * sendtype,
int merr = 0;
int ddt_datatype_index, ddt_c_dt;
MPI_Count tsize;
MPI_Aint blen, stride, count, align_tot_count;
MPI_Aint blen, stride, count, align_tot_count, lb;
MPI_Datatype old_type = MPI_DOUBLE;
/* Check index */
......@@ -427,7 +440,7 @@ static inline int MTestGetRecvDerivedDatatypes(MTestDatatype * sendtype,
/* Set datatype structure */
merr = MTestDdtStructDefine(ddt_datatype_index, tot_count, &count, &blen,
&stride, &align_tot_count);
&stride, &align_tot_count, &lb);
if (merr) {
printf("Wrong index: global %d, recv %d recv-ddt %d, or undefined ddt structure in %s\n",
datatype_index, ddt_datatype_index, ddt_c_dt, __FUNCTION__);
......@@ -435,7 +448,7 @@ static inline int MTestGetRecvDerivedDatatypes(MTestDatatype * sendtype,
}
/* Create receive datatype */
merr = mtestDdtCreators[ddt_c_dt] (count, blen, stride, old_type, "recv", recvtype);
merr = mtestDdtCreators[ddt_c_dt] (count, blen, stride, lb, old_type, "recv", recvtype);
if (merr)
return merr;
......@@ -504,15 +517,19 @@ int MTestGetDatatypes(MTestDatatype * sendtype, MTestDatatype * recvtype, MPI_Ai
if (verbose >= 2 && datatype_index > 0) {
MPI_Count ssize, rsize;
MPI_Aint slb, rlb, sextent, rextent;
const char *sendtype_nm = MTestGetDatatypeName(sendtype);
const char *recvtype_nm = MTestGetDatatypeName(recvtype);
MPI_Type_size_x(sendtype->datatype, &ssize);
MPI_Type_size_x(recvtype->datatype, &rsize);
MTestPrintfMsg(2, "Get datatypes: send = %s(size %d count %d basesize %d), "
"recv = %s(size %d count %d basesize %d), tot_count=%d\n",
sendtype_nm, ssize, sendtype->count, sendtype->basesize,
recvtype_nm, rsize, recvtype->count, recvtype->basesize,
MPI_Type_get_extent(sendtype->datatype, &slb, &sextent);
MPI_Type_get_extent(recvtype->datatype, &rlb, &rextent);
MTestPrintfMsg(2, "Get datatypes: send = %s(size %d ext %ld lb %ld count %d basesize %d), "
"recv = %s(size %d ext %ld lb %ld count %d basesize %d), tot_count=%d\n",
sendtype_nm, ssize, sextent, slb, sendtype->count, sendtype->basesize,
recvtype_nm, rsize, rextent, rlb, recvtype->count, recvtype->basesize,
tot_count);
fflush(stdout);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment