From: Paul Bédaride Date: Wed, 10 Apr 2013 13:38:23 +0000 (+0200) Subject: Add test for mpi alltoallv X-Git-Tag: v3_9_90~412^2~16 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/febfa21172b9cc827797849be5c0923aa399717f Add test for mpi alltoallv --- diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 909e6dd194..7e05a67a98 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -383,6 +383,9 @@ if(NOT enable_memcheck) simple bruck basic_linear pairwise) ADD_TEST(smpi-alltoall-coll-${ALLTOALL_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/alltoall:${ALLTOALL_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/alltoall_coll.tesh) ENDFOREACH() + FOREACH (ALLTOALLV_COLL default) + ADD_TEST(smpi-alltoallv-coll-${ALLTOALLV_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/alltoallv:${ALLTOALLV_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/alltoallv_coll.tesh) + ENDFOREACH() FOREACH (BCAST_COLL default arrival_nb arrival_pattern_aware arrival_pattern_aware_wait arrival_scatter binomial_tree flattree flattree_pipeline NTSB NTSL NTSL_Isend scatter_LR_allgather scatter_rdb_allgather SMP_binary SMP_binomial SMP_linear) diff --git a/src/include/smpi/smpi_interface.h b/src/include/smpi/smpi_interface.h index 294cd09c96..6c5852fc5f 100644 --- a/src/include/smpi/smpi_interface.h +++ b/src/include/smpi/smpi_interface.h @@ -40,7 +40,7 @@ XBT_PUBLIC_DATA(int (*mpi_coll_allreduce_fun) MPI_Op op, MPI_Comm comm)); -/** \ingroup MPI alltoallcollectives +/** \ingroup MPI alltoall * \brief The list of all available alltoall collectives */ XBT_PUBLIC_DATA(s_mpi_coll_description_t) mpi_coll_alltoall_description[]; @@ -48,6 +48,14 @@ XBT_PUBLIC_DATA(int (*mpi_coll_alltoall_fun) (void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm)); +/** \ingroup MPI alltoallv + * \brief The list of all available alltoallv collectives + */ +XBT_PUBLIC_DATA(s_mpi_coll_description_t) mpi_coll_alltoallv_description[]; +XBT_PUBLIC_DATA(int (*mpi_coll_alltoallv_fun) + (void *, int*, int*, MPI_Datatype, void *, int*, int*, MPI_Datatype, + MPI_Comm)); + /** \ingroup MPI bcast * \brief The list of all available bcast collectives diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 433195f9db..80df369c3e 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -258,6 +258,10 @@ static void _sg_cfg_cb__coll_alltoall(const char *name, int pos) { _sg_cfg_cb__coll("alltoall", mpi_coll_alltoall_description, name, pos); } +static void _sg_cfg_cb__coll_alltoallv(const char *name, int pos) +{ + _sg_cfg_cb__coll("alltoallv", mpi_coll_alltoallv_description, name, pos); +} static void _sg_cfg_cb__coll_bcast(const char *name, int pos) { _sg_cfg_cb__coll("bcast", mpi_coll_bcast_description, name, pos); @@ -771,6 +775,12 @@ void sg_config_init(int *argc, char **argv) xbt_cfgelm_string, &default_value, 1, 1, &_sg_cfg_cb__coll_alltoall, NULL); + default_value = xbt_strdup("default"); + xbt_cfg_register(&_sg_cfg_set, "smpi/alltoallv", + "Which collective to use for alltoallv", + xbt_cfgelm_string, &default_value, 1, 1, &_sg_cfg_cb__coll_alltoallv, + NULL); + default_value = xbt_strdup("default"); xbt_cfg_register(&_sg_cfg_set, "smpi/bcast", "Which collective to use for bcast", diff --git a/src/smpi/smpi_coll.c b/src/smpi/smpi_coll.c index 13ff3b3e30..8f0115ca78 100644 --- a/src/smpi/smpi_coll.c +++ b/src/smpi/smpi_coll.c @@ -46,6 +46,14 @@ COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; +s_mpi_coll_description_t mpi_coll_alltoallv_description[] = { + {"default", + "Ompi alltoallv default collective", + smpi_coll_basic_alltoallv}, + + {NULL, NULL, NULL} /* this array must be NULL terminated */ +}; + s_mpi_coll_description_t mpi_coll_bcast_description[] = { {"default", "allgather default collective", @@ -104,6 +112,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, int (*mpi_coll_allgather_fun)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm); int (*mpi_coll_allreduce_fun)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm); int (*mpi_coll_alltoall_fun)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm); +int (*mpi_coll_alltoallv_fun)(void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm); int (*mpi_coll_bcast_fun)(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com); int (*mpi_coll_reduce_fun)(void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 7b5a844ed1..302c3ed7bd 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -378,6 +378,12 @@ int smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[]) void*, int, MPI_Datatype, MPI_Comm)) mpi_coll_alltoall_description[alltoall_id].coll; + int alltoallv_id = find_coll_description(mpi_coll_alltoallv_description, + sg_cfg_get_string("smpi/alltoallv")); + mpi_coll_alltoallv_fun = (int (*)(void *, int*, int*, MPI_Datatype, + void*, int*, int*, MPI_Datatype, MPI_Comm)) + mpi_coll_alltoallv_description[alltoallv_id].coll; + int bcast_id = find_coll_description(mpi_coll_bcast_description, sg_cfg_get_string("smpi/bcast")); mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype, \ diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 7778277dc2..266ec5e4a8 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -14,35 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, int MPI_Init(int *argc, char ***argv) { - int allgather_id = find_coll_description(mpi_coll_allgather_description, - sg_cfg_get_string("smpi/allgather")); - mpi_coll_allgather_fun = (int (*)(void *, int, MPI_Datatype, - void*, int, MPI_Datatype, MPI_Comm)) - mpi_coll_allgather_description[allgather_id].coll; - - int allreduce_id = find_coll_description(mpi_coll_allreduce_description, - sg_cfg_get_string("smpi/allreduce")); - mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount, \ - MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)) - mpi_coll_allreduce_description[allreduce_id].coll; - - int alltoall_id = find_coll_description(mpi_coll_alltoall_description, - sg_cfg_get_string("smpi/alltoall")); - mpi_coll_alltoall_fun = (int (*)(void *, int, MPI_Datatype, - void*, int, MPI_Datatype, MPI_Comm)) - mpi_coll_alltoall_description[alltoall_id].coll; - - int bcast_id = find_coll_description(mpi_coll_bcast_description, - sg_cfg_get_string("smpi/bcast")); - mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype, \ - int root, MPI_Comm com)) - mpi_coll_bcast_description[bcast_id].coll; - - int reduce_id = find_coll_description(mpi_coll_reduce_description, - sg_cfg_get_string("smpi/reduce")); - mpi_coll_reduce_fun = (int (*)(void *buf, void *rbuf, int count, MPI_Datatype datatype, \ - MPI_Op op, int root, MPI_Comm comm)) - mpi_coll_reduce_description[reduce_id].coll; return PMPI_Init(argc, argv); } diff --git a/teshsuite/smpi/CMakeLists.txt b/teshsuite/smpi/CMakeLists.txt index ca976289c5..4c1f9683b6 100644 --- a/teshsuite/smpi/CMakeLists.txt +++ b/teshsuite/smpi/CMakeLists.txt @@ -15,7 +15,7 @@ if(enable_smpi) add_executable(alltoall2 alltoall2.c) add_executable(alltoall_basic alltoall_basic.c) add_executable(alltoall_coll alltoall_coll.c) - add_executable(alltoallv alltoallv.c) + add_executable(alltoallv_coll alltoallv_coll.c) add_executable(allreduce allreduce.c) add_executable(allreduce_coll allreduce_coll.c) add_executable(bcast bcast.c) @@ -39,7 +39,7 @@ if(enable_smpi) target_link_libraries(alltoall2 simgrid) target_link_libraries(alltoall_basic simgrid) target_link_libraries(alltoall_coll simgrid) - target_link_libraries(alltoallv simgrid) + target_link_libraries(alltoallv_coll simgrid) target_link_libraries(allreduce simgrid) target_link_libraries(allreduce_coll simgrid) target_link_libraries(bcast simgrid) @@ -97,7 +97,7 @@ set(examples_src ${CMAKE_CURRENT_SOURCE_DIR}/alltoall_coll.c ${CMAKE_CURRENT_SOURCE_DIR}/bcast_coll.c ${CMAKE_CURRENT_SOURCE_DIR}/reduce_coll.c - ${CMAKE_CURRENT_SOURCE_DIR}/alltoallv.c + ${CMAKE_CURRENT_SOURCE_DIR}/alltoallv_coll.c ${CMAKE_CURRENT_SOURCE_DIR}/get_processor_name.c ${CMAKE_CURRENT_SOURCE_DIR}/pingpong.c ${CMAKE_CURRENT_SOURCE_DIR}/bcast.c diff --git a/teshsuite/smpi/alltoallv.c b/teshsuite/smpi/alltoallv_coll.c similarity index 52% rename from teshsuite/smpi/alltoallv.c rename to teshsuite/smpi/alltoallv_coll.c index f2717b9c56..0b4c71b1f0 100644 --- a/teshsuite/smpi/alltoallv.c +++ b/teshsuite/smpi/alltoallv_coll.c @@ -44,16 +44,16 @@ <2> rdisp: (#3): [0][2][4] after MPI_Alltoallv : - <0> rbuf: (#9): [0][-1][-2][-3][-4][-5][-6][-7][-8] - <1> rbuf: (#9): [1][101][201][-3][-4][-5][-6][-7][-8] - <2> rbuf: (#9): [3][4][103][104][203][204][-6][-7][-8] + <0> rbuf: (#9): [-1][-1][-1][-1][-1][-1][-1][-1][-1] + <1> rbuf: (#9): [1][101][201][-1][-1][-1][-1][-1][-1] + <2> rbuf: (#9): [3][4][103][104][203][204][-1][-1][-1] */ static void print_buffer_int(void *buf, int len, char *msg, int rank) { int tmp, *v; - printf("**<%d> %s (#%d): ", rank, msg, len); + printf("[%d] %s (#%d): ", rank, msg, len); for (tmp = 0; tmp < len; tmp++) { v = buf; printf("[%d]", v[tmp]); @@ -67,96 +67,53 @@ int main(int argc, char **argv) { MPI_Comm comm; - int *sbuf, *rbuf, *erbuf; + int *sbuf, *rbuf; int rank, size; int *sendcounts, *recvcounts, *rdispls, *sdispls; - int i, j, *p, err; + int i; MPI_Init(&argc, &argv); - err = 0; comm = MPI_COMM_WORLD; /* Create the buffer */ MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank); - sbuf = (int *) malloc(size * size * sizeof(int)); - rbuf = (int *) malloc(size * size * sizeof(int)); - erbuf = (int *) malloc(size * size * sizeof(int)); // expected - if (!sbuf || !rbuf) { - fprintf(stderr, "Could not allocated buffers!\n"); - MPI_Abort(comm, 1); - } + sbuf = (int *) xbt_malloc(size * size * sizeof(int)); + rbuf = (int *) xbt_malloc(size * size * sizeof(int)); /* Load up the buffers */ for (i = 0; i < size * size; i++) { sbuf[i] = i + 100 * rank; - rbuf[i] = -i; - erbuf[i] = -i; + rbuf[i] = -1; } /* Create and load the arguments to alltoallv */ - sendcounts = (int *) malloc(size * sizeof(int)); - recvcounts = (int *) malloc(size * sizeof(int)); - rdispls = (int *) malloc(size * sizeof(int)); - sdispls = (int *) malloc(size * sizeof(int)); - if (!sendcounts || !recvcounts || !rdispls || !sdispls) { - fprintf(stderr, "Could not allocate arg items!\n"); - MPI_Abort(comm, 1); - } + sendcounts = (int *) xbt_malloc(size * sizeof(int)); + recvcounts = (int *) xbt_malloc(size * sizeof(int)); + rdispls = (int *) xbt_malloc(size * sizeof(int)); + sdispls = (int *) xbt_malloc(size * sizeof(int)); for (i = 0; i < size; i++) { sendcounts[i] = i; recvcounts[i] = rank; rdispls[i] = i * rank; sdispls[i] = (i * (i + 1)) / 2; } - - /* debug */ - /* - print_buffer_int( sbuf, size*size, strdup("sbuf:"),rank); - print_buffer_int( sendcounts, size, strdup("scount:"),rank); - print_buffer_int( recvcounts, size, strdup("rcount:"),rank); - print_buffer_int( sdispls, size, strdup("sdisp:"),rank); - print_buffer_int( rdispls, size, strdup("rdisp:"),rank); - */ - - - /* debug : erbuf */ - /* debug - for (i=0; i got %d expected %d for %dth\n", - rank, p[j], (i * (i + 1)) / 2 + j, j); - err++; - } - } - } + print_buffer_int( rbuf, size*size, strdup("rbuf:"),rank); - /* Summary */ - if (err > 0) { - printf("<%d> Alltoallv test: failure (%d errors).\n", rank, err); - } + MPI_Barrier(MPI_COMM_WORLD); if (0 == rank) { - printf("* Alltoallv TEST COMPLETE.\n"); + printf("Alltoallv TEST COMPLETE.\n"); } free(sdispls); free(rdispls); @@ -165,7 +122,6 @@ int main(int argc, char **argv) free(rbuf); free(sbuf); - MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return 0; }