From: Arnaud Giersch Date: Tue, 10 Oct 2017 10:09:09 +0000 (+0200) Subject: Apply clang-format on previously renamed files. X-Git-Tag: v3.18~504^2~1 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/70fa17187e0b928ff89cb8663426edbf6b74601a Apply clang-format on previously renamed files. --- diff --git a/src/bindings/java/jmsg.hpp b/src/bindings/java/jmsg.hpp index afb050fc63..295a93800b 100644 --- a/src/bindings/java/jmsg.hpp +++ b/src/bindings/java/jmsg.hpp @@ -25,28 +25,28 @@ extern "C" { extern int JAVA_HOST_LEVEL; static std::unordered_map java_storage_map; -JavaVM *get_java_VM(); -JNIEnv *get_current_thread_env(); +JavaVM* get_java_VM(); +JNIEnv* get_current_thread_env(); /** * This function throws the correct exception according to the status provided. */ -void jmsg_throw_status(JNIEnv *env, msg_error_t status); +void jmsg_throw_status(JNIEnv* env, msg_error_t status); -JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv * env, jclass cls); -JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls); +JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv* env, jclass cls); +JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv* env, jclass cls); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv* env, jclass cls, jobjectArray jargs); JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_energyInit(); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv * env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv * env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv * env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv * env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv * env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv* env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv* env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv* env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv* env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv* env, jclass cls, jstring jargs); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv* env, jclass cls, jstring jargs); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile); -JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls); -JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jdeploymentFile); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv* env, jclass cls, jstring jplatformFile); +JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv* env, jclass cls); +JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_deployApplication(JNIEnv* env, jclass cls, jstring jdeploymentFile); } #endif diff --git a/src/bindings/java/jmsg_as.hpp b/src/bindings/java/jmsg_as.hpp index ffe15a794d..2ce24f7dd2 100644 --- a/src/bindings/java/jmsg_as.hpp +++ b/src/bindings/java/jmsg_as.hpp @@ -27,10 +27,10 @@ void jnetzone_unref(JNIEnv* env, jobject jnetzone); void jnetzone_bind(jobject jas, msg_netzone_t as, JNIEnv* env); simgrid::s4u::NetZone* jnetzone_get_native(JNIEnv* env, jobject jnetzone); -JNIEXPORT void JNICALL Java_org_simgrid_msg_As_nativeInit(JNIEnv *env, jclass cls); -JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getName(JNIEnv * env, jobject jas); +JNIEXPORT void JNICALL Java_org_simgrid_msg_As_nativeInit(JNIEnv* env, jclass cls); +JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getName(JNIEnv* env, jobject jas); JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv* env, jobject jnetzone); -JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobject jhost, jobject jname); +JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv* env, jobject jhost, jobject jname); JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv* env, jobject jnetzone); } #endif diff --git a/src/bindings/java/jxbt_utilities.hpp b/src/bindings/java/jxbt_utilities.hpp index 1026f96c26..e496893d53 100644 --- a/src/bindings/java/jxbt_utilities.hpp +++ b/src/bindings/java/jxbt_utilities.hpp @@ -15,38 +15,40 @@ extern "C" { /* Search a class and throw an exception if not found */ -jclass jxbt_get_class(JNIEnv * env, const char *name); +jclass jxbt_get_class(JNIEnv* env, const char* name); /* Search a method in a class and throw an exception if not found(it's ok to to pass a NULL class: it's a noop) */ -jmethodID jxbt_get_jmethod(JNIEnv * env, jclass cls, const char *name, const char *signature); +jmethodID jxbt_get_jmethod(JNIEnv* env, jclass cls, const char* name, const char* signature); /* Like the jxbt_get_class() but get a static method */ -jmethodID jxbt_get_static_jmethod(JNIEnv * env, jclass cls, const char *name, const char *signature); +jmethodID jxbt_get_static_jmethod(JNIEnv* env, jclass cls, const char* name, const char* signature); /* Search a field in a class and throw an exception if not found (it's ok to to pass a NULL class: it's a noop) */ -jfieldID jxbt_get_jfield(JNIEnv * env, jclass cls, const char *name, const char *signature); +jfieldID jxbt_get_jfield(JNIEnv* env, jclass cls, const char* name, const char* signature); /* Search a method in a class and throw an exception if not found (it's ok to to pass a NULL class: it's a noop) */ -jmethodID jxbt_get_smethod(JNIEnv * env, const char *classname, const char *name, const char *signature); +jmethodID jxbt_get_smethod(JNIEnv* env, const char* classname, const char* name, const char* signature); /* Like the jxbt_get_smethod() but get a static method */ -jmethodID jxbt_get_static_smethod(JNIEnv * env, const char *classname, const char *name, const char *signature); +jmethodID jxbt_get_static_smethod(JNIEnv* env, const char* classname, const char* name, const char* signature); /* Search a field in a class and throw an exception if not found (it's ok to to pass a NULL class: it's a noop) */ -jfieldID jxbt_get_sfield(JNIEnv * env, const char *classname, const char *name, const char *signature); +jfieldID jxbt_get_sfield(JNIEnv* env, const char* classname, const char* name, const char* signature); -#define jxbt_check_res(fun, res, allowed_exceptions, detail) do {\ - if (res != MSG_OK && (res | allowed_exceptions)) { \ - xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.",fun,res); \ - } else if (res == MSG_HOST_FAILURE) { \ - jxbt_throw_host_failure(env, detail); \ - } else if (res == MSG_TRANSFER_FAILURE) { \ - jxbt_throw_transfer_failure(env,detail); \ - } else if (res == MSG_TIMEOUT) { \ - jxbt_throw_time_out_failure(env,detail); \ - } else if (res == MSG_TASK_CANCELED){ \ - jxbt_throw_task_cancelled(env,detail); \ - } } while (0) +#define jxbt_check_res(fun, res, allowed_exceptions, detail) \ + do { \ + if (res != MSG_OK && (res | allowed_exceptions)) { \ + xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.", fun, res); \ + } else if (res == MSG_HOST_FAILURE) { \ + jxbt_throw_host_failure(env, detail); \ + } else if (res == MSG_TRANSFER_FAILURE) { \ + jxbt_throw_transfer_failure(env, detail); \ + } else if (res == MSG_TIMEOUT) { \ + jxbt_throw_time_out_failure(env, detail); \ + } else if (res == MSG_TASK_CANCELED) { \ + jxbt_throw_task_cancelled(env, detail); \ + } \ + } while (0) /* Throws an exception according to its name */ void jxbt_throw_by_name(JNIEnv* env, const char* name, std::string msg); diff --git a/src/bindings/lua/lua_private.hpp b/src/bindings/lua/lua_private.hpp index e51fae30fd..abcfd7070f 100644 --- a/src/bindings/lua/lua_private.hpp +++ b/src/bindings/lua/lua_private.hpp @@ -19,14 +19,16 @@ msg_host_t sglua_check_host(lua_State* L, int index); void sglua_register_platf_functions(lua_State* L); const char* sglua_get_msg_error(msg_error_t err); - } -#define lua_ensure(...) \ - _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__) -#define _lua_ensure_ARG1(cond) \ - _lua_ensure_ARGN(cond, "Assertion %s failed", #cond) -#define _lua_ensure_ARGN(cond, ...) \ - do { if (!(cond)) { luaL_error(L, __VA_ARGS__); return -1;} } while (0) +#define lua_ensure(...) _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__) +#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN(cond, "Assertion %s failed", #cond) +#define _lua_ensure_ARGN(cond, ...) \ + do { \ + if (!(cond)) { \ + luaL_error(L, __VA_ARGS__); \ + return -1; \ + } \ + } while (0) #endif diff --git a/src/bindings/lua/lua_utils.hpp b/src/bindings/lua/lua_utils.hpp index a5e060f73b..cbf83e74ab 100644 --- a/src/bindings/lua/lua_utils.hpp +++ b/src/bindings/lua/lua_utils.hpp @@ -25,12 +25,11 @@ typedef struct s_sglua_buffer { const char* sglua_tostring(lua_State* L, int index); const char* sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index); -void sglua_stack_dump(lua_State* L, const char *msg); +void sglua_stack_dump(lua_State* L, const char* msg); static int sglua_dump_table(lua_State* L); void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname); const char* sglua_get_spaces(int length); int sglua_memory_writer(lua_State* L, const void* source, size_t size, void* userdata); - } #endif diff --git a/src/bindings/lua/simgrid_lua.hpp b/src/bindings/lua/simgrid_lua.hpp index d9d5edb238..33e8a47858 100644 --- a/src/bindings/lua/simgrid_lua.hpp +++ b/src/bindings/lua/simgrid_lua.hpp @@ -13,8 +13,8 @@ extern "C" { /* Plaftorm functions */ /* ********************************************************************************* */ -int console_open(lua_State *L); -int console_close(lua_State *L); +int console_open(lua_State* L); +int console_close(lua_State* L); int console_add_backbone(lua_State*); int console_add_host___link(lua_State*); @@ -24,7 +24,7 @@ int console_add_router(lua_State* L); int console_add_route(lua_State*); int console_add_ASroute(lua_State*); int console_AS_open(lua_State*); -int console_AS_seal(lua_State *L); +int console_AS_seal(lua_State* L); int console_set_function(lua_State*); int console_host_set_property(lua_State*); } diff --git a/src/include/surf/maxmin.hpp b/src/include/surf/maxmin.hpp index 31c5d19768..1df50434b3 100644 --- a/src/include/surf/maxmin.hpp +++ b/src/include/surf/maxmin.hpp @@ -131,13 +131,13 @@ XBT_PUBLIC_DATA(double) sg_maxmin_precision; XBT_PUBLIC_DATA(double) sg_surf_precision; XBT_PUBLIC_DATA(int) sg_concurrency_limit; -static inline void double_update(double *variable, double value, double precision) +static inline void double_update(double* variable, double value, double precision) { - //printf("Updating %g -= %g +- %g\n",*variable,value,precision); - //xbt_assert(value==0 || value>precision); - //Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding may happen, - //and the precision mechanism is not active... - //xbt_assert(*variable< (2<precision); + // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding may + // happen, and the precision mechanism is not active... + // xbt_assert(*variable< (2< trivaNodeTypes; extern XBT_PRIVATE std::set trivaEdgeTypes; -XBT_PRIVATE long long int instr_new_paje_id (); -XBT_PUBLIC(container_t) PJ_container_get (const char *name); +XBT_PRIVATE long long int instr_new_paje_id(); +XBT_PUBLIC(container_t) PJ_container_get(const char* name); XBT_PUBLIC(simgrid::instr::Container*) PJ_container_get_or_null(const char* name); XBT_PUBLIC(container_t) PJ_container_get_root (); XBT_PUBLIC(void) PJ_container_set_root (container_t root); @@ -340,14 +331,14 @@ XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get_root(); XBT_PRIVATE void TRACE_TI_start(); XBT_PRIVATE void TRACE_TI_end(); -XBT_PRIVATE void TRACE_paje_dump_buffer (int force); -XBT_PRIVATE void dump_comment_file (const char *filename); -XBT_PRIVATE void dump_comment (const char *comment); +XBT_PRIVATE void TRACE_paje_dump_buffer(int force); +XBT_PRIVATE void dump_comment_file(const char* filename); +XBT_PRIVATE void dump_comment(const char* comment); struct s_instr_extra_data; -typedef struct s_instr_extra_data *instr_extra_data; +typedef struct s_instr_extra_data* instr_extra_data; -typedef enum{ +typedef enum { TRACING_INIT, TRACING_FINALIZE, TRACING_COMM_SIZE, @@ -381,7 +372,7 @@ typedef enum{ TRACING_SLEEPING, TRACING_SCAN, TRACING_EXSCAN -} e_caller_type ; +} e_caller_type; typedef struct s_instr_extra_data { e_caller_type type; @@ -394,15 +385,16 @@ typedef struct s_instr_extra_data { int root; const char* datatype1; const char* datatype2; - int * sendcounts; - int * recvcounts; + int* sendcounts; + int* recvcounts; int num_processes; } s_instr_extra_data_t; /* Format of TRACING output. * - paje is the regular format, that we all know - * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such trace can easily be replayed with smpi_replay afterward. - * This trick should be removed and replaced by some code using the signal that we will create to cleanup the TRACING + * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such + * trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code + * using the signal that we will create to cleanup the TRACING */ typedef enum { instr_fmt_paje, instr_fmt_TI } instr_fmt_type_t; extern instr_fmt_type_t instr_fmt_type; @@ -413,8 +405,8 @@ void LogVariableTypeDefinition(simgrid::instr::Type* type); void LogStateTypeDefinition(simgrid::instr::Type* type); void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest); void LogEntityValue(simgrid::instr::Value* val); -void LogContainerCreation (container_t container); -void LogContainerDestruction (container_t container); +void LogContainerCreation(container_t container); +void LogContainerDestruction(container_t container); void LogDefineEventType(simgrid::instr::Type* type); #endif diff --git a/src/instr/instr_smpi.hpp b/src/instr/instr_smpi.hpp index 4abfe02827..9b01f6f3ae 100644 --- a/src/instr/instr_smpi.hpp +++ b/src/instr/instr_smpi.hpp @@ -43,8 +43,10 @@ typedef struct smpi_trace_call_location { const char* previous_filename; int previous_linenumber; - std::string get_composed_key() { - return std::string(previous_filename) + ':' + std::to_string(previous_linenumber) + ':' + filename + ':' + std::to_string(linenumber); + std::string get_composed_key() + { + return std::string(previous_filename) + ':' + std::to_string(previous_linenumber) + ':' + filename + ':' + + std::to_string(linenumber); } } smpi_trace_call_location_t; diff --git a/src/mc/mc_exit.hpp b/src/mc/mc_exit.hpp index 83fe9dc19d..cede412ee8 100644 --- a/src/mc/mc_exit.hpp +++ b/src/mc/mc_exit.hpp @@ -7,21 +7,21 @@ #define SIMGRID_MC_EXIT_HPP #include "xbt/base.h" -#define SIMGRID_MC_EXIT_SUCCESS 0 -#define SIMGRID_MC_EXIT_SAFETY 1 +#define SIMGRID_MC_EXIT_SUCCESS 0 +#define SIMGRID_MC_EXIT_SAFETY 1 #define SIMGRID_MC_EXIT_LIVENESS 2 #define SIMGRID_MC_EXIT_DEADLOCK 3 #define SIMGRID_MC_EXIT_NON_TERMINATION 4 #define SIMGRID_MC_EXIT_NON_DETERMINISM 5 #define SIMGRID_MC_EXIT_PROGRAM_CRASH 6 -#define SIMGRID_MC_EXIT_ERROR 63 +#define SIMGRID_MC_EXIT_ERROR 63 namespace simgrid { namespace mc { -XBT_PUBLIC_CLASS DeadlockError {}; -XBT_PUBLIC_CLASS TerminationError {}; -XBT_PUBLIC_CLASS LivenessError {}; +XBT_PUBLIC_CLASS DeadlockError{}; +XBT_PUBLIC_CLASS TerminationError{}; +XBT_PUBLIC_CLASS LivenessError{}; } } diff --git a/src/mc/mc_mmu.hpp b/src/mc/mc_mmu.hpp index d406e8989e..b220822584 100644 --- a/src/mc/mc_mmu.hpp +++ b/src/mc/mc_mmu.hpp @@ -28,24 +28,21 @@ static int chunkSize() static XBT_ALWAYS_INLINE std::size_t chunkCount(std::size_t size) { size_t page_count = size >> xbt_pagebits; - if (size & (xbt_pagesize-1)) - page_count ++; + if (size & (xbt_pagesize - 1)) + page_count++; return page_count; } /** @brief Split into chunk number and remaining offset */ static XBT_ALWAYS_INLINE std::pair split(std::uintptr_t offset) { - return { - offset >> xbt_pagebits, - offset & (xbt_pagesize-1) - }; + return {offset >> xbt_pagebits, offset & (xbt_pagesize - 1)}; } /** Merge chunk number and remaining offset info a global offset */ static XBT_ALWAYS_INLINE std::uintptr_t join(std::size_t page, std::uintptr_t offset) { - return ((std::uintptr_t) page << xbt_pagebits) + offset; + return ((std::uintptr_t)page << xbt_pagebits) + offset; } static XBT_ALWAYS_INLINE std::uintptr_t join(std::pair value) @@ -57,7 +54,6 @@ static XBT_ALWAYS_INLINE bool sameChunk(std::uintptr_t a, std::uintptr_t b) { return (a >> xbt_pagebits) == (b >> xbt_pagebits); } - } } } diff --git a/src/mc/mc_private.hpp b/src/mc/mc_private.hpp index 8869643741..f51b0e9782 100644 --- a/src/mc/mc_private.hpp +++ b/src/mc/mc_private.hpp @@ -16,13 +16,11 @@ namespace simgrid { namespace mc { struct DerefAndCompareByActorsCountAndUsedHeap { - template - bool operator()(X const& a, Y const& b) + template bool operator()(X const& a, Y const& b) { return std::make_pair(a->actors_count, a->heap_bytes_used) < std::make_pair(b->actors_count, b->heap_bytes_used); } }; - } } @@ -32,7 +30,7 @@ extern "C" { XBT_PRIVATE void MC_init_dot_output(); -XBT_PRIVATE extern FILE *dot_output; +XBT_PRIVATE extern FILE* dot_output; XBT_PRIVATE void MC_show_deadlock(void); @@ -47,15 +45,14 @@ XBT_PRIVATE void MC_show_deadlock(void); namespace simgrid { namespace mc { -XBT_PRIVATE void find_object_address( - std::vector const& maps, simgrid::mc::ObjectInformation* result); +XBT_PRIVATE void find_object_address(std::vector const& maps, + simgrid::mc::ObjectInformation* result); XBT_PRIVATE int snapshot_compare(int num1, simgrid::mc::Snapshot* s1, int num2, simgrid::mc::Snapshot* s2); // Move is somewhere else (in the LivenessChecker class, in the Session class?): extern XBT_PRIVATE xbt_automaton_t property_automaton; - } } diff --git a/src/mc/mc_record.hpp b/src/mc/mc_record.hpp index 2b7bfffc9a..af9948263f 100644 --- a/src/mc/mc_record.hpp +++ b/src/mc/mc_record.hpp @@ -35,7 +35,6 @@ XBT_PRIVATE void dumpRecordPath(); XBT_PRIVATE void replay(RecordTrace const& trace); XBT_PRIVATE void replay(const char* trace); - } } diff --git a/src/mc/mc_request.hpp b/src/mc/mc_request.hpp index 23c39c8ef1..6036769b50 100644 --- a/src/mc/mc_request.hpp +++ b/src/mc/mc_request.hpp @@ -24,7 +24,6 @@ XBT_PRIVATE std::string request_to_string(smx_simcall_t req, int value, simgrid: XBT_PRIVATE bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx); XBT_PRIVATE std::string request_get_dot_output(smx_simcall_t req, int value); - } } diff --git a/src/mc/mc_safety.hpp b/src/mc/mc_safety.hpp index 97c939c009..bf1853dd57 100644 --- a/src/mc/mc_safety.hpp +++ b/src/mc/mc_safety.hpp @@ -18,7 +18,6 @@ enum class ReductionMode { }; extern XBT_PRIVATE simgrid::mc::ReductionMode reduction_mode; - } } diff --git a/src/mc/mc_snapshot.hpp b/src/mc/mc_snapshot.hpp index a1d4049e88..8c97902ecf 100644 --- a/src/mc/mc_snapshot.hpp +++ b/src/mc/mc_snapshot.hpp @@ -24,29 +24,27 @@ XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region) { - auto split = simgrid::mc::mmu::split(addr - region->start().address()); - auto pageno = split.first; - auto offset = split.second; + auto split = simgrid::mc::mmu::split(addr - region->start().address()); + auto pageno = split.first; + auto offset = split.second; const void* snapshot_page = region->page_data().page(pageno); - return (char*) snapshot_page + offset; + return (char*)snapshot_page + offset; } static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, mc_mem_region_t region, int process_index) { switch (region->storage_type()) { - case simgrid::mc::StorageType::Flat: - { - uintptr_t offset = (uintptr_t) addr - (uintptr_t) region->start().address(); - return (void *) ((uintptr_t) region->flat_data().get() + offset); + case simgrid::mc::StorageType::Flat: { + uintptr_t offset = (uintptr_t)addr - (uintptr_t)region->start().address(); + return (void*)((uintptr_t)region->flat_data().get() + offset); } - case simgrid::mc::StorageType::Chunked: - return mc_translate_address_region_chunked(addr, region); - case simgrid::mc::StorageType::Privatized: - { - xbt_assert(process_index >= 0, "Missing process index for privatized region"); - xbt_assert((size_t)process_index < region->privatized_data().size(), "Out of range process index"); - simgrid::mc::RegionSnapshot& subregion = region->privatized_data()[process_index]; - return mc_translate_address_region(addr, &subregion, process_index); + case simgrid::mc::StorageType::Chunked: + return mc_translate_address_region_chunked(addr, region); + case simgrid::mc::StorageType::Privatized: { + xbt_assert(process_index >= 0, "Missing process index for privatized region"); + xbt_assert((size_t)process_index < region->privatized_data().size(), "Out of range process index"); + simgrid::mc::RegionSnapshot& subregion = region->privatized_data()[process_index]; + return mc_translate_address_region(addr, &subregion, process_index); } case simgrid::mc::StorageType::NoData: default: @@ -70,7 +68,7 @@ typedef struct s_mc_snapshot_ignored_data { std::vector data; } s_mc_snapshot_ignored_data_t; -typedef struct s_fd_infos{ +typedef struct s_fd_infos { std::string filename; int number; off_t current_position; @@ -90,12 +88,12 @@ typedef struct s_mc_stack_frame { } s_mc_stack_frame_t; typedef s_mc_stack_frame_t* mc_stack_frame_t; -typedef struct s_local_variable{ +typedef struct s_local_variable { simgrid::mc::Frame* subprogram; unsigned long ip; std::string name; simgrid::mc::Type* type; - void *address; + void* address; int region; } s_local_variable_t; typedef s_local_variable_t* local_variable_t; @@ -114,9 +112,8 @@ class XBT_PRIVATE Snapshot final : public AddressSpace { public: Snapshot(RemoteClient* process, int num_state); ~Snapshot() = default; - const void* read_bytes(void* buffer, std::size_t size, - RemotePtr address, int process_index = ProcessIndexAny, - ReadOptions options = ReadOptions::none()) const override; + const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index = ProcessIndexAny, + ReadOptions options = ReadOptions::none()) const override; // To be private int num_state; @@ -131,7 +128,6 @@ public: std::vector ignored_data; std::vector current_fds; }; - } } @@ -147,7 +143,6 @@ static XBT_ALWAYS_INLINE mc_mem_region_t mc_get_region_hinted(void* addr, simgri } static const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot); - } namespace simgrid { @@ -155,7 +150,6 @@ namespace mc { XBT_PRIVATE std::shared_ptr take_snapshot(int num_state); XBT_PRIVATE void restore_snapshot(std::shared_ptr snapshot); - } } @@ -164,20 +158,17 @@ extern "C" { XBT_PRIVATE void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr, simgrid::mc::ChunkedData const& pagenos); -const void* MC_region_read_fragmented( - mc_mem_region_t region, void* target, const void* addr, std::size_t size); +const void* MC_region_read_fragmented(mc_mem_region_t region, void* target, const void* addr, std::size_t size); -int MC_snapshot_region_memcmp( - const void* addr1, mc_mem_region_t region1, - const void* addr2, mc_mem_region_t region2, std::size_t size); -XBT_PRIVATE int MC_snapshot_memcmp( - const void* addr1, simgrid::mc::Snapshot* snapshot1, - const void* addr2, simgrid::mc::Snapshot* snapshot2, int process_index, std::size_t size); +int MC_snapshot_region_memcmp(const void* addr1, mc_mem_region_t region1, const void* addr2, mc_mem_region_t region2, + std::size_t size); +XBT_PRIVATE int MC_snapshot_memcmp(const void* addr1, simgrid::mc::Snapshot* snapshot1, const void* addr2, + simgrid::mc::Snapshot* snapshot2, int process_index, std::size_t size); static XBT_ALWAYS_INLINE const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot) { - if(snapshot==nullptr) - xbt_die("snapshot is nullptr"); + if (snapshot == nullptr) + xbt_die("snapshot is nullptr"); return mc_model_checker->process().get_heap()->breakval; } @@ -199,37 +190,36 @@ static XBT_ALWAYS_INLINE const void* MC_region_read(mc_mem_region_t region, void xbt_assert(region->contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary."); switch (region->storage_type()) { - case simgrid::mc::StorageType::NoData: - default: - xbt_die("Storage type not supported"); + case simgrid::mc::StorageType::NoData: + default: + xbt_die("Storage type not supported"); - case simgrid::mc::StorageType::Flat: - return (char*) region->flat_data().get() + offset; + case simgrid::mc::StorageType::Flat: + return (char*)region->flat_data().get() + offset; - case simgrid::mc::StorageType::Chunked: - { + case simgrid::mc::StorageType::Chunked: { // Last byte of the region: - void* end = (char*) addr + size - 1; - if (simgrid::mc::mmu::sameChunk((std::uintptr_t) addr, (std::uintptr_t) end) ) { + void* end = (char*)addr + size - 1; + if (simgrid::mc::mmu::sameChunk((std::uintptr_t)addr, (std::uintptr_t)end)) { // The memory is contained in a single page: - return mc_translate_address_region_chunked((uintptr_t) addr, region); + return mc_translate_address_region_chunked((uintptr_t)addr, region); } else { // The memory spans several pages: return MC_region_read_fragmented(region, target, addr, size); } } - // We currently do not pass the process_index to this function so we assume - // that the privatized region has been resolved in the callers: - case simgrid::mc::StorageType::Privatized: - xbt_die("Storage type not supported"); + // We currently do not pass the process_index to this function so we assume + // that the privatized region has been resolved in the callers: + case simgrid::mc::StorageType::Privatized: + xbt_die("Storage type not supported"); } } static XBT_ALWAYS_INLINE void* MC_region_read_pointer(mc_mem_region_t region, const void* addr) { void* res; - return *(void**) MC_region_read(region, &res, addr, sizeof(void*)); + return *(void**)MC_region_read(region, &res, addr, sizeof(void*)); } } diff --git a/src/mc/mc_state.hpp b/src/mc/mc_state.hpp index 8fe92e3dc7..edef946f08 100644 --- a/src/mc/mc_state.hpp +++ b/src/mc/mc_state.hpp @@ -17,8 +17,8 @@ namespace simgrid { namespace mc { enum class PatternCommunicationType { - none = 0, - send = 1, + none = 0, + send = 1, receive = 2, }; @@ -27,37 +27,33 @@ public: int num = 0; simgrid::kernel::activity::CommImpl* comm_addr; PatternCommunicationType type = PatternCommunicationType::send; - unsigned long src_proc = 0; - unsigned long dst_proc = 0; - const char *src_host = nullptr; - const char *dst_host = nullptr; + unsigned long src_proc = 0; + unsigned long dst_proc = 0; + const char* src_host = nullptr; + const char* dst_host = nullptr; std::string rdv; std::vector data; - int tag = 0; + int tag = 0; int index = 0; - PatternCommunication() - { - std::memset(&comm_addr, 0, sizeof(comm_addr)); - } + PatternCommunication() { std::memset(&comm_addr, 0, sizeof(comm_addr)); } PatternCommunication dup() const { simgrid::mc::PatternCommunication res; // num? res.comm_addr = this->comm_addr; - res.type = this->type; + res.type = this->type; // src_proc? // dst_proc? res.dst_proc = this->dst_proc; res.dst_host = this->dst_host; - res.rdv = this->rdv; - res.data = this->data; + res.rdv = this->rdv; + res.data = this->data; // tag? res.index = this->index; return res; } - }; /* On every state, each process has an entry of the following type. @@ -79,28 +75,22 @@ class ProcessState { /** Exploration control information */ InterleavingType state = InterleavingType::disabled; + public: /** Number of times that the process was considered to be executed */ // TODO, make this private unsigned int times_considered = 0; - bool isDisabled() const { - return this->state == InterleavingType::disabled; - } - bool isDone() const { - return this->state == InterleavingType::done; - } - bool isTodo() const { - return this->state == InterleavingType::todo; - } + bool isDisabled() const { return this->state == InterleavingType::disabled; } + bool isDone() const { return this->state == InterleavingType::done; } + bool isTodo() const { return this->state == InterleavingType::todo; } /** Mark that we should try executing this process at some point in the future of the checker algorithm */ - void consider() { + void consider() + { this->state = InterleavingType::todo; this->times_considered = 0; } - void setDone() { - this->state = InterleavingType::done; - } + void setDone() { this->state = InterleavingType::done; } }; /* A node in the exploration graph (kind-of) @@ -141,7 +131,6 @@ public: void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid].consider(); } Transition getTransition() const; }; - } } diff --git a/src/mc/mc_unw.hpp b/src/mc/mc_unw.hpp index e5e066d144..7eeec0a0a3 100644 --- a/src/mc/mc_unw.hpp +++ b/src/mc/mc_unw.hpp @@ -37,7 +37,6 @@ namespace unw { XBT_PRIVATE unw_addr_space_t create_addr_space(); XBT_PRIVATE void* create_context(unw_addr_space_t as, pid_t pid); - } } @@ -57,30 +56,19 @@ public: unw_cursor_t cursor(); private: // Methods and virtual table for libunwind - static int find_proc_info(unw_addr_space_t as, - unw_word_t ip, unw_proc_info_t *pip, - int need_unwind_info, void* arg) noexcept; - static void put_unwind_info(unw_addr_space_t as, - unw_proc_info_t *pip, void* arg) noexcept; - static int get_dyn_info_list_addr(unw_addr_space_t as, - unw_word_t *dilap, void* arg) noexcept; - static int access_mem(unw_addr_space_t as, - unw_word_t addr, unw_word_t *valp, - int write, void* arg) noexcept; + static int find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t* pip, int need_unwind_info, + void* arg) noexcept; + static void put_unwind_info(unw_addr_space_t as, unw_proc_info_t* pip, void* arg) noexcept; + static int get_dyn_info_list_addr(unw_addr_space_t as, unw_word_t* dilap, void* arg) noexcept; + static int access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t* valp, int write, void* arg) noexcept; static void* get_reg(unw_context_t* context, unw_regnum_t regnum) noexcept; - static int access_reg(unw_addr_space_t as, - unw_regnum_t regnum, unw_word_t *valp, - int write, void* arg) noexcept; - static int access_fpreg(unw_addr_space_t as, - unw_regnum_t regnum, unw_fpreg_t *fpvalp, - int write, void* arg) noexcept; - static int resume(unw_addr_space_t as, - unw_cursor_t *cp, void* arg) noexcept; - static int get_proc_name(unw_addr_space_t as, - unw_word_t addr, char *bufp, - size_t buf_len, unw_word_t *offp, - void* arg) noexcept; + static int access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t* valp, int write, void* arg) noexcept; + static int access_fpreg(unw_addr_space_t as, unw_regnum_t regnum, unw_fpreg_t* fpvalp, int write, void* arg) noexcept; + static int resume(unw_addr_space_t as, unw_cursor_t* cp, void* arg) noexcept; + static int get_proc_name(unw_addr_space_t as, unw_word_t addr, char* bufp, size_t buf_len, unw_word_t* offp, + void* arg) noexcept; static unw_accessors_t accessors; + public: // Create a libunwind address space: static unw_addr_space_t createUnwindAddressSpace(); @@ -89,7 +77,6 @@ public: void MC_dump_stack_unw(FILE* file, unw_cursor_t cursor); void dumpStack(FILE* file, unw_cursor_t cursor); void dumpStack(FILE* file, pid_t pid); - } } diff --git a/src/msg/msg_private.hpp b/src/msg/msg_private.hpp index 6516a84d50..e7d1ef9953 100644 --- a/src/msg/msg_private.hpp +++ b/src/msg/msg_private.hpp @@ -21,9 +21,7 @@ class MsgHostExt { public: static simgrid::xbt::Extension EXTENSION_ID; - ~MsgHostExt() { - delete file_descriptor_table; - } + ~MsgHostExt() { delete file_descriptor_table; } std::vector* file_descriptor_table = nullptr; // Created lazily on need }; } @@ -36,29 +34,26 @@ typedef struct simdata_task { xbt_free(this->host_list); } void setUsed(); - void setNotUsed() - { - this->isused = false; - } + void setNotUsed() { this->isused = false; } simgrid::kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */ simgrid::kernel::activity::CommImplPtr comm = nullptr; /* SIMIX modeling of communication */ - double bytes_amount = 0.0; /* Data size */ - double flops_amount = 0.0; /* Computation size */ - msg_process_t sender = nullptr; - msg_process_t receiver = nullptr; - msg_host_t source = nullptr; + double bytes_amount = 0.0; /* Data size */ + double flops_amount = 0.0; /* Computation size */ + msg_process_t sender = nullptr; + msg_process_t receiver = nullptr; + msg_host_t source = nullptr; double priority = 1.0; double bound = 0.0; /* Capping for CPU resource, or 0 for no capping */ double rate = -1; /* Capping for network resource, or -1 for no capping*/ - bool isused = false; /* Indicates whether the task is used in SIMIX currently */ - int host_nb = 0; /* ==0 if sequential task; parallel task if not */ + bool isused = false; /* Indicates whether the task is used in SIMIX currently */ + int host_nb = 0; /* ==0 if sequential task; parallel task if not */ /******* Parallel Tasks Only !!!! *******/ - sg_host_t *host_list = nullptr; - double *flops_parallel_amount = nullptr; - double *bytes_parallel_amount = nullptr; + sg_host_t* host_list = nullptr; + double* flops_parallel_amount = nullptr; + double* bytes_parallel_amount = nullptr; private: void reportMultipleUse() const; @@ -72,15 +67,15 @@ class ActorExt { public: explicit ActorExt(void* d) : data(d) {} msg_error_t errno_ = MSG_OK; /* the last value returned by a MSG_function */ - void* data = nullptr; /* user data */ + void* data = nullptr; /* user data */ }; class Comm { public: - msg_task_t task_sent; /* task sent (NULL for the receiver) */ - msg_task_t *task_received; /* where the task will be received (NULL for the sender) */ - smx_activity_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */ - msg_error_t status = MSG_OK; /* status of the communication once finished */ + msg_task_t task_sent; /* task sent (NULL for the receiver) */ + msg_task_t* task_received; /* where the task will be received (NULL for the sender) */ + smx_activity_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */ + msg_error_t status = MSG_OK; /* status of the communication once finished */ Comm(msg_task_t sent, msg_task_t* received, smx_activity_t comm) : task_sent(sent), task_received(received), s_comm(std::move(comm)) { @@ -91,9 +86,9 @@ public: /************************** Global variables ********************************/ typedef struct MSG_Global { - int debug_multiple_use; /* whether we want an error message when reusing the same Task for 2 things */ + int debug_multiple_use; /* whether we want an error message when reusing the same Task for 2 things */ std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */ - void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst); + void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst); void_f_pvoid_t process_data_cleanup; } s_MSG_Global_t; typedef s_MSG_Global_t* MSG_Global_t; @@ -114,26 +109,26 @@ XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task); /********** Tracing **********/ /* declaration of instrumentation functions from msg_task_instr.c */ -XBT_PRIVATE void TRACE_msg_set_task_category(msg_task_t task, const char *category); +XBT_PRIVATE void TRACE_msg_set_task_category(msg_task_t task, const char* category); XBT_PRIVATE void TRACE_msg_task_create(msg_task_t task); XBT_PRIVATE void TRACE_msg_task_execute_start(msg_task_t task); XBT_PRIVATE void TRACE_msg_task_execute_end(msg_task_t task); XBT_PRIVATE void TRACE_msg_task_destroy(msg_task_t task); XBT_PRIVATE void TRACE_msg_task_get_end(double start_time, msg_task_t task); XBT_PRIVATE void TRACE_msg_task_get_start(); -XBT_PRIVATE int TRACE_msg_task_put_start(msg_task_t task); //returns TRUE if the task_put_end must be called +XBT_PRIVATE int TRACE_msg_task_put_start(msg_task_t task); // returns TRUE if the task_put_end must be called XBT_PRIVATE void TRACE_msg_task_put_end(); /* declaration of instrumentation functions from msg_process_instr.c */ -XBT_PRIVATE char *instr_process_id (msg_process_t proc, char *str, int len); -XBT_PRIVATE char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len); +XBT_PRIVATE char* instr_process_id(msg_process_t proc, char* str, int len); +XBT_PRIVATE char* instr_process_id_2(const char* process_name, int process_pid, char* str, int len); XBT_PRIVATE void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host); -XBT_PRIVATE void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host); -XBT_PRIVATE void TRACE_msg_process_destroy (const char *process_name, int process_pid); +XBT_PRIVATE void TRACE_msg_process_create(const char* process_name, int process_pid, msg_host_t host); +XBT_PRIVATE void TRACE_msg_process_destroy(const char* process_name, int process_pid); XBT_PRIVATE void TRACE_msg_process_kill(smx_process_exit_status_t status, msg_process_t process); XBT_PRIVATE void TRACE_msg_process_suspend(msg_process_t process); XBT_PRIVATE void TRACE_msg_process_resume(msg_process_t process); -XBT_PRIVATE void TRACE_msg_process_sleep_in(msg_process_t process); //called from msg/gos.c +XBT_PRIVATE void TRACE_msg_process_sleep_in(msg_process_t process); // called from msg/gos.c XBT_PRIVATE void TRACE_msg_process_sleep_out(msg_process_t process); } diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index e311a67bf8..d6c0a5c354 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -24,24 +24,24 @@ XBT_PUBLIC_DATA(const char*) simcall_names[]; /* Name of each simcall */ typedef int (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*); typedef void (*simix_copy_data_func_t)(smx_activity_t, void*, size_t); -typedef void (*simix_clean_func_t)(void *); +typedef void (*simix_clean_func_t)(void*); typedef void (*FPtr)(void); // Hide the ugliness /* Pack all possible scalar types in an union */ union u_smx_scalar { - char c; - short s; - int i; - long l; - long long ll; - unsigned char uc; - unsigned short us; - unsigned int ui; - unsigned long ul; + char c; + short s; + int i; + long l; + long long ll; + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long ul; unsigned long long ull; - double d; - void* dp; - FPtr fp; + double d; + void* dp; + FPtr fp; }; /** @@ -64,7 +64,7 @@ struct s_smx_simcall { XBT_PRIVATE void SIMIX_simcall_answer(smx_simcall_t simcall); XBT_PRIVATE void SIMIX_simcall_handle(smx_simcall_t simcall, int value); XBT_PRIVATE void SIMIX_simcall_exit(smx_activity_t synchro); -XBT_PRIVATE const char *SIMIX_simcall_name(e_smx_simcall_t kind); +XBT_PRIVATE const char* SIMIX_simcall_name(e_smx_simcall_t kind); XBT_PRIVATE void SIMIX_run_kernel(std::function const* code); XBT_PRIVATE void SIMIX_run_blocking(std::function const* code); } @@ -86,17 +86,15 @@ XBT_PRIVATE void SIMIX_run_blocking(std::function const* code); namespace simgrid { namespace simix { -template -class type { - constexpr bool operator==(type) const { return true; } - template - constexpr bool operator==(type) const { return false; } - constexpr bool operator!=(type) const { return false; } - template - constexpr bool operator!=(type) const { return true; } +template class type { + constexpr bool operator==(type) const { return true; } + template constexpr bool operator==(type) const { return false; } + constexpr bool operator!=(type) const { return false; } + template constexpr bool operator!=(type) const { return true; } }; -template struct marshal_t {}; +template struct marshal_t { +}; #define SIMIX_MARSHAL(T, field) \ inline void marshal(type, u_smx_scalar& simcall, T value) { simcall.field = value; } \ inline T unmarshal(type, u_smx_scalar const& simcall) { return simcall.field; } \ @@ -126,13 +124,11 @@ inline void unmarshal_raw(type, u_smx_scalar const& simcall) /* Nothing to do for void data */ } -template inline -void marshal(type, u_smx_scalar& simcall, T* value) +template inline void marshal(type, u_smx_scalar& simcall, T* value) { - simcall.dp = (void*) value; + simcall.dp = (void*)value; } -template inline -T* unmarshal(type, u_smx_scalar const& simcall) +template inline T* unmarshal(type, u_smx_scalar const& simcall) { return static_cast(simcall.dp); } @@ -162,28 +158,24 @@ template inline T* unmarshal_raw(type>, u_smx_ return static_cast(simcall.dp); } -template inline -void marshal(type, u_smx_scalar& simcall, R(*value)(T...)) +template inline void marshal(type, u_smx_scalar& simcall, R (*value)(T...)) { - simcall.fp = (FPtr) value; + simcall.fp = (FPtr)value; } -template inline -auto unmarshal(type, u_smx_scalar simcall) -> R(*)(T...) +template inline auto unmarshal(type, u_smx_scalar simcall) -> R (*)(T...) { - return (R(*)(T...)) simcall.fp; + return (R(*)(T...))simcall.fp; } template inline auto unmarshal_raw(type, u_smx_scalar simcall) -> R (*)(T...) { return (R(*)(T...))simcall.fp; } -template inline -void marshal(u_smx_scalar& simcall, T const& value) +template inline void marshal(u_smx_scalar& simcall, T const& value) { return marshal(type(), simcall, value); } -template inline -typename std::remove_reference::type unmarshal(u_smx_scalar& simcall) +template inline typename std::remove_reference::type unmarshal(u_smx_scalar& simcall) { return unmarshal(type(), simcall); } @@ -192,32 +184,29 @@ template inline typename std::remove_reference::type unmarshal_raw( return unmarshal(type(), simcall); } -template -inline void marshalArgs(smx_simcall_t simcall) {} +template inline void marshalArgs(smx_simcall_t simcall) +{ +} -template -inline void marshalArgs(smx_simcall_t simcall, A const& a) +template inline void marshalArgs(smx_simcall_t simcall, A const& a) { marshal(simcall->args[I], a); } -template -inline void marshalArgs(smx_simcall_t simcall, A const& a, B const&... b) +template inline void marshalArgs(smx_simcall_t simcall, A const& a, B const&... b) { marshal(simcall->args[I], a); - marshalArgs(simcall, b...); + marshalArgs(simcall, b...); } /** Initialize the simcall */ -template inline -void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A const&... a) +template inline void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A const&... a) { simcall->call = call; memset(&simcall->result, 0, sizeof(simcall->result)); memset(simcall->args, 0, sizeof(simcall->args)); marshalArgs<0>(simcall, a...); } - } } diff --git a/src/simix/smx_host_private.hpp b/src/simix/smx_host_private.hpp index 5aab49d436..6943f1991f 100644 --- a/src/simix/smx_host_private.hpp +++ b/src/simix/smx_host_private.hpp @@ -20,23 +20,23 @@ /** @brief Host datatype from SIMIX POV */ namespace simgrid { - namespace simix { - class ProcessArg; +namespace simix { +class ProcessArg; - class Host { - public: - static simgrid::xbt::Extension EXTENSION_ID; +class Host { +public: + static simgrid::xbt::Extension EXTENSION_ID; - explicit Host(); - virtual ~Host(); + explicit Host(); + virtual ~Host(); - xbt_swag_t process_list; - std::vector auto_restart_processes; - std::vector boot_processes; + xbt_swag_t process_list; + std::vector auto_restart_processes; + std::vector boot_processes; - void turnOn(); - }; - } + void turnOn(); +}; +} } extern "C" { @@ -48,7 +48,7 @@ XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host); XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec); -XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char *category); +XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char* category); } XBT_PRIVATE boost::intrusive_ptr @@ -58,4 +58,3 @@ SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_li double* bytes_amount, double rate, double timeout); #endif - diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index 49aa5eef51..a14ab8bfd1 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -37,7 +37,7 @@ public: xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr); #endif xbt_swag_t process_to_destroy = nullptr; - smx_actor_t maestro_process = nullptr; + smx_actor_t maestro_process = nullptr; // Maps function names to actor code: std::unordered_map registered_functions; @@ -49,14 +49,13 @@ public: void_pfn_smxprocess_t kill_process_function = nullptr; /** Callback used when killing a SMX_process */ void_pfn_smxprocess_t cleanup_process_function = nullptr; - xbt_os_mutex_t mutex = nullptr; + xbt_os_mutex_t mutex = nullptr; std::vector> tasks; std::vector> tasksTemp; std::vector daemons; }; - } } @@ -68,14 +67,15 @@ XBT_PUBLIC(void) SIMIX_clean(); /******************************** Exceptions *********************************/ /** @brief Ask to the provided simix process to raise the provided exception */ -#define SMX_EXCEPTION(issuer, cat, val, msg) \ - if (1) { \ - smx_actor_t _smx_throw_issuer = (issuer); /* evaluate only once */ \ - xbt_ex e(XBT_THROW_POINT, msg); \ - e.category = cat; \ - e.value = val; \ - _smx_throw_issuer->exception = std::make_exception_ptr(e); \ - } else ((void)0) +#define SMX_EXCEPTION(issuer, cat, val, msg) \ + if (1) { \ + smx_actor_t _smx_throw_issuer = (issuer); /* evaluate only once */ \ + xbt_ex e(XBT_THROW_POINT, msg); \ + e.category = cat; \ + e.value = val; \ + _smx_throw_issuer->exception = std::make_exception_ptr(e); \ + } else \ + ((void)0) } #endif diff --git a/src/smpi/colls/coll_tuned_topo.hpp b/src/smpi/colls/coll_tuned_topo.hpp index b4b008a2df..82718230d8 100644 --- a/src/smpi/colls/coll_tuned_topo.hpp +++ b/src/smpi/colls/coll_tuned_topo.hpp @@ -25,46 +25,34 @@ #define MAXTREEFANOUT 32 -#define COLL_TUNED_COMPUTED_SEGCOUNT(SEGSIZE, TYPELNG, SEGCOUNT) \ - if( ((SEGSIZE) >= (TYPELNG)) && \ - ((SEGSIZE) < ((TYPELNG) * (SEGCOUNT))) ) { \ - size_t residual; \ - (SEGCOUNT) = (int)((SEGSIZE) / (TYPELNG)); \ - residual = (SEGSIZE) - (SEGCOUNT) * (TYPELNG); \ - if( residual > ((TYPELNG) >> 1) ) \ - (SEGCOUNT)++; \ - } \ - - - typedef struct ompi_coll_tree_t { - int32_t tree_root; - int32_t tree_fanout; - int32_t tree_bmtree; - int32_t tree_prev; - int32_t tree_next[MAXTREEFANOUT]; - int32_t tree_nextsize; - } ompi_coll_tree_t; - - ompi_coll_tree_t* - ompi_coll_tuned_topo_build_tree( int fanout, - MPI_Comm com, - int root ); - ompi_coll_tree_t* - ompi_coll_tuned_topo_build_in_order_bintree( MPI_Comm comm ); - - ompi_coll_tree_t* - ompi_coll_tuned_topo_build_bmtree( MPI_Comm comm, - int root ); - ompi_coll_tree_t* ompi_coll_tuned_topo_build_in_order_bmtree(MPI_Comm comm, int root); - ompi_coll_tree_t* - ompi_coll_tuned_topo_build_chain( int fanout, - MPI_Comm com, - int root ); - - int ompi_coll_tuned_topo_destroy_tree( ompi_coll_tree_t** tree ); - - /* debugging stuff, will be removed later */ - int ompi_coll_tuned_topo_dump_tree (ompi_coll_tree_t* tree, int rank); - -#endif /* MCA_COLL_TUNED_TOPO_H_HAS_BEEN_INCLUDED */ - +#define COLL_TUNED_COMPUTED_SEGCOUNT(SEGSIZE, TYPELNG, SEGCOUNT) \ + if (((SEGSIZE) >= (TYPELNG)) && ((SEGSIZE) < ((TYPELNG) * (SEGCOUNT)))) { \ + size_t residual; \ + (SEGCOUNT) = (int)((SEGSIZE) / (TYPELNG)); \ + residual = (SEGSIZE) - (SEGCOUNT) * (TYPELNG); \ + if (residual > ((TYPELNG) >> 1)) \ + (SEGCOUNT)++; \ + } + +typedef struct ompi_coll_tree_t { + int32_t tree_root; + int32_t tree_fanout; + int32_t tree_bmtree; + int32_t tree_prev; + int32_t tree_next[MAXTREEFANOUT]; + int32_t tree_nextsize; +} ompi_coll_tree_t; + +ompi_coll_tree_t* ompi_coll_tuned_topo_build_tree(int fanout, MPI_Comm com, int root); +ompi_coll_tree_t* ompi_coll_tuned_topo_build_in_order_bintree(MPI_Comm comm); + +ompi_coll_tree_t* ompi_coll_tuned_topo_build_bmtree(MPI_Comm comm, int root); +ompi_coll_tree_t* ompi_coll_tuned_topo_build_in_order_bmtree(MPI_Comm comm, int root); +ompi_coll_tree_t* ompi_coll_tuned_topo_build_chain(int fanout, MPI_Comm com, int root); + +int ompi_coll_tuned_topo_destroy_tree(ompi_coll_tree_t** tree); + +/* debugging stuff, will be removed later */ +int ompi_coll_tuned_topo_dump_tree(ompi_coll_tree_t* tree, int rank); + +#endif /* MCA_COLL_TUNED_TOPO_H_HAS_BEEN_INCLUDED */ diff --git a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp index ca81613bf4..7f69d1c550 100644 --- a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp +++ b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp @@ -1,5 +1,6 @@ /* selector for collective algorithms based on mvapich decision logic, with calibration from Stampede cluster at TACC*/ -/* This is the tuning used by MVAPICH for Stampede platform based on (MV2_ARCH_INTEL_XEON_E5_2680_16, MV2_HCA_MLX_CX_FDR) */ +/* This is the tuning used by MVAPICH for Stampede platform based on (MV2_ARCH_INTEL_XEON_E5_2680_16, + * MV2_HCA_MLX_CX_FDR) */ /* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */ @@ -8,17 +9,15 @@ /************ Alltoall variables and initializers */ -#define MV2_MAX_NB_THRESHOLDS 32 - +#define MV2_MAX_NB_THRESHOLDS 32 XBT_PUBLIC(void) smpi_coll_cleanup_mvapich2(void); typedef struct { int min; int max; - int (*MV2_pt_Alltoall_function) (void *sendbuf, int sendcount, MPI_Datatype sendtype, - void *recvbuf, int recvcount, MPI_Datatype recvtype, - MPI_Comm comm_ptr ); + int (*MV2_pt_Alltoall_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm_ptr); } mv2_alltoall_tuning_element; typedef struct { @@ -28,15 +27,15 @@ typedef struct { mv2_alltoall_tuning_element in_place_algo_table[MV2_MAX_NB_THRESHOLDS]; } mv2_alltoall_tuning_table; -int (*MV2_Alltoall_function) (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm_ptr)=NULL; +int (*MV2_Alltoall_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm_ptr) = NULL; /* Indicates number of processes per node */ -int *mv2_alltoall_table_ppn_conf = NULL; +int* mv2_alltoall_table_ppn_conf = NULL; /* Indicates total number of configurations */ -int mv2_alltoall_num_ppn_conf = 1; -int *mv2_size_alltoall_tuning_table = NULL; -mv2_alltoall_tuning_table **mv2_alltoall_thresholds_table = NULL; - +int mv2_alltoall_num_ppn_conf = 1; +int* mv2_size_alltoall_tuning_table = NULL; +mv2_alltoall_tuning_table** mv2_alltoall_thresholds_table = NULL; #define MPIR_Alltoall_bruck_MV2 simgrid::smpi::Coll_alltoall_bruck::alltoall #define MPIR_Alltoall_RD_MV2 simgrid::smpi::Coll_alltoall_rdb::alltoall @@ -44,225 +43,271 @@ mv2_alltoall_tuning_table **mv2_alltoall_thresholds_table = NULL; #define MPIR_Alltoall_pairwise_MV2 simgrid::smpi::Coll_alltoall_pair::alltoall #define MPIR_Alltoall_inplace_MV2 simgrid::smpi::Coll_alltoall_ring::alltoall - -static void init_mv2_alltoall_tables_stampede(){ +static void init_mv2_alltoall_tables_stampede() +{ int i; - int agg_table_sum = 0; - mv2_alltoall_tuning_table **table_ptrs = NULL; - mv2_alltoall_num_ppn_conf = 3; - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_alltoall_thresholds_table = static_cast(xbt_malloc(sizeof(mv2_alltoall_tuning_table *) - * mv2_alltoall_num_ppn_conf)); - table_ptrs = static_cast(xbt_malloc(sizeof(mv2_alltoall_tuning_table *) - * mv2_alltoall_num_ppn_conf)); - mv2_size_alltoall_tuning_table = static_cast(xbt_malloc(sizeof(int) * - mv2_alltoall_num_ppn_conf)); - mv2_alltoall_table_ppn_conf = static_cast(xbt_malloc(mv2_alltoall_num_ppn_conf * sizeof(int))); - mv2_alltoall_table_ppn_conf[0] = 1; + int agg_table_sum = 0; + mv2_alltoall_tuning_table** table_ptrs = NULL; + mv2_alltoall_num_ppn_conf = 3; + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_alltoall_thresholds_table = static_cast( + xbt_malloc(sizeof(mv2_alltoall_tuning_table*) * mv2_alltoall_num_ppn_conf)); + table_ptrs = static_cast( + xbt_malloc(sizeof(mv2_alltoall_tuning_table*) * mv2_alltoall_num_ppn_conf)); + mv2_size_alltoall_tuning_table = static_cast(xbt_malloc(sizeof(int) * mv2_alltoall_num_ppn_conf)); + mv2_alltoall_table_ppn_conf = static_cast(xbt_malloc(mv2_alltoall_num_ppn_conf * sizeof(int))); + mv2_alltoall_table_ppn_conf[0] = 1; mv2_size_alltoall_tuning_table[0] = 6; mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_1ppn[] = { - {2, + { + 2, 1, - {{0, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {4, + { + 4, 2, - {{0, 262144, &MPIR_Alltoall_Scatter_dest_MV2}, - {262144, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, 262144, &MPIR_Alltoall_Scatter_dest_MV2}, {262144, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {8, + { + 8, 2, - {{0, 8, &MPIR_Alltoall_RD_MV2}, - {8, -1, &MPIR_Alltoall_Scatter_dest_MV2}, + { + {0, 8, &MPIR_Alltoall_RD_MV2}, {8, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {16, + { + 16, 3, - {{0, 64, &MPIR_Alltoall_RD_MV2}, + { + {0, 64, &MPIR_Alltoall_RD_MV2}, {64, 512, &MPIR_Alltoall_bruck_MV2}, {512, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0,-1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {32, + { + 32, 3, - {{0, 32, &MPIR_Alltoall_RD_MV2}, + { + {0, 32, &MPIR_Alltoall_RD_MV2}, {32, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {64, + { + 64, 3, - {{0, 8, &MPIR_Alltoall_RD_MV2}, + { + {0, 8, &MPIR_Alltoall_RD_MV2}, {8, 1024, &MPIR_Alltoall_bruck_MV2}, {1024, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, }; - table_ptrs[0] = mv2_tmp_alltoall_thresholds_table_1ppn; - mv2_alltoall_table_ppn_conf[1] = 2; - mv2_size_alltoall_tuning_table[1] = 6; + table_ptrs[0] = mv2_tmp_alltoall_thresholds_table_1ppn; + mv2_alltoall_table_ppn_conf[1] = 2; + mv2_size_alltoall_tuning_table[1] = 6; mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_2ppn[] = { - {4, + { + 4, 2, - {{0, 32, &MPIR_Alltoall_RD_MV2}, - {32, -1, &MPIR_Alltoall_Scatter_dest_MV2}, + { + {0, 32, &MPIR_Alltoall_RD_MV2}, {32, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {8, + { + 8, 2, - {{0, 64, &MPIR_Alltoall_RD_MV2}, - {64, -1, &MPIR_Alltoall_Scatter_dest_MV2}, + { + {0, 64, &MPIR_Alltoall_RD_MV2}, {64, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {16, + { + 16, 3, - {{0, 64, &MPIR_Alltoall_RD_MV2}, + { + {0, 64, &MPIR_Alltoall_RD_MV2}, {64, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0,-1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {32, + { + 32, 3, - {{0, 16, &MPIR_Alltoall_RD_MV2}, + { + {0, 16, &MPIR_Alltoall_RD_MV2}, {16, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {64, + { + 64, 3, - {{0, 8, &MPIR_Alltoall_RD_MV2}, + { + {0, 8, &MPIR_Alltoall_RD_MV2}, {8, 1024, &MPIR_Alltoall_bruck_MV2}, {1024, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {128, + { + 128, 3, - {{0, 4, &MPIR_Alltoall_RD_MV2}, + { + {0, 4, &MPIR_Alltoall_RD_MV2}, {4, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{0, -1, &MPIR_Alltoall_inplace_MV2}, + { + {0, -1, &MPIR_Alltoall_inplace_MV2}, }, }, }; - table_ptrs[1] = mv2_tmp_alltoall_thresholds_table_2ppn; - mv2_alltoall_table_ppn_conf[2] = 16; - mv2_size_alltoall_tuning_table[2] = 7; + table_ptrs[1] = mv2_tmp_alltoall_thresholds_table_2ppn; + mv2_alltoall_table_ppn_conf[2] = 16; + mv2_size_alltoall_tuning_table[2] = 7; mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_16ppn[] = { - {16, + { + 16, 2, - {{0, 2048, &MPIR_Alltoall_bruck_MV2}, - {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, + { + {0, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{32768, -1, &MPIR_Alltoall_inplace_MV2}, + { + {32768, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {32, + { + 32, 2, - {{0, 2048, &MPIR_Alltoall_bruck_MV2}, - {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, + { + {0, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2}, }, - {{16384, -1, &MPIR_Alltoall_inplace_MV2}, + { + {16384, -1, &MPIR_Alltoall_inplace_MV2}, }, }, - {64, + { + 64, 3, - {{0, 2048, &MPIR_Alltoall_bruck_MV2}, + { + {0, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, 16384, &MPIR_Alltoall_Scatter_dest_MV2}, {16384, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{32768, 131072, &MPIR_Alltoall_inplace_MV2}, + { + {32768, 131072, &MPIR_Alltoall_inplace_MV2}, }, }, - {128, + { + 128, 2, - {{0, 2048, &MPIR_Alltoall_bruck_MV2}, - {2048, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, 2048, &MPIR_Alltoall_bruck_MV2}, {2048, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{16384,65536, &MPIR_Alltoall_inplace_MV2}, + { + {16384, 65536, &MPIR_Alltoall_inplace_MV2}, }, }, - {256, + { + 256, 2, - {{0, 1024, &MPIR_Alltoall_bruck_MV2}, - {1024, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, 1024, &MPIR_Alltoall_bruck_MV2}, {1024, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{16384, 65536, &MPIR_Alltoall_inplace_MV2}, + { + {16384, 65536, &MPIR_Alltoall_inplace_MV2}, }, }, - {512, + { + 512, 2, - {{0, 1024, &MPIR_Alltoall_bruck_MV2}, - {1024, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, 1024, &MPIR_Alltoall_bruck_MV2}, {1024, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{16384, 65536, &MPIR_Alltoall_inplace_MV2}, + { + {16384, 65536, &MPIR_Alltoall_inplace_MV2}, }, }, - {1024, + { + 1024, 2, - {{0, 1024, &MPIR_Alltoall_bruck_MV2}, - {1024, -1, &MPIR_Alltoall_pairwise_MV2}, + { + {0, 1024, &MPIR_Alltoall_bruck_MV2}, {1024, -1, &MPIR_Alltoall_pairwise_MV2}, }, - {{16384, 65536, &MPIR_Alltoall_inplace_MV2}, + { + {16384, 65536, &MPIR_Alltoall_inplace_MV2}, }, }, @@ -270,38 +315,27 @@ static void init_mv2_alltoall_tables_stampede(){ table_ptrs[2] = mv2_tmp_alltoall_thresholds_table_16ppn; agg_table_sum = 0; for (i = 0; i < mv2_alltoall_num_ppn_conf; i++) { - agg_table_sum += mv2_size_alltoall_tuning_table[i]; + agg_table_sum += mv2_size_alltoall_tuning_table[i]; } mv2_alltoall_thresholds_table[0] = - static_cast(xbt_malloc(agg_table_sum * sizeof (mv2_alltoall_tuning_table))); + static_cast(xbt_malloc(agg_table_sum * sizeof(mv2_alltoall_tuning_table))); memcpy(mv2_alltoall_thresholds_table[0], table_ptrs[0], - (sizeof(mv2_alltoall_tuning_table) - * mv2_size_alltoall_tuning_table[0])); + (sizeof(mv2_alltoall_tuning_table) * mv2_size_alltoall_tuning_table[0])); for (i = 1; i < mv2_alltoall_num_ppn_conf; i++) { - mv2_alltoall_thresholds_table[i] = - mv2_alltoall_thresholds_table[i - 1] - + mv2_size_alltoall_tuning_table[i - 1]; - memcpy(mv2_alltoall_thresholds_table[i], table_ptrs[i], - (sizeof(mv2_alltoall_tuning_table) - * mv2_size_alltoall_tuning_table[i])); + mv2_alltoall_thresholds_table[i] = mv2_alltoall_thresholds_table[i - 1] + mv2_size_alltoall_tuning_table[i - 1]; + memcpy(mv2_alltoall_thresholds_table[i], table_ptrs[i], + (sizeof(mv2_alltoall_tuning_table) * mv2_size_alltoall_tuning_table[i])); } xbt_free(table_ptrs); - - } - /************ Allgather variables and initializers */ typedef struct { int min; int max; - int (*MV2_pt_Allgatherction)(void *sendbuf, - int sendcount, - MPI_Datatype sendtype, - void *recvbuf, - int recvcount, - MPI_Datatype recvtype, MPI_Comm comm_ptr); + int (*MV2_pt_Allgatherction)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm_ptr); } mv2_allgather_tuning_element; typedef struct { @@ -311,26 +345,18 @@ typedef struct { mv2_allgather_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; } mv2_allgather_tuning_table; -int (*MV2_Allgatherction)(void *sendbuf, - int sendcount, - MPI_Datatype sendtype, - void *recvbuf, - int recvcount, - MPI_Datatype recvtype, MPI_Comm comm); - -int *mv2_allgather_table_ppn_conf = NULL; -int mv2_allgather_num_ppn_conf = 1; -int *mv2_size_allgather_tuning_table = NULL; -mv2_allgather_tuning_table **mv2_allgather_thresholds_table = NULL; - -static int MPIR_Allgather_RD_Allgather_Comm_MV2( void *sendbuf, - int sendcount, - MPI_Datatype sendtype, - void *recvbuf, - int recvcount, - MPI_Datatype recvtype, MPI_Comm comm_ptr) +int (*MV2_Allgatherction)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm); + +int* mv2_allgather_table_ppn_conf = NULL; +int mv2_allgather_num_ppn_conf = 1; +int* mv2_size_allgather_tuning_table = NULL; +mv2_allgather_tuning_table** mv2_allgather_thresholds_table = NULL; + +static int MPIR_Allgather_RD_Allgather_Comm_MV2(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, + int recvcount, MPI_Datatype recvtype, MPI_Comm comm_ptr) { - return 0; + return 0; } #define MPIR_Allgather_Bruck_MV2 simgrid::smpi::Coll_allgather_bruck::allgather @@ -338,24 +364,22 @@ static int MPIR_Allgather_RD_Allgather_Comm_MV2( void *sendbuf, #define MPIR_Allgather_Ring_MV2 simgrid::smpi::Coll_allgather_ring::allgather #define MPIR_2lvl_Allgather_MV2 simgrid::smpi::Coll_allgather_mvapich2_smp::allgather -static void init_mv2_allgather_tables_stampede(){ +static void init_mv2_allgather_tables_stampede() +{ int i; int agg_table_sum = 0; - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_allgather_tuning_table **table_ptrs = NULL; - mv2_allgather_num_ppn_conf = 3; - mv2_allgather_thresholds_table - = static_cast(xbt_malloc(sizeof(mv2_allgather_tuning_table *) - * mv2_allgather_num_ppn_conf)); - table_ptrs = static_cast(xbt_malloc(sizeof(mv2_allgather_tuning_table *) - * mv2_allgather_num_ppn_conf)); - mv2_size_allgather_tuning_table = static_cast(xbt_malloc(sizeof(int) * - mv2_allgather_num_ppn_conf)); - mv2_allgather_table_ppn_conf - = static_cast(xbt_malloc(mv2_allgather_num_ppn_conf * sizeof(int))); - mv2_allgather_table_ppn_conf[0] = 1; + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_allgather_tuning_table** table_ptrs = NULL; + mv2_allgather_num_ppn_conf = 3; + mv2_allgather_thresholds_table = static_cast( + xbt_malloc(sizeof(mv2_allgather_tuning_table*) * mv2_allgather_num_ppn_conf)); + table_ptrs = static_cast( + xbt_malloc(sizeof(mv2_allgather_tuning_table*) * mv2_allgather_num_ppn_conf)); + mv2_size_allgather_tuning_table = static_cast(xbt_malloc(sizeof(int) * mv2_allgather_num_ppn_conf)); + mv2_allgather_table_ppn_conf = static_cast(xbt_malloc(mv2_allgather_num_ppn_conf * sizeof(int))); + mv2_allgather_table_ppn_conf[0] = 1; mv2_size_allgather_tuning_table[0] = 6; mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_1ppn[] = { { @@ -368,66 +392,60 @@ static void init_mv2_allgather_tables_stampede(){ }, { 4, - {0,0}, + {0, 0}, 2, { - {0, 262144, &MPIR_Allgather_RD_MV2}, - {262144, -1, &MPIR_Allgather_Ring_MV2}, + {0, 262144, &MPIR_Allgather_RD_MV2}, {262144, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 8, - {0,0}, + {0, 0}, 2, { - {0, 131072, &MPIR_Allgather_RD_MV2}, - {131072, -1, &MPIR_Allgather_Ring_MV2}, + {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 16, - {0,0}, + {0, 0}, 2, { - {0, 131072, &MPIR_Allgather_RD_MV2}, - {131072, -1, &MPIR_Allgather_Ring_MV2}, + {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 32, - {0,0}, + {0, 0}, 2, { - {0, 65536, &MPIR_Allgather_RD_MV2}, - {65536, -1, &MPIR_Allgather_Ring_MV2}, + {0, 65536, &MPIR_Allgather_RD_MV2}, {65536, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 64, - {0,0}, + {0, 0}, 2, { - {0, 32768, &MPIR_Allgather_RD_MV2}, - {32768, -1, &MPIR_Allgather_Ring_MV2}, + {0, 32768, &MPIR_Allgather_RD_MV2}, {32768, -1, &MPIR_Allgather_Ring_MV2}, }, }, }; - table_ptrs[0] = mv2_tmp_allgather_thresholds_table_1ppn; - mv2_allgather_table_ppn_conf[1] = 2; - mv2_size_allgather_tuning_table[1] = 6; + table_ptrs[0] = mv2_tmp_allgather_thresholds_table_1ppn; + mv2_allgather_table_ppn_conf[1] = 2; + mv2_size_allgather_tuning_table[1] = 6; mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_2ppn[] = { { 4, - {0,0}, + {0, 0}, 2, { - {0, 524288, &MPIR_Allgather_RD_MV2}, - {524288, -1, &MPIR_Allgather_Ring_MV2}, + {0, 524288, &MPIR_Allgather_RD_MV2}, {524288, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 8, - {0,1,0}, + {0, 1, 0}, 2, { {0, 32768, &MPIR_Allgather_RD_MV2}, @@ -437,7 +455,7 @@ static void init_mv2_allgather_tables_stampede(){ }, { 16, - {0,1,0}, + {0, 1, 0}, 2, { {0, 16384, &MPIR_Allgather_RD_MV2}, @@ -447,7 +465,7 @@ static void init_mv2_allgather_tables_stampede(){ }, { 32, - {1,1,0}, + {1, 1, 0}, 2, { {0, 65536, &MPIR_Allgather_RD_MV2}, @@ -457,7 +475,7 @@ static void init_mv2_allgather_tables_stampede(){ }, { 64, - {1,1,0}, + {1, 1, 0}, 2, { {0, 32768, &MPIR_Allgather_RD_MV2}, @@ -467,7 +485,7 @@ static void init_mv2_allgather_tables_stampede(){ }, { 128, - {1,1,0}, + {1, 1, 0}, 2, { {0, 65536, &MPIR_Allgather_RD_MV2}, @@ -476,62 +494,56 @@ static void init_mv2_allgather_tables_stampede(){ }, }, }; - table_ptrs[1] = mv2_tmp_allgather_thresholds_table_2ppn; - mv2_allgather_table_ppn_conf[2] = 16; - mv2_size_allgather_tuning_table[2] = 6; + table_ptrs[1] = mv2_tmp_allgather_thresholds_table_2ppn; + mv2_allgather_table_ppn_conf[2] = 16; + mv2_size_allgather_tuning_table[2] = 6; mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_16ppn[] = { { 16, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 32, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 64, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 128, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 256, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, { 512, - {0,0}, + {0, 0}, 2, { - {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, - {1024, -1, &MPIR_Allgather_Ring_MV2}, + {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, }, }, @@ -539,36 +551,29 @@ static void init_mv2_allgather_tables_stampede(){ table_ptrs[2] = mv2_tmp_allgather_thresholds_table_16ppn; agg_table_sum = 0; for (i = 0; i < mv2_allgather_num_ppn_conf; i++) { - agg_table_sum += mv2_size_allgather_tuning_table[i]; + agg_table_sum += mv2_size_allgather_tuning_table[i]; } mv2_allgather_thresholds_table[0] = - static_cast(xbt_malloc(agg_table_sum * sizeof (mv2_allgather_tuning_table))); + static_cast(xbt_malloc(agg_table_sum * sizeof(mv2_allgather_tuning_table))); memcpy(mv2_allgather_thresholds_table[0], table_ptrs[0], - (sizeof(mv2_allgather_tuning_table) - * mv2_size_allgather_tuning_table[0])); + (sizeof(mv2_allgather_tuning_table) * mv2_size_allgather_tuning_table[0])); for (i = 1; i < mv2_allgather_num_ppn_conf; i++) { - mv2_allgather_thresholds_table[i] = - mv2_allgather_thresholds_table[i - 1] - + mv2_size_allgather_tuning_table[i - 1]; - memcpy(mv2_allgather_thresholds_table[i], table_ptrs[i], - (sizeof(mv2_allgather_tuning_table) - * mv2_size_allgather_tuning_table[i])); + mv2_allgather_thresholds_table[i] = mv2_allgather_thresholds_table[i - 1] + mv2_size_allgather_tuning_table[i - 1]; + memcpy(mv2_allgather_thresholds_table[i], table_ptrs[i], + (sizeof(mv2_allgather_tuning_table) * mv2_size_allgather_tuning_table[i])); } xbt_free(table_ptrs); } - /************ Gather variables and initializers */ typedef struct { int min; int max; - int (*MV2_pt_Gather_function)(void *sendbuf, int sendcnt, - MPI_Datatype sendtype, void *recvbuf, int recvcnt, - MPI_Datatype recvtype, int root, MPI_Comm comm_ptr); + int (*MV2_pt_Gather_function)(void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm_ptr); } mv2_gather_tuning_element; - typedef struct { int numproc; int size_inter_table; @@ -577,90 +582,88 @@ typedef struct { mv2_gather_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; } mv2_gather_tuning_table; -int mv2_size_gather_tuning_table=7; -mv2_gather_tuning_table * mv2_gather_thresholds_table=NULL; +int mv2_size_gather_tuning_table = 7; +mv2_gather_tuning_table* mv2_gather_thresholds_table = NULL; -typedef int (*MV2_Gather_function_ptr) (void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm); +typedef int (*MV2_Gather_function_ptr)(void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm); MV2_Gather_function_ptr MV2_Gather_inter_leader_function = NULL; -MV2_Gather_function_ptr MV2_Gather_intra_node_function = NULL; - - +MV2_Gather_function_ptr MV2_Gather_intra_node_function = NULL; #define MPIR_Gather_MV2_Direct simgrid::smpi::Coll_gather_ompi_basic_linear::gather #define MPIR_Gather_MV2_two_level_Direct simgrid::smpi::Coll_gather_mvapich2_two_level::gather #define MPIR_Gather_intra simgrid::smpi::Coll_gather_mpich::gather +static void init_mv2_gather_tables_stampede() +{ -static void init_mv2_gather_tables_stampede(){ - - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_size_gather_tuning_table=7; - mv2_gather_thresholds_table = static_cast(xbt_malloc(mv2_size_gather_tuning_table* - sizeof (mv2_gather_tuning_table))); - mv2_gather_tuning_table mv2_tmp_gather_thresholds_table[]={ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_size_gather_tuning_table = 7; + mv2_gather_thresholds_table = + static_cast(xbt_malloc(mv2_size_gather_tuning_table * sizeof(mv2_gather_tuning_table))); + mv2_gather_tuning_table mv2_tmp_gather_thresholds_table[] = { {16, - 2,{{0, 524288, &MPIR_Gather_MV2_Direct}, - {524288, -1, &MPIR_Gather_intra}}, - 1,{{0, -1, &MPIR_Gather_MV2_Direct}}}, - {32, - 3,{{0, 16384, &MPIR_Gather_MV2_Direct}, - {16384, 131072, &MPIR_Gather_intra}, - {131072, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, - {64, - 3,{{0, 256, &MPIR_Gather_MV2_two_level_Direct}, - {256, 16384, &MPIR_Gather_MV2_Direct}, - {256, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, - {128, - 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct}, - {512, 16384, &MPIR_Gather_MV2_Direct}, - {16384, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, - {256, - 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct}, - {512, 16384, &MPIR_Gather_MV2_Direct}, - {16384, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, - {512, - 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct}, - {512, 16384, &MPIR_Gather_MV2_Direct}, - {8196, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, - {1024, - 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct}, - {512, 16384, &MPIR_Gather_MV2_Direct}, - {8196, -1, &MPIR_Gather_MV2_two_level_Direct}}, - 1,{{0, -1, &MPIR_Gather_intra}}}, + 2, + {{0, 524288, &MPIR_Gather_MV2_Direct}, {524288, -1, &MPIR_Gather_intra}}, + 1, + {{0, -1, &MPIR_Gather_MV2_Direct}}}, + {32, + 3, + {{0, 16384, &MPIR_Gather_MV2_Direct}, + {16384, 131072, &MPIR_Gather_intra}, + {131072, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, + {64, + 3, + {{0, 256, &MPIR_Gather_MV2_two_level_Direct}, + {256, 16384, &MPIR_Gather_MV2_Direct}, + {256, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, + {128, + 3, + {{0, 512, &MPIR_Gather_MV2_two_level_Direct}, + {512, 16384, &MPIR_Gather_MV2_Direct}, + {16384, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, + {256, + 3, + {{0, 512, &MPIR_Gather_MV2_two_level_Direct}, + {512, 16384, &MPIR_Gather_MV2_Direct}, + {16384, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, + {512, + 3, + {{0, 512, &MPIR_Gather_MV2_two_level_Direct}, + {512, 16384, &MPIR_Gather_MV2_Direct}, + {8196, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, + {1024, + 3, + {{0, 512, &MPIR_Gather_MV2_two_level_Direct}, + {512, 16384, &MPIR_Gather_MV2_Direct}, + {8196, -1, &MPIR_Gather_MV2_two_level_Direct}}, + 1, + {{0, -1, &MPIR_Gather_intra}}}, }; memcpy(mv2_gather_thresholds_table, mv2_tmp_gather_thresholds_table, - mv2_size_gather_tuning_table * sizeof (mv2_gather_tuning_table)); - + mv2_size_gather_tuning_table * sizeof(mv2_gather_tuning_table)); } - /************ Allgatherv variables and initializers */ typedef struct { int min; int max; - int (*MV2_pt_Allgatherv_function)(void *sendbuf, - int sendcount, - MPI_Datatype sendtype, - void *recvbuf, - int *recvcounts, - int *displs, - MPI_Datatype recvtype, - MPI_Comm commg); + int (*MV2_pt_Allgatherv_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, + int* displs, MPI_Datatype recvtype, MPI_Comm commg); } mv2_allgatherv_tuning_element; typedef struct { @@ -669,95 +672,79 @@ typedef struct { mv2_allgatherv_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; } mv2_allgatherv_tuning_table; -int (*MV2_Allgatherv_function)(void *sendbuf, - int sendcount, - MPI_Datatype sendtype, - void *recvbuf, - int *recvcounts, - int *displs, - MPI_Datatype recvtype, - MPI_Comm comm); +int (*MV2_Allgatherv_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, + int* displs, MPI_Datatype recvtype, MPI_Comm comm); -int mv2_size_allgatherv_tuning_table = 0; -mv2_allgatherv_tuning_table *mv2_allgatherv_thresholds_table = NULL; +int mv2_size_allgatherv_tuning_table = 0; +mv2_allgatherv_tuning_table* mv2_allgatherv_thresholds_table = NULL; #define MPIR_Allgatherv_Rec_Doubling_MV2 simgrid::smpi::Coll_allgatherv_mpich_rdb::allgatherv #define MPIR_Allgatherv_Bruck_MV2 simgrid::smpi::Coll_allgatherv_ompi_bruck::allgatherv #define MPIR_Allgatherv_Ring_MV2 simgrid::smpi::Coll_allgatherv_mpich_ring::allgatherv - -static void init_mv2_allgatherv_tables_stampede(){ - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_size_allgatherv_tuning_table = 6; - mv2_allgatherv_thresholds_table = static_cast(xbt_malloc(mv2_size_allgatherv_tuning_table * - sizeof (mv2_allgatherv_tuning_table))); +static void init_mv2_allgatherv_tables_stampede() +{ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_size_allgatherv_tuning_table = 6; + mv2_allgatherv_thresholds_table = static_cast( + xbt_malloc(mv2_size_allgatherv_tuning_table * sizeof(mv2_allgatherv_tuning_table))); mv2_allgatherv_tuning_table mv2_tmp_allgatherv_thresholds_table[] = { { 16, 2, { - {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {512, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2}, {512, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, { 32, 2, { - {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {512, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2}, {512, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, { 64, 2, { - {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {256, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, {256, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, { 128, 2, { - {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {256, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, {256, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, { 256, 2, { - {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {256, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, {256, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, { 512, 2, { - {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, - {256, -1, &MPIR_Allgatherv_Ring_MV2}, + {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2}, {256, -1, &MPIR_Allgatherv_Ring_MV2}, }, }, }; memcpy(mv2_allgatherv_thresholds_table, mv2_tmp_allgatherv_thresholds_table, - mv2_size_allgatherv_tuning_table * sizeof (mv2_allgatherv_tuning_table)); + mv2_size_allgatherv_tuning_table * sizeof(mv2_allgatherv_tuning_table)); } - /************ Allreduce variables and initializers */ typedef struct { int min; int max; - int (*MV2_pt_Allreducection)(void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm); + int (*MV2_pt_Allreducection)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm); } mv2_allreduce_tuning_element; typedef struct { @@ -770,62 +757,38 @@ typedef struct { mv2_allreduce_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; } mv2_allreduce_tuning_table; +int (*MV2_Allreducection)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm) = NULL; -int (*MV2_Allreducection)(void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm)=NULL; - - -int (*MV2_Allreduce_intra_function)( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm)=NULL; - -int mv2_size_allreduce_tuning_table = 0; -mv2_allreduce_tuning_table *mv2_allreduce_thresholds_table = NULL; - +int (*MV2_Allreduce_intra_function)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm) = NULL; +int mv2_size_allreduce_tuning_table = 0; +mv2_allreduce_tuning_table* mv2_allreduce_thresholds_table = NULL; - - -static int MPIR_Allreduce_mcst_reduce_two_level_helper_MV2( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm) +static int MPIR_Allreduce_mcst_reduce_two_level_helper_MV2(void* sendbuf, void* recvbuf, int count, + MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { return 0; } -static int MPIR_Allreduce_mcst_reduce_redscat_gather_MV2( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm) +static int MPIR_Allreduce_mcst_reduce_redscat_gather_MV2(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, + MPI_Op op, MPI_Comm comm) { return 0; } -static int MPIR_Allreduce_reduce_p2p_MV2( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm) +static int MPIR_Allreduce_reduce_p2p_MV2(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm) { - simgrid::smpi::Colls::reduce(sendbuf,recvbuf,count,datatype,op,0,comm); + simgrid::smpi::Colls::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm); return MPI_SUCCESS; } -static int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, MPI_Comm comm) +static int MPIR_Allreduce_reduce_shmem_MV2(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm) { - simgrid::smpi::Colls::reduce(sendbuf,recvbuf,count,datatype,op,0,comm); + simgrid::smpi::Colls::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm); return MPI_SUCCESS; } @@ -833,13 +796,13 @@ static int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf, #define MPIR_Allreduce_pt2pt_rs_MV2 simgrid::smpi::Coll_allreduce_mvapich2_rs::allreduce #define MPIR_Allreduce_two_level_MV2 simgrid::smpi::Coll_allreduce_mvapich2_two_level::allreduce - -static void init_mv2_allreduce_tables_stampede(){ - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_size_allreduce_tuning_table = 8; - mv2_allreduce_thresholds_table = static_cast(xbt_malloc(mv2_size_allreduce_tuning_table * - sizeof (mv2_allreduce_tuning_table))); +static void init_mv2_allreduce_tables_stampede() +{ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_size_allreduce_tuning_table = 8; + mv2_allreduce_thresholds_table = static_cast( + xbt_malloc(mv2_size_allreduce_tuning_table * sizeof(mv2_allreduce_tuning_table))); mv2_allreduce_tuning_table mv2_tmp_allreduce_thresholds_table[] = { { 16, @@ -847,13 +810,11 @@ static void init_mv2_allreduce_tables_stampede(){ {1, 0}, 2, { - {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, - {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2}, + {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2}, }, 2, { - {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2}, - {1024, -1, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2}, {1024, -1, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -868,8 +829,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2}, - {1024, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2}, {1024, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -884,8 +844,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -900,8 +859,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -916,8 +874,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -932,8 +889,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -949,8 +905,7 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, { @@ -967,57 +922,50 @@ static void init_mv2_allreduce_tables_stampede(){ }, 2, { - {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, - {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, + {0, 512, &MPIR_Allreduce_reduce_shmem_MV2}, {512, -1, &MPIR_Allreduce_reduce_p2p_MV2}, }, }, }; memcpy(mv2_allreduce_thresholds_table, mv2_tmp_allreduce_thresholds_table, - mv2_size_allreduce_tuning_table * sizeof (mv2_allreduce_tuning_table)); + mv2_size_allreduce_tuning_table * sizeof(mv2_allreduce_tuning_table)); } - - - typedef struct { - int min; - int max; - int (*MV2_pt_Bcast_function) (void *buf, int count, MPI_Datatype datatype, - int root, MPI_Comm comm_ptr); - int zcpy_pipelined_knomial_factor; + int min; + int max; + int (*MV2_pt_Bcast_function)(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm_ptr); + int zcpy_pipelined_knomial_factor; } mv2_bcast_tuning_element; typedef struct { - int numproc; - int bcast_segment_size; - int intra_node_knomial_factor; - int inter_node_knomial_factor; - int is_two_level_bcast[MV2_MAX_NB_THRESHOLDS]; - int size_inter_table; - mv2_bcast_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; - int size_intra_table; - mv2_bcast_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; + int numproc; + int bcast_segment_size; + int intra_node_knomial_factor; + int inter_node_knomial_factor; + int is_two_level_bcast[MV2_MAX_NB_THRESHOLDS]; + int size_inter_table; + mv2_bcast_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; + int size_intra_table; + mv2_bcast_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; } mv2_bcast_tuning_table; -int mv2_size_bcast_tuning_table = 0; -mv2_bcast_tuning_table *mv2_bcast_thresholds_table = NULL; - +int mv2_size_bcast_tuning_table = 0; +mv2_bcast_tuning_table* mv2_bcast_thresholds_table = NULL; -int (*MV2_Bcast_function) (void *buffer, int count, MPI_Datatype datatype, - int root, MPI_Comm comm_ptr) = NULL; +int (*MV2_Bcast_function)(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm_ptr) = NULL; -int (*MV2_Bcast_intra_node_function) (void *buffer, int count, MPI_Datatype datatype, - int root, MPI_Comm comm_ptr) = NULL; +int (*MV2_Bcast_intra_node_function)(void* buffer, int count, MPI_Datatype datatype, int root, + MPI_Comm comm_ptr) = NULL; -int zcpy_knomial_factor = 2; +int zcpy_knomial_factor = 2; int mv2_pipelined_zcpy_knomial_factor = -1; -int bcast_segment_size = 8192; -int mv2_inter_node_knomial_factor = 4; -int mv2_intra_node_knomial_factor = 4; -#define mv2_bcast_two_level_system_size 64 -#define mv2_bcast_short_msg 16384 -#define mv2_bcast_large_msg 512*1024 +int bcast_segment_size = 8192; +int mv2_inter_node_knomial_factor = 4; +int mv2_intra_node_knomial_factor = 4; +#define mv2_bcast_two_level_system_size 64 +#define mv2_bcast_short_msg 16384 +#define mv2_bcast_large_msg 512 * 1024 #define INTRA_NODE_ROOT 0 @@ -1033,230 +981,192 @@ int mv2_intra_node_knomial_factor = 4; #define MPIR_Knomial_Bcast_intra_node_MV2 simgrid::smpi::Coll_bcast_mvapich2_knomial_intra_node::bcast #define MPIR_Bcast_intra_MV2 simgrid::smpi::Coll_bcast_mvapich2_intra_node::bcast -static void init_mv2_bcast_tables_stampede(){ - //Stampede, - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_size_bcast_tuning_table=8; - mv2_bcast_thresholds_table = static_cast(xbt_malloc(mv2_size_bcast_tuning_table * - sizeof (mv2_bcast_tuning_table))); - - mv2_bcast_tuning_table mv2_tmp_bcast_thresholds_table[]={ - { - 16, - 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - 11, - { - {0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16, 1024, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {1024, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {8192, 16384, &MPIR_Bcast_binomial_MV2, -1}, - {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {65536, 131072, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}, - {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}, - {262144, 524288, &MPIR_Bcast_scatter_doubling_allgather_MV2, -1}, - {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1} - }, - 11, - { - {0, 8, &MPIR_Shmem_Bcast_MV2, 2}, - {8, 16, &MPIR_Shmem_Bcast_MV2, 4}, - {16, 1024, &MPIR_Shmem_Bcast_MV2, 2}, - {1024, 8192, &MPIR_Shmem_Bcast_MV2, 4}, - {8192, 16384, &MPIR_Shmem_Bcast_MV2, -1}, - {16384, 32768, &MPIR_Shmem_Bcast_MV2, 4}, - {32768, 65536, &MPIR_Shmem_Bcast_MV2, 2}, - {65536, 131072, &MPIR_Shmem_Bcast_MV2, -1}, - {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, - {262144, 524288, &MPIR_Shmem_Bcast_MV2, -1}, - {524288, -1, &MPIR_Shmem_Bcast_MV2, -1} - } - }, - { - 32, - 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1}, - 8, - { - {0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {256, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {65536, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {131072, 262144, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {524288, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8} - }, - 8, - { - {0, 128, &MPIR_Shmem_Bcast_MV2, 2}, - {128, 256, &MPIR_Shmem_Bcast_MV2, 4}, - {256, 32768, &MPIR_Shmem_Bcast_MV2, 2}, - {32768, 65536, &MPIR_Shmem_Bcast_MV2, 4}, - {65536, 131072, &MPIR_Shmem_Bcast_MV2, 2}, - {131072, 262144, &MPIR_Shmem_Bcast_MV2, 8}, - {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2}, - {524288, -1, &MPIR_Shmem_Bcast_MV2, 8} - } - }, - { - 64, - 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1, 1}, - 9, - { - {0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {4, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {32, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {256, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {4096, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {32768, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2} - }, - 9, - { - {0, 2, &MPIR_Shmem_Bcast_MV2, 4}, - {2, 4, &MPIR_Shmem_Bcast_MV2, 8}, - {4, 16, &MPIR_Shmem_Bcast_MV2, 4}, - {16, 32, &MPIR_Shmem_Bcast_MV2, 8}, - {32, 128, &MPIR_Shmem_Bcast_MV2, 4}, - {128, 256, &MPIR_Shmem_Bcast_MV2, 8}, - {256, 4096, &MPIR_Shmem_Bcast_MV2, 4}, - {4096, 32768, &MPIR_Shmem_Bcast_MV2, 8}, - {32768, -1, &MPIR_Shmem_Bcast_MV2, 2} - } - }, - { - 128, - 8192, 4, 4, - {1, 1, 1, 0}, - 4, - { - {0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16384, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1} - }, - 4, - { - {0, 8192, &MPIR_Shmem_Bcast_MV2, 8}, - {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4}, - {16384, 524288, &MPIR_Shmem_Bcast_MV2, 2}, - {524288, -1, NULL, -1} - } - }, - { - 256, - 8192, 4, 4, - {1, 1, 1, 1, 1}, - 5, - { - {0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}, - {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1} - }, - 5, - { - {0, 16384, &MPIR_Shmem_Bcast_MV2, 4}, - {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2}, - {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, - {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2}, - {524288, -1, &MPIR_Shmem_Bcast_MV2, -1} - } - }, - { - 512, - 8192, 4, 4, - {1, 1, 1, 1, 1}, - 5, - { - {0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {131072, 262144, &MPIR_Pipelined_Bcast_MV2, -1}, - {262144, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1} - }, - 5, - { - {0, 4096, &MPIR_Shmem_Bcast_MV2, 8}, - {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4}, - {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2}, - {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, - {262144, -1, &MPIR_Shmem_Bcast_MV2, -1} - } - }, - { - 1024, - 8192, 4, 4, - {1, 1, 1, 1, 1}, - 5, - { - {0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16384, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {65536, 524288, &MPIR_Pipelined_Bcast_MV2, -1}, - {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1} - }, - 5, - { - {0, 8192, &MPIR_Shmem_Bcast_MV2, 8}, - {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4}, - {16384, 65536, &MPIR_Shmem_Bcast_MV2, 2}, - {65536, 524288, &MPIR_Shmem_Bcast_MV2, -1}, - {524288, -1, &MPIR_Shmem_Bcast_MV2, -1} - } - }, - { - 2048, - 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1}, - 7, - { - {0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {32, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, - {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, - {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, - {32768, 524288, &MPIR_Pipelined_Bcast_MV2, -1}, - {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1} - }, - 7, - { - {0, 16, &MPIR_Shmem_Bcast_MV2, 8}, - {16, 32, &MPIR_Shmem_Bcast_MV2, 4}, - {32, 4096, &MPIR_Shmem_Bcast_MV2, 8}, - {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4}, - {16384, 32768, &MPIR_Shmem_Bcast_MV2, 2}, - {32768, 524288, &MPIR_Shmem_Bcast_MV2, -1}, - {524288, -1, &MPIR_Shmem_Bcast_MV2, -1} - } - } - }; - - memcpy(mv2_bcast_thresholds_table, mv2_tmp_bcast_thresholds_table, - mv2_size_bcast_tuning_table * sizeof (mv2_bcast_tuning_table)); +static void init_mv2_bcast_tables_stampede() +{ + // Stampede, + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_size_bcast_tuning_table = 8; + mv2_bcast_thresholds_table = + static_cast(xbt_malloc(mv2_size_bcast_tuning_table * sizeof(mv2_bcast_tuning_table))); + + mv2_bcast_tuning_table mv2_tmp_bcast_thresholds_table[] = { + {16, + 8192, + 4, + 4, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + 11, + {{0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16, 1024, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {1024, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {8192, 16384, &MPIR_Bcast_binomial_MV2, -1}, + {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {65536, 131072, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}, + {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}, + {262144, 524288, &MPIR_Bcast_scatter_doubling_allgather_MV2, -1}, + {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}}, + 11, + {{0, 8, &MPIR_Shmem_Bcast_MV2, 2}, + {8, 16, &MPIR_Shmem_Bcast_MV2, 4}, + {16, 1024, &MPIR_Shmem_Bcast_MV2, 2}, + {1024, 8192, &MPIR_Shmem_Bcast_MV2, 4}, + {8192, 16384, &MPIR_Shmem_Bcast_MV2, -1}, + {16384, 32768, &MPIR_Shmem_Bcast_MV2, 4}, + {32768, 65536, &MPIR_Shmem_Bcast_MV2, 2}, + {65536, 131072, &MPIR_Shmem_Bcast_MV2, -1}, + {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, + {262144, 524288, &MPIR_Shmem_Bcast_MV2, -1}, + {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}}}, + {32, + 8192, + 4, + 4, + {1, 1, 1, 1, 1, 1, 1, 1}, + 8, + {{0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {256, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {65536, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {131072, 262144, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {524288, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}}, + 8, + {{0, 128, &MPIR_Shmem_Bcast_MV2, 2}, + {128, 256, &MPIR_Shmem_Bcast_MV2, 4}, + {256, 32768, &MPIR_Shmem_Bcast_MV2, 2}, + {32768, 65536, &MPIR_Shmem_Bcast_MV2, 4}, + {65536, 131072, &MPIR_Shmem_Bcast_MV2, 2}, + {131072, 262144, &MPIR_Shmem_Bcast_MV2, 8}, + {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2}, + {524288, -1, &MPIR_Shmem_Bcast_MV2, 8}}}, + {64, + 8192, + 4, + 4, + {1, 1, 1, 1, 1, 1, 1, 1, 1}, + 9, + {{0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {4, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {32, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {256, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {4096, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {32768, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}}, + 9, + {{0, 2, &MPIR_Shmem_Bcast_MV2, 4}, + {2, 4, &MPIR_Shmem_Bcast_MV2, 8}, + {4, 16, &MPIR_Shmem_Bcast_MV2, 4}, + {16, 32, &MPIR_Shmem_Bcast_MV2, 8}, + {32, 128, &MPIR_Shmem_Bcast_MV2, 4}, + {128, 256, &MPIR_Shmem_Bcast_MV2, 8}, + {256, 4096, &MPIR_Shmem_Bcast_MV2, 4}, + {4096, 32768, &MPIR_Shmem_Bcast_MV2, 8}, + {32768, -1, &MPIR_Shmem_Bcast_MV2, 2}}}, + {128, + 8192, + 4, + 4, + {1, 1, 1, 0}, + 4, + {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16384, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}}, + 4, + {{0, 8192, &MPIR_Shmem_Bcast_MV2, 8}, + {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4}, + {16384, 524288, &MPIR_Shmem_Bcast_MV2, 2}, + {524288, -1, NULL, -1}}}, + {256, + 8192, + 4, + 4, + {1, 1, 1, 1, 1}, + 5, + {{0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}, + {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}}, + 5, + {{0, 16384, &MPIR_Shmem_Bcast_MV2, 4}, + {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2}, + {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, + {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2}, + {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}}}, + {512, + 8192, + 4, + 4, + {1, 1, 1, 1, 1}, + 5, + {{0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {131072, 262144, &MPIR_Pipelined_Bcast_MV2, -1}, + {262144, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}}, + 5, + {{0, 4096, &MPIR_Shmem_Bcast_MV2, 8}, + {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4}, + {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2}, + {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1}, + {262144, -1, &MPIR_Shmem_Bcast_MV2, -1}}}, + {1024, + 8192, + 4, + 4, + {1, 1, 1, 1, 1}, + 5, + {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16384, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {65536, 524288, &MPIR_Pipelined_Bcast_MV2, -1}, + {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}}, + 5, + {{0, 8192, &MPIR_Shmem_Bcast_MV2, 8}, + {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4}, + {16384, 65536, &MPIR_Shmem_Bcast_MV2, 2}, + {65536, 524288, &MPIR_Shmem_Bcast_MV2, -1}, + {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}}}, + {2048, + 8192, + 4, + 4, + {1, 1, 1, 1, 1, 1, 1}, + 7, + {{0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {32, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, + {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, + {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, + {32768, 524288, &MPIR_Pipelined_Bcast_MV2, -1}, + {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}}, + 7, + {{0, 16, &MPIR_Shmem_Bcast_MV2, 8}, + {16, 32, &MPIR_Shmem_Bcast_MV2, 4}, + {32, 4096, &MPIR_Shmem_Bcast_MV2, 8}, + {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4}, + {16384, 32768, &MPIR_Shmem_Bcast_MV2, 2}, + {32768, 524288, &MPIR_Shmem_Bcast_MV2, -1}, + {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}}}}; + + memcpy(mv2_bcast_thresholds_table, mv2_tmp_bcast_thresholds_table, + mv2_size_bcast_tuning_table * sizeof(mv2_bcast_tuning_table)); } - /************ Reduce variables and initializers */ typedef struct { int min; int max; - int (*MV2_pt_Reduce_function)(void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, - int root, - MPI_Comm comm_ptr); + int (*MV2_pt_Reduce_function)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, + MPI_Comm comm_ptr); } mv2_reduce_tuning_element; typedef struct { @@ -1270,29 +1180,17 @@ typedef struct { mv2_reduce_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; } mv2_reduce_tuning_table; -int mv2_size_reduce_tuning_table = 0; -mv2_reduce_tuning_table *mv2_reduce_thresholds_table = NULL; - +int mv2_size_reduce_tuning_table = 0; +mv2_reduce_tuning_table* mv2_reduce_thresholds_table = NULL; int mv2_reduce_intra_knomial_factor = -1; int mv2_reduce_inter_knomial_factor = -1; -int (*MV2_Reduce_function)( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, - int root, - MPI_Comm comm_ptr)=NULL; - -int (*MV2_Reduce_intra_function)( void *sendbuf, - void *recvbuf, - int count, - MPI_Datatype datatype, - MPI_Op op, - int root, - MPI_Comm comm_ptr)=NULL; +int (*MV2_Reduce_function)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, + MPI_Comm comm_ptr) = NULL; +int (*MV2_Reduce_intra_function)(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, + MPI_Comm comm_ptr) = NULL; #define MPIR_Reduce_inter_knomial_wrapper_MV2 simgrid::smpi::Coll_reduce_mvapich2_knomial::reduce #define MPIR_Reduce_intra_knomial_wrapper_MV2 simgrid::smpi::Coll_reduce_mvapich2_knomial::reduce @@ -1301,14 +1199,14 @@ int (*MV2_Reduce_intra_function)( void *sendbuf, #define MPIR_Reduce_shmem_MV2 simgrid::smpi::Coll_reduce_ompi_basic_linear::reduce #define MPIR_Reduce_two_level_helper_MV2 simgrid::smpi::Coll_reduce_mvapich2_two_level::reduce - -static void init_mv2_reduce_tables_stampede(){ - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; +static void init_mv2_reduce_tables_stampede() +{ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; /*Stampede*/ mv2_size_reduce_tuning_table = 8; - mv2_reduce_thresholds_table = static_cast(xbt_malloc(mv2_size_reduce_tuning_table * - sizeof (mv2_reduce_tuning_table))); + mv2_reduce_thresholds_table = + static_cast(xbt_malloc(mv2_size_reduce_tuning_table * sizeof(mv2_reduce_tuning_table))); mv2_reduce_tuning_table mv2_tmp_reduce_thresholds_table[] = { { 16, @@ -1323,8 +1221,7 @@ static void init_mv2_reduce_tables_stampede(){ }, 2, { - {0, 65536, &MPIR_Reduce_shmem_MV2}, - {65536,-1, &MPIR_Reduce_binomial_MV2}, + {0, 65536, &MPIR_Reduce_shmem_MV2}, {65536, -1, &MPIR_Reduce_binomial_MV2}, }, }, { @@ -1349,7 +1246,7 @@ static void init_mv2_reduce_tables_stampede(){ {16384, 32768, &MPIR_Reduce_shmem_MV2}, {32768, 65536, &MPIR_Reduce_shmem_MV2}, {65536, 262144, &MPIR_Reduce_shmem_MV2}, - {262144,-1, &MPIR_Reduce_binomial_MV2}, + {262144, -1, &MPIR_Reduce_binomial_MV2}, }, }, { @@ -1471,7 +1368,7 @@ static void init_mv2_reduce_tables_stampede(){ 2048, 4, 4, - {1, 0, 1, 1, 1,1}, + {1, 0, 1, 1, 1, 1}, 6, { {0, 2048, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1494,7 +1391,7 @@ static void init_mv2_reduce_tables_stampede(){ }; memcpy(mv2_reduce_thresholds_table, mv2_tmp_reduce_thresholds_table, - mv2_size_reduce_tuning_table * sizeof (mv2_reduce_tuning_table)); + mv2_size_reduce_tuning_table * sizeof(mv2_reduce_tuning_table)); } /************ Reduce scatter variables and initializers */ @@ -1502,12 +1399,8 @@ static void init_mv2_reduce_tables_stampede(){ typedef struct { int min; int max; - int (*MV2_pt_Red_scat_function)(void *sendbuf, - void *recvbuf, - int *recvcnts, - MPI_Datatype datatype, - MPI_Op op, - MPI_Comm comm_ptr); + int (*MV2_pt_Red_scat_function)(void* sendbuf, void* recvbuf, int* recvcnts, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm_ptr); } mv2_red_scat_tuning_element; typedef struct { @@ -1516,42 +1409,30 @@ typedef struct { mv2_red_scat_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; } mv2_red_scat_tuning_table; -int mv2_size_red_scat_tuning_table = 0; -mv2_red_scat_tuning_table *mv2_red_scat_thresholds_table = NULL; - - -int (*MV2_Red_scat_function)(void *sendbuf, - void *recvbuf, - int *recvcnts, - MPI_Datatype datatype, - MPI_Op op, - MPI_Comm comm_ptr); +int mv2_size_red_scat_tuning_table = 0; +mv2_red_scat_tuning_table* mv2_red_scat_thresholds_table = NULL; +int (*MV2_Red_scat_function)(void* sendbuf, void* recvbuf, int* recvcnts, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm_ptr); - -static int MPIR_Reduce_Scatter_Basic_MV2(void *sendbuf, - void *recvbuf, - int *recvcnts, - MPI_Datatype datatype, - MPI_Op op, - MPI_Comm comm) +static int MPIR_Reduce_Scatter_Basic_MV2(void* sendbuf, void* recvbuf, int* recvcnts, MPI_Datatype datatype, MPI_Op op, + MPI_Comm comm) { - simgrid::smpi::Coll_reduce_scatter_default::reduce_scatter(sendbuf,recvbuf,recvcnts,datatype,op,comm); + simgrid::smpi::Coll_reduce_scatter_default::reduce_scatter(sendbuf, recvbuf, recvcnts, datatype, op, comm); return MPI_SUCCESS; } #define MPIR_Reduce_scatter_non_comm_MV2 simgrid::smpi::Coll_reduce_scatter_mpich_noncomm::reduce_scatter -#define MPIR_Reduce_scatter_Rec_Halving_MV2 simgrid::smpi::Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter +#define MPIR_Reduce_scatter_Rec_Halving_MV2 \ + simgrid::smpi::Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter #define MPIR_Reduce_scatter_Pair_Wise_MV2 simgrid::smpi::Coll_reduce_scatter_mpich_pair::reduce_scatter - - - -static void init_mv2_reduce_scatter_tables_stampede(){ - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - mv2_size_red_scat_tuning_table = 6; - mv2_red_scat_thresholds_table = static_cast(xbt_malloc(mv2_size_red_scat_tuning_table * - sizeof (mv2_red_scat_tuning_table))); +static void init_mv2_reduce_scatter_tables_stampede() +{ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + mv2_size_red_scat_tuning_table = 6; + mv2_red_scat_thresholds_table = static_cast( + xbt_malloc(mv2_size_red_scat_tuning_table * sizeof(mv2_red_scat_tuning_table))); mv2_red_scat_tuning_table mv2_tmp_red_scat_thresholds_table[] = { { 16, @@ -1584,30 +1465,27 @@ static void init_mv2_reduce_scatter_tables_stampede(){ 128, 2, { - {0, 128, &MPIR_Reduce_Scatter_Basic_MV2}, - {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, + {0, 128, &MPIR_Reduce_Scatter_Basic_MV2}, {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, }, }, { 256, 2, { - {0, 128, &MPIR_Reduce_Scatter_Basic_MV2}, - {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, + {0, 128, &MPIR_Reduce_Scatter_Basic_MV2}, {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, }, }, { 512, 2, { - {0, 256, &MPIR_Reduce_Scatter_Basic_MV2}, - {256, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, + {0, 256, &MPIR_Reduce_Scatter_Basic_MV2}, {256, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2}, }, }, }; memcpy(mv2_red_scat_thresholds_table, mv2_tmp_red_scat_thresholds_table, - mv2_size_red_scat_tuning_table * sizeof (mv2_red_scat_tuning_table)); + mv2_size_red_scat_tuning_table * sizeof(mv2_red_scat_tuning_table)); } /************ Scatter variables and initializers */ @@ -1615,13 +1493,8 @@ static void init_mv2_reduce_scatter_tables_stampede(){ typedef struct { int min; int max; - int (*MV2_pt_Scatter_function)(void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm); + int (*MV2_pt_Scatter_function)(void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm); } mv2_scatter_tuning_element; typedef struct { @@ -1632,356 +1505,334 @@ typedef struct { mv2_scatter_tuning_element intra_node[MV2_MAX_NB_THRESHOLDS]; } mv2_scatter_tuning_table; +int* mv2_scatter_table_ppn_conf = NULL; +int mv2_scatter_num_ppn_conf = 1; +int* mv2_size_scatter_tuning_table = NULL; +mv2_scatter_tuning_table** mv2_scatter_thresholds_table = NULL; + +int (*MV2_Scatter_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, int root, MPI_Comm comm) = NULL; -int *mv2_scatter_table_ppn_conf = NULL; -int mv2_scatter_num_ppn_conf = 1; -int *mv2_size_scatter_tuning_table = NULL; -mv2_scatter_tuning_table **mv2_scatter_thresholds_table = NULL; - -int (*MV2_Scatter_function) (void *sendbuf, int sendcount, MPI_Datatype sendtype, - void *recvbuf, int recvcount, MPI_Datatype recvtype, - int root, MPI_Comm comm)=NULL; - -int (*MV2_Scatter_intra_function) (void *sendbuf, int sendcount, MPI_Datatype sendtype, - void *recvbuf, int recvcount, MPI_Datatype recvtype, - int root, MPI_Comm comm)=NULL; -int MPIR_Scatter_mcst_wrap_MV2(void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm_ptr); - -int MPIR_Scatter_mcst_wrap_MV2(void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm_ptr) +int (*MV2_Scatter_intra_function)(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype, int root, MPI_Comm comm) = NULL; +int MPIR_Scatter_mcst_wrap_MV2(void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm_ptr); + +int MPIR_Scatter_mcst_wrap_MV2(void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, MPI_Comm comm_ptr) { return 0; } #define MPIR_Scatter_MV2_Binomial simgrid::smpi::Coll_scatter_ompi_binomial::scatter -#define MPIR_Scatter_MV2_Direct simgrid::smpi::Coll_scatter_ompi_basic_linear::scatter -#define MPIR_Scatter_MV2_two_level_Binomial simgrid::smpi::Coll_scatter_mvapich2_two_level_binomial::scatter -#define MPIR_Scatter_MV2_two_level_Direct simgrid::smpi::Coll_scatter_mvapich2_two_level_direct::scatter - - - - -static void init_mv2_scatter_tables_stampede(){ - if(simgrid::smpi::Colls::smpi_coll_cleanup_callback==NULL) - simgrid::smpi::Colls::smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; - - int agg_table_sum = 0; - int i; - mv2_scatter_tuning_table **table_ptrs = NULL; - mv2_scatter_num_ppn_conf = 3; - mv2_scatter_thresholds_table - = static_cast(xbt_malloc(sizeof(mv2_scatter_tuning_table *) - * mv2_scatter_num_ppn_conf)); - table_ptrs = static_cast(xbt_malloc(sizeof(mv2_scatter_tuning_table *) - * mv2_scatter_num_ppn_conf)); - mv2_size_scatter_tuning_table = static_cast(xbt_malloc(sizeof(int) * - mv2_scatter_num_ppn_conf)); - mv2_scatter_table_ppn_conf - = static_cast(xbt_malloc(mv2_scatter_num_ppn_conf * sizeof(int))); - mv2_scatter_table_ppn_conf[0] = 1; - mv2_size_scatter_tuning_table[0] = 6; - mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_1ppn[] = { - {2, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - - {4, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - {8, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - {16, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - {32, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - {64, - 2, - { - {0, 32, &MPIR_Scatter_MV2_Binomial}, - {32, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - }; - table_ptrs[0] = mv2_tmp_scatter_thresholds_table_1ppn; - mv2_scatter_table_ppn_conf[1] = 2; - mv2_size_scatter_tuning_table[1] = 6; - mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_2ppn[] = { - {4, - 2, - { - {0, 4096, &MPIR_Scatter_MV2_Binomial}, - {4096, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - {8, - 2, - { - {0, 512, &MPIR_Scatter_MV2_two_level_Direct}, - {512, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - - {16, - 2, - { - {0, 2048, &MPIR_Scatter_MV2_two_level_Direct}, - {2048, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - - {32, - 2, - { - {0, 2048, &MPIR_Scatter_MV2_two_level_Direct}, - {2048, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - - {64, - 2, - { - {0, 8192, &MPIR_Scatter_MV2_two_level_Direct}, - {8192, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - - {128, - 4, - { - {0, 16, &MPIR_Scatter_MV2_Binomial}, - {16, 128, &MPIR_Scatter_MV2_two_level_Binomial}, - {128, 16384, &MPIR_Scatter_MV2_two_level_Direct}, - {16384, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - {0, 128, &MPIR_Scatter_MV2_Direct}, - {128, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - }; - table_ptrs[1] = mv2_tmp_scatter_thresholds_table_2ppn; - mv2_scatter_table_ppn_conf[2] = 16; - mv2_size_scatter_tuning_table[2] = 8; - mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_16ppn[] = { - { - 16, - 2, - { - {0, 256, &MPIR_Scatter_MV2_Binomial}, - {256, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - { - 32, - 2, - { - {0, 512, &MPIR_Scatter_MV2_Binomial}, - {512, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - { - 64, - 2, - { - {0, 1024, &MPIR_Scatter_MV2_two_level_Direct}, - {1024, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - { - 128, - 4, - { - {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, - {0, 16, &MPIR_Scatter_MV2_two_level_Direct}, - {16, 2048, &MPIR_Scatter_MV2_two_level_Direct}, - {2048, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - { - 256, - 4, - { - {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, - {0, 16, &MPIR_Scatter_MV2_two_level_Direct}, - {16, 2048, &MPIR_Scatter_MV2_two_level_Direct}, - {2048, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - - { - 512, - 4, - { - {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, - {16, 16, &MPIR_Scatter_MV2_two_level_Direct}, - {16, 4096, &MPIR_Scatter_MV2_two_level_Direct}, - {4096, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - { - 1024, - 5, - { - {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, - {0, 16, &MPIR_Scatter_MV2_Binomial}, - {16, 32, &MPIR_Scatter_MV2_Binomial}, - {32, 4096, &MPIR_Scatter_MV2_two_level_Direct}, - {4096, -1, &MPIR_Scatter_MV2_Direct}, - }, - 1, - { - { 0, -1, &MPIR_Scatter_MV2_Binomial}, - }, - }, - { - 2048, - 7, - { - {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, - {0, 16, &MPIR_Scatter_MV2_two_level_Binomial}, - {16, 128, &MPIR_Scatter_MV2_two_level_Binomial}, - {128, 1024, &MPIR_Scatter_MV2_two_level_Direct}, - {1024, 16384, &MPIR_Scatter_MV2_two_level_Direct}, - {16384, 65536, &MPIR_Scatter_MV2_Direct}, - {65536, -1, &MPIR_Scatter_MV2_two_level_Direct}, - }, - 6, - { - {0, 16, &MPIR_Scatter_MV2_Binomial}, - {16, 128, &MPIR_Scatter_MV2_Binomial}, - {128, 1024, &MPIR_Scatter_MV2_Binomial}, - {1024, 16384, &MPIR_Scatter_MV2_Direct}, - {16384, 65536, &MPIR_Scatter_MV2_Direct}, - {65536, -1, &MPIR_Scatter_MV2_Direct}, - }, - }, - }; - table_ptrs[2] = mv2_tmp_scatter_thresholds_table_16ppn; - agg_table_sum = 0; - for (i = 0; i < mv2_scatter_num_ppn_conf; i++) { - agg_table_sum += mv2_size_scatter_tuning_table[i]; - } - mv2_scatter_thresholds_table[0] = - static_cast(xbt_malloc(agg_table_sum * sizeof (mv2_scatter_tuning_table))); - memcpy(mv2_scatter_thresholds_table[0], table_ptrs[0], - (sizeof(mv2_scatter_tuning_table) - * mv2_size_scatter_tuning_table[0])); - for (i = 1; i < mv2_scatter_num_ppn_conf; i++) { - mv2_scatter_thresholds_table[i] = - mv2_scatter_thresholds_table[i - 1] - + mv2_size_scatter_tuning_table[i - 1]; - memcpy(mv2_scatter_thresholds_table[i], table_ptrs[i], - (sizeof(mv2_scatter_tuning_table) - * mv2_size_scatter_tuning_table[i])); - } - xbt_free(table_ptrs); +#define MPIR_Scatter_MV2_Direct simgrid::smpi::Coll_scatter_ompi_basic_linear::scatter +#define MPIR_Scatter_MV2_two_level_Binomial simgrid::smpi::Coll_scatter_mvapich2_two_level_binomial::scatter +#define MPIR_Scatter_MV2_two_level_Direct simgrid::smpi::Coll_scatter_mvapich2_two_level_direct::scatter -} +static void init_mv2_scatter_tables_stampede() +{ + if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) + simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; + + int agg_table_sum = 0; + int i; + mv2_scatter_tuning_table** table_ptrs = NULL; + mv2_scatter_num_ppn_conf = 3; + mv2_scatter_thresholds_table = + static_cast(xbt_malloc(sizeof(mv2_scatter_tuning_table*) * mv2_scatter_num_ppn_conf)); + table_ptrs = + static_cast(xbt_malloc(sizeof(mv2_scatter_tuning_table*) * mv2_scatter_num_ppn_conf)); + mv2_size_scatter_tuning_table = static_cast(xbt_malloc(sizeof(int) * mv2_scatter_num_ppn_conf)); + mv2_scatter_table_ppn_conf = static_cast(xbt_malloc(mv2_scatter_num_ppn_conf * sizeof(int))); + mv2_scatter_table_ppn_conf[0] = 1; + mv2_size_scatter_tuning_table[0] = 6; + mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_1ppn[] = { + { + 2, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + + { + 4, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 8, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 16, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 32, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 64, + 2, + { + {0, 32, &MPIR_Scatter_MV2_Binomial}, {32, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + }; + table_ptrs[0] = mv2_tmp_scatter_thresholds_table_1ppn; + mv2_scatter_table_ppn_conf[1] = 2; + mv2_size_scatter_tuning_table[1] = 6; + mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_2ppn[] = { + { + 4, + 2, + { + {0, 4096, &MPIR_Scatter_MV2_Binomial}, {4096, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 8, + 2, + { + {0, 512, &MPIR_Scatter_MV2_two_level_Direct}, {512, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + + { + 16, + 2, + { + {0, 2048, &MPIR_Scatter_MV2_two_level_Direct}, {2048, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + + { + 32, + 2, + { + {0, 2048, &MPIR_Scatter_MV2_two_level_Direct}, {2048, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + + { + 64, + 2, + { + {0, 8192, &MPIR_Scatter_MV2_two_level_Direct}, {8192, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + + { + 128, + 4, + { + {0, 16, &MPIR_Scatter_MV2_Binomial}, + {16, 128, &MPIR_Scatter_MV2_two_level_Binomial}, + {128, 16384, &MPIR_Scatter_MV2_two_level_Direct}, + {16384, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, 128, &MPIR_Scatter_MV2_Direct}, {128, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + }; + table_ptrs[1] = mv2_tmp_scatter_thresholds_table_2ppn; + mv2_scatter_table_ppn_conf[2] = 16; + mv2_size_scatter_tuning_table[2] = 8; + mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_16ppn[] = { + { + 16, + 2, + { + {0, 256, &MPIR_Scatter_MV2_Binomial}, {256, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 32, + 2, + { + {0, 512, &MPIR_Scatter_MV2_Binomial}, {512, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 64, + 2, + { + {0, 1024, &MPIR_Scatter_MV2_two_level_Direct}, {1024, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 128, + 4, + { + {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, + {0, 16, &MPIR_Scatter_MV2_two_level_Direct}, + {16, 2048, &MPIR_Scatter_MV2_two_level_Direct}, + {2048, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + + { + 256, + 4, + { + {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, + {0, 16, &MPIR_Scatter_MV2_two_level_Direct}, + {16, 2048, &MPIR_Scatter_MV2_two_level_Direct}, + {2048, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + { + 512, + 4, + { + {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, + {16, 16, &MPIR_Scatter_MV2_two_level_Direct}, + {16, 4096, &MPIR_Scatter_MV2_two_level_Direct}, + {4096, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + { + 1024, + 5, + { + {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, + {0, 16, &MPIR_Scatter_MV2_Binomial}, + {16, 32, &MPIR_Scatter_MV2_Binomial}, + {32, 4096, &MPIR_Scatter_MV2_two_level_Direct}, + {4096, -1, &MPIR_Scatter_MV2_Direct}, + }, + 1, + { + {0, -1, &MPIR_Scatter_MV2_Binomial}, + }, + }, + { + 2048, + 7, + { + {0, 16, &MPIR_Scatter_mcst_wrap_MV2}, + {0, 16, &MPIR_Scatter_MV2_two_level_Binomial}, + {16, 128, &MPIR_Scatter_MV2_two_level_Binomial}, + {128, 1024, &MPIR_Scatter_MV2_two_level_Direct}, + {1024, 16384, &MPIR_Scatter_MV2_two_level_Direct}, + {16384, 65536, &MPIR_Scatter_MV2_Direct}, + {65536, -1, &MPIR_Scatter_MV2_two_level_Direct}, + }, + 6, + { + {0, 16, &MPIR_Scatter_MV2_Binomial}, + {16, 128, &MPIR_Scatter_MV2_Binomial}, + {128, 1024, &MPIR_Scatter_MV2_Binomial}, + {1024, 16384, &MPIR_Scatter_MV2_Direct}, + {16384, 65536, &MPIR_Scatter_MV2_Direct}, + {65536, -1, &MPIR_Scatter_MV2_Direct}, + }, + }, + }; + table_ptrs[2] = mv2_tmp_scatter_thresholds_table_16ppn; + agg_table_sum = 0; + for (i = 0; i < mv2_scatter_num_ppn_conf; i++) { + agg_table_sum += mv2_size_scatter_tuning_table[i]; + } + mv2_scatter_thresholds_table[0] = + static_cast(xbt_malloc(agg_table_sum * sizeof(mv2_scatter_tuning_table))); + memcpy(mv2_scatter_thresholds_table[0], table_ptrs[0], + (sizeof(mv2_scatter_tuning_table) * mv2_size_scatter_tuning_table[0])); + for (i = 1; i < mv2_scatter_num_ppn_conf; i++) { + mv2_scatter_thresholds_table[i] = mv2_scatter_thresholds_table[i - 1] + mv2_size_scatter_tuning_table[i - 1]; + memcpy(mv2_scatter_thresholds_table[i], table_ptrs[i], + (sizeof(mv2_scatter_tuning_table) * mv2_size_scatter_tuning_table[i])); + } + xbt_free(table_ptrs); +} diff --git a/src/surf/ns3/ns3_interface.hpp b/src/surf/ns3/ns3_interface.hpp index e9966b58e7..8b1bc35bbc 100644 --- a/src/surf/ns3/ns3_interface.hpp +++ b/src/surf/ns3/ns3_interface.hpp @@ -26,8 +26,7 @@ extern "C" { XBT_PUBLIC(void) ns3_initialize(const char* TcpProtocol); XBT_PUBLIC(void) -ns3_create_flow(sg_host_t src, sg_host_t dst, u_int32_t TotalBytes, - simgrid::surf::NetworkNS3Action* action); +ns3_create_flow(sg_host_t src, sg_host_t dst, u_int32_t TotalBytes, simgrid::surf::NetworkNS3Action* action); XBT_PUBLIC(void) ns3_simulator(double maxSeconds); XBT_PUBLIC(void*) ns3_add_router(const char* id); XBT_PUBLIC(void) ns3_add_link(NetPointNs3* src, NetPointNs3* dst, double bw, double lat); diff --git a/src/surf/surf_private.hpp b/src/surf/surf_private.hpp index 9b35b7c5ac..0e9fec31bd 100644 --- a/src/surf/surf_private.hpp +++ b/src/surf/surf_private.hpp @@ -14,33 +14,32 @@ extern "C" { -extern XBT_PRIVATE const char *surf_action_state_names[6]; +extern XBT_PRIVATE const char* surf_action_state_names[6]; /** @ingroup SURF_interface * @brief Possible update mechanisms */ typedef enum { - UM_FULL, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ - UM_LAZY, /**< Lazy update mechanism: only the modified actions get recomputed. - It may be slower than full if your system is tightly coupled to the point where every action - gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for - a simple full update. */ - UM_UNDEFINED /**< Mechanism not defined */ + UM_FULL, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ + UM_LAZY, /**< Lazy update mechanism: only the modified actions get recomputed. + It may be slower than full if your system is tightly coupled to the point where every action + gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for + a simple full update. */ + UM_UNDEFINED /**< Mechanism not defined */ } e_UM_t; /* Generic functions common to all models */ -XBT_PRIVATE FILE *surf_fopen(const char *name, const char *mode); +XBT_PRIVATE FILE* surf_fopen(const char* name, const char* mode); XBT_PRIVATE std::ifstream* surf_ifsopen(std::string name); /* The __surf_is_absolute_file_path() returns 1 if * file_path is a absolute file path, in the other * case the function returns 0. */ -XBT_PRIVATE int __surf_is_absolute_file_path(const char *file_path); - -extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set *future_evt_set; +XBT_PRIVATE int __surf_is_absolute_file_path(const char* file_path); +extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set* future_evt_set; XBT_PUBLIC(void) storage_register_callbacks(); @@ -49,8 +48,8 @@ XBT_PRIVATE void parse_after_config(); /********** Tracing **********/ /* from surf_instr.c */ -void TRACE_surf_host_set_speed(double date, const char *resource, double power); -void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth); +void TRACE_surf_host_set_speed(double date, const char* resource, double power); +void TRACE_surf_link_set_bandwidth(double date, const char* resource, double bandwidth); } #endif