From: Martin Quinson Date: Sat, 1 Jul 2017 21:12:27 +0000 (+0200) Subject: rename SIMIX_host_self() into sg_host_self(), and make it public X-Git-Tag: v3_17~494 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/049a664e2a9c8e702a7ce52c86f7c590d11ad642 rename SIMIX_host_self() into sg_host_self(), and make it public --- diff --git a/include/simgrid/host.h b/include/simgrid/host.h index eac85bf036..1c418b2a82 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -39,6 +39,8 @@ XBT_PUBLIC(xbt_dynar_t) sg_host_get_attached_storage_list(sg_host_t host); XBT_PUBLIC(double) sg_host_speed(sg_host_t host); XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host); +XBT_PUBLIC(sg_host_t) sg_host_self(); +XBT_PUBLIC(const char*) sg_host_self_get_name(); XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host); XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host); XBT_PUBLIC(void) sg_host_set_pstate(sg_host_t host,int pstate); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index b464cf1123..f134c43c99 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -184,8 +184,6 @@ XBT_PUBLIC(smx_actor_t) SIMIX_process_attach( XBT_PUBLIC(void) SIMIX_process_detach(); /*********************************** Host *************************************/ -XBT_PUBLIC(sg_host_t) SIMIX_host_self(); -XBT_PUBLIC(const char*) SIMIX_host_self_get_name(); XBT_PUBLIC(void) SIMIX_host_off(sg_host_t host, smx_actor_t issuer); XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data); XBT_PUBLIC(void*) SIMIX_host_self_get_data(); @@ -227,7 +225,6 @@ XBT_PUBLIC(void) simcall_call(smx_actor_t process); /******************************* Host simcalls ********************************/ XBT_PUBLIC(void) simcall_host_set_data(sg_host_t host, void *data); - XBT_PUBLIC(smx_activity_t) simcall_execution_start(const char *name, double flops_amount, double priority, double bound); diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 2ac7f7d415..69054e2849 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -92,16 +92,16 @@ void SIMIX_host_off(sg_host_t h, smx_actor_t issuer) } } -sg_host_t SIMIX_host_self() +sg_host_t sg_host_self() { smx_actor_t process = SIMIX_process_self(); return (process == nullptr) ? nullptr : process->host; } /* needs to be public and without simcall for exceptions and logging events */ -const char* SIMIX_host_self_get_name() +const char* sg_host_self_get_name() { - sg_host_t host = SIMIX_host_self(); + sg_host_t host = sg_host_self(); if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process) return ""; diff --git a/src/smpi/instr_smpi.cpp b/src/smpi/instr_smpi.cpp index d0f4c4dd8f..eb3b1410a0 100644 --- a/src/smpi/instr_smpi.cpp +++ b/src/smpi/instr_smpi.cpp @@ -197,7 +197,7 @@ void TRACE_smpi_init(int rank) container_t father; if (TRACE_smpi_is_grouped()){ - father = PJ_container_get (SIMIX_host_self_get_name()); + father = PJ_container_get(sg_host_self_get_name()); }else{ father = PJ_container_get_root (); } diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index f128f59d02..d5ac71c5fa 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -333,19 +333,20 @@ void Comm::init_smp(){ } //identify neighbours in comm //get the indexes of all processes sharing the same simix host - xbt_swag_t process_list = SIMIX_host_self()->extension()->process_list; - int intra_comm_size = 0; - int min_index = INT_MAX;//the minimum index will be the leader - smx_actor_t actor = nullptr; - xbt_swag_foreach(actor, process_list) { - int index = actor->pid -1; - - if(this->group()->rank(index)!=MPI_UNDEFINED){ - intra_comm_size++; - //the process is in the comm - if(index < min_index) - min_index=index; - } + xbt_swag_t process_list = sg_host_self()->extension()->process_list; + int intra_comm_size = 0; + int min_index = INT_MAX; // the minimum index will be the leader + smx_actor_t actor = nullptr; + xbt_swag_foreach(actor, process_list) + { + int index = actor->pid - 1; + + if (this->group()->rank(index) != MPI_UNDEFINED) { + intra_comm_size++; + // the process is in the comm + if (index < min_index) + min_index = index; + } } XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size); MPI_Group group_intra = new Group(intra_comm_size); diff --git a/src/smpi/smpi_dvfs.cpp b/src/smpi/smpi_dvfs.cpp index bc9d903607..c19e14e825 100644 --- a/src/smpi/smpi_dvfs.cpp +++ b/src/smpi/smpi_dvfs.cpp @@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi, "Logging specific to SMPI (expe */ double smpi_get_host_power_peak_at(int pstate_index) { - return SIMIX_host_self()->getPstateSpeed(pstate_index); + return sg_host_self()->getPstateSpeed(pstate_index); } /** @@ -34,7 +34,7 @@ double smpi_get_host_power_peak_at(int pstate_index) */ double smpi_get_host_current_power_peak() { - return SIMIX_host_self()->speed(); + return sg_host_self()->speed(); } /** @@ -42,7 +42,7 @@ double smpi_get_host_current_power_peak() */ int smpi_get_host_nb_pstates() { - return sg_host_get_nb_pstates(SIMIX_host_self()); + return sg_host_get_nb_pstates(sg_host_self()); } /** @@ -52,11 +52,11 @@ int smpi_get_host_nb_pstates() */ void smpi_set_host_pstate(int pstate_index) { - sg_host_set_pstate(SIMIX_host_self(), pstate_index); + sg_host_set_pstate(sg_host_self(), pstate_index); } /** @brief Gets the pstate at which the processor currently running */ int smpi_get_host_pstate() { - return sg_host_get_pstate(SIMIX_host_self()); + return sg_host_get_pstate(sg_host_self()); } /** @@ -65,7 +65,7 @@ int smpi_get_host_pstate() { * \return Returns the consumed energy */ double smpi_get_host_consumed_energy() { - return sg_host_get_consumed_energy(SIMIX_host_self()); + return sg_host_get_consumed_energy(sg_host_self()); } #if SMPI_FORTRAN diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 4c68e80ff1..6a1b4d3242 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -2153,9 +2153,9 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype int PMPI_Get_processor_name(char *name, int *resultlen) { - strncpy(name, SIMIX_host_self()->cname(), strlen(SIMIX_host_self()->cname()) < MPI_MAX_PROCESSOR_NAME - 1 - ? strlen(SIMIX_host_self()->cname()) + 1 - : MPI_MAX_PROCESSOR_NAME - 1); + strncpy(name, sg_host_self()->cname(), strlen(sg_host_self()->cname()) < MPI_MAX_PROCESSOR_NAME - 1 + ? strlen(sg_host_self()->cname()) + 1 + : MPI_MAX_PROCESSOR_NAME - 1); *resultlen = strlen(name) > MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name); return MPI_SUCCESS; diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 3407ff765d..9ac550d6b2 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -5,10 +5,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "xbt/sysdep.h" +#include "simgrid/host.h" +#include "simgrid/simix.h" /* SIMIX_host_self_get_name */ #include "src/xbt/log_private.h" -#include "simgrid/simix.h" /* SIMIX_host_self_get_name */ #include "surf/surf.h" +#include "xbt/sysdep.h" #include extern const char *xbt_log_priority_names[8]; @@ -119,7 +120,7 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co show_string(xbt_log_priority_names[ev->priority]); break; case 'h': /* host name; SimGrid extension */ - show_string(SIMIX_host_self_get_name()); + show_string(sg_host_self_get_name()); break; case 't': /* thread name; LOG4J compliant */ show_string(SIMIX_process_self_get_name()); diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index 8d77b3e63a..a7f9052bf6 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -36,12 +36,12 @@ static int xbt_log_layout_simple_doit(xbt_log_layout_t l, xbt_log_event_t ev, co /* Display the proc info if available */ procname = xbt_procname(); if (procname && strcmp(procname,"maestro")) { - len = snprintf(p, rem_size, "%s:%s:(%d) ", SIMIX_host_self_get_name(), procname, xbt_getpid()); + len = snprintf(p, rem_size, "%s:%s:(%d) ", sg_host_self_get_name(), procname, xbt_getpid()); check_overflow(len); } else if (!procname) { - len = snprintf(p, rem_size, "%s::(%d) ", SIMIX_host_self_get_name(), xbt_getpid()); - check_overflow(len); + len = snprintf(p, rem_size, "%s::(%d) ", sg_host_self_get_name(), xbt_getpid()); + check_overflow(len); } /* Display the date */