option(enable_debug "Set NDEBUG flag" on)
option(enable_supernovae "Whether Supernovae mode (helping compiler optimization) is activated." on)
-if(enable_supernovae AND enable_model-checking)
- set(enable_model-checking false CACHE TYPE INTERNAL FORCE)
- message("\n\nWith supernovae mode the model checking must be disable.!!!\n\n")
-endif(enable_supernovae AND enable_model-checking)
+#if(enable_supernovae AND enable_model-checking)
+# set(enable_model-checking OFF CACHE TYPE INTERNAL FORCE)
+# message("\n\nCannot enable supernovae mode and model-checking at the same time (yet)\n\n")
+#endif(enable_supernovae AND enable_model-checking)
if(WIN32)
option(enable_smpi "Whether the smpi library is compiled." off)
static xbt_swag_t
cpu_running_action_set_that_does_not_need_being_checked = NULL;
-/* added to manage the communication action's heap */
-static void net_action_update_index_heap(void *action, int i)
-{
- surf_action_cpu_Cas01_t a = action;
- GENERIC_LMM_ACTION(a).index_heap = i;
-}
-
-/* insert action on heap using a given key and a hat (heap_action_type)
- * a hat can be of three types for communications:
- *
- * NORMAL = this is a normal heap entry stating the date to finish transmitting
- * LATENCY = this is a heap entry to warn us when the latency is payed
- * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
- */
-static void heap_insert(surf_action_cpu_Cas01_t action, double key,
- enum heap_action_type hat)
-{
- GENERIC_LMM_ACTION(action).hat = hat;
- xbt_heap_push(cpu_action_heap, action, key);
-}
-
-static void heap_remove(surf_action_cpu_Cas01_t action)
-{
- GENERIC_LMM_ACTION(action).hat = NOTSET;
- if (GENERIC_LMM_ACTION(action).index_heap >= 0) {
- xbt_heap_remove(cpu_action_heap, GENERIC_LMM_ACTION(action).index_heap);
- }
-}
static void *cpu_create_resource(const char *name, double power_peak,
double power_scale,
((surf_action_lmm_t) action)->variable);
if (cpu_update_mechanism == UM_LAZY) {
/* remove from heap */
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
xbt_swag_remove(action, cpu_modified_set);
}
#ifdef HAVE_TRACING
surf_action_state_set(action, SURF_ACTION_FAILED);
if (cpu_update_mechanism == UM_LAZY) {
xbt_swag_remove(action, cpu_modified_set);
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
}
return;
}
return;
}
-static void update_action_remaining_lazy(double now)
+static void cpu_update_action_remaining_lazy(double now)
{
surf_action_cpu_Cas01_t action;
double delta = 0.0;
XBT_DEBUG
("Before share resources, the size of modified actions set is %d",
xbt_swag_size(cpu_modified_set));
- update_action_remaining_lazy(now);
+ cpu_update_action_remaining_lazy(now);
lmm_solve(cpu_maxmin_system);
GENERIC_ACTION(action).max_duration);
if (min != -1) {
- heap_remove(action);
- heap_insert(action, min, max_dur_flag ? MAX_DURATION : NORMAL);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
+ surf_action_lmm_heap_insert(cpu_action_heap,(surf_action_lmm_t)action, min, max_dur_flag ? MAX_DURATION : NORMAL);
XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
now);
} else DIE_IMPOSSIBLE;
/* set the remains to 0 due to precision problems when updating the remaining amount */
GENERIC_ACTION(action).remains = 0;
cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
- heap_remove(action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
}
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
lmm_update_variable_weight(cpu_maxmin_system,
GENERIC_LMM_ACTION(action).variable, 0.0);
if (cpu_update_mechanism == UM_LAZY) { // remove action from the heap
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
// 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
0.0);
((surf_action_lmm_t) action)->suspended = 1;
if (cpu_update_mechanism == UM_LAZY)
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
}
XBT_OUT();
}
action->priority);
((surf_action_lmm_t) action)->suspended = 0;
if (cpu_update_mechanism == UM_LAZY)
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
}
XBT_OUT();
}
action->max_duration = duration;
if (cpu_update_mechanism == UM_LAZY)
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
XBT_OUT();
}
priority);
if (cpu_update_mechanism == UM_LAZY)
- heap_remove((surf_action_cpu_Cas01_t) action);
+ surf_action_lmm_heap_remove(cpu_action_heap,(surf_action_lmm_t)action);
XBT_OUT();
}
XBT_IN("(%p)", action);
/* update remains before return it */
if (cpu_update_mechanism == UM_LAZY)
- update_action_remaining_lazy(surf_get_clock());
+ cpu_update_action_remaining_lazy(surf_get_clock());
XBT_OUT();
return action->remains;
}
if (cpu_update_mechanism == UM_LAZY) {
cpu_action_heap = xbt_heap_new(8, NULL);
xbt_heap_set_update_callback(cpu_action_heap,
- net_action_update_index_heap);
+ surf_action_lmm_update_index_heap);
cpu_modified_set =
xbt_swag_new(xbt_swag_offset(comp, generic_lmm_action.action_list_hookup));
cpu_maxmin_system->keep_track = cpu_modified_set;
*/
static void cpu_ti_update_remaining_amount(cpu_ti_t cpu, double now)
{
-#define GENERIC_ACTION(action) action->generic_action
double area_total;
surf_action_cpu_ti_t action;
cpu->last_update);
xbt_swag_foreach(action, cpu->action_set) {
+ surf_action_t generic = (surf_action_t)action;
/* action not running, skip it */
- if (GENERIC_ACTION(action).state_set !=
+ if (generic->state_set !=
surf_cpu_model->states.running_action_set)
continue;
/* bogus priority, skip it */
- if (GENERIC_ACTION(action).priority <= 0)
+ if (generic->priority <= 0)
continue;
/* action suspended, skip it */
continue;
/* action don't need update */
- if (GENERIC_ACTION(action).start >= now)
+ if (generic->start >= now)
continue;
/* skip action that are finishing now */
- if (GENERIC_ACTION(action).finish >= 0
- && GENERIC_ACTION(action).finish <= now)
+ if (generic->finish >= 0
+ && generic->finish <= now)
continue;
/* update remaining */
- double_update(&(GENERIC_ACTION(action).remains),
+ double_update(&(generic->remains),
area_total / (cpu->sum_priority *
- GENERIC_ACTION(action).priority));
+ generic->priority));
XBT_DEBUG("Update remaining action(%p) remaining %lf", action,
- GENERIC_ACTION(action).remains);
+ generic->remains);
}
cpu->last_update = now;
#undef GENERIC_ACTION
static int net_selective_update = 0;
static int net_action_is_suspended(surf_action_t action);
-static void update_action_remaining_lazy(double now);
+static void net_update_action_remaining_lazy(double now);
static xbt_swag_t net_modified_set = NULL;
static xbt_heap_t net_action_heap = NULL;
-/* added to manage the communication action's heap */
-static void net_action_update_index_heap(void *action, int i)
-{
- surf_action_network_CM02_t a = action;
- GENERIC_LMM_ACTION(a).index_heap = i;
-}
-
-/* insert action on heap using a given key and a hat (heap_action_type)
- * a hat can be of three types for communications:
- *
- * NORMAL = this is a normal heap entry stating the date to finish transmitting
- * LATENCY = this is a heap entry to warn us when the latency is payed
- * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
- */
-static void heap_insert(surf_action_network_CM02_t action, double key,
- enum heap_action_type hat)
-{
- GENERIC_LMM_ACTION(action).hat = hat;
- xbt_heap_push(net_action_heap, action, key);
-}
-
-static void heap_remove(surf_action_network_CM02_t action)
-{
- GENERIC_LMM_ACTION(action).hat = NOTSET;
- if (GENERIC_LMM_ACTION(action).index_heap >= 0) {
- xbt_heap_remove(net_action_heap, GENERIC_LMM_ACTION(action).index_heap);
- }
-}
/******************************************************************************/
/* Factors callbacks */
((surf_action_lmm_t) action)->variable);
}
if (network_update_mechanism == UM_LAZY) { // remove action from the heap
- heap_remove((surf_action_network_CM02_t) action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t) action);
xbt_swag_remove(action, net_modified_set);
}
surf_action_free(&action);
surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
if (network_update_mechanism == UM_LAZY) { // remove action from the heap
xbt_swag_remove(action, net_modified_set);
- heap_remove((surf_action_network_CM02_t) action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t) action);
}
}
double net_action_get_remains(surf_action_t action)
{
if (network_update_mechanism == UM_LAZY) /* update remains before return it */
- update_action_remaining_lazy(surf_get_clock());
+ net_update_action_remaining_lazy(surf_get_clock());
return action->remains;
}
-static void update_action_remaining_lazy(double now)
+static void net_update_action_remaining_lazy(double now)
{
- surf_action_network_CM02_t action = NULL;
+ surf_action_lmm_t action = NULL;
double delta = 0.0;
xbt_swag_foreach(action, net_modified_set) {
- if (GENERIC_LMM_ACTION(action).suspended != 0) {
+ if (action->suspended != 0) {
continue;
}
- delta = now - GENERIC_LMM_ACTION(action).last_update;
+ delta = now - action->last_update;
double_update(&(((surf_action_t)action)->remains),
- lmm_variable_getvalue(((surf_action_lmm_t) action)->variable) * delta);
+ lmm_variable_getvalue(action->variable) * delta);
if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
double_update(&(((surf_action_t)action)->max_duration), delta);
if ((((surf_action_t)action)->remains <= 0) &&
- (lmm_get_variable_weight(((surf_action_lmm_t)action)->variable) > 0)) {
+ (lmm_get_variable_weight(action->variable) > 0)) {
((surf_action_t)action)->finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
- heap_remove(action);
+ surf_action_lmm_heap_remove(net_action_heap,action);
} else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
&& (((surf_action_t)action)->max_duration <= 0))) {
((surf_action_t)action)->finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
- heap_remove(action);
+ surf_action_lmm_heap_remove(net_action_heap,action);
}
- GENERIC_LMM_ACTION(action).last_update = now;
+ action->last_update = now;
}
}
XBT_DEBUG
("Before share resources, the size of modified actions set is %d",
xbt_swag_size(net_modified_set));
- update_action_remaining_lazy(now);
+ net_update_action_remaining_lazy(now);
lmm_solve(network_maxmin_system);
GENERIC_ACTION(action).max_duration);
if (min != -1) {
- heap_remove(action);
- heap_insert(action, min, max_dur_flag ? MAX_DURATION : NORMAL);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
+ surf_action_lmm_heap_insert(net_action_heap,(surf_action_lmm_t)action, min, max_dur_flag ? MAX_DURATION : NORMAL);
XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
now);
} else DIE_IMPOSSIBLE;
if (GENERIC_LMM_ACTION(action).hat == LATENCY) {
lmm_update_variable_weight(network_maxmin_system, GENERIC_LMM_ACTION(action).variable,
action->weight);
- heap_remove(action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
// if I am wearing a max_duration or normal hat
((surf_action_t)action)->finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
- heap_remove(action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
}
}
return;
// add to the heap the event when the latency is payed
XBT_DEBUG("Added action (%p) one latency event at date %f", action,
action->latency + GENERIC_LMM_ACTION(action).last_update);
- heap_insert(action, action->latency + GENERIC_LMM_ACTION(action).last_update,
+ surf_action_lmm_heap_insert(net_action_heap,(surf_action_lmm_t)action, action->latency + GENERIC_LMM_ACTION(action).last_update,
xbt_dynar_is_empty(route) ? NORMAL : LATENCY);
}
} else
action)->generic_lmm_action.variable, 0.0);
if (network_update_mechanism == UM_LAZY) // remove action from the heap
- heap_remove((surf_action_network_CM02_t) action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
}
static void net_action_resume(surf_action_t action)
action)->weight);
((surf_action_network_CM02_t) action)->generic_lmm_action.suspended = 0;
if (network_update_mechanism == UM_LAZY) // remove action from the heap
- heap_remove((surf_action_network_CM02_t) action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
}
}
{
action->max_duration = duration;
if (network_update_mechanism == UM_LAZY) // remove action from the heap
- heap_remove((surf_action_network_CM02_t) action);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
}
#ifdef HAVE_TRACING
if (network_update_mechanism == UM_LAZY) {
net_action_heap = xbt_heap_new(8, NULL);
xbt_heap_set_update_callback(net_action_heap,
- net_action_update_index_heap);
+ surf_action_lmm_update_index_heap);
net_modified_set =
xbt_swag_new(xbt_swag_offset(comm, generic_lmm_action.action_list_hookup));
network_maxmin_system->keep_track = net_modified_set;
action->refcount++;
}
-/*
-void surf_action_suspend(surf_action_t action)
-{
- action->suspended = 1;
-}*/
-
/*
* Maxmin action
*/
+
+/* added to manage the communication action's heap */
+void surf_action_lmm_update_index_heap(void *action, int i) {
+ surf_action_lmm_t a = action;
+ a->index_heap = i;
+}
+/* insert action on heap using a given key and a hat (heap_action_type)
+ * a hat can be of three types for communications:
+ *
+ * NORMAL = this is a normal heap entry stating the date to finish transmitting
+ * LATENCY = this is a heap entry to warn us when the latency is payed
+ * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
+ */
+void surf_action_lmm_heap_insert(xbt_heap_t heap, surf_action_lmm_t action, double key,
+ enum heap_action_type hat)
+{
+ action->hat = hat;
+ xbt_heap_push(heap, action, key);
+}
+
+void surf_action_lmm_heap_remove(xbt_heap_t heap, surf_action_lmm_t action)
+{
+ action->hat = NOTSET;
+ if (action->index_heap >= 0) {
+ xbt_heap_remove(heap, action->index_heap);
+ }
+}
void surf_action_state_set(surf_action_t action,
e_surf_action_state_t state);
void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
+
+void surf_action_lmm_update_index_heap(void *action, int i); /* callback for heap management shared by cpu and net models */
+void surf_action_lmm_heap_insert(xbt_heap_t heap, surf_action_lmm_t action,
+ double key, enum heap_action_type hat);
+void surf_action_lmm_heap_remove(xbt_heap_t heap,surf_action_lmm_t action);
+
+
FILE *surf_fopen(const char *name, const char *mode);
extern tmgr_history_t history;