From: Christian Heinrich Date: Thu, 28 Jun 2018 10:40:11 +0000 (+0200) Subject: [SMPI] Colls: Move description & name for colls to std::string X-Git-Tag: v3_21~612 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4443c1a30c45a0727ffeb75f45c04854083d109e?hp=6e0df0c4cb4b49fb4b82e8beafa39cd6d475bf9a [SMPI] Colls: Move description & name for colls to std::string --- diff --git a/src/smpi/colls/smpi_automatic_selector.cpp b/src/smpi/colls/smpi_automatic_selector.cpp index 8c90b96415..333c8e6bb1 100644 --- a/src/smpi/colls/smpi_automatic_selector.cpp +++ b/src/smpi/colls/smpi_automatic_selector.cpp @@ -29,10 +29,10 @@ int min_coll = -1, global_coll = -1; \ int i; \ double buf_in, buf_out, max_min = DBL_MAX; \ - for (i = 0; Colls::mpi_coll_##cat##_description[i].name; i++) { \ - if (not strcmp(Colls::mpi_coll_##cat##_description[i].name, "automatic")) \ + for (i = 0; not Colls::mpi_coll_##cat##_description[i].name.empty(); i++) { \ + if (Colls::mpi_coll_##cat##_description[i].name == "automatic") \ continue; \ - if (not strcmp(Colls::mpi_coll_##cat##_description[i].name, "default")) \ + if (Colls::mpi_coll_##cat##_description[i].name == "default") \ continue; \ Coll_barrier_default::barrier(comm); \ TRACE_AUTO_COLL(cat) \ @@ -58,11 +58,11 @@ } \ if (comm->rank() == 0) { \ XBT_WARN("For rank 0, the quickest was %s : %f , but global was %s : %f at max", \ - Colls::mpi_coll_##cat##_description[min_coll].name, time_min, \ - Colls::mpi_coll_##cat##_description[global_coll].name, max_min); \ + Colls::mpi_coll_##cat##_description[min_coll].name.c_str(), time_min, \ + Colls::mpi_coll_##cat##_description[global_coll].name.c_str(), max_min); \ } else \ XBT_WARN("The quickest %s was %s on rank %d and took %f", #cat, \ - Colls::mpi_coll_##cat##_description[min_coll].name, comm->rank(), time_min); \ + Colls::mpi_coll_##cat##_description[min_coll].name.c_str(), comm->rank(), time_min); \ return (min_coll != -1) ? MPI_SUCCESS : MPI_ERR_INTERN; \ } diff --git a/src/smpi/colls/smpi_coll.cpp b/src/smpi/colls/smpi_coll.cpp index e167de885c..b67212c666 100644 --- a/src/smpi/colls/smpi_coll.cpp +++ b/src/smpi/colls/smpi_coll.cpp @@ -32,49 +32,49 @@ void (*Colls::smpi_coll_cleanup_callback)(); /* these arrays must be nullptr terminated */ s_mpi_coll_description_t Colls::mpi_coll_gather_description[] = { - COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_allgather_description[] = { - COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_allgatherv_description[] = { - COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_allreduce_description[] ={ - COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_reduce_scatter_description[] = { - COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_scatter_description[] ={ - COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_barrier_description[] ={ - COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_alltoall_description[] = { - COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_alltoallv_description[] = { - COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_bcast_description[] = { - COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; s_mpi_coll_description_t Colls::mpi_coll_reduce_description[] = { - COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} }; + COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA), {"", "", nullptr} }; /** Displays the long description of all registered models, and quit */ void Colls::coll_help(const char *category, s_mpi_coll_description_t * table) { XBT_WARN("Long description of the %s models accepted by this simulator:\n", category); - for (int i = 0; table[i].name; i++) - XBT_WARN(" %s: %s\n", table[i].name, table[i].description); + for (int i = 0; not table[i].name.empty(); i++) + XBT_WARN(" %s: %s\n", table[i].name.c_str(), table[i].description.c_str()); } int Colls::find_coll_description(s_mpi_coll_description_t* table, std::string name, const char* desc) { - for (int i = 0; table[i].name; i++) + for (int i = 0; not table[i].name.empty(); i++) if (name == table[i].name) { - if (strcmp(table[i].name,"default")) - XBT_INFO("Switch to algorithm %s for collective %s",table[i].name,desc); + if (table[i].name != "default") + XBT_INFO("Switch to algorithm %s for collective %s",table[i].name.c_str(),desc); return i; } - if (not table[0].name) + if (table[0].name.empty()) xbt_die("No collective is valid for '%s'! This is a bug.", name.c_str()); - std::string name_list = std::string(table[0].name); - for (int i = 1; table[i].name; i++) + std::string name_list = table[0].name; + for (int i = 1; not table[i].name.empty(); i++) name_list = name_list + ", " + table[i].name; xbt_die("Collective '%s' is invalid! Valid collectives are: %s.", name.c_str(), name_list.c_str()); diff --git a/src/smpi/include/smpi_coll.hpp b/src/smpi/include/smpi_coll.hpp index 0d7a9d94fc..a88a16b863 100644 --- a/src/smpi/include/smpi_coll.hpp +++ b/src/smpi/include/smpi_coll.hpp @@ -83,8 +83,8 @@ namespace simgrid{ namespace smpi{ struct s_mpi_coll_description_t { - const char *name; - const char *description; + std::string name; + std::string description; void *coll; };