X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/da4b64609d1b4d1829801004cab5ea40ec8b22f1..50bc81a8526eb95a52e6a4b4a2ae1be94dfb24c1:/teshsuite/smpi/mpich3-test/datatype/large_type_sendrec.c diff --git a/teshsuite/smpi/mpich3-test/datatype/large_type_sendrec.c b/teshsuite/smpi/mpich3-test/datatype/large_type_sendrec.c new file mode 100644 index 0000000000..056c4a7c4c --- /dev/null +++ b/teshsuite/smpi/mpich3-test/datatype/large_type_sendrec.c @@ -0,0 +1,179 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2013 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include + +/* Defines INT32_MAX, which is not appropriate for int types. */ +#include + +/* Defines INT_MAX */ +#include + +#include + +#include +static void verbose_abort(int errorcode) +{ + /* We do not check error codes here + * because if MPI is in a really sorry state, + * all of them might fail. */ + + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + char errorstring[MPI_MAX_ERROR_STRING]; + memset(errorstring, 0, MPI_MAX_ERROR_STRING); /* optional */ + + int errorclass; + MPI_Error_class(errorcode, &errorclass); + + int resultlen; + MPI_Error_string(errorcode, errorstring, &resultlen); + + fprintf(stderr, "%d: MPI failed (%d: %s) \n", rank, errorclass, errorstring); + fflush(stderr); /* almost certainly redundant with the following... */ + + MPI_Abort(MPI_COMM_WORLD, errorclass); + + return; +} +#define MPI_ASSERT(rc) \ + do { if ((rc)!=MPI_SUCCESS) verbose_abort(rc); } while (0) + +int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, + MPI_Datatype * newtype); + +#define BIGMPI_MAX INT_MAX + +/* + * Synopsis + * + * int Type_contiguous_x(MPI_Count count, + * MPI_Datatype oldtype, + * MPI_Datatype * newtype) + * + * Input Parameters + * + * count replication count (nonnegative integer) + * oldtype old datatype (handle) + * + * Output Parameter + * + * newtype new datatype (handle) + * + */ +int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newtype) +{ + MPI_Count c = count/BIGMPI_MAX; + MPI_Count r = count%BIGMPI_MAX; + + MPI_Datatype chunk; + MPI_ASSERT(MPI_Type_contiguous(BIGMPI_MAX, oldtype, &chunk)); + + MPI_Datatype chunks; + MPI_ASSERT(MPI_Type_contiguous(c, chunk, &chunks)); + + MPI_Datatype remainder; + MPI_ASSERT(MPI_Type_contiguous(r, oldtype, &remainder)); + + int typesize; + MPI_ASSERT(MPI_Type_size(oldtype, &typesize)); + + MPI_Aint remdisp = (MPI_Aint)c*BIGMPI_MAX*typesize; /* must explicit-cast to avoid overflow */ + int array_of_blocklengths[2] = {1,1}; + MPI_Aint array_of_displacements[2] = {0,remdisp}; + MPI_Datatype array_of_types[2] = {chunks,remainder}; + + MPI_ASSERT(MPI_Type_create_struct(2, array_of_blocklengths, array_of_displacements, array_of_types, newtype)); + MPI_ASSERT(MPI_Type_commit(newtype)); + + MPI_ASSERT(MPI_Type_free(&chunk)); + MPI_ASSERT(MPI_Type_free(&chunks)); + MPI_ASSERT(MPI_Type_free(&remainder)); + + return MPI_SUCCESS; +} + + +int main(int argc, char * argv[]) +{ + int provided; + size_t i; + MPI_Count j; + MPI_ASSERT(MPI_Init_thread(&argc, &argv, MPI_THREAD_SINGLE, &provided)); + + int rank, size; + MPI_ASSERT(MPI_Comm_rank(MPI_COMM_WORLD, &rank)); + MPI_ASSERT(MPI_Comm_size(MPI_COMM_WORLD, &size)); + + int logn = (argc>1) ? atoi(argv[1]) : 32; + size_t count = (size_t)1<