> [ 0.010309] (2:worker@Tremblay) Received "Task"
> [ 0.010309] (2:worker@Tremblay) Communication time : "0.010309"
> [ 0.010309] (2:worker@Tremblay) Processing "Task"
-> [ 1.000000] (0:maestro@) Restart processes on host: Fafard
+> [ 1.000000] (0:maestro@) Restart processes on host Fafard
> [ 1.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-1'. Nevermind. Let's keep going!
> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
-> [ 2.000000] (0:maestro@) Restart processes on host: Jupiter
+> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.010309] (2:worker@Tremblay) "Task" done
> [ 11.000000] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
> [ 12.030928] (1:master@Tremblay) Send completed
> [ 0.010825] (2:worker@Tremblay) Received "Task"
> [ 0.010825] (2:worker@Tremblay) Communication time : "0.010825"
> [ 0.010825] (2:worker@Tremblay) Processing "Task"
-> [ 1.000000] (0:maestro@) Restart processes on host: Fafard
+> [ 1.000000] (0:maestro@) Restart processes on host Fafard
> [ 1.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-1'. Nevermind. Let's keep going!
> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
-> [ 2.000000] (0:maestro@) Restart processes on host: Jupiter
+> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.010825] (2:worker@Tremblay) "Task" done
> [ 11.000000] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
> [ 12.082474] (1:master@Tremblay) Send completed
> [ 0.010825] (2:worker@Tremblay) Received "Task"
> [ 0.010825] (2:worker@Tremblay) Communication time : "0.010825"
> [ 0.010825] (2:worker@Tremblay) Processing "Task"
-> [ 1.000000] (0:maestro@) Restart processes on host: Fafard
+> [ 1.000000] (0:maestro@) Restart processes on host Fafard
> [ 1.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-1'. Nevermind. Let's keep going!
> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
-> [ 2.000000] (0:maestro@) Restart processes on host: Jupiter
+> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.010825] (2:worker@Tremblay) "Task" done
> [ 11.000000] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
> [ 12.082474] (1:master@Tremblay) Send completed
} e_surf_vm_state_t;
namespace simgrid {
-namespace surf {
+namespace vm {
class VirtualMachineImpl;
};
namespace s4u {
double getRamsize();
/* FIXME: protect me */
- simgrid::surf::VirtualMachineImpl* pimpl_vm_ = nullptr;
+ simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
};
}
} // namespace simgrid::s4u
for (int i = 1; i < argc; i++)
env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i]));
//Retrieve the host for the process.
- jstring jhostName = env->NewStringUTF(MSG_host_get_name(MSG_host_self()));
+ jstring jhostName = env->NewStringUTF(MSG_host_self()->cname());
jobject jhost = Java_org_simgrid_msg_Host_getByName(env, nullptr, jhostName);
//creates the process
jobject jprocess = env->NewObject(class_Process, constructor_Process, jhost, jname, args);
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (!jhost) {
- jname = env->NewStringUTF(MSG_host_get_name(host));
+ jname = env->NewStringUTF(host->cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls, jname);
const char *jhost_get_name(jobject jhost, JNIEnv * env) {
msg_host_t host = jhost_get_native(env, jhost);
- return MSG_host_get_name(host);
+ return host->cname();
}
jboolean jhost_is_valid(jobject jhost, JNIEnv * env) {
return nullptr;
}
/* Sets the host name */
- const char *name = MSG_host_get_name(host);
- jobject jname = env->NewStringUTF(name);
+ jobject jname = env->NewStringUTF(host->cname());
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
if (!jhost) {
- jname = env->NewStringUTF(MSG_host_get_name(host));
+ jname = env->NewStringUTF(host->cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
/* FIXME: leak of jname ? */
static int l_host_get_name(lua_State * L)
{
sg_host_t ht = sglua_check_host(L, 1);
- lua_pushstring(L, sg_host_get_name(ht));
+ lua_pushstring(L, ht->cname());
return 1;
}
class Model;
class CpuModel;
class HostModel;
-class VMModel;
class NetworkModel;
class StorageModel;
class Resource;
class ActionLmm;
class StorageActionLmm;
}
+namespace vm {
+class VMModel; // FIXME: KILLME
+}
namespace kernel {
namespace routing {
class RoutingPlatf;
typedef simgrid::surf::Model surf_Model;
typedef simgrid::surf::CpuModel surf_CpuModel;
typedef simgrid::surf::HostModel surf_HostModel;
-typedef simgrid::surf::VMModel surf_VMModel;
+typedef simgrid::vm::VMModel surf_VMModel;
typedef simgrid::surf::NetworkModel surf_NetworkModel;
typedef simgrid::surf::StorageModel surf_StorageModel;
typedef simgrid::surf::Resource surf_Resource;
const char* MC_smx_process_get_host_name(smx_actor_t p)
{
if (mc_model_checker == nullptr)
- return sg_host_get_name(p->host);
+ return p->host->cname();
simgrid::mc::Process* process = &mc_model_checker->process();
-/* Copyright (c) 2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010, 2012-2016. The SimGrid Team. All rights reserved. */
/* 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 "src/simix/ActorImpl.hpp"
#include "msg_private.h"
+#include "src/simix/ActorImpl.hpp"
+#include <simgrid/s4u/host.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
int len = INSTR_DEFAULT_STR_SIZE;
char str[INSTR_DEFAULT_STR_SIZE];
- container_t host_container = PJ_container_get (sg_host_get_name(host));
+ container_t host_container = PJ_container_get(host->cname());
PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
}
}
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_host);
- if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){
+ if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size);
msg_host_t *m_host_list = nullptr;
xbt_free(m_host_list);
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
- XBT_WARN("Transfer error, %s remote host just turned off!", MSG_host_get_name(attached_host));
+ XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
- if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){
+ if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size);
msg_host_t *m_host_list = nullptr;
free(m_host_list);
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
- XBT_WARN("Transfer error, %s remote host just turned off!", MSG_host_get_name(attached_host));
+ XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
priv->desc_id = __MSG_host_get_file_descriptor_id(MSG_host_self());
- name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id);
+ name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
msg_file_t fd = static_cast<msg_file_t>(xbt_lib_get_elm_or_null(file_lib, name));
xbt_free(priv->data);
int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
- name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id);
+ name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
__MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id);
xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
xbt_free(name);
host_name_dest = (char*)storage_dest_priv->hostname;
host_dest = MSG_host_by_name(host_name_dest);
}else{
- XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, sg_host_get_name(host));
+ XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->cname());
return MSG_TASK_CANCELED;
}
simdata->last_errno = MSG_OK;
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
- process = SIMIX_process_attach(name, simdata, sg_host_get_name(host), properties, nullptr);
+ process = SIMIX_process_attach(name, simdata, host->cname(), properties, nullptr);
if (!process)
xbt_die("Could not attach");
simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
if (pm_ramsize && !pm_overcommit) { /* Only verify that we don't overcommit on need */
/* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
long total_ramsize_of_vms = 0;
- for (simgrid::s4u::VirtualMachine* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_)
+ for (simgrid::s4u::VirtualMachine* ws_vm : simgrid::vm::VirtualMachineImpl::allVms_)
if (pm == ws_vm->pimpl_vm_->getPm())
total_ramsize_of_vms += ws_vm->pimpl_vm_->getRamsize();
if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
- sg_host_get_name(vm), sg_host_get_name(pm), vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
+ vm->cname(), pm->cname(), vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
THROWF(vm_error, 0, "Memory shortage on host '%s', VM '%s' cannot be started", pm->cname(), vm->cname());
}
}
snprintf(key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
// start link
- container_t msg = PJ_container_get(vm->name().c_str());
+ container_t msg = PJ_container_get(vm->cname());
type_t type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
// destroy existing container of this vm
- container_t existing_container = PJ_container_get(vm->name().c_str());
+ container_t existing_container = PJ_container_get(vm->cname());
PJ_container_remove_from_parent(existing_container);
PJ_container_free(existing_container);
// create new container on the new_host location
- PJ_container_new(vm->cname(), INSTR_MSG_VM, PJ_container_get(sg_host_get_name(ms->dst_pm)));
+ PJ_container_new(vm->cname(), INSTR_MSG_VM, PJ_container_get(ms->dst_pm->cname()));
// end link
msg = PJ_container_get(vm->name().c_str());
static void start_dirty_page_tracking(msg_vm_t vm)
{
- simgrid::surf::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
+ simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
pimpl->dp_enabled = 1;
if (!pimpl->dp_objs)
double computed = dp->prev_remaining - remaining;
double duration = clock - dp->prev_clock;
- XBT_DEBUG("%s@%s: computed %f ops (remaining %f -> %f) in %f secs (%f -> %f)",
- key, sg_host_get_name(vm), computed, dp->prev_remaining, remaining, duration, dp->prev_clock, clock);
+ XBT_DEBUG("%s@%s: computed %f ops (remaining %f -> %f) in %f secs (%f -> %f)", key, vm->cname(), computed,
+ dp->prev_remaining, remaining, duration, dp->prev_clock, clock);
return computed;
}
static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug, int stage2_round_for_fancy_debug)
{
- simgrid::surf::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
+ simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
double total = 0;
char *key = nullptr;
simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm == nullptr)
return;
- simgrid::surf::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
+ simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
double remaining = MSG_task_get_flops_amount(task);
char *key = bprintf("%s-%p", task->name, task);
pimpl->dp_objs = xbt_dict_new();
xbt_assert(xbt_dict_get_or_null(pimpl->dp_objs, key) == nullptr);
xbt_dict_set(pimpl->dp_objs, key, dp, nullptr);
- XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, sg_host_get_name(host), remaining, pimpl->dp_enabled);
+ XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, host->cname(), remaining, pimpl->dp_enabled);
xbt_free(key);
}
simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm == nullptr)
return;
- simgrid::surf::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
+ simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
char *key = bprintf("%s-%p", task->name, task);
dirty_page_t dp = (dirty_page_t)(pimpl->dp_objs ? xbt_dict_get_or_null(pimpl->dp_objs, key) : NULL);
xbt_dict_remove(pimpl->dp_objs, key);
xbt_free(dp);
- XBT_DEBUG("del %s on %s", key, sg_host_get_name(host));
+ XBT_DEBUG("del %s on %s", key, host->cname());
xbt_free(key);
}
if(ret == MSG_HOST_FAILURE){
//XBT_DEBUG("SRC host failed during migration of %s (stage %d)", sg_host_name(vm), stage);
MSG_task_destroy(task);
- THROWF(host_error, 0, "SRC host failed during migration of %s (stage %d)", sg_host_get_name(vm), stage);
+ THROWF(host_error, 0, "SRC host failed during migration of %s (stage %d)", vm->cname(), stage);
}else if(ret == MSG_TRANSFER_FAILURE){
//XBT_DEBUG("DST host failed during migration of %s (stage %d)", sg_host_name(vm), stage);
MSG_task_destroy(task);
- THROWF(host_error, 0, "DST host failed during migration of %s (stage %d)", sg_host_get_name(vm), stage);
+ THROWF(host_error, 0, "DST host failed during migration of %s (stage %d)", vm->cname(), stage);
}
double clock_end = MSG_get_clock();
* The second one would be easier.
*/
- simgrid::s4u::VirtualMachine* typedVm = static_cast<simgrid::s4u::VirtualMachine*>(vm);
- simgrid::surf::VirtualMachineImpl* pimpl = typedVm->pimpl_vm_;
- msg_host_t src_pm = pimpl->getPm();
+ simgrid::s4u::VirtualMachine* typedVm = static_cast<simgrid::s4u::VirtualMachine*>(vm);
+ simgrid::vm::VirtualMachineImpl* pimpl = typedVm->pimpl_vm_;
+ msg_host_t src_pm = pimpl->getPm();
if (src_pm->isOff())
THROWF(vm_error, 0, "Cannot migrate VM '%s' from host '%s', which is offline.", vm->cname(), src_pm->cname());
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module");
-simgrid::surf::VMModel* surf_vm_model = nullptr;
+simgrid::vm::VMModel* surf_vm_model = nullptr;
void surf_vm_model_init_HL13()
{
if (surf_cpu_model_vm) {
- surf_vm_model = new simgrid::surf::VMModel();
+ surf_vm_model = new simgrid::vm::VMModel();
all_existing_models->push_back(surf_vm_model);
}
}
namespace simgrid {
-namespace surf {
+namespace vm {
/*************
* Callbacks *
*************/
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
+simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmCreation;
+simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmDestruction;
+simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmStateChange;
/*********
* Model *
/* iterate for all virtual machines */
for (s4u::VirtualMachine* ws_vm : VirtualMachineImpl::allVms_) {
- Cpu* cpu = ws_vm->pimpl_cpu;
+ surf::Cpu* cpu = ws_vm->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->value;
/* 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*>(host_dest->pimpl_cpu->execution_start(0));
+ surf::CpuAction* new_cpu_action = static_cast<surf::CpuAction*>(host_dest->pimpl_cpu->execution_start(0));
- Action::State state = action_->getState();
- if (state != Action::State::done)
+ surf::Action::State state = action_->getState();
+ if (state != surf::Action::State::done)
XBT_CRITICAL("FIXME: may need a proper handling, %d", static_cast<int>(state));
if (action_->getRemainsNoUpdate() > 0)
XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->getRemainsNoUpdate());
// It corresponds to the cost of a VM running no tasks.
namespace simgrid {
-namespace surf {
+namespace vm {
/***********
* Classes *
/** @ingroup SURF_callbacks
* @brief Callbacks fired after VM creation. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmCreation;
/** @ingroup SURF_callbacks
* @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmDestruction;
/** @ingroup SURF_callbacks
* @brief Callbacks after VM State changes. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmStateChange;
/************
* Resource *
* @brief SURF VM interface class
* @details A VM represent a virtual machine
*/
-class VirtualMachineImpl : public HostImpl {
+class VirtualMachineImpl : public surf::HostImpl {
friend simgrid::s4u::VirtualMachine;
public:
void setParams(vm_params_t params);
/* The vm object of the lower layer */
- Action* action_ = nullptr;
+ surf::Action* action_ = nullptr;
/* Dirty pages stuff */
int dp_enabled = 0;
* @brief SURF VM model interface class
* @details A model is an object which handle the interactions between its Resources and its Actions
*/
-class VMModel : public HostModel {
+class VMModel : public surf::HostModel {
public:
void adjustWeightOfDummyCpuActions() override{};
{
XBT_DEBUG("Create VM %s", name);
- pimpl_vm_ = new surf::VirtualMachineImpl(this, pm);
+ pimpl_vm_ = new vm::VirtualMachineImpl(this, pm);
/* Currently, a VM uses the network resource of its physical host */
pimpl_netcard = pm->pimpl_netcard;
// Create a VCPU for this VM
extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
if (TRACE_msg_vm_is_enabled()) {
- container_t host_container = PJ_container_get(sg_host_get_name(pm));
+ container_t host_container = PJ_container_get(pm->cname());
PJ_container_new(name, INSTR_MSG_VM, host_container);
}
}
xbt_dict_cursor_t cursor=nullptr;
char *key,*data;
- XBT_INFO("Displaying host %s", sg_host_get_name(host));
+ XBT_INFO("Displaying host %s", host->cname());
XBT_INFO(" - speed: %.0f", host->speed());
XBT_INFO(" - available speed: %.2f", sg_host_get_available_speed(host));
- props = sg_host_get_properties(host);
+ props = host->properties();
if (!xbt_dict_is_empty(props)){
XBT_INFO(" - properties:");
arg->properties,
arg->auto_restart);
}
- XBT_DEBUG("Process %s (%s) is dead",
- arg->name.c_str(), sg_host_get_name(arg->host));
+ XBT_DEBUG("Process %s@%s is dead", arg->cname(), arg->host->cname());
arg->context->stop();
}
/* Now insert it in the global process list and in the process to run list */
xbt_swag_insert(process, simix_global->process_list);
- XBT_DEBUG("Inserting %s(%s) in the to_run list",
- process->name.c_str(), sg_host_get_name(host));
+ XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
if (kill_time > SIMIX_get_clock() && simix_global->kill_process_function) {
- XBT_DEBUG("Process %s(%s) will be kill at time %f",
- process->name.c_str(), sg_host_get_name(process->host), kill_time);
+ XBT_DEBUG("Process %s(%s) will be kill at time %f", process->cname(), process->host->cname(), kill_time);
process->kill_timer = SIMIX_timer_set(kill_time, [=]() {
simix_global->kill_process_function(process);
});
}
/* Tracing the process creation */
- TRACE_msg_process_create(process->name.c_str(), process->pid, process->host);
+ TRACE_msg_process_create(process->cname(), process->pid, process->host);
}
return process;
}
/* Now insert it in the global process list and in the process to run list */
xbt_swag_insert(process, simix_global->process_list);
- XBT_DEBUG("Inserting %s(%s) in the to_run list",
- process->name.c_str(), sg_host_get_name(host));
+ XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
/* Tracing the process creation */
- TRACE_msg_process_create(process->name.c_str(), process->pid, process->host);
+ TRACE_msg_process_create(process->cname(), process->pid, process->host);
auto context = dynamic_cast<simgrid::kernel::context::AttachContext*>(process->context);
if (!context)
*/
void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
- XBT_DEBUG("Killing process %s on %s",
- process->name.c_str(), sg_host_get_name(process->host));
+ XBT_DEBUG("Killing process %s@%s", process->cname(), process->host->cname());
process->context->iwannadie = 1;
process->blocked = 0;
{
sg_host_t host = process->host;
- /* check if the host is active */
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
+ THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host->cname());
simgrid::kernel::activity::Sleep *synchro = new simgrid::kernel::activity::Sleep();
synchro->host = host;
}
/** @brief Restart a process, starting it again from the beginning. */
smx_actor_t SIMIX_process_restart(smx_actor_t process, smx_actor_t issuer) {
- XBT_DEBUG("Restarting process %s on %s", process->name.c_str(), sg_host_get_name(process->host));
+ XBT_DEBUG("Restarting process %s on %s", process->cname(), process->host->cname());
//retrieve the arguments of the old process
//FIXME: Factorize this with SIMIX_host_add_auto_restart_process ?
unsigned long pid = 0;
unsigned long ppid = 0;
simgrid::xbt::string name;
+ const char* cname() { return name.c_str(); }
sg_host_t host = nullptr; /* the host on which the process is running */
smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
return;
- XBT_DEBUG("Set kill time %f for process %s(%s)",
- kill_time, process->name.c_str(), sg_host_get_name(process->host));
+ XBT_DEBUG("Set kill time %f for process %s@%s", kill_time, process->cname(), process->host->cname());
process->kill_timer = SIMIX_timer_set(kill_time, [=] {
simix_global->kill_process_function(process);
process->kill_timer=nullptr;
sg_host_t host = sg_host_by_name(process_host);
if (!host)
THROWF(arg_error, 0, "Host '%s' unknown", process_host);
- process.host = sg_host_get_name(host);
+ process.host = host->cname();
process.argc = 1 + xbt_dynar_length(arguments);
process.argv = (const char**)xbt_new(char *, process.argc + 1);
/* Autorestart all process */
for (auto host: host_that_restart) {
- XBT_INFO("Restart processes on host: %s", sg_host_get_name(host));
+ XBT_INFO("Restart processes on host %s", host->cname());
SIMIX_host_autorestart(host);
}
host_that_restart.clear();
break;
*/
- XBT_INFO("Process %lu (%s@%s): waiting for %s synchro %p (%s) in state %d to finish",
- process->pid, process->name.c_str(), sg_host_get_name(process->host),
- synchro_description, process->waiting_synchro,
- process->waiting_synchro->name.c_str(), (int)process->waiting_synchro->state);
+ XBT_INFO("Process %lu (%s@%s): waiting for %s synchro %p (%s) in state %d to finish", process->pid,
+ process->cname(), process->host->cname(), synchro_description, process->waiting_synchro,
+ process->waiting_synchro->name.c_str(), (int)process->waiting_synchro->state);
}
else {
- XBT_INFO("Process %lu (%s@%s)", process->pid, process->name.c_str(), sg_host_get_name(process->host));
+ XBT_INFO("Process %lu (%s@%s)", process->pid, process->cname(), process->host->cname());
}
}
}
smx_actor_t process = nullptr;
xbt_swag_foreach(process, host->process_list) {
SIMIX_process_kill(process, issuer);
- XBT_DEBUG("Killing %s@%s on behalf of %s", process->name.c_str(), sg_host_get_name(process->host),
- issuer->name.c_str());
+ XBT_DEBUG("Killing %s@%s on behalf of %s", process->cname(), process->host->cname(), issuer->cname());
}
}
} else {
- XBT_INFO("Host %s is already off", h->name().c_str());
+ XBT_INFO("Host %s is already off", h->cname());
}
}
if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
return "";
- return sg_host_get_name(host);
+ return host->cname();
}
void _SIMIX_host_free_process_arg(void *data)
arg->properties = properties;
arg->auto_restart = auto_restart;
- if( host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_get_name(host))){
- xbt_dict_set(watched_hosts_lib,sg_host_get_name(host),host,nullptr);
- XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_get_name(host));
+ if (host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib, host->cname())) {
+ xbt_dict_set(watched_hosts_lib, host->cname(), host, nullptr);
+ XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF", host->cname());
}
sg_host_simix(host)->auto_restart_processes.push_back(arg);
}
for (auto arg : process_list) {
- XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->name().c_str());
+ XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->cname());
simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host, arg->kill_time,
arg->properties, arg->auto_restart, nullptr);
}
break;
case SIMIX_FAILED:
- XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", sg_host_get_name(simcall->issuer->host));
+ XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", simcall->issuer->host->cname());
simcall->issuer->context->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
break;
{
/* check if the host is active */
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
-
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
synchro->host = host;
smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
{
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
synchro->host = host;
smx_activity_t SIMIX_file_open(const char* fullpath, sg_host_t host)
{
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
synchro->host = host;
smx_activity_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
{
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
synchro->host = host;
int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
{
if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
int res = surf_host_unlink(host, fd->surf_file);
xbt_free(fd);
simgrid::s4u::Host* sender = comm->src_proc->host;
simgrid::s4u::Host* receiver = comm->dst_proc->host;
- XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, sg_host_get_name(sender), sg_host_get_name(receiver));
+ XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, sender->cname(), receiver->cname());
comm->surf_comm = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
comm->surf_comm->setData(synchro);
/* If a link is failed, detect it immediately */
if (comm->surf_comm->getState() == simgrid::surf::Action::State::failed) {
- XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure",
- sg_host_get_name(sender), sg_host_get_name(receiver));
+ XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->cname(),
+ receiver->cname());
comm->state = SIMIX_LINK_FAILURE;
comm->cleanupSurf();
}
it will be restarted when the sender process resume */
if (SIMIX_process_is_suspended(comm->src_proc) || SIMIX_process_is_suspended(comm->dst_proc)) {
if (SIMIX_process_is_suspended(comm->src_proc))
- XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the communication",
- comm->src_proc->name.c_str(), sg_host_get_name(comm->src_proc->host));
+ XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the "
+ "communication",
+ comm->src_proc->cname(), comm->src_proc->host->cname());
else
- XBT_DEBUG("The communication is suspended on startup because dst (%s@%s) was suspended since it initiated the communication",
- comm->dst_proc->name.c_str(), sg_host_get_name(comm->dst_proc->host));
+ XBT_DEBUG("The communication is suspended on startup because dst (%s@%s) was suspended since it initiated the "
+ "communication",
+ comm->dst_proc->cname(), comm->dst_proc->host->cname());
comm->surf_comm->suspend();
}
case SIMIX_LINK_FAILURE:
- XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
- synchro,
- comm->src_proc ? sg_host_get_name(comm->src_proc->host) : nullptr,
- comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : nullptr,
- simcall->issuer->name.c_str(), simcall->issuer, comm->detached);
+ XBT_DEBUG(
+ "Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
+ synchro, comm->src_proc ? comm->src_proc->host->cname() : nullptr,
+ comm->dst_proc ? comm->dst_proc->host->cname() : nullptr, simcall->issuer->cname(), simcall->issuer,
+ comm->detached);
if (comm->src_proc == simcall->issuer) {
XBT_DEBUG("I'm source");
} else if (comm->dst_proc == simcall->issuer) {
if (!comm->src_buff || !comm->dst_buff || comm->copied)
return;
- XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
- comm,
- comm->src_proc ? sg_host_get_name(comm->src_proc->host) : "a finished process",
- comm->src_buff,
- comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : "a finished process",
- comm->dst_buff, buff_size);
+ XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)", comm,
+ comm->src_proc ? comm->src_proc->host->cname() : "a finished process", comm->src_buff,
+ comm->dst_proc ? comm->dst_proc->host->cname() : "a finished process", comm->dst_buff, buff_size);
/* Copy at most dst_buff_size bytes of the message to receiver's buffer */
if (comm->dst_buff_size)
*/
void SIMIX_vm_save(sg_host_t vm, smx_actor_t issuer)
{
- const char *name = sg_host_get_name(vm);
-
if (static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() != SURF_VM_STATE_RUNNING)
- THROWF(vm_error, 0, "VM(%s) is not running", name);
+ THROWF(vm_error, 0, "VM(%s) is not running", vm->cname());
- XBT_DEBUG("save VM(%s), where %d processes exist", name, xbt_swag_size(sg_host_simix(vm)->process_list));
+ XBT_DEBUG("save VM(%s), where %d processes exist", vm->cname(), xbt_swag_size(sg_host_simix(vm)->process_list));
- /* jump to vm_ws_save() */
static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->save();
smx_actor_t smx_process, smx_process_safe;
xbt_swag_foreach_safe(smx_process, smx_process_safe, sg_host_simix(vm)->process_list) {
- XBT_DEBUG("suspend %s", smx_process->name.c_str());
+ XBT_DEBUG("suspend %s", smx_process->cname());
SIMIX_process_suspend(smx_process, issuer);
}
}
-
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
/* 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 <simgrid/s4u/host.hpp>
#include <xbt/ex.hpp>
#include "private.h"
{
int retval = MPI_SUCCESS;
- strncpy(name, sg_host_get_name(SIMIX_host_self()),
- strlen(sg_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
- strlen(sg_host_get_name(SIMIX_host_self())) +1 : MPI_MAX_PROCESSOR_NAME - 1 );
+ 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);
*resultlen = strlen(name) > MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
return retval;
void HostModel::adjustWeightOfDummyCpuActions()
{
/* iterate for all virtual machines */
- for (s4u::VirtualMachine* ws_vm : VirtualMachineImpl::allVms_) {
+ for (s4u::VirtualMachine* ws_vm : vm::VirtualMachineImpl::allVms_) {
Cpu* cpu = ws_vm->pimpl_cpu;
delete arg;
});
} else { // start_time <= SIMIX_get_clock()
- XBT_DEBUG("Starting Process %s(%s) right now",
- arg->name.c_str(), sg_host_get_name(host));
+ XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->cname());
process_created = simix_global->create_process_function(
arg->name.c_str(), std::move(code), nullptr,
std::qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
for (i = 0; i < totalHosts; i++) {
- std::printf(" <host id=\"%s\" speed=\"%.0f\"", sg_host_get_name(hosts[i]), sg_host_speed(hosts[i]));
+ std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->cname(), sg_host_speed(hosts[i]));
props = sg_host_get_properties(hosts[i]);
if (hosts[i]->coreCount()>1) {
std::printf(" core=\"%d\"", hosts[i]->coreCount());