This means that we describe the external event (what it does for the
caller) instead of the internal behavior (how it gets to that result)
25 files changed:
-double CpuCas01Model::shareResourcesFull(double /*now*/)
+double CpuCas01Model::next_occuring_event_full(double /*now*/)
- return Model::shareResourcesMaxMin(getRunningActionSet(),
- p_maxminSystem, lmm_solve);
+ return Model::shareResourcesMaxMin(getRunningActionSet(), p_maxminSystem, lmm_solve);
}
void CpuCas01Model::addTraces()
}
void CpuCas01Model::addTraces()
tmgr_trace_t speedTrace, int core,
int initiallyOn,
tmgr_trace_t state_trace) override;
tmgr_trace_t speedTrace, int core,
int initiallyOn,
tmgr_trace_t state_trace) override;
- double shareResourcesFull(double now) override;
+ double next_occuring_event_full(double now) override;
void addTraces() override;
ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
};
void addTraces() override;
ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
};
void updateActionsStateLazy(double now, double delta);
void updateActionsStateFull(double now, double delta);
void updateActionsStateLazy(double now, double delta);
void updateActionsStateFull(double now, double delta);
- bool shareResourcesIsIdempotent() {return true;}
+ bool next_occuring_event_isIdempotent() {return true;}
-double CpuTiModel::shareResources(double now)
+double CpuTiModel::next_occuring_event(double now)
{
double min_action_duration = -1;
{
double min_action_duration = -1;
tmgr_trace_t speedTrace, int core,
int initiallyOn,
tmgr_trace_t state_trace) override;
tmgr_trace_t speedTrace, int core,
int initiallyOn,
tmgr_trace_t state_trace) override;
- double shareResources(double now) override;
+ double next_occuring_event(double now) override;
void updateActionsState(double now, double delta) override;
void addTraces() override;
void updateActionsState(double now, double delta) override;
void addTraces() override;
namespace simgrid {
namespace surf {
namespace simgrid {
namespace surf {
-double HostCLM03Model::shareResources(double now){
+double HostCLM03Model::next_occuring_event(double now){
adjustWeightOfDummyCpuActions();
adjustWeightOfDummyCpuActions();
- double min_by_cpu = surf_cpu_model_pm->shareResources(now);
- double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1;
- double min_by_sto = surf_storage_model->shareResources(now);
+ double min_by_cpu = surf_cpu_model_pm->next_occuring_event(now);
+ double min_by_net = surf_network_model->next_occuring_event_isIdempotent() ? surf_network_model->next_occuring_event(now) : -1;
+ double min_by_sto = surf_storage_model->next_occuring_event(now);
XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
this, typeid(surf_cpu_model_pm).name(), min_by_cpu,
XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
this, typeid(surf_cpu_model_pm).name(), min_by_cpu,
public:
HostCLM03Model(): HostModel(){}
~HostCLM03Model() {}
public:
HostCLM03Model(): HostModel(){}
~HostCLM03Model() {}
- double shareResources(double now) override;
+ double next_occuring_event(double now) override;
void updateActionsState(double now, double delta) override;
};
void updateActionsState(double now, double delta) override;
};
double *bytes_amount,
double rate);
double *bytes_amount,
double rate);
- bool shareResourcesIsIdempotent() override {return true;}
+ bool next_occuring_event_isIdempotent() override {return true;}
-double HostL07Model::shareResources(double /*now*/)
+double HostL07Model::next_occuring_event(double /*now*/)
HostL07Model();
~HostL07Model();
HostL07Model();
~HostL07Model();
- double shareResources(double now) override;
+ 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,
void updateActionsState(double now, double delta) override;
Action *executeParallelTask(int host_nb, sg_host_t *host_list,
double *flops_amount, double *bytes_amount,
Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
void addTraces() override {DIE_IMPOSSIBLE;};
Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
void addTraces() override {DIE_IMPOSSIBLE;};
- bool shareResourcesIsIdempotent() override {return true;}
+ bool next_occuring_event_isIdempotent() override {return true;}
HostL07Model *p_hostModel;
};
HostL07Model *p_hostModel;
};
void updateActionsStateFull(double now, double delta) override;
Action *communicate(NetCard *src, NetCard *dst,
double size, double rate) override;
void updateActionsStateFull(double now, double delta) override;
Action *communicate(NetCard *src, NetCard *dst,
double size, double rate) override;
- bool shareResourcesIsIdempotent() override {return true;}
+ bool next_occuring_event_isIdempotent() override {return true;}
virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkAction * /*action*/) {};
protected:
bool m_haveGap = false;
virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkAction * /*action*/) {};
protected:
bool m_haveGap = false;
namespace simgrid {
namespace surf {
namespace simgrid {
namespace surf {
-double NetworkConstantModel::shareResources(double /*now*/)
+double NetworkConstantModel::next_occuring_event(double /*now*/)
{
NetworkConstantAction *action = NULL;
double min = -1.0;
{
NetworkConstantAction *action = NULL;
double min = -1.0;
~NetworkConstantModel() { }
Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
~NetworkConstantModel() { }
Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
- double shareResources(double now) override;
+ double next_occuring_event(double now) override;
+ bool next_occuring_event_isIdempotent() override {return true;}
void updateActionsState(double now, double delta) override;
void updateActionsState(double now, double delta) override;
- bool shareResourcesIsIdempotent() override {return true;}
Link*
createLink(const char *name,
Link*
createLink(const char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- int initiallyOn,
- tmgr_trace_t state_trace,
+ double bw_initial, tmgr_trace_t bw_trace,
+ double lat_initial, tmgr_trace_t lat_trace,
+ int initiallyOn, tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties) override { DIE_IMPOSSIBLE; }
void addTraces() override { DIE_IMPOSSIBLE; }
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties) override { DIE_IMPOSSIBLE; }
void addTraces() override { DIE_IMPOSSIBLE; }
-double NetworkModel::shareResourcesFull(double now)
+double NetworkModel::next_occuring_event_full(double now)
{
NetworkAction *action = NULL;
ActionList *runningActions = surf_network_model->getRunningActionSet();
{
NetworkAction *action = NULL;
ActionList *runningActions = surf_network_model->getRunningActionSet();
* @return The new bandwidth.
*/
virtual double bandwidthConstraint(double rate, double bound, double size);
* @return The new bandwidth.
*/
virtual double bandwidthConstraint(double rate, double bound, double size);
- double shareResourcesFull(double now);
+ double next_occuring_event_full(double now) override;
return (surf_action_t) action;
}
return (surf_action_t) action;
}
-double NetworkNS3Model::shareResources(double now)
+double NetworkNS3Model::next_occuring_event(double now)
- XBT_DEBUG("ns3_share_resources");
+ XBT_DEBUG("ns3_next_occuring_event");
//get the first relevant value from the running_actions list
if (!getRunningActionSet()->size() || now == 0.0)
//get the first relevant value from the running_actions list
if (!getRunningActionSet()->size() || now == 0.0)
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties);
xbt_dynar_t getRoute(NetCard *src, NetCard *dst);
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties);
xbt_dynar_t getRoute(NetCard *src, NetCard *dst);
- Action *communicate(NetCard *src, NetCard *dst,
- double size, double rate);
- double shareResources(double now);
- void updateActionsState(double now, double delta);
- void addTraces(){DIE_IMPOSSIBLE;}
- bool shareResourcesIsIdempotent() {return false;}
+ Action *communicate(NetCard *src, NetCard *dst, double size, double rate);
+ double next_occuring_event(double now) override;
+ void updateActionsState(double now, double delta) override;
+ void addTraces() override {DIE_IMPOSSIBLE;}
+ bool next_occuring_event_isIdempotent() {return false;}
xbt_dict_t properties,
const char *attach) = 0;
xbt_dict_t properties,
const char *attach) = 0;
- bool shareResourcesIsIdempotent() {return true;}
+ bool next_occuring_event_isIdempotent() {return true;}
xbt_dynar_t p_storageList;
};
xbt_dynar_t p_storageList;
};
-double StorageN11Model::shareResources(double /*now*/)
+double StorageN11Model::next_occuring_event(double /*now*/)
{
XBT_DEBUG("storage_share_resources");
unsigned int i, j;
{
XBT_DEBUG("storage_share_resources");
unsigned int i, j;
~StorageN11Model();
Storage *createStorage(const char* id, const char* type_id,
const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach);
~StorageN11Model();
Storage *createStorage(const char* id, const char* type_id,
const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach);
- void addTraces(){DIE_IMPOSSIBLE;}
- double shareResources(double now);
- void updateActionsState(double now, double delta);
+ void addTraces() override {DIE_IMPOSSIBLE;}
+ double next_occuring_event(double now) override;
+ void updateActionsState(double now, double delta) override;
double surf_solve(double max_date)
{
double surf_solve(double max_date)
{
- double surf_min = -1.0; /* duration */
+ double time_delta = -1.0; /* duration */
double next_event_date = -1.0;
double model_next_action_end = -1.0;
double value = -1.0;
double next_event_date = -1.0;
double model_next_action_end = -1.0;
double value = -1.0;
if(!host_that_restart)
host_that_restart = xbt_dynar_new(sizeof(char*), NULL);
if(!host_that_restart)
host_that_restart = xbt_dynar_new(sizeof(char*), NULL);
- if (max_date > 0.0 && max_date != NOW) {
- surf_min = max_date - NOW;
+ if (max_date > 0.0) {
+ xbt_assert(max_date > NOW,"You asked to simulate up to %f, but that's in the past already", max_date);
+
+ time_delta = max_date - NOW;
}
/* Physical models MUST be resolved first */
XBT_DEBUG("Looking for next event in physical models");
}
/* Physical models MUST be resolved first */
XBT_DEBUG("Looking for next event in physical models");
- double next_event_phy = surf_host_model->shareResources(NOW);
- if ((surf_min < 0.0 || next_event_phy < surf_min) && next_event_phy >= 0.0) {
- surf_min = next_event_phy;
+ double next_event_phy = surf_host_model->next_occuring_event(NOW);
+ if ((time_delta < 0.0 || next_event_phy < time_delta) && next_event_phy >= 0.0) {
+ time_delta = next_event_phy;
}
if (surf_vm_model != NULL) {
XBT_DEBUG("Looking for next event in virtual models");
}
if (surf_vm_model != NULL) {
XBT_DEBUG("Looking for next event in virtual models");
- double next_event_virt = surf_vm_model->shareResources(NOW);
- if ((surf_min < 0.0 || next_event_virt < surf_min) && next_event_virt >= 0.0)
- surf_min = next_event_virt;
+ double next_event_virt = surf_vm_model->next_occuring_event(NOW);
+ if ((time_delta < 0.0 || next_event_virt < time_delta) && next_event_virt >= 0.0)
+ time_delta = next_event_virt;
- XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", surf_min);
+ XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", time_delta);
XBT_DEBUG("Looking for next trace event");
XBT_DEBUG("Looking for next trace event");
next_event_date = future_evt_set->next_date();
XBT_DEBUG("Next TRACE event: %f", next_event_date);
next_event_date = future_evt_set->next_date();
XBT_DEBUG("Next TRACE event: %f", next_event_date);
- if(! surf_network_model->shareResourcesIsIdempotent()){ // NS3, I see you
- if (next_event_date!=-1.0 && surf_min!=-1.0) {
- surf_min = MIN(next_event_date - NOW, surf_min);
+ if(! surf_network_model->next_occuring_event_isIdempotent()){ // NS3, I see you
+ if (next_event_date!=-1.0 && time_delta!=-1.0) {
+ time_delta = MIN(next_event_date - NOW, time_delta);
- surf_min = MAX(next_event_date - NOW, surf_min); // Get the positive component
+ time_delta = MAX(next_event_date - NOW, time_delta); // Get the positive component
- XBT_DEBUG("Run the NS3 network at most %fs", surf_min);
+ XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
// run until min or next flow
// run until min or next flow
- model_next_action_end = surf_network_model->shareResources(surf_min);
+ model_next_action_end = surf_network_model->next_occuring_event(time_delta);
XBT_DEBUG("Min for network : %f", model_next_action_end);
if(model_next_action_end>=0.0)
XBT_DEBUG("Min for network : %f", model_next_action_end);
if(model_next_action_end>=0.0)
- surf_min = model_next_action_end;
+ time_delta = model_next_action_end;
}
if (next_event_date < 0.0) {
}
if (next_event_date < 0.0) {
- if ((surf_min == -1.0) || (next_event_date > NOW + surf_min))
+ if ((time_delta == -1.0) || (next_event_date > NOW + time_delta))
break; // next event occurs after the next resource change, bail out
break; // next event occurs after the next resource change, bail out
- XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", surf_min, NOW, next_event_date);
+ 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())) {
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())) {
- surf_min = next_event_date - NOW;
- XBT_DEBUG("This event will modify model state. Next event set to %f", surf_min);
+ time_delta = next_event_date - NOW;
+ XBT_DEBUG("This event will modify model state. Next event set to %f", time_delta);
}
// FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min will work
double round_start = NOW;
}
// FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min will work
double round_start = NOW;
/* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
* This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
* The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
/* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
* This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
* The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
- if (surf_min == -1.0) {
+ if (time_delta == -1.0) {
XBT_DEBUG("No next event at all. Bail out now.");
return -1.0;
}
XBT_DEBUG("No next event at all. Bail out now.");
return -1.0;
}
- XBT_DEBUG("Duration set to %f", surf_min);
+ XBT_DEBUG("Duration set to %f", time_delta);
// Bump the time: jump into the future
// Bump the time: jump into the future
+ NOW = NOW + time_delta;
// Inform the models of the date change
xbt_dynar_foreach(all_existing_models, iter, model) {
// Inform the models of the date change
xbt_dynar_foreach(all_existing_models, iter, model) {
- model->updateActionsState(NOW, surf_min);
+ model->updateActionsState(NOW, time_delta);
}
TRACE_paje_dump_buffer (0);
}
TRACE_paje_dump_buffer (0);
delete p_doneActionSet;
}
delete p_doneActionSet;
}
-double Model::shareResources(double now)
+double Model::next_occuring_event(double now)
{
//FIXME: set the good function once and for all
if (p_updateMechanism == UM_LAZY)
{
//FIXME: set the good function once and for all
if (p_updateMechanism == UM_LAZY)
- return shareResourcesLazy(now);
+ return next_occuring_event_lazy(now);
else if (p_updateMechanism == UM_FULL)
else if (p_updateMechanism == UM_FULL)
- return shareResourcesFull(now);
+ return next_occuring_event_full(now);
else
xbt_die("Invalid cpu update mechanism!");
}
else
xbt_die("Invalid cpu update mechanism!");
}
-double Model::shareResourcesLazy(double now)
+double Model::next_occuring_event_lazy(double now)
{
Action *action = NULL;
double min = -1;
{
Action *action = NULL;
double min = -1;
-double Model::shareResourcesFull(double /*now*/) {
+double Model::next_occuring_event_full(double /*now*/) {
* @param now The current time of the simulation
* @return The delta of time till the next action will finish
*/
* @param now The current time of the simulation
* @return The delta of time till the next action will finish
*/
- virtual double shareResources(double now);
- virtual double shareResourcesLazy(double now);
- virtual double shareResourcesFull(double now);
+ virtual double next_occuring_event(double now);
+ virtual double next_occuring_event_lazy(double now);
+ virtual double next_occuring_event_full(double now);
double shareResourcesMaxMin(ActionList* running_actions,
double shareResourcesMaxMin(ActionList* running_actions,
- lmm_system_t sys,
- void (*solve) (lmm_system_t));
+ lmm_system_t sys, void (*solve) (lmm_system_t));
/**
* @brief Update action to the current time
/**
* @brief Update action to the current time
* The only model that is not is NS3: computing the next timestamp moves the model up to that point,
* so we need to call it only when the next timestamp of other sources is computed.
*/
* The only model that is not is NS3: computing the next timestamp moves the model up to that point,
* so we need to call it only when the next timestamp of other sources is computed.
*/
- virtual bool shareResourcesIsIdempotent()=0;
+ virtual bool next_occuring_event_isIdempotent()=0;
protected:
ActionLmmListPtr p_modifiedSet;
protected:
ActionLmmListPtr p_modifiedSet;
// const double virt_overhead = 0.95;
const double virt_overhead = 1;
// const double virt_overhead = 0.95;
const double virt_overhead = 1;
-double VMHL13Model::shareResources(double now)
+double VMHL13Model::next_occuring_event(double now)
{
/* TODO: update action's cost with the total cost of processes on the VM. */
{
/* TODO: update action's cost with the total cost of processes on the VM. */
/* 2. Calculate resource share at the virtual machine layer. */
adjustWeightOfDummyCpuActions();
/* 2. Calculate resource share at the virtual machine layer. */
adjustWeightOfDummyCpuActions();
- double min_by_cpu = surf_cpu_model_vm->shareResources(now);
- double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1;
+ double min_by_cpu = surf_cpu_model_vm->next_occuring_event(now);
+ double min_by_net = surf_network_model->next_occuring_event_isIdempotent() ? surf_network_model->next_occuring_event(now) : -1;
// Fixme: take storage into account once it's implemented
double min_by_sto = -1;
// Fixme: take storage into account once it's implemented
double min_by_sto = -1;
~VMHL13Model(){};
VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
~VMHL13Model(){};
VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
- double shareResources(double now) override;
+ double next_occuring_event(double now) override;
void adjustWeightOfDummyCpuActions() override {};
void updateActionsState(double /*now*/, double /*delta*/) override;
};
void adjustWeightOfDummyCpuActions() override {};
void updateActionsState(double /*now*/, double /*delta*/) override;
};