surf/gtnets/gtnets_simulator.h \
surf/gtnets/gtnets_topology.h \
\
+ include/surf/datatypes.h \
include/surf/maxmin.h \
include/surf/trace_mgr.h \
include/surf/surf.h \
--- /dev/null
+/* Copyright (c) 2009 The SimGrid team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef MAXMIN_DATATYPES_H
+#define MAXMIN_DATATYPES_H
+
+/** \brief Model datatype
+ * \ingroup SURF_models
+ *
+ * Generic data structure for a model. The workstations,
+ * the CPUs and the network links are examples of models.
+ */
+typedef struct surf_model *surf_model_t;
+/** \brief Action datatype
+ * \ingroup SURF_actions
+ *
+ * An action is some working amount on a model.
+ * It is represented as a cost, a priority, a duration and a state.
+ */
+typedef struct surf_action *surf_action_t;
+
+
+typedef struct lmm_element *lmm_element_t;
+typedef struct lmm_variable *lmm_variable_t;
+typedef struct lmm_constraint *lmm_constraint_t;
+typedef struct lmm_system *lmm_system_t;
+
+typedef struct tmgr_history *tmgr_history_t;
+typedef struct tmgr_trace *tmgr_trace_t;
+typedef struct tmgr_trace_event *tmgr_trace_event_t;
+
+
+#endif /* MAXMIN_DATATYPES_H */
#include "portable.h"
#include "xbt/misc.h"
+#include "surf/datatypes.h"
#define MAXMIN_PRECISION 0.00001
static XBT_INLINE void double_update(double *variable, double value)
return (value > MAXMIN_PRECISION);
}
-typedef struct lmm_element *lmm_element_t;
-typedef struct lmm_variable *lmm_variable_t;
-typedef struct lmm_constraint *lmm_constraint_t;
-typedef struct lmm_system *lmm_system_t;
-
XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
*/
XBT_PUBLIC(void) lmm_set_default_protocol_function(double (*func_f)
-
-
-
-
-
-
- (lmm_variable_t var,
- double x),
+ (lmm_variable_t var, double x),
double (*func_fp)
-
-
-
-
-
- (lmm_variable_t var,
- double x),
+ (lmm_variable_t var, double x),
double (*func_fpi)
-
-
-
-
-
- (lmm_variable_t var,
- double x));
+ (lmm_variable_t var, double x));
XBT_PUBLIC(double func_reno_f) (lmm_variable_t var, double x);
XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
#include "xbt/misc.h"
#include "portable.h"
#include "xbt/config.h"
+#include "surf/datatypes.h"
SG_BEGIN_DECL()
-/* Actions and models are higly connected structures... */
+/* Actions and models are highly connected structures... */
-/** \brief Model datatype
- * \ingroup SURF_models
- *
- * Generic data structure for a model. The workstations,
- * the CPUs and the network links are examples of models.
- */
- typedef struct surf_model *surf_model_t;
-
+typedef enum {
+ SURF_RESOURCE_ON = 1, /**< Up & ready */
+ SURF_RESOURCE_OFF = 0 /**< Down & broken */
+} e_surf_resource_state_t;
-/** \brief Action datatype
- * \ingroup SURF_actions
- *
- * An action is some working amount on a model.
- * It is represented as a cost, a priority, a duration and a state.
- *
- * \see e_surf_action_state_t
- */
-typedef struct surf_action *surf_action_t;
/** @Brief Specify that we use that action */
XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
/** @brief Creates a new action.
typedef struct {
s_surf_action_t generic_action;
- void *variable; /* of type lmm_variable_t, which is only visible by loading maxmin */
+ lmm_variable_t variable;
int suspended;
- } s_surf_action_maxmin_t,*surf_action_maxmin_t;
+ } s_surf_action_lmm_t,*surf_action_lmm_t;
/** \brief Action states
* \ingroup SURF_actions
*
/* Cpu model */
- /** \brief CPU state
- * \ingroup SURF_models
- */
- typedef enum {
- SURF_CPU_ON = 1, /**< Up & ready */
- SURF_CPU_OFF = 0 /**< Down & broken */
- } e_surf_cpu_state_t;
-
/** \brief CPU model extension public
* \ingroup SURF_models
*
typedef struct surf_cpu_model_extension_public {
surf_action_t(*execute) (void *cpu, double size);
surf_action_t(*sleep) (void *cpu, double duration);
- e_surf_cpu_state_t(*get_state) (void *cpu);
+ e_surf_resource_state_t (*get_state) (void *cpu);
double (*get_speed) (void *cpu, double load);
double (*get_available_speed) (void *cpu);
} s_surf_model_extension_cpu_t;
surf_action_t(*execute) (void *workstation, double size); /**< Execute a computation amount on a workstation
and create the corresponding action */
surf_action_t(*sleep) (void *workstation, double duration); /**< Make a workstation sleep during a given duration */
- e_surf_cpu_state_t(*get_state) (void *workstation); /**< Return the CPU state of a workstation */
+ e_surf_resource_state_t(*get_state) (void *workstation); /**< Return the CPU state of a workstation */
double (*get_speed) (void *workstation, double load); /**< Return the speed of a workstation */
double (*get_available_speed) (void *workstation); /**< Return tha available speed of a workstation */
surf_action_t(*communicate) (void *workstation_src, /**< Execute a communication amount between two workstations */
XBT_PUBLIC(const char*) surf_resource_name(const void *resource);
XBT_PUBLIC(void) surf_resource_free(void* resource);
+
+/**
+ * Resource which have a metric handled by a maxmin system
+ */
+typedef struct surf_resource_lmm {
+ s_surf_resource_t generic_resource;
+ lmm_constraint_t constraint;
+ e_surf_resource_state_t state_current;
+ tmgr_trace_event_t state_event;
+ double metric_current;
+ tmgr_trace_event_t metric_event;
+}s_surf_resource_lmm_t, *surf_resource_lmm_t;
+
/**************************************/
/* Implementations of model object */
/**************************************/
#include "xbt/heap.h"
#include "xbt/dynar.h"
#include "surf/maxmin.h"
-
-typedef struct tmgr_history *tmgr_history_t;
-typedef struct tmgr_trace *tmgr_trace_t;
-typedef struct tmgr_trace_event *tmgr_trace_event_t;
+#include "surf/datatypes.h"
/* Creation functions */
XBT_PUBLIC(tmgr_history_t) tmgr_history_new(void);
SIMIX_mutex_destroy(mutex);
if (SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
- if (SIMIX_host_get_state(SIMIX_host_self()) == SURF_CPU_OFF) {
+ if (SIMIX_host_get_state(SIMIX_host_self()) == SURF_RESOURCE_OFF) {
SIMIX_action_destroy(act_sleep);
MSG_RETURN(MSG_HOST_FAILURE);
}
#define SIMIX_CHECK_HOST() xbt_assert0(surf_workstation_model->extension.workstation. \
- get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
+ get_state(SIMIX_host_self()->simdata->host)==SURF_RESOURCE_ON,\
"Host failed, you cannot call this function.")
smx_host_t __SIMIX_host_create(const char *name, void *workstation,
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(sender->simdata->host) != SURF_CPU_ON) {
+ workstation.get_state(sender->simdata->host) != SURF_RESOURCE_ON) {
THROW1(network_error, 0, "Host %s failed, you cannot call this function",
sender->name);
}
if (surf_workstation_model->extension.
- workstation.get_state(receiver->simdata->host) != SURF_CPU_ON) {
+ workstation.get_state(receiver->simdata->host) != SURF_RESOURCE_ON) {
THROW1(network_error, 0, "Host %s failed, you cannot call this function",
receiver->name);
}
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(host->simdata->host) != SURF_CPU_ON) {
+ workstation.get_state(host->simdata->host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(host->simdata->host) != SURF_CPU_ON) {
+ workstation.get_state(host->simdata->host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
#include "surf_private.h"
-typedef s_surf_action_maxmin_t s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
+typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
typedef struct cpu_Cas01 {
s_surf_resource_t generic_resource;
double power_scale;
double power_current;
tmgr_trace_event_t power_event;
- e_surf_cpu_state_t state_current;
+ e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
lmm_constraint_t constraint;
} s_cpu_Cas01_t, *cpu_Cas01_t;
static cpu_Cas01_t cpu_new(char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
- e_surf_cpu_state_t state_initial,
+ e_surf_resource_state_t state_initial,
tmgr_trace_t state_trace,
xbt_dict_t cpu_properties)
{
double power_scale = 0.0;
double power_initial = 0.0;
tmgr_trace_t power_trace = NULL;
- e_surf_cpu_state_t state_initial = SURF_CPU_OFF;
+ e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
tmgr_trace_t state_trace = NULL;
power_scale = get_cpu_power(A_surfxml_host_power);
(A_surfxml_host_state == A_surfxml_host_state_OFF),
"Invalid state");
if (A_surfxml_host_state == A_surfxml_host_state_ON)
- state_initial = SURF_CPU_ON;
+ state_initial = SURF_RESOURCE_ON;
if (A_surfxml_host_state == A_surfxml_host_state_OFF)
- state_initial = SURF_CPU_OFF;
+ state_initial = SURF_RESOURCE_OFF;
surf_parse_get_trace(&state_trace, A_surfxml_host_state_file);
current_property_set = xbt_dict_new();
cpu->power_current * cpu->power_scale);
} else if (event_type == cpu->state_event) {
if (value > 0)
- cpu->state_current = SURF_CPU_ON;
+ cpu->state_current = SURF_RESOURCE_ON;
else {
lmm_constraint_t cnst = cpu->constraint;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- cpu->state_current = SURF_CPU_OFF;
+ cpu->state_current = SURF_RESOURCE_OFF;
while ((var = lmm_get_var_from_cnst(cpu_maxmin_system, cnst, &elem))) {
surf_action_t action = lmm_variable_id(var);
XBT_IN2("(%s,%g)", CPU->generic_resource.name, size);
action = surf_action_new(sizeof(s_surf_action_cpu_Cas01_t),size,surf_cpu_model,
- CPU->state_current != SURF_CPU_ON);
+ CPU->state_current != SURF_RESOURCE_ON);
action->suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
XBT_OUT;
}
-static e_surf_cpu_state_t get_state(void *cpu)
+static e_surf_resource_state_t get_state(void *cpu)
{
return ((cpu_Cas01_t) cpu)->state_current;
}
tmgr_trace_t bw_trace,
double lat_initial,
tmgr_trace_t lat_trace,
- e_surf_link_state_t
+ e_surf_resource_state_t
state_initial,
tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t
tmgr_trace_t bw_trace;
double lat_initial;
tmgr_trace_t lat_trace;
- e_surf_link_state_t state_initial_link = SURF_LINK_ON;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
tmgr_trace_t state_trace;
|| (A_surfxml_link_state ==
A_surfxml_link_state_OFF), "Invalid state");
if (A_surfxml_link_state == A_surfxml_link_state_ON)
- state_initial_link = SURF_LINK_ON;
+ state_initial_link = SURF_RESOURCE_ON;
else if (A_surfxml_link_state == A_surfxml_link_state_OFF)
- state_initial_link = SURF_LINK_OFF;
+ state_initial_link = SURF_RESOURCE_OFF;
if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
policy_initial_link = SURF_LINK_SHARED;
}
} else if (event_type == nw_link->state_event) {
if (value > 0)
- nw_link->state_current = SURF_LINK_ON;
+ nw_link->state_current = SURF_RESOURCE_ON;
else {
lmm_constraint_t cnst = nw_link->constraint;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- nw_link->state_current = SURF_LINK_OFF;
+ nw_link->state_current = SURF_RESOURCE_OFF;
while ((var = lmm_get_var_from_cnst
(network_maxmin_system, cnst, &elem))) {
surf_action_t action = lmm_variable_id(var);
link_CM02_t link;
int failed=0;
xbt_dynar_foreach(route,i,link) {
- if (link->state_current == SURF_LINK_OFF) {
+ if (link->state_current == SURF_RESOURCE_OFF) {
failed = 1;
break;
}
routing_model_create(sizeof(link_CM02_t),
link_new(xbt_strdup("__loopback__"),
498000000, NULL, 0.000015, NULL,
- SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
+ SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL));
}
/************************************************************************/
char *name;
double bw;
double lat;
- e_surf_link_state_t state;
+ e_surf_resource_state_t state;
name = xbt_strdup(A_surfxml_link_id);
surf_parse_get_double(&bw, A_surfxml_link_bandwidth);
surf_parse_get_double(&lat, A_surfxml_link_latency);
- state = SURF_LINK_ON;
+ state = SURF_RESOURCE_ON;
tmgr_trace_t bw_trace;
tmgr_trace_t state_trace;
tmgr_trace_event_t bw_event;
double lat_current;
tmgr_trace_event_t lat_event;
- e_surf_link_state_t state_current;
+ e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
lmm_constraint_t constraint;
} s_link_CM02_t, *link_CM02_t;
extern const char *surf_action_state_names[6];
-typedef enum {
- SURF_LINK_ON = 1, /* Ready */
- SURF_LINK_OFF = 0 /* Running */
-} e_surf_link_state_t;
-
typedef enum {
SURF_LINK_SHARED = 1,
SURF_LINK_FATPIPE = 0
size, rate);
}
-static e_surf_cpu_state_t get_state(void *workstation)
+static e_surf_resource_state_t get_state(void *workstation)
{
return surf_cpu_model->extension.
cpu.get_state(((workstation_CLM03_t) workstation)->cpu);
double power_scale;
double power_current;
tmgr_trace_event_t power_event;
- e_surf_cpu_state_t state_current;
+ e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
int id; /* cpu and network card are a single object... */
} s_cpu_L07_t, *cpu_L07_t;
tmgr_trace_event_t lat_event;
double bw_current;
tmgr_trace_event_t bw_event;
- e_surf_link_state_t state_current;
+ e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
} s_link_L07_t, *link_L07_t;
if (((((link_L07_t) constraint_id)->type ==
SURF_WORKSTATION_RESOURCE_LINK) &&
(((link_L07_t) constraint_id)->state_current ==
- SURF_LINK_OFF)) ||
+ SURF_RESOURCE_OFF)) ||
((((cpu_L07_t) constraint_id)->type ==
SURF_WORKSTATION_RESOURCE_CPU) &&
- (((cpu_L07_t) constraint_id)->state_current == SURF_CPU_OFF))) {
+ (((cpu_L07_t) constraint_id)->state_current == SURF_RESOURCE_OFF))) {
DEBUG1("Action (%p) Failed!!", action);
action->generic_action.finish = surf_get_clock();
surf_action_state_set((surf_action_t) action,
} else if (event_type == nw_link->state_event) {
if (value > 0)
- nw_link->state_current = SURF_LINK_ON;
+ nw_link->state_current = SURF_RESOURCE_ON;
else
- nw_link->state_current = SURF_LINK_OFF;
+ nw_link->state_current = SURF_RESOURCE_OFF;
} else {
CRITICAL0("Unknown event ! \n");
xbt_abort();
cpu->power_current * cpu->power_scale);
} else if (event_type == cpu->state_event) {
if (value > 0)
- cpu->state_current = SURF_CPU_ON;
+ cpu->state_current = SURF_RESOURCE_ON;
else
- cpu->state_current = SURF_CPU_OFF;
+ cpu->state_current = SURF_RESOURCE_OFF;
} else {
CRITICAL0("Unknown event ! \n");
xbt_abort();
/******* Resource Private **********/
/**************************************/
-static e_surf_cpu_state_t resource_get_state(void *cpu)
+static e_surf_resource_state_t resource_get_state(void *cpu)
{
return ((cpu_L07_t) cpu)->state_current;
}
static cpu_L07_t cpu_new(const char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
- e_surf_cpu_state_t state_initial,
+ e_surf_resource_state_t state_initial,
tmgr_trace_t state_trace, xbt_dict_t cpu_properties)
{
cpu_L07_t cpu = xbt_new0(s_cpu_L07_t, 1);
double power_scale = 0.0;
double power_initial = 0.0;
tmgr_trace_t power_trace = NULL;
- e_surf_cpu_state_t state_initial = SURF_CPU_OFF;
+ e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
tmgr_trace_t state_trace = NULL;
power_scale = get_cpu_power(A_surfxml_host_power);
(A_surfxml_host_state == A_surfxml_host_state_OFF),
"Invalid state");
if (A_surfxml_host_state == A_surfxml_host_state_ON)
- state_initial = SURF_CPU_ON;
+ state_initial = SURF_RESOURCE_ON;
if (A_surfxml_host_state == A_surfxml_host_state_OFF)
- state_initial = SURF_CPU_OFF;
+ state_initial = SURF_RESOURCE_OFF;
surf_parse_get_trace(&state_trace, A_surfxml_host_state_file);
current_property_set = xbt_dict_new();
tmgr_trace_t bw_trace,
double lat_initial,
tmgr_trace_t lat_trace,
- e_surf_link_state_t
+ e_surf_resource_state_t
state_initial,
tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t
tmgr_trace_t bw_trace;
double lat_initial;
tmgr_trace_t lat_trace;
- e_surf_link_state_t state_initial_link = SURF_LINK_ON;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
tmgr_trace_t state_trace;
|| (A_surfxml_link_state ==
A_surfxml_link_state_OFF), "Invalid state");
if (A_surfxml_link_state == A_surfxml_link_state_ON)
- state_initial_link = SURF_LINK_ON;
+ state_initial_link = SURF_RESOURCE_ON;
else if (A_surfxml_link_state == A_surfxml_link_state_OFF)
- state_initial_link = SURF_LINK_OFF;
+ state_initial_link = SURF_RESOURCE_OFF;
if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
policy_initial_link = SURF_LINK_SHARED;
routing_model_create(sizeof(link_L07_t),
link_new(xbt_strdup("__loopback__"),
498000000, NULL, 0.000015, NULL,
- SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
+ SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL));
}