// ***** Methods *****
- /** Retrieves the actor that have the given PID (or NULL if not existing) */
- //static Actor *byPid(int pid); not implemented
-
/** Retrieves the name of that actor */
- simgrid::xbt::string getName();
+ simgrid::xbt::string name();
/** Retrieves the host on which that actor is running */
- s4u::Host *getHost();
+ s4u::Host* host();
/** Retrieves the PID of that actor */
- int getPid();
+ int pid();
/** Retrieves the PPID of that actor */
- int getPpid();
+ int ppid();
/** If set to true, the actor will automatically restart when its host reboots */
void setAutoRestart(bool autorestart);
/** Sets the time at which that actor should be killed */
void setKillTime(double time);
/** Retrieves the time at which that actor will be killed (or -1 if not set) */
- double getKillTime();
+ double killTime();
/** Ask the actor to die.
*
* It will only notice your request when doing a simcall next time (a communication or similar).
* SimGrid sometimes have issues when you kill actors that are currently communicating and such.
- * We are working on it to fix the issues.
+ * Still. Please report any bug that you may encounter with a minimal working example.
*/
void kill();
static void kill(int pid);
- static ActorPtr forPid(int pid);
-
- /**
- * Wait for the actor to finish.
- */
+
+ /** Retrieves the actor that have the given PID (or nullptr if not existing) */
+ static ActorPtr byPid(int pid);
+
+ /** @brief Wait for the actor to finish.
+ *
+ * This blocks the calling actor until the actor on which we call join() is terminated
+ */
void join();
// Static methods on all actors:
protected:
/** Returns the internal implementation of this actor */
- smx_actor_t getImpl();
+ simix::ActorImpl* getImpl();
};
/** @ingroup s4u_api
* See \ref Comm for the full communication API (including non blocking communications).
*/
XBT_PUBLIC(void) send(MailboxPtr chan, void*payload, size_t simulatedSize);
-
- /**
- * Return the PID of the current actor.
- */
- XBT_PUBLIC(int) getPid();
-
- /**
- * Return the PPID of the current actor.
- */
- int getPpid();
+ /** @brief Return the PID of the current actor. */
+ XBT_PUBLIC(int) pid();
+
+ /** @brief Return the PPID of the current actor. */
+ int ppid();
};
/** @} */
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
for (auto link : route)
- instr_user_variable (time, link->getName(), variable, father_type, value, what, nullptr, user_link_variables);
+ instr_user_variable(time, link->cname(), variable, father_type, value, what, nullptr, user_link_variables);
}
/** \ingroup TRACE_API
xbt_node_t backboneNode = nullptr;
if (backbone_) {
- backboneNode = new_xbt_graph_node(graph, backbone_->getName(), nodes);
+ backboneNode = new_xbt_graph_node(graph, backbone_->cname(), nodes);
new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
}
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id());
if (info.first) { // link up
- xbt_node_t current = new_xbt_graph_node(graph, info.first->getName(), nodes);
+ xbt_node_t current = new_xbt_graph_node(graph, info.first->cname(), nodes);
new_xbt_graph_edge(graph, previous, current, edges);
if (backbone_) {
}
if (info.second) { // link down
- xbt_node_t current = new_xbt_graph_node(graph, info.second->getName(), nodes);
+ xbt_node_t current = new_xbt_graph_node(graph, info.second->cname(), nodes);
new_xbt_graph_edge(graph, previous, current, edges);
if (backbone_) {
}
for (auto link : *route->link_list) {
- const char* link_name = link->getName();
+ const char* link_name = link->cname();
current = new_xbt_graph_node(graph, link_name, nodes);
current_name = link_name;
new_xbt_graph_edge(graph, previous, current, edges);
// TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
// cpu_cas01->constraint->bound = solved_value;
- xbt_assert(cpu->getModel() == surf_cpu_model_vm);
- lmm_system_t vcpu_system = cpu->getModel()->getMaxminSystem();
- lmm_update_constraint_bound(vcpu_system, cpu->getConstraint(), virt_overhead * solved_value);
+ xbt_assert(cpu->model() == surf_cpu_model_vm);
+ lmm_system_t vcpu_system = cpu->model()->getMaxminSystem();
+ lmm_update_constraint_bound(vcpu_system, cpu->constraint(), virt_overhead * solved_value);
}
/* 2. Calculate resource share at the virtual machine layer. */
// ***** Actor methods *****
void Actor::join() {
- simcall_process_join(pimpl_, -1);
+ simcall_process_join(this->pimpl_, -1);
}
void Actor::setAutoRestart(bool autorestart) {
simcall_process_auto_restart_set(pimpl_,autorestart);
}
-s4u::Host *Actor::getHost() {
- return pimpl_->host;
+s4u::Host* Actor::host()
+{
+ return this->pimpl_->host;
}
-simgrid::xbt::string Actor::getName() {
- return pimpl_->name;
+simgrid::xbt::string Actor::name()
+{
+ return this->pimpl_->name;
}
-int Actor::getPid(){
- return pimpl_->pid;
+int Actor::pid()
+{
+ return this->pimpl_->pid;
}
-int Actor::getPpid() {
- return pimpl_->ppid;
+int Actor::ppid()
+{
+ return this->pimpl_->ppid;
}
void Actor::setKillTime(double time) {
simcall_process_set_kill_time(pimpl_,time);
}
-double Actor::getKillTime() {
+double Actor::killTime()
+{
return simcall_process_get_kill_time(pimpl_);
}
// ***** Static functions *****
-ActorPtr Actor::forPid(int pid)
+ActorPtr Actor::byPid(int pid)
{
smx_actor_t process = SIMIX_process_from_PID(pid);
if (process != nullptr)
c.wait();
}
-int getPid() {
+int pid()
+{
return SIMIX_process_self()->pid;
}
-int getPpid() {
+int ppid()
+{
return SIMIX_process_self()->ppid;
}
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", cname(), dest->cname(),
(latency == nullptr ? -1 : *latency));
for (auto link : *links)
- XBT_CDEBUG(surf_route, "Link %s", link->getName());
+ XBT_CDEBUG(surf_route, "Link %s", link->cname());
}
}
}
const char* Link::name()
{
- return this->pimpl_->getName();
+ return this->pimpl_->cname();
}
bool Link::isUsed()
{
});
simgrid::surf::storageCreatedCallbacks.connect([](simgrid::surf::Storage* storage) {
- const char* name = storage->getName();
+ const char* name = storage->cname();
// TODO, create sg_storage_by_name
sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, name);
xbt_assert(s != nullptr, "Storage not found for name %s", name);
Cpu* cpu = ws_vm->pimpl_cpu;
- int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
+ int is_active = lmm_constraint_used(cpu->model()->getMaxminSystem(), cpu->constraint());
if (is_active) {
/* some tasks exist on this VM */
char* storage_name = nullptr;
xbt_dynar_foreach (storage_, i, mnt) {
- storage_name = (char*)static_cast<simgrid::surf::Storage*>(mnt.storage)->getName();
+ storage_name = (char*)static_cast<simgrid::surf::Storage*>(mnt.storage)->cname();
xbt_dict_set(storage_list, mnt.name, storage_name, nullptr);
}
return storage_list;
simgrid::surf::Storage* storage = static_cast<simgrid::surf::Storage*>(
xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
if (!strcmp((const char*)storage->attach_, piface_->cname())) {
- xbt_dynar_push_as(result, void*, (void*)storage->getName());
+ xbt_dynar_push_as(result, void*, (void*)storage->cname());
}
}
}
} else
xbt_die("Can't find mount point for '%s' on '%s'", fullpath, piface_->cname());
- XBT_DEBUG("OPEN %s on disk '%s'", path, st->getName());
+ XBT_DEBUG("OPEN %s on disk '%s'", path, st->cname());
Action* action = st->open((const char*)mount_name, (const char*)path);
free((char*)path);
free((char*)mount_name);
Action* HostImpl::close(surf_file_t fd)
{
simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("CLOSE %s on disk '%s'", fd->name, st->getName());
+ XBT_DEBUG("CLOSE %s on disk '%s'", fd->name, st->cname());
return st->close(fd);
}
Action* HostImpl::read(surf_file_t fd, sg_size_t size)
{
simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("READ %s on disk '%s'", fd->name, st->getName());
+ XBT_DEBUG("READ %s on disk '%s'", fd->name, st->cname());
return st->read(fd, size);
}
Action* HostImpl::write(surf_file_t fd, sg_size_t size)
{
simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("WRITE %s on disk '%s'", fd->name, st->getName());
+ XBT_DEBUG("WRITE %s on disk '%s'", fd->name, st->cname());
return st->write(fd, size);
}
simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
/* Check if the file is on this storage */
if (!xbt_dict_get_or_null(st->content_, fd->name)) {
- XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name, st->getName());
+ XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name, st->cname());
return -1;
} else {
- XBT_DEBUG("UNLINK %s on disk '%s'", fd->name, st->getName());
+ XBT_DEBUG("UNLINK %s on disk '%s'", fd->name, st->cname());
st->usedSize_ -= fd->size;
// Remove the file from storage
xbt_dynar_t info = xbt_dynar_new(sizeof(void*), nullptr);
xbt_dynar_push_as(info, sg_size_t*, psize);
xbt_dynar_push_as(info, void*, fd->mount);
- xbt_dynar_push_as(info, void*, (void*)st->getName());
+ xbt_dynar_push_as(info, void*, (void*)st->cname());
xbt_dynar_push_as(info, void*, st->typeId_);
xbt_dynar_push_as(info, void*, st->contentType_);
CpuCas01::~CpuCas01()
{
- if (getModel() == surf_cpu_model_pm)
+ if (model() == surf_cpu_model_pm)
speedPerPstate_.clear();
}
bool CpuCas01::isUsed()
{
- return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ return lmm_constraint_used(model()->getMaxminSystem(), constraint());
}
/** @brief take into account changes of speed (either load or max) */
lmm_variable_t var = nullptr;
lmm_element_t elem = nullptr;
- lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
- coresAmount_ * speed_.scale * speed_.peak);
- while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
- CpuCas01Action *action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
+ lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), coresAmount_ * speed_.scale * speed_.peak);
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
- lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
+ lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
host_that_restart.push_back(getHost());
turnOn();
} else {
- lmm_constraint_t cnst = getConstraint();
+ lmm_constraint_t cnst = constraint();
lmm_variable_t var = nullptr;
lmm_element_t elem = nullptr;
double date = surf_get_clock();
turnOff();
- while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) {
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), cnst, &elem))) {
Action *action = static_cast<Action*>(lmm_variable_id(var));
if (action->getState() == Action::State::running ||
CpuAction *CpuCas01::execution_start(double size)
{
- return new CpuCas01Action(getModel(), size, isOff(), speed_.scale * speed_.peak, getConstraint());
+ return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint());
}
CpuAction *CpuCas01::sleep(double duration)
if (duration > 0)
duration = MAX(duration, sg_surf_precision);
- XBT_IN("(%s,%g)", getName(), duration);
- CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, isOff(), speed_.scale * speed_.peak, getConstraint());
+ XBT_IN("(%s,%g)", cname(), duration);
+ CpuCas01Action* action = new CpuCas01Action(model(), 1.0, isOff(), speed_.scale * speed_.peak, constraint());
// FIXME: sleep variables should not consume 1.0 in lmm_expand
action->maxDuration_ = duration;
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
- action->stateSet_ = static_cast<CpuCas01Model*>(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
+ action->stateSet_ = static_cast<CpuCas01Model*>(model())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
action->getStateSet()->push_back(*action);
}
- lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0);
- if (getModel()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
- action->heapRemove(getModel()->getActionHeap());
+ lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), 0.0);
+ if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
+ action->heapRemove(model()->getActionHeap());
// this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
// max_duration correctly at the next call to share_resources
- getModel()->getModifiedSet()->push_front(*action);
+ model()->getModifiedSet()->push_front(*action);
}
XBT_OUT();
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
- TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
- lmm_variable_getvalue(action->getVariable()),
- action->getLastUpdate(),
- now - action->getLastUpdate());
+ TRACE_surf_host_set_utilization(cpu->cname(), action->getCategory(), lmm_variable_getvalue(action->getVariable()),
+ action->getLastUpdate(), now - action->getLastUpdate());
}
action->finish();
if (TRACE_is_enabled()) {
Cpu *cpu = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) );
- TRACE_surf_host_set_utilization(cpu->getName(),
- action->getCategory(),
- lmm_variable_getvalue(action->getVariable()),
- now - delta,
- delta);
+ TRACE_surf_host_set_utilization(cpu->cname(), action->getCategory(), lmm_variable_getvalue(action->getVariable()),
+ now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
}
void Cpu::setPState(int pstate_index)
{
xbt_assert(pstate_index <= static_cast<int>(speedPerPstate_.size()),
- "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index,
- static_cast<int>(speedPerPstate_.size()));
+ "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", cname(), pstate_index,
+ static_cast<int>(speedPerPstate_.size()));
double new_peak_speed = speedPerPstate_[pstate_index];
pstate_ = pstate_index;
}
void Cpu::onSpeedChange() {
- TRACE_surf_host_set_speed(surf_get_clock(), getName(), coresAmount_ * speed_.scale * speed_.peak);
+ TRACE_surf_host_set_speed(surf_get_clock(), cname(), coresAmount_ * speed_.scale * speed_.peak);
}
int Cpu::coreCount()
if (TRACE_is_enabled()) {
Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
- TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
+ TRACE_surf_host_set_utilization(cpu->cname(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
}
XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, remains_);
}
action->setFinishTime(date);
action->setState(Action::State::failed);
if (action->indexHeap_ >= 0) {
- CpuTiAction *heap_act =
- static_cast<CpuTiAction*>(xbt_heap_remove(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, action->indexHeap_));
+ CpuTiAction* heap_act = static_cast<CpuTiAction*>(
+ xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->indexHeap_));
if (heap_act != action)
DIE_IMPOSSIBLE;
}
/* add in action heap */
XBT_DEBUG("action(%p) index %d", action, action->indexHeap_);
if (action->indexHeap_ >= 0) {
- CpuTiAction *heap_act =
- static_cast<CpuTiAction*>(xbt_heap_remove(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, action->indexHeap_));
+ CpuTiAction* heap_act = static_cast<CpuTiAction*>(
+ xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->indexHeap_));
if (heap_act != action)
DIE_IMPOSSIBLE;
}
if (min_finish > NO_MAX_DURATION)
- xbt_heap_push(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, action, min_finish);
+ xbt_heap_push(static_cast<CpuTiModel*>(model())->tiActionHeap_, action, min_finish);
- XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
- getName(), action, action->getStartTime(), action->finishTime_, action->getMaxDuration());
+ XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", cname(), action,
+ action->getStartTime(), action->finishTime_, action->getMaxDuration());
}
/* remove from modified cpu */
modified(false);
for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) {
CpuTiAction *action = &*it;
/* action not running, skip it */
- if (action->getStateSet() != getModel()->getRunningActionSet())
+ if (action->getStateSet() != model()->getRunningActionSet())
continue;
/* bogus priority, skip it */
CpuAction *CpuTi::execution_start(double size)
{
- XBT_IN("(%s,%g)", getName(), size);
- CpuTiAction *action = new CpuTiAction(static_cast<CpuTiModel*>(getModel()), size, isOff(), this);
+ XBT_IN("(%s,%g)", cname(), size);
+ CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), size, isOff(), this);
actionSet_->push_back(*action);
if (duration > 0)
duration = MAX(duration, sg_surf_precision);
- XBT_IN("(%s,%g)", getName(), duration);
- CpuTiAction *action = new CpuTiAction(static_cast<CpuTiModel*>(getModel()), 1.0, isOff(), this);
+ XBT_IN("(%s,%g)", cname(), duration);
+ CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
action->maxDuration_ = duration;
action->suspended_ = 2;
/* Move to the *end* of the corresponding action set. This convention
is used to speed up update_resource_state */
action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
- action->stateSet_ = static_cast<CpuTiModel*>(getModel())->runningActionSetThatDoesNotNeedBeingChecked_;
- action->getStateSet()->push_back(*action);
+ action->stateSet_ = static_cast<CpuTiModel*>(model())->runningActionSetThatDoesNotNeedBeingChecked_;
+ action->getStateSet()->push_back(*action);
}
actionSet_->push_back(*action);
}
void CpuTi::modified(bool modified){
- CpuTiList *modifiedCpu = static_cast<CpuTiModel*>(getModel())->modifiedCpu_;
+ CpuTiList* modifiedCpu = static_cast<CpuTiModel*>(model())->modifiedCpu_;
if (modified) {
if (!cpu_ti_hook.is_linked()) {
modifiedCpu->push_back(*this);
double bandwidth_value = link->bandwidth();
double latency_value = link->latency();
- container_t container = PJ_container_new(link->getName(), INSTR_LINK, father);
+ container_t container = PJ_container_new(link->cname(), INSTR_LINK, father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (! TRACE_disable_link())) {
type_t bandwidth = PJ_type_get_or_null("bandwidth", container->type);
NetworkCm02Link *link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
double value = lmm_variable_getvalue(action->getVariable())*
lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i);
- TRACE_surf_link_set_utilization(link->getName(), action->getCategory(), value,
- action->getLastUpdate(), now - action->getLastUpdate());
+ TRACE_surf_link_set_utilization(link->cname(), action->getCategory(), value, action->getLastUpdate(),
+ now - action->getLastUpdate());
}
}
lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
NetworkCm02Link* link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
- TRACE_surf_link_set_utilization(link->getName(),
- action->getCategory(),
- (lmm_variable_getvalue(action->getVariable())*
- lmm_get_cnst_weight_from_var(maxminSystem_,
- action->getVariable(),
- i)),
- action->getLastUpdate(),
- now - action->getLastUpdate());
+ TRACE_surf_link_set_utilization(link->cname(), action->getCategory(),
+ (lmm_variable_getvalue(action->getVariable()) *
+ lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i)),
+ action->getLastUpdate(), now - action->getLastUpdate());
}
}
if (!lmm_get_number_of_cnst_from_var (maxminSystem_, action->getVariable())) {
}
for (auto link: *route)
- lmm_expand(maxminSystem_, link->getConstraint(), action->getVariable(), 1.0);
+ lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
if (back_route != nullptr) { // sg_network_crosstraffic was activated
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
for (auto link : *back_route)
- lmm_expand(maxminSystem_, link->getConstraint(), action->getVariable(), .05);
-
+ lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
+
//Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
//(You would also have to change lmm_element_concurrency())
//lmm_variable_concurrency_share_set(action->getVariable(),2);
latency_.peak = latency;
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(getConstraint());
+ lmm_constraint_shared(constraint());
LinkImpl::onCreation(this);
}
double now = surf_get_clock();
turnOff();
- while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
Action *action = static_cast<Action*>( lmm_variable_id(var) );
if (action->getState() == Action::State::running ||
xbt_die("Unknown event!\n");
}
- XBT_DEBUG("There was a resource state event, need to update actions related to the constraint (%p)",
- getConstraint());
+ XBT_DEBUG("There was a resource state event, need to update actions related to the constraint (%p)", constraint());
}
void NetworkCm02Link::setBandwidth(double value)
bandwidth_.peak = value;
- lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
+ lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(),
sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
- TRACE_surf_link_set_bandwidth(surf_get_clock(), getName(), sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale);
+ TRACE_surf_link_set_bandwidth(surf_get_clock(), cname(), sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale);
if (sg_weight_S_parameter > 0) {
double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale);
lmm_variable_t var;
lmm_element_t elem = nullptr, nextelem = nullptr;
int numelem = 0;
- while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
+ while ((var = lmm_get_var_from_cnst_safe(model()->getMaxminSystem(), constraint(), &elem, &nextelem, &numelem))) {
NetworkCm02Action *action = (NetworkCm02Action*) lmm_variable_id(var);
action->weight_ += delta;
if (!action->isSuspended())
- lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->weight_);
+ lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
}
}
}
latency_.peak = value;
- while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
+ while ((var = lmm_get_var_from_cnst_safe(model()->getMaxminSystem(), constraint(), &elem, &nextelem, &numelem))) {
NetworkCm02Action *action = (NetworkCm02Action*) lmm_variable_id(var);
action->latCurrent_ += delta;
action->weight_ += delta;
if (action->rate_ < 0)
- lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->latCurrent_));
+ lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
+ sg_tcp_gamma / (2.0 * action->latCurrent_));
else {
- lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(),
+ lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
}
}
if (!action->isSuspended())
- lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->weight_);
+ lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
}
}
bool LinkImpl::isUsed()
{
- return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ return lmm_constraint_used(model()->getMaxminSystem(), constraint());
}
double LinkImpl::latency()
int LinkImpl::sharingPolicy()
{
- return lmm_constraint_sharing_policy(getConstraint());
+ return lmm_constraint_sharing_policy(constraint());
}
void LinkImpl::turnOn()
}
void LinkImpl::setStateTrace(tmgr_trace_t trace)
{
- xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Link %s", getName());
+ xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Link %s", cname());
stateEvent_ = future_evt_set->add_trace(trace, 0.0, this);
}
void LinkImpl::setBandwidthTrace(tmgr_trace_t trace)
{
- xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", getName());
+ xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", cname());
bandwidth_.event = future_evt_set->add_trace(trace, 0.0, this);
}
void LinkImpl::setLatencyTrace(tmgr_trace_t trace)
{
- xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", getName());
+ xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", cname());
latency_.event = future_evt_set->add_trace(trace, 0.0, this);
}
if (link_list->size() == 1) {
simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list->at(0));
- XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->cname(), dst->cname(), link->getName(),
+ XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->cname(), dst->cname(), link->cname(),
(symmetrical ? "(symmetrical)" : "(not symmetrical)"));
char* link_bdw = bprintf("%fBps", link->bandwidth());
char* link_lat = bprintf("%fs", link->latency());
// XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id);
- XBT_DEBUG("\tLink (%s) bdw:%s lat:%s", link->getName(), link_bdw, link_lat);
+ XBT_DEBUG("\tLink (%s) bdw:%s lat:%s", link->cname(), link_bdw, link_lat);
// create link ns3
NetPointNs3* host_src = src->extension<NetPointNs3>();
action->src_->routeTo(action->dst_, &route, nullptr);
for (auto link : route)
- TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta);
+ TRACE_surf_link_set_utilization(link->cname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
+ delta);
action->lastSent_ = sgFlow->sentBytes_;
}
void NetworkSmpiModel::gapAppend(double size, LinkImpl* link, NetworkAction* act)
{
- const char *src = link->getName();
+ const char* src = link->cname();
xbt_fifo_t fifo;
NetworkCm02Action *action= static_cast<NetworkCm02Action*>(act);
// We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
cpu_load = 1;
else
- cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->getConstraint()) / host->pimpl_cpu->getPstateSpeedCurrent();
+ cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->constraint()) / host->pimpl_cpu->getPstateSpeedCurrent();
/** Divide by the number of cores here **/
cpu_load /= host->pimpl_cpu->coreCount();
latency = MAX(latency, lat);
for (auto link : route)
- affected_links.insert(link->getName());
+ affected_links.insert(link->cname());
}
}
}
lmm_update_variable_weight(model->getMaxminSystem(), this->getVariable(), 0.0);
for (int i = 0; i < host_nb; i++)
- lmm_expand(model->getMaxminSystem(), host_list[i]->pimpl_cpu->getConstraint(),
- this->getVariable(), flops_amount[i]);
+ lmm_expand(model->getMaxminSystem(), host_list[i]->pimpl_cpu->constraint(), this->getVariable(), flops_amount[i]);
if(bytes_amount != nullptr) {
for (int i = 0; i < host_nb; i++) {
hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
for (auto link : route)
- lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), this->getVariable(), bytes_amount[i * host_nb + j]);
+ lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
+ bytes_amount[i * host_nb + j]);
}
}
}
latency_.peak = latency;
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(getConstraint());
+ lmm_constraint_shared(constraint());
LinkImpl::onCreation(this);
}
host_list[0] = getHost();
flops_amount[0] = size;
- return static_cast<CpuL07Model*>(getModel())->hostModel_->executeParallelTask(1, host_list, flops_amount, nullptr, -1);
+ return static_cast<CpuL07Model*>(model())->hostModel_->executeParallelTask(1, host_list, flops_amount, nullptr, -1);
}
Action *CpuL07::sleep(double duration)
L07Action *action = static_cast<L07Action*>(execution_start(1.0));
action->maxDuration_ = duration;
action->suspended_ = 2;
- lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0);
+ lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), 0.0);
return action;
}
bool CpuL07::isUsed(){
- return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ return lmm_constraint_used(model()->getMaxminSystem(), constraint());
}
/** @brief take into account changes of speed (either load or max) */
lmm_variable_t var = nullptr;
lmm_element_t elem = nullptr;
- lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), speed_.peak * speed_.scale);
- while ((var = lmm_get_var_from_cnst (getModel()->getMaxminSystem(), getConstraint(), &elem))) {
- Action *action = static_cast<Action*>(lmm_variable_id(var));
+ lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), speed_.peak * speed_.scale);
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ Action* action = static_cast<Action*>(lmm_variable_id(var));
- lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
+ lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
bool LinkL07::isUsed(){
- return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ return lmm_constraint_used(model()->getMaxminSystem(), constraint());
}
void CpuL07::apply_event(tmgr_trace_iterator_t triggered, double value){
- XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
+ XBT_DEBUG("Updating cpu %s (%p) with value %g", cname(), this, value);
if (triggered == speed_.event) {
speed_.scale = value;
onSpeedChange();
}
void LinkL07::apply_event(tmgr_trace_iterator_t triggered, double value) {
- XBT_DEBUG("Updating link %s (%p) with value=%f", getName(), this, value);
+ XBT_DEBUG("Updating link %s (%p) with value=%f", cname(), this, value);
if (triggered == bandwidth_.event) {
setBandwidth(value);
tmgr_trace_event_unref(&bandwidth_.event);
void LinkL07::setBandwidth(double value)
{
bandwidth_.peak = value;
- lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), bandwidth_.peak * bandwidth_.scale);
+ lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), bandwidth_.peak * bandwidth_.scale);
}
void LinkL07::setLatency(double value)
lmm_element_t elem = nullptr;
latency_.peak = value;
- while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
action = static_cast<L07Action*>(lmm_variable_id(var));
action->updateBound();
}
static_cast<simgrid::surf::Storage*>(xbt_lib_get_or_null(storage_lib, key, SURF_STORAGE_LEVEL));
simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(storage->attach_);
if (!host_elm)
- surf_parse_error("Unable to attach storage %s: host %s does not exist.", storage->getName(), storage->attach_);
+ surf_parse_error("Unable to attach storage %s: host %s does not exist.", storage->cname(), storage->attach_);
}
}
}
file->mount = xbt_strdup(mount);
file->current_position = 0;
- StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, OPEN);
+ StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, OPEN);
action->file_ = file;
return action;
free(fd->name);
free(fd->mount);
xbt_free(fd);
- StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, CLOSE);
+ StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, CLOSE);
return action;
}
else
fd->current_position += size;
- StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, READ);
+ StorageAction* action = new StorageN11Action(model(), size, isOff(), this, READ);
return action;
}
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
- StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, WRITE);
+ StorageAction* action = new StorageN11Action(model(), size, isOff(), this, WRITE);
action->file_ = fd;
/* Substract the part of the file that might disappear from the used sized on the storage element */
usedSize_ -= (fd->size - fd->current_position);
: StorageAction(model, cost, failed,
lmm_variable_new(model->getMaxminSystem(), this, 1.0, -1.0 , 3),
storage, type) {
- XBT_IN("(%s,%g", storage->getName(), cost);
+ XBT_IN("(%s,%g", storage->cname(), cost);
// Must be less than the max bandwidth for all actions
- lmm_expand(model->getMaxminSystem(), storage->getConstraint(), getVariable(), 1.0);
+ lmm_expand(model->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
switch(type) {
case OPEN:
case CLOSE:
XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date);
while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
- if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->getName())) {
+ if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->cname())) {
time_delta = next_event_date - NOW;
XBT_DEBUG("This event invalidates the next_occuring_event() computation of models. Next event set to %f", time_delta);
}
NOW = next_event_date;
/* update state of the corresponding resource to the new value. Does not touch lmm.
It will be modified if needed when updating actions */
- XBT_DEBUG("Calling update_resource_state for resource %s", resource->getName());
+ XBT_DEBUG("Calling update_resource_state for resource %s", resource->cname());
resource->apply_event(event, value);
NOW = round_start;
}
isOn_ = false;
}
-Model *Resource::getModel() const {
+Model* Resource::model() const
+{
return model_;
}
-const char *Resource::getName() const {
+const char* Resource::cname() const
+{
return name_.c_str();
}
return name_ == other.name_;
}
-lmm_constraint_t Resource::getConstraint() const {
+lmm_constraint_t Resource::constraint() const
+{
return constraint_;
}
if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) {
simgrid::surf::Resource *cpu = static_cast<simgrid::surf::Resource*>(
lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
- TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
+ TRACE_surf_host_set_utilization(cpu->cname(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
}
XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
}
virtual ~Resource();
/** @brief Get the Model of the current Resource */
- Model *getModel() const;
+ Model* model() const;
/** @brief Get the name of the current Resource */
- const char *getName() const;
+ const char* cname() const;
bool operator==(const Resource &other) const;
public: /* LMM */
/** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
- lmm_constraint_t getConstraint() const;
+ lmm_constraint_t constraint() const;
+
protected:
const lmm_constraint_t constraint_ = nullptr;
};
{
std::size_t operator()(const simgrid::surf::Resource& r) const
{
- return (std::size_t) xbt_str_hash(r.getName());
+ return (std::size_t) xbt_str_hash(r.cname());
}
};
}
if (!route.empty()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->cname(), host2->cname());
for (auto link : route)
- std::printf("<link_ctn id=\"%s\"/>",link->getName());
+ std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
for (auto link : route)
- std::printf("<link_ctn id=\"%s\"/>",link->getName());
+ std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, &route, nullptr);
for (auto link : route)
- std::printf("<link_ctn id=\"%s\"/>",link->getName());
+ std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, &route, nullptr);
for (auto link : route)
- std::printf("<link_ctn id=\"%s\"/>",link->getName());
+ std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
while (next_event_date > -1.0) {
XBT_INFO("%g:", next_event_date);
while (fes->pop_leq(next_event_date, &value, &resource)) {
- XBT_INFO(" %s: %g", resource->getName(), value);
+ XBT_INFO(" %s: %g", resource->cname(), value);
}
if (next_event_date > 100)
break;