delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
}
-Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
{
return new CpuCas01(this, host, speedPerPstate, core);
}
/************
* Resource *
************/
-CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
-: Cpu(model, host,
- lmm_constraint_new(model->getMaxminSystem(), this, core * xbt_dynar_get_as(speedPerPstate, 0/*pstate*/, double)),
+CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
+: Cpu(model, host, lmm_constraint_new(model->getMaxminSystem(), this, core * speedPerPstate->front()),
speedPerPstate, core)
{
}
CpuCas01::~CpuCas01()
{
if (getModel() == surf_cpu_model_pm)
- xbt_dynar_free(&speedPerPstate_);
+ speedPerPstate_->clear();
}
-xbt_dynar_t CpuCas01::getSpeedPeakList(){
+std::vector<double> * CpuCas01::getSpeedPeakList(){
return speedPerPstate_;
}
lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
coresAmount_ * speed_.scale * speed_.peak);
- while ((var = lmm_get_var_from_cnst
- (getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &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(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
CpuAction *CpuCas01::execution_start(double size)
{
-
XBT_IN("(%s,%g)", getName(), size);
- CpuCas01Action *action = new CpuCas01Action(getModel(), size, isOff(),
- speed_.scale * speed_.peak, getConstraint());
+ CpuCas01Action *action = new CpuCas01Action(getModel(), size, isOff(), speed_.scale * speed_.peak, getConstraint());
XBT_OUT();
return action;
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());
+ CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, isOff(), speed_.scale * speed_.peak, getConstraint());
// FIXME: sleep variables should not consume 1.0 in lmm_expand
action->maxDuration_ = duration;
action->suspended_ = 2;
if (duration == NO_MAX_DURATION) {
- /* Move to the *end* of the corresponding action set. This convention
- is used to speed up update_resource_state */
+ /* 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->getStateSet()->push_back(*action);
}
- lmm_update_variable_weight(getModel()->getMaxminSystem(),
- action->getVariable(), 0.0);
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0);
if (getModel()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
action->heapRemove(getModel()->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
+ // 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);
}
**********/
CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint)
- : CpuAction(model, cost, failed,
- lmm_variable_new(model->getMaxminSystem(), this,
- 1.0, speed, 1))
+ : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
{
if (model->getUpdateMechanism() == UM_LAZY) {
indexHeap_ = -1;
lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
}
-CpuCas01Action::~CpuCas01Action() {}
+CpuCas01Action::~CpuCas01Action()=default;
}
}
CpuCas01Model();
~CpuCas01Model() override;
- Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override;
+ Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
double next_occuring_event_full(double now) override;
ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
};
class CpuCas01 : public Cpu {
public:
- CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core);
+ CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
~CpuCas01() override;
void apply_event(tmgr_trace_iterator_t event, double value) override;
CpuAction *execution_start(double size) override;
bool isUsed() override;
- xbt_dynar_t getSpeedPeakList(); // FIXME: killme to hide our internals
+ std::vector<double> * getSpeedPeakList(); // FIXME: killme to hide our internals
protected:
void onSpeedChange() override;
friend CpuAction *CpuCas01::execution_start(double size);
friend CpuAction *CpuCas01::sleep(double duration);
public:
- CpuCas01Action(Model *model, double cost, bool failed, double speed,
- lmm_constraint_t constraint);
+ CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint);
~CpuCas01Action() override;
};
/************
* Resource *
************/
-Cpu::Cpu(Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+Cpu::Cpu(Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
: Cpu(model, host, nullptr/*constraint*/, speedPerPstate, core)
{
}
Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
- xbt_dynar_t speedPerPstate, int core)
+ std::vector<double> * speedPerPstate, int core)
: Resource(model, host->name().c_str(), constraint)
, coresAmount_(core)
, host_(host)
{
xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->name().c_str());
- speed_.peak = xbt_dynar_get_as(speedPerPstate, 0/*pstate*/, double);
+ speed_.peak = speedPerPstate->front();
speed_.scale = 1;
host->pimpl_cpu = this;
xbt_assert(speed_.scale > 0, "Speed of host %s must be >0", host->name().c_str());
// Copy the power peak array:
- speedPerPstate_ = xbt_dynar_new(sizeof(double), nullptr);
- unsigned long n = xbt_dynar_length(speedPerPstate);
+ speedPerPstate_ = new std::vector<double>();
+ unsigned long n = speedPerPstate->size();
for (unsigned long i = 0; i != n; ++i) {
- double value = xbt_dynar_get_as(speedPerPstate, i, double);
- xbt_dynar_push(speedPerPstate_, &value);
+ double value = speedPerPstate->at(i);
+ speedPerPstate_->push_back(value);
}
xbt_assert(model == surf_cpu_model_pm || core==1, "Currently, VM cannot be multicore");
Cpu::~Cpu()
{
- xbt_dynar_free(&speedPerPstate_);
+ delete speedPerPstate_;
}
double Cpu::getPstateSpeedCurrent()
int Cpu::getNbPStates()
{
- return xbt_dynar_length(speedPerPstate_);
+ return speedPerPstate_->size();
}
void Cpu::setPState(int pstate_index)
{
- xbt_dynar_t plist = speedPerPstate_;
- xbt_assert(pstate_index <= (int)xbt_dynar_length(plist),
- "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index, (int)xbt_dynar_length(plist));
+ std::vector<double> *plist = speedPerPstate_;
+ xbt_assert(pstate_index <= static_cast<int>(plist->size()),
+ "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index,
+ static_cast<int>(plist->size()));
- double new_peak_speed = xbt_dynar_get_as(plist, pstate_index, double);
+ double new_peak_speed = plist->at(pstate_index);
pstate_ = pstate_index;
speed_.peak = new_peak_speed;
double Cpu::getPstateSpeed(int pstate_index)
{
- xbt_dynar_t plist = speedPerPstate_;
- xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
+ std::vector<double> *plist = speedPerPstate_;
+ xbt_assert((pstate_index <= static_cast<int>(plist->size())), "Invalid parameters (pstate index out of bounds)");
- return xbt_dynar_get_as(plist, pstate_index, double);
+ return plist->at(pstate_index);
}
double Cpu::getSpeed(double load)
#include <list>
#include <xbt/base.h>
-#include <xbt/dynar.h>
#include <xbt/signal.hpp>
#include <simgrid/forward.h>
* @param speedPerPstate Processor speed (in Flops) of each pstate. This ignores any potential external load coming from a trace.
* @param core The number of core of this Cpu
*/
- virtual Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)=0;
+ virtual Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *, int core)=0;
void updateActionsStateLazy(double now, double delta) override;
void updateActionsStateFull(double now, double delta) override;
* @param speedPerPstate Processor speed (in flop per second) for each pstate
* @param core The number of core of this Cpu
*/
- Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, xbt_dynar_t speedPerPstate, int core);
+ Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
+ std::vector<double> *speedPerPstate, int core);
/**
* @brief Cpu constructor
* @param speedPerPstate Processor speed (in flop per second) for each pstate
* @param core The number of core of this Cpu
*/
- Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core);
+ Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
~Cpu();
int coresAmount_ = 1;
simgrid::s4u::Host* host_;
- xbt_dynar_t speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */
+ std::vector<double> *speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */
int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
public:
xbt_heap_free(tiActionHeap_);
}
-Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core)
{
return new CpuTi(this, host, speedPerPstate, core);
}
/************
* Resource *
************/
-CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
: Cpu(model, host, speedPerPstate, core)
{
xbt_assert(core==1,"Multi-core not handled by this model yet");
actionSet_ = new ActionTiList();
- xbt_dynar_get_cpy(speedPerPstate, 0, &speed_.peak);
+ speed_.peak = speedPerPstate->front();
XBT_DEBUG("CPU create: peak=%f", speed_.peak);
speedIntegratedTrace_ = new CpuTiTgmr(nullptr, 1/*scale*/);
************/
class CpuTi : public Cpu {
public:
- CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core);
+ CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
~CpuTi() override;
void setSpeedTrace(tmgr_trace_t trace) override;
public:
CpuTiModel();
~CpuTiModel() override;
- Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override;
+ Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core) override;
double next_occuring_event(double now) override;
void updateActionsState(double now, double delta) override;
speed = PJ_type_variable_new ("power", nullptr, container->type);
}
- double current_speed_state;
- xbt_dynar_get_cpy(host->speed_per_pstate, host->pstate, ¤t_speed_state);
+ double current_speed_state = host->speed_per_pstate->at(host->pstate);
new_pajeSetVariable (0, container, speed, current_speed_state);
}
if (TRACE_uncategorized()){
L07Action *action;
ActionList *running_actions = getRunningActionSet();
- double min = this->shareResourcesMaxMin(running_actions,
- maxminSystem_,
- bottleneck_solve);
+ double min = this->shareResourcesMaxMin(running_actions, maxminSystem_, bottleneck_solve);
- for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
- ; it != itend ; ++it) {
+ for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()); it != itend ; ++it) {
action = static_cast<L07Action*>(&*it);
if (action->m_latency > 0) {
if (min < 0) {
min = action->m_latency;
- XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
- action->getStartTime(), min);
+ XBT_DEBUG("Updating min (value) with %p (start %f): %f", action, action->getStartTime(), min);
} else if (action->m_latency < min) {
min = action->m_latency;
- XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
- action->getStartTime(), min);
+ XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action, action->getStartTime(), min);
}
}
}
}
Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t *host_list,
- double *flops_amount, double *bytes_amount,
- double rate) {
+ double *flops_amount, double *bytes_amount,double rate) {
return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate);
}
-L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list,
- double *flops_amount, double *bytes_amount, double rate)
+L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
+ double *flops_amount, double *bytes_amount, double rate)
: CpuAction(model, 1, 0)
{
int nb_link = 0;
return p_hostModel->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate);
}
-Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
{
return new CpuL07(this, host, speedPerPstate, core);
}
* Resource *
************/
-CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)
+CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
: Cpu(model, host, speedPerPstate, core)
{
- constraint_ = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPerPstate,0,double));
+ constraint_ = lmm_constraint_new(model->getMaxminSystem(), this, speedPerPstate->front());
}
-CpuL07::~CpuL07()
-{
-}
+CpuL07::~CpuL07()=default;
LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bandwidth, double latency,
e_surf_link_sharing_policy_t policy)
host_list[0] = getHost();
flops_amount[0] = size;
- return static_cast<CpuL07Model*>(getModel())->p_hostModel
- ->executeParallelTask( 1, host_list, flops_amount, nullptr, -1);
+ return static_cast<CpuL07Model*>(getModel())->p_hostModel->executeParallelTask(1, host_list, flops_amount, nullptr, -1);
}
Action *CpuL07::sleep(double duration)
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))) {
+ while ((var = lmm_get_var_from_cnst (getModel()->getMaxminSystem(), getConstraint(), &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(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
if (m_rate < 0)
lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), lat_bound);
else
- lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(),
- std::min(m_rate, lat_bound));
+ lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), std::min(m_rate, lat_bound));
}
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <cstdlib>
-
#include <vector>
-
#include <xbt/base.h>
-
#include "src/surf/HostImpl.hpp"
#ifndef HOST_L07_HPP_
double next_occuring_event(double now) override;
void updateActionsState(double now, double delta) override;
Action *executeParallelTask(int host_nb, sg_host_t *host_list,
- double *flops_amount, double *bytes_amount,
- double rate) override;
+ double *flops_amount, double *bytes_amount, double rate) override;
};
class CpuL07Model : public CpuModel {
CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
~CpuL07Model();
- Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override;
+ Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
HostL07Model *p_hostModel;
};
class CpuL07 : public Cpu {
public:
- CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedList, int core);
+ CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> * speedPerPstate, int core);
~CpuL07();
bool isUsed() override;
void apply_event(tmgr_trace_iterator_t event, double value) override;
class L07Action : public CpuAction {
friend Action *CpuL07::execution_start(double size);
friend Action *CpuL07::sleep(double duration);
- friend Action *HostL07Model::executeParallelTask(int host_nb,
- sg_host_t*host_list,
- double *flops_amount,
- double *bytes_amount,
- double rate);
+ friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list,
+ double *flops_amount, double *bytes_amount, double rate);
public:
- L07Action(Model *model, int host_nb,
- sg_host_t*host_list,
- double *flops_amount,
- double *bytes_amount,
- double rate);
+ L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate);
~L07Action();
void updateBound();
}
}
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
- xbt_dynar_push(host.speed_per_pstate,&cluster->speed);
+ host.speed_per_pstate = new std::vector<double>();
+ host.speed_per_pstate->push_back(cluster->speed);
host.pstate = 0;
host.core_amount = cluster->core_amount;
host.coord = "";
sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_per_pstate);
+ // delete host.speed_per_pstate;
XBT_DEBUG("</host>");
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id, cluster->bw, cluster->lat);
host.pstate = 0;
host.core_amount = 1;
host.id = hostname;
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
- xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
+ host.speed_per_pstate = new std::vector<double>();
+ host.speed_per_pstate->push_back(cabinet->speed);
sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_per_pstate);
+ delete host.speed_per_pstate;
s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
memset(&host, 0, sizeof(host));
host.id = host_id;
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
- xbt_dynar_push(host.speed_per_pstate,&peer->speed);
+ host.speed_per_pstate = new std::vector<double>();
+ host.speed_per_pstate->push_back(peer->speed);
host.pstate = 0;
host.speed_trace = peer->availability_trace;
host.state_trace = peer->state_trace;
host.core_amount = 1;
sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_per_pstate);
+ delete host.speed_per_pstate;
s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
typedef struct {
const char* id;
- xbt_dynar_t speed_per_pstate;
+ std::vector<double> *speed_per_pstate;
int pstate;
int core_amount;
tmgr_trace_t speed_trace;
buf = A_surfxml_host_speed;
XBT_DEBUG("Buffer: %s", buf);
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
+ host.speed_per_pstate = new std::vector<double>();
if (strchr(buf, ',') == nullptr){
double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id);
- xbt_dynar_push_as(host.speed_per_pstate,double, speed);
+ host.speed_per_pstate->push_back(speed);
}
else {
xbt_dynar_t pstate_list = xbt_str_split(buf, ",");
xbt_dynar_foreach(pstate_list, i, speed_str) {
xbt_str_trim(speed_str, nullptr);
double speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
- xbt_dynar_push_as(host.speed_per_pstate, double, speed);
+ host.speed_per_pstate->push_back(speed);
XBT_DEBUG("Speed value: %f", speed);
}
xbt_dynar_free(&pstate_list);
host.coord = A_surfxml_host_coordinates;
sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_per_pstate);
+ delete host.speed_per_pstate;
current_property_set = nullptr;
}