From: Martin Quinson Date: Sun, 27 Dec 2015 21:12:58 +0000 (+0100) Subject: this is C++ X-Git-Tag: v3_13~1379 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/874710913c18743b0423e42006b8d697e788b2a5 this is C++ --- diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 166915901c..d215f17891 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -51,11 +51,6 @@ XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host); XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv); XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host); -// ========== SURF CPU ============ -XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host); -XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu); -XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host); - // ========== RoutingEdge ============ XBT_PUBLIC(routing_edge_t) sg_host_edge(sg_host_t host); XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, routing_edge_t edge); diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index fdcc13233e..233d081757 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -124,16 +124,6 @@ void sg_host_simix_destroy(sg_host_t host) { host->extension_set(SIMIX_HOST_LEVEL, nullptr); } -// ========== SURF CPU ============ -surf_cpu_t sg_host_surfcpu(sg_host_t host) { - return host->p_cpu; -} -void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) { - host->p_cpu = cpu; -} -void sg_host_surfcpu_destroy(sg_host_t host) { - host->p_cpu = nullptr; -} // ========== RoutingEdge ============ surf_RoutingEdge *sg_host_edge(sg_host_t host) { return (surf_RoutingEdge*) host->extension(ROUTING_HOST_LEVEL); diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 46bec973f5..26df06f386 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -130,7 +130,7 @@ void CpuCas01Model::addTraces() /* connect all traces relative to hosts */ xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuCas01 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuCas01 *host = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -140,7 +140,7 @@ void CpuCas01Model::addTraces() xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuCas01 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuCas01 *host = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 6f77ebf135..d6a976ba67 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -502,7 +502,7 @@ void CpuTiModel::addTraces() /* connect all traces relative to hosts */ xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuTi *cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuTi *cpu = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(cpu, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -518,7 +518,7 @@ void CpuTiModel::addTraces() xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuTi *cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuTi *cpu = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(cpu, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 23495dab15..6f3675a131 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -249,7 +249,7 @@ L07Action::L07Action(Model *model, int host_nb, for (int i = 0; i < host_nb; i++) lmm_expand(model->getMaxminSystem(), - sg_host_surfcpu(host_list[i])->getConstraint(), + host_list[i]->p_cpu->getConstraint(), this->getVariable(), flops_amount[i]); for (int i = 0; i < host_nb; i++) { @@ -341,7 +341,7 @@ void HostL07Model::addTraces() /* Connect traces relative to cpu */ xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuL07 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuL07 *host = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -351,7 +351,7 @@ void HostL07Model::addTraces() xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuL07 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuL07 *host = static_cast(sg_host_by_name(elm)->p_cpu); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 80ad4c2c64..e557df9342 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -260,15 +260,15 @@ xbt_dict_t sg_host_get_properties(sg_host_t host) { } double surf_host_get_speed(sg_host_t host, double load){ - return sg_host_surfcpu(host)->getSpeed(load); + return host->p_cpu->getSpeed(load); } double surf_host_get_available_speed(sg_host_t host){ - return sg_host_surfcpu(host)->getAvailableSpeed(); + return host->p_cpu->getAvailableSpeed(); } int surf_host_get_core(sg_host_t host){ - return sg_host_surfcpu(host)->getCore(); + return host->p_cpu->getCore(); } surf_action_t surf_host_execute(sg_host_t host, double size){ @@ -276,22 +276,22 @@ surf_action_t surf_host_execute(sg_host_t host, double size){ } double surf_host_get_current_power_peak(sg_host_t host){ - return sg_host_surfcpu(host)->getCurrentPowerPeak(); + return host->p_cpu->getCurrentPowerPeak(); } double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){ - return sg_host_surfcpu(host)->getPowerPeakAt(pstate_index); + return host->p_cpu->getPowerPeakAt(pstate_index); } int surf_host_get_nb_pstates(sg_host_t host){ - return sg_host_surfcpu(host)->getNbPStates(); + return host->p_cpu->getNbPStates(); } void surf_host_set_pstate(sg_host_t host, int pstate_index){ - sg_host_surfcpu(host)->setPState(pstate_index); + host->p_cpu->setPState(pstate_index); } int surf_host_get_pstate(sg_host_t host){ - return sg_host_surfcpu(host)->getPState(); + return host->p_cpu->getPState(); } using simgrid::energy::HostEnergy; @@ -392,7 +392,7 @@ void surf_vm_destroy(sg_host_t resource){ * Do not call xbt_lib_remove() here. It deletes all levels of the key, * including MSG_HOST_LEVEL and others. We should unregister only what we know. */ - sg_host_surfcpu_destroy(resource); + resource->p_cpu = nullptr; // FIXME: memleaking? sg_host_edge_destroy(resource,1); resource->extension_set(nullptr); @@ -428,8 +428,8 @@ void surf_vm_set_bound(sg_host_t vm, double bound){ return get_casted_vm(vm)->setBound(bound); } -void surf_vm_set_affinity(sg_host_t vm, sg_host_t cpu, unsigned long mask){ - return get_casted_vm(vm)->setAffinity(sg_host_surfcpu(cpu), mask); +void surf_vm_set_affinity(sg_host_t vm, sg_host_t host, unsigned long mask){ + return get_casted_vm(vm)->setAffinity(host->p_cpu, mask); } xbt_dict_t surf_storage_get_content(surf_resource_t resource){ @@ -456,12 +456,14 @@ const char* surf_storage_get_host(surf_resource_t resource){ return static_cast(surf_storage_resource_priv(resource))->p_attach; } -surf_action_t surf_cpu_execute(sg_host_t cpu, double size){ - return sg_host_surfcpu(cpu)->execute(size); +surf_action_t surf_cpu_execute(sg_host_t host, double size){ + xbt_die("FIXME: DEADCODE"); + return host->p_cpu->execute(size); } surf_action_t surf_cpu_sleep(sg_host_t host, double duration){ - return sg_host_surfcpu(host)->sleep(duration); + xbt_die("FIXME: DEADCODE"); + return host->p_cpu->sleep(duration); } double surf_action_get_start_time(surf_action_t action){ @@ -516,8 +518,8 @@ double surf_action_get_cost(surf_action_t action){ return action->getCost(); } -void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask) { - static_cast(action)->setAffinity(sg_host_surfcpu(cpu), mask); +void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t host, unsigned long mask) { + static_cast(action)->setAffinity(host->p_cpu, mask); } void surf_cpu_action_set_bound(surf_action_t action, double bound) { diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index e7b9a42f8a..cf79554f5f 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -184,7 +184,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos // //// CPU RELATED STUFF //// // Roughly, create a vcpu resource by using the values of the sub_cpu one. - CpuCas01 *sub_cpu = static_cast(sg_host_surfcpu(host_PM)); + CpuCas01 *sub_cpu = static_cast(host_PM->p_cpu); p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM sub_cpu->getSpeedPeakList(), // host->power_peak, @@ -293,8 +293,7 @@ void VMHL13::migrate(sg_host_t host_dest) /* Update vcpu's action for the new pm */ { /* create a cpu action bound to the pm model at the destination. */ - CpuAction *new_cpu_action = static_cast( - static_cast(sg_host_surfcpu(host_dest))->execute(0)); + CpuAction *new_cpu_action = static_cast(host_dest->p_cpu->execute(0)); e_surf_action_state_t state = p_action->getState(); if (state != SURF_ACTION_DONE) diff --git a/teshsuite/surf/surf_usage/CMakeLists.txt b/teshsuite/surf/surf_usage/CMakeLists.txt index 43a48bd4c8..a0661028fc 100644 --- a/teshsuite/surf/surf_usage/CMakeLists.txt +++ b/teshsuite/surf/surf_usage/CMakeLists.txt @@ -1,7 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") -add_executable(surf_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage.c) -add_executable(surf_usage2 ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage2.c) +add_executable(surf_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage.cpp) +add_executable(surf_usage2 ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage2.cpp) ### Add definitions for compile if(NOT WIN32) @@ -23,8 +23,8 @@ set(xml_files ) set(testsuite_src ${testsuite_src} - ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage.c - ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage2.c + ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage2.cpp PARENT_SCOPE ) set(bin_files diff --git a/teshsuite/surf/surf_usage/surf_usage.c b/teshsuite/surf/surf_usage/surf_usage.cpp similarity index 89% rename from teshsuite/surf/surf_usage/surf_usage.c rename to teshsuite/surf/surf_usage/surf_usage.cpp index 24285da0fc..fe6b1d4afe 100644 --- a/teshsuite/surf/surf_usage/surf_usage.c +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -37,8 +37,8 @@ const char *string_action(e_surf_action_state_t state) void test(char *platform); void test(char *platform) { - sg_host_t cpuA = NULL; - sg_host_t cpuB = NULL; + sg_host_t hostA = NULL; + sg_host_t hostB = NULL; surf_action_t actionA = NULL; surf_action_t actionB = NULL; surf_action_t actionC = NULL; @@ -52,17 +52,17 @@ void test(char *platform) /*********************** CPU ***********************************/ XBT_DEBUG("%p", surf_cpu_model_pm); - cpuA = sg_host_by_name("Cpu A"); - cpuB = sg_host_by_name("Cpu B"); + hostA = sg_host_by_name("Cpu A"); + hostB = sg_host_by_name("Cpu B"); /* Let's check that those two processors exist */ - XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuA)), cpuA); - XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuB)), cpuB); + XBT_DEBUG("%s : %p", surf_cpu_name(hostA->p_cpu), hostA); + XBT_DEBUG("%s : %p", surf_cpu_name(hostB->p_cpu), hostB); /* Let's do something on it */ - actionA = surf_cpu_execute(cpuA, 1000.0); - actionB = surf_cpu_execute(cpuB, 1000.0); - actionC = surf_cpu_sleep(cpuB, 7.32); + actionA = surf_host_execute(hostA, 1000.0); + actionB = surf_host_execute(hostB, 1000.0); + actionC = surf_host_sleep(hostB, 7.32); /* Use whatever calling style you want... */ stateActionA = surf_action_get_state(actionA); /* When you know actionA model type */ @@ -78,7 +78,7 @@ void test(char *platform) XBT_DEBUG("%p", surf_network_model); /* Let's do something on it */ - surf_network_model_communicate(surf_network_model, cpuA, cpuB, 150.0, -1.0); + surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0); surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */ do { diff --git a/teshsuite/surf/surf_usage/surf_usage2.c b/teshsuite/surf/surf_usage/surf_usage2.cpp similarity index 100% rename from teshsuite/surf/surf_usage/surf_usage2.c rename to teshsuite/surf/surf_usage/surf_usage2.cpp