From dcf15a2f87c8964df192d059be802e3bb436c853 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 15 May 2017 16:53:23 +0200 Subject: [PATCH] mostly cosmetics --- src/kernel/context/ContextBoost.cpp | 27 +++++++-------- src/smpi/smpi_coll.hpp | 52 ++++++++++++----------------- src/smpi/smpi_utils.cpp | 7 ++-- src/xbt/parmap.cpp | 2 ++ src/xbt/xbt_main.cpp | 17 +++++----- 5 files changed, 48 insertions(+), 57 deletions(-) diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 051dc6fcda..aa1ce97a55 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -86,8 +86,8 @@ BoostContextFactory::~BoostContextFactory() #endif } -smx_context_t BoostContextFactory::create_context(std::function code, - void_pfn_smxprocess_t cleanup_func, smx_actor_t process) +smx_context_t BoostContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup_func, + smx_actor_t process) { BoostContext* context = nullptr; if (BoostContext::parallel_) @@ -140,12 +140,11 @@ BoostContext::BoostContext(std::function code, : Context(std::move(code), cleanup_func, process) { - /* if the user provided a function for the process then use it, - otherwise it is the context for maestro */ + /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ if (has_code()) { this->stack_ = SIMIX_context_stack_new(); - // We need to pass the bottom of the stack to make_fcontext, - // depending on the stack direction it may be the lower or higher address: +// We need to pass the bottom of the stack to make_fcontext, depending on the stack direction it may be the lower +// or higher address: #if PTH_STACKGROWTH == -1 void* stack = static_cast(this->stack_) + smx_context_usable_stack_size - 1; #else @@ -191,15 +190,15 @@ void BoostSerialContext::suspend() { /* determine the next context */ BoostSerialContext* next_context = nullptr; - unsigned long int i = process_index_++; + unsigned long int i = process_index_; + process_index_++; if (i < xbt_dynar_length(simix_global->process_to_run)) { /* execute the next process */ XBT_DEBUG("Run next process"); - next_context = static_cast(xbt_dynar_get_as( - simix_global->process_to_run, i, smx_actor_t)->context); - } - else { + next_context = + static_cast(xbt_dynar_get_as(simix_global->process_to_run, i, smx_actor_t)->context); + } else { /* all processes were run, return to maestro */ XBT_DEBUG("No more process to run"); next_context = static_cast(maestro_context_); @@ -230,11 +229,9 @@ void BoostParallelContext::suspend() if (next_work != nullptr) { XBT_DEBUG("Run next process"); next_context = static_cast(next_work->context); - } - else { + } else { XBT_DEBUG("No more processes to run"); - uintptr_t worker_id = - (uintptr_t) xbt_os_thread_get_specific(worker_id_key_); + uintptr_t worker_id = (uintptr_t)xbt_os_thread_get_specific(worker_id_key_); next_context = static_cast(workers_context_[worker_id]); } diff --git a/src/smpi/smpi_coll.hpp b/src/smpi/smpi_coll.hpp index 1f5dfa47c2..8410ae7ab7 100644 --- a/src/smpi/smpi_coll.hpp +++ b/src/smpi/smpi_coll.hpp @@ -36,8 +36,8 @@ static ret cat (COLL_UNPAREN args); \ #define COLL_APPLY(action, sig, name) action(sig, name) #define COLL_COMMA , -#define COLL_NOsep -#define COLL_NOTHING(...) +#define COLL_NOsep +#define COLL_NOTHING(...) #define COLL_GATHER_SIG gather, int, \ (void *send_buff, int send_count, MPI_Datatype send_type, \ @@ -90,31 +90,30 @@ typedef struct mpi_coll_description s_mpi_coll_description_t; class Colls{ public: - static XBT_PUBLIC(void) coll_help(const char *category, s_mpi_coll_description_t * table); static XBT_PUBLIC(int) find_coll_description(s_mpi_coll_description_t * table, const char *name, const char *desc); static void set_collectives(); - // for each collective type, create the set_* prototype, the description array - // and the function pointer - COLL_APPLY(COLL_DEFS,COLL_GATHER_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_ALLGATHER_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_ALLGATHERV_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_REDUCE_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_ALLREDUCE_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_REDUCE_SCATTER_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_SCATTER_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_BARRIER_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_BCAST_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_ALLTOALL_SIG,""); - COLL_APPLY(COLL_DEFS,COLL_ALLTOALLV_SIG,""); - -//These fairly unused collectives only have one implementation in SMPI - - static int gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int *recvcounts, int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm); - static int scatterv(void *sendbuf, int *sendcounts, int *displs, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); - static int scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); - static int exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); + // for each collective type, create the set_* prototype, the description array and the function pointer + COLL_APPLY(COLL_DEFS, COLL_GATHER_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_ALLGATHER_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_ALLGATHERV_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_REDUCE_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_ALLREDUCE_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_REDUCE_SCATTER_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_SCATTER_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_BARRIER_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_BCAST_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_ALLTOALL_SIG, ""); + COLL_APPLY(COLL_DEFS, COLL_ALLTOALLV_SIG, ""); + + // These fairly unused collectives only have one implementation in SMPI + static int gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, + MPI_Datatype recvtype, int root, MPI_Comm comm); + static int scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, + int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); + static int scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); + static int exscan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); static void (*smpi_coll_cleanup_callback)(); }; @@ -239,7 +238,6 @@ COLL_ALLREDUCES(COLL_PROTO, COLL_NOsep) * ALLTOALL * ************/ - #define COLL_ALLTOALLS(action, COLL_sep) \ COLL_APPLY(action, COLL_ALLTOALL_SIG, default) COLL_sep \ COLL_APPLY(action, COLL_ALLTOALL_SIG, 2dmesh) COLL_sep \ @@ -322,7 +320,6 @@ COLL_APPLY(action, COLL_BCAST_SIG, automatic) COLL_BCASTS(COLL_PROTO, COLL_NOsep) - /********** * REDUCE * **********/ @@ -368,11 +365,8 @@ COLL_APPLY(action, COLL_REDUCE_SCATTER_SIG, mvapich2) COLL_sep \ COLL_APPLY(action, COLL_REDUCE_SCATTER_SIG, impi) COLL_sep \ COLL_APPLY(action, COLL_REDUCE_SCATTER_SIG, automatic) - - COLL_REDUCE_SCATTERS(COLL_PROTO, COLL_NOsep) - /************* * SCATTER * *************/ @@ -412,8 +406,6 @@ COLL_APPLY(action, COLL_BARRIER_SIG, automatic) COLL_BARRIERS(COLL_PROTO, COLL_NOsep) - } } - #endif diff --git a/src/smpi/smpi_utils.cpp b/src/smpi/smpi_utils.cpp index 7f43538aab..91e01ced43 100644 --- a/src/smpi/smpi_utils.cpp +++ b/src/smpi/smpi_utils.cpp @@ -38,15 +38,14 @@ std::vector parse_factor(const char *smpi_coef_string) xbt_die("Malformed radical for smpi factor: '%s'", smpi_coef_string); } unsigned int iteration = 0; - for (Tokenizer::iterator factor_iter = factor_values.begin(); - factor_iter != factor_values.end(); factor_iter++, iteration++) { + for (Tokenizer::iterator factor_iter = factor_values.begin(); factor_iter != factor_values.end(); factor_iter++) { + iteration++; char *errmsg; if (factor_iter == factor_values.begin()) { /* first element */ errmsg = bprintf("Invalid factor in chunk #%zu: %%s", smpi_factor.size()+1); fact.factor = xbt_str_parse_int(factor_iter->c_str(), errmsg); - } - else { + } else { errmsg = bprintf("Invalid factor value %d in chunk #%zu: %%s", iteration, smpi_factor.size()+1); fact.values.push_back(xbt_str_parse_double(factor_iter->c_str(), errmsg)); } diff --git a/src/xbt/parmap.cpp b/src/xbt/parmap.cpp index 67ed936e31..2a1851bdf0 100644 --- a/src/xbt/parmap.cpp +++ b/src/xbt/parmap.cpp @@ -218,6 +218,8 @@ static void xbt_parmap_set_mode(xbt_parmap_t parmap, e_xbt_parmap_mode_t mode) case XBT_PARMAP_DEFAULT: THROW_IMPOSSIBLE; break; + default: + THROW_IMPOSSIBLE; } } diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 9176b29286..ce2bc71196 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -96,7 +96,7 @@ static void xbt_preinit(void) { xbt_log_preinit(); xbt_os_thread_mod_preinit(); xbt_dict_preinit(); - + srand(seed); #ifndef _WIN32 srand48(seed); @@ -106,7 +106,8 @@ static void xbt_preinit(void) { static void xbt_postexit(void) { - if(!_sg_do_clean_atexit) return; + if (!_sg_do_clean_atexit) + return; xbt_initialized--; xbt_dict_postexit(); xbt_os_thread_mod_postexit(); @@ -123,14 +124,15 @@ void xbt_init(int *argc, char **argv) { simgrid::xbt::installExceptionHandler(); - if (xbt_initialized++) { - XBT_DEBUG("XBT was initialized %d times.", xbt_initialized); + if (xbt_initialized) { + xbt_initialized++; + XBT_DEBUG("XBT has been initialized %d times.", xbt_initialized); return; } xbt_binary_name = xbt_strdup(argv[0]); - xbt_cmdline = xbt_dynar_new(sizeof(char*),NULL); - for (int i=0;i<*argc;i++) + xbt_cmdline = xbt_dynar_new(sizeof(char*), NULL); + for (int i = 0; i < *argc; i++) xbt_dynar_push(xbt_cmdline,&(argv[i])); xbt_log_init(argc, argv); @@ -158,8 +160,7 @@ void xbt_abort(void) __gcov_flush(); #endif #ifdef _WIN32 - /* It was said *in silence*. We don't want to see the error message printed - * by the Microsoft's implementation of abort(). */ + /* We said *in silence*. We don't want to see the error message printed by Microsoft's implementation of abort(). */ raise(SIGABRT); signal(SIGABRT, SIG_DFL); raise(SIGABRT); -- 2.20.1