X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/933849e1079bf5389d6a38447d49cbe5cc65101d..414839787a24ee470f3124f95659a5f6569a2cd5:/src/smpi/colls/smpi_coll.cpp diff --git a/src/smpi/colls/smpi_coll.cpp b/src/smpi/colls/smpi_coll.cpp index c8c322e5d9..cf22e98031 100644 --- a/src/smpi/colls/smpi_coll.cpp +++ b/src/smpi/colls/smpi_coll.cpp @@ -1,6 +1,6 @@ /* smpi_coll.c -- various optimized routing for collectives */ -/* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -13,15 +13,17 @@ #include "smpi_request.hpp" #include "xbt/config.hpp" +#include #include +#include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI collectives."); -namespace simgrid { -namespace smpi { +namespace simgrid::smpi { std::map, std::less<>> smpi_coll_descriptions( - {{std::string("gather"), + {{"gather", {{"default", "gather default collective", (void*)gather__default}, {"ompi", "gather ompi collective", (void*)gather__ompi}, {"ompi_basic_linear", "gather ompi_basic_linear collective", (void*)gather__ompi_basic_linear}, @@ -243,6 +245,29 @@ std::vector* colls::get_smpi_coll_descriptions(const s return &iter->second; } +std::string colls::get_smpi_coll_help() +{ + size_t max_name_len = + std::accumulate(begin(smpi_coll_descriptions), end(smpi_coll_descriptions), 0, [](auto len, auto const& coll) { + return std::max(len, std::accumulate(begin(coll.second), end(coll.second), 0, [](auto len, auto const& descr) { + return std::max(len, descr.name.length()); + })); + }); + std::ostringstream oss; + std::string title = "Available collective algorithms (select them with \"smpi/collective_name:algo_name\"):"; + oss << title << '\n' << std::setfill('=') << std::setw(title.length() + 1) << '\n'; + for (auto const& [coll, algos] : smpi_coll_descriptions) { + std::string line = "Collective: \"" + coll + "\""; + oss << line << '\n' << std::setfill('-') << std::setw(line.length() + 1) << '\n'; + oss << std::setfill(' ') << std::left; + for (auto const& [name, descr, _] : algos) + oss << " " << std::setw(max_name_len) << name << " " << descr << "\n"; + oss << std::right << '\n'; + } + oss << "Please see https://simgrid.org/doc/latest/app_smpi.html#available-algorithms for more information.\n"; + return oss.str(); +} + static s_mpi_coll_description_t* find_coll_description(const std::string& collective, const std::string& algo) { std::vector* table = colls::get_smpi_coll_descriptions(collective); @@ -259,7 +284,8 @@ static s_mpi_coll_description_t* find_coll_description(const std::string& collec std::string name_list = table->at(0).name; for (unsigned long i = 1; i < table->size(); i++) name_list = name_list + ", " + table->at(i).name; - xbt_die("Collective '%s' has no algorithm '%s'! Valid algorithms: %s.", collective.c_str(), algo.c_str(), name_list.c_str()); + xbt_die("Collective '%s' has no algorithm '%s'! Valid algorithms: %s. Please use --help-coll for details.", + collective.c_str(), algo.c_str(), name_list.c_str()); } int (*colls::gather)(const void* send_buff, int send_count, MPI_Datatype send_type, void* recv_buff, int recv_count, @@ -482,5 +508,4 @@ int colls::alltoallw(const void* sendbuf, const int* sendcounts, const int* send return Request::wait(&request, MPI_STATUS_IGNORE); } -} -} +} // namespace simgrid::smpi