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);
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);
/* 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<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
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<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
/* 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<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
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<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
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++) {
/* 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<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
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<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
}
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){
}
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;
* 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<simgrid::surf::Host>(nullptr);
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){
return static_cast<simgrid::surf::Storage*>(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){
return action->getCost();
}
-void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask) {
- static_cast<simgrid::surf::CpuAction*>(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<simgrid::surf::CpuAction*>(action)->setAffinity(host->p_cpu, mask);
}
void surf_cpu_action_set_bound(surf_action_t action, double bound) {
// //// CPU RELATED STUFF ////
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
- CpuCas01 *sub_cpu = static_cast<CpuCas01*>(sg_host_surfcpu(host_PM));
+ CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->p_cpu);
p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM
sub_cpu->getSpeedPeakList(), // host->power_peak,
/* 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<CpuAction*>(
- static_cast<Cpu*>(sg_host_surfcpu(host_dest))->execute(0));
+ CpuAction *new_cpu_action = static_cast<CpuAction*>(host_dest->p_cpu->execute(0));
e_surf_action_state_t state = p_action->getState();
if (state != SURF_ACTION_DONE)
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)
)
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
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;
/*********************** 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 */
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 {