/** @{ @ingroup SURF_c_bindings */
-/**
- * @brief Get the name of a surf model
+/** @brief Get the name of a surf model (dont rely on exact value)
*
- * @param model A model
- * @return The name of the model
+ * This is implemented using typeid(), so it may change with the compiler
*/
XBT_PUBLIC(const char *) surf_model_name(surf_model_t model);
void updateActionsStateLazy(double now, double delta);
void updateActionsStateFull(double now, double delta);
+ bool shareResourcesIsIdempotent() {return true;}
};
/************
adjustWeightOfDummyCpuActions();
double min_by_cpu = surf_cpu_model_pm->shareResources(now);
- double min_by_net = (strcmp(surf_network_model->getName(), "network NS3")) ? surf_network_model->shareResources(now) : -1;
+ double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1;
double min_by_sto = surf_storage_model->shareResources(now);
XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
- this, surf_cpu_model_pm->getName(), min_by_cpu,
- surf_network_model->getName(), min_by_net,
- surf_storage_model->getName(), min_by_sto);
+ this, typeid(surf_cpu_model_pm).name(), min_by_cpu,
+ typeid(surf_network_model).name(), min_by_net,
+ typeid(surf_storage_model).name(), min_by_sto);
double res = max(max(min_by_cpu, min_by_net), min_by_sto);
if (min_by_cpu >= 0.0 && min_by_cpu < res)
double rate)=0;
virtual Action *communicate(Host *src, Host *dst, double size, double rate)=0;
+
+ bool shareResourcesIsIdempotent() {return true;}
};
/************
Action *communicate(RoutingEdge */*src*/, RoutingEdge */*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
void addTraces() {DIE_IMPOSSIBLE;};
+ bool shareResourcesIsIdempotent() {return true;}
+
HostL07Model *p_hostModel;
};
void updateActionsStateFull(double now, double delta);
Action *communicate(RoutingEdge *src, RoutingEdge *dst,
double size, double rate);
+ bool shareResourcesIsIdempotent() {return true;}
};
/************
double shareResources(double now);
void updateActionsState(double now, double delta);
void addTraces(){DIE_IMPOSSIBLE;}
+ bool shareResourcesIsIdempotent() {return false;}
};
/************
xbt_dict_t properties,
const char *attach) = 0;
+ bool shareResourcesIsIdempotent() {return true;}
+
xbt_dynar_t p_storageList;
};
XBT_DEBUG("Looking for next action end for all models except NS3");
xbt_dynar_foreach(model_list_invoke, iter, model) {
double next_action_end = -1.0;
- if (strcmp(model->getName(), "network NS3")) {
- XBT_DEBUG("Running for Resource [%s]", model->getName());
+ if (model->shareResourcesIsIdempotent()) {
+ XBT_DEBUG("Running for Resource [%s]", typeid(model).name());
next_action_end = model->shareResources(NOW);
XBT_DEBUG("Resource [%s] : next action end = %f",
- model->getName(), next_action_end);
+ typeid(model).name(), next_action_end);
}
if ((surf_min < 0.0 || next_action_end < surf_min)
&& next_action_end >= 0.0) {
next_event_date = tmgr_history_next_date(history);
- if(!strcmp(surf_network_model->getName(), "network NS3")){
+ 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);
} else{
}
const char *surf_model_name(surf_model_t model){
- return model->getName();
+ return typeid(model).name();
}
surf_action_t surf_model_extract_done_action_set(surf_model_t model){
virtual void updateActionsStateLazy(double now, double delta);
virtual void updateActionsStateFull(double now, double delta);
+ /** @brief Returns whether this model have an idempotent shareResource()
+ *
+ * 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;
+
protected:
ActionLmmListPtr p_modifiedSet;
lmm_system_t p_maxminSystem;
adjustWeightOfDummyCpuActions();
double min_by_cpu = surf_cpu_model_vm->shareResources(now);
- double min_by_net = (strcmp(surf_network_model->getName(), "network NS3")) ? surf_network_model->shareResources(now) : -1;
+ double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1;
// Fixme: take storage into account once it's implemented
double min_by_sto = -1;