void surf_action_set_category(surf_action_t action, const char *category);
e_surf_action_state_t surf_action_get_state(surf_action_t action);
int surf_action_get_cost(surf_action_t action);
-surf_file_t surf_storage_action_get_file(surf_storage_action_lmm_t action);
-xbt_dict_t surf_storage_action_get_ls_dict(surf_storage_action_lmm_t action);
+surf_file_t surf_storage_action_get_file(surf_action_t action);
+xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action);
#ifdef __cplusplus
}
surf_workstations = xbt_new(void *, workstation_nb);
for (i = 0; i < workstation_nb; i++)
- surf_workstations[i] = task->workstation_list[i];
+ surf_workstations[i] = surf_workstation_resource_priv(task->workstation_list[i]);
double *computation_amount = xbt_new0(double, workstation_nb);
double *communication_amount = xbt_new0(double, workstation_nb * workstation_nb);
/* set surf's action */
workstation_list = xbt_new0(void *, host_nb);
for (i = 0; i < host_nb; i++)
- workstation_list[i] = host_list[i];
+ workstation_list[i] = surf_workstation_resource_priv(host_list[i]);
/* set surf's action */
if (!MC_is_active()) {
switch (simcall->call) {
case SIMCALL_FILE_OPEN:;
smx_file_t tmp = xbt_new(s_smx_file_t,1);
- tmp->surf_file = surf_storage_action_get_file((surf_storage_action_lmm_t)action->io.surf_io);
+ tmp->surf_file = surf_storage_action_get_file(action->io.surf_io);
simcall_file_open__set__result(simcall, tmp);
break;
// xbt_dict_set((action->io.surf_io)->ls_dict,key,dst,xbt_free);
// }
// }
- simcall_file_ls__set__result(simcall, surf_storage_action_get_ls_dict((surf_storage_action_lmm_t)action->io.surf_io));
+ simcall_file_ls__set__result(simcall, surf_storage_action_get_ls_dict(action->io.surf_io));
break;
default:
break;
if (!p_maxminSystem)
p_maxminSystem = lmm_system_new(m_selectiveUpdate);
- routing_model_create(static_cast<NetworkCm02LinkPtr>(createResource("__loopback__",
+ routing_model_create(static_cast<ResourcePtr>(createResource("__loopback__",
498000000, NULL, 0.000015, NULL,
SURF_RESOURCE_ON, NULL,
SURF_LINK_FATPIPE, NULL)));
xbt_dynar_t mount_list = NULL; /* temporary store of current mount storage */
StorageModelPtr surf_storage_model = NULL;
-lmm_system_t storage_maxmin_system = NULL;
static int storage_selective_update = 0;
static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = NULL;
xbt_dynar_push(model_list, &surf_storage_model);
}
-StorageModel::StorageModel() : Model("Storage"){
+StorageModel::StorageModel() : Model("Storage") {
StorageActionLmm action;
XBT_DEBUG("surf_storage_model_init_internal");
storage_running_action_set_that_does_not_need_being_checked =
xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
- if (!storage_maxmin_system) {
- storage_maxmin_system = lmm_system_new(storage_selective_update);
+ if (!p_maxminSystem) {
+ p_maxminSystem = lmm_system_new(storage_selective_update);
}
}
StorageModel::~StorageModel(){
- lmm_system_free(storage_maxmin_system);
- storage_maxmin_system = NULL;
+ lmm_system_free(p_maxminSystem);
surf_storage_model = NULL;
double Bconnection = atof((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
StoragePtr storage = new StorageLmm(this, NULL, NULL, p_maxminSystem,
- Bread, Bwrite, Bconnection,
- parseContent((char*)content_name, &(storage->m_usedSize)),
- storage_type->size);
+ Bread, Bwrite, Bconnection, (char *)content_name, storage_type->size);
xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
StorageActionLmmPtr write_action;
double min_completion = shareResourcesMaxMin(p_runningActionSet,
- storage_maxmin_system, lmm_solve);
+ p_maxminSystem, lmm_solve);
double rate;
// Foreach disk
// Update the file size
// For each action of type write
xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
- action = (StorageActionLmmPtr) _action;
+ action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
if(action->m_type == WRITE)
{
double rate = lmm_variable_getvalue(action->p_variable);
}
xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
- action = (StorageActionLmmPtr) _action;
+ action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
double_update(&action->m_remains,
lmm_variable_getvalue(action->p_variable) * delta);
return;
}
-xbt_dict_t StorageModel::parseContent(char *filename, size_t *used_size)
+xbt_dict_t Storage::parseContent(char *filename)
{
- *used_size = 0;
+ m_usedSize = 0;
if ((!filename) || (strcmp(filename, "") == 0))
return NULL;
while ((read = xbt_getline(&line, &len, file)) != -1) {
if (read){
if(sscanf(line,"%s %zu",path, &size)==2) {
- *used_size += size;
+ m_usedSize += size;
xbt_dict_set(parse_content,path,(void*) size,NULL);
} else {
xbt_die("Be sure of passing a good format for content file.\n");
* Resource *
************/
-Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties) {
+Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties)
+: Resource(model, name, properties)
+{
p_writeActions = xbt_dynar_new(sizeof(char *),NULL);
}
StorageLmm::StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
- xbt_dict_t content, size_t size)
- : ResourceLmm(), Storage(model, name, properties) {
+ char *content_name, size_t size)
+ : Resource(model, name, properties), ResourceLmm(), Storage(model, name, properties) {
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", bconnection, bread, bwrite, ((unsigned long)size));
+ p_stateCurrent = SURF_RESOURCE_ON;
+ m_usedSize = 0;
+ m_size = 0;
+
+ p_content = parseContent(content_name);
p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
- p_content = content;
m_size = size;
}
{
if(size > fd->size)
size = fd->size;
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
return action;
}
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
// If the storage is full
**********/
StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
- : ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
+ : Action(model, cost, failed), ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
XBT_IN("(%s,%zu", storage->m_name, cost);
+ p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
+
// Must be less than the max bandwidth for all actions
- lmm_expand(storage_maxmin_system, storage->p_constraint, p_variable, 1.0);
+ lmm_expand(p_model->p_maxminSystem, storage->p_constraint, p_variable, 1.0);
switch(type) {
case OPEN:
case CLOSE:
case LS:
break;
case READ:
- lmm_expand(storage_maxmin_system, storage->p_constraintRead,
+ lmm_expand(p_model->p_maxminSystem, storage->p_constraintRead,
p_variable, 1.0);
break;
case WRITE:
- lmm_expand(storage_maxmin_system, storage->p_constraintWrite,
+ lmm_expand(p_model->p_maxminSystem, storage->p_constraintWrite,
p_variable, 1.0);
- xbt_dynar_push(storage->p_writeActions,this);
+ xbt_dynar_push(storage->p_writeActions, static_cast<ActionPtr>(this));
break;
}
XBT_OUT();
if (!m_refcount) {
xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
if (p_variable)
- lmm_variable_free(storage_maxmin_system, p_variable);
+ lmm_variable_free(p_model->p_maxminSystem, p_variable);
#ifdef HAVE_TRACING
xbt_free(p_category);
#endif
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
- lmm_update_variable_weight(storage_maxmin_system,
+ lmm_update_variable_weight(p_model->p_maxminSystem,
p_variable,
0.0);
m_suspended = 1;
/*********
* Model *
*********/
-class StorageModel : Model {
+class StorageModel : public Model {
public:
StorageModel();
~StorageModel();
double shareResources(double now);
void updateActionsState(double now, double delta);
- xbt_dict_t parseContent(char *filename, size_t *used_size);
};
/************
//virtual size_t getSize(surf_file_t fd);
virtual StorageActionPtr read(void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
virtual StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
+ xbt_dict_t parseContent(char *filename);
size_t m_size;
size_t m_usedSize;
public:
StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
- xbt_dict_t content, size_t size);
+ char *content_name, size_t size);
StorageActionPtr open(const char* mount, const char* path);
StorageActionPtr close(surf_file_t fd);
class StorageAction : virtual public Action {
public:
StorageAction(){};
- StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type){};
+ StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
+ : p_storage(storage), m_type(type) {};
void updateResourceState(void *id, tmgr_trace_event_t event_type,
double value, double time);
- lmm_system_t p_maxminSystem;
xbt_swag_t p_modifiedSet;
xbt_heap_t p_actionHeap;
int m_selectiveUpdate;
return action->m_cost;
}
-surf_file_t surf_storage_action_get_file(surf_storage_action_lmm_t action){
- return action->p_file;
+surf_file_t surf_storage_action_get_file(surf_action_t action){
+ return dynamic_cast<StorageActionPtr>(action)->p_file;
}
-xbt_dict_t surf_storage_action_get_ls_dict(surf_storage_action_lmm_t action){
- return action->p_lsDict;
+xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action){
+ return dynamic_cast<StorageActionPtr>(action)->p_lsDict;
}
{
xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
#define ELEMENTS_FATHER_MAXDEPTH 16 /* increase if it is not enough */
- AS_t src_as, dst_as;
- AS_t path_src[ELEMENTS_FATHER_MAXDEPTH];
- AS_t path_dst[ELEMENTS_FATHER_MAXDEPTH];
+ AsPtr src_as, dst_as;
+ AsPtr path_src[ELEMENTS_FATHER_MAXDEPTH];
+ AsPtr path_dst[ELEMENTS_FATHER_MAXDEPTH];
int index_src = 0;
int index_dst = 0;
- AS_t current;
- AS_t current_src;
- AS_t current_dst;
- AS_t father;
+ AsPtr current;
+ AsPtr current_src;
+ AsPtr current_dst;
+ AsPtr father;
/* (1) find the as where the src and dst are located */
sg_routing_edge_t src_data = src;
/* Creation routing model functions */
AsCluster::AsCluster() : AsNone()
{
+ p_backbone = 0;
+ p_loopback = 0;
+ p_router = 0;
}
/* Business methods */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
}
-AS_t model_dijkstra_create(void){
- return new AsDijkstra(0);
-}
-
-AS_t model_dijkstracache_create(void){
- return new AsDijkstra(1);
-}
-
-void model_dijkstra_both_end(AS_t as)
-{
- delete as;
-}
-
/* Free functions */
static void route_cache_elem_free(void *e)
}
}
+AS_t model_dijkstra_create(void){
+ return new AsDijkstra(0);
+}
+
+AS_t model_dijkstracache_create(void){
+ return new AsDijkstra(1);
+}
+
+void model_dijkstra_both_end(AS_t as)
+{
+ AsDijkstraPtr THIS_AS = static_cast<AsDijkstraPtr>(as);
+ xbt_node_t node = NULL;
+ unsigned int cursor2;
+ xbt_dynar_t nodes = NULL;
+
+ /* Create the topology graph */
+ if(!THIS_AS->p_routeGraph)
+ THIS_AS->p_routeGraph = xbt_graph_new_graph(1, NULL);
+ if(!THIS_AS->p_graphNodeMap)
+ THIS_AS->p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
+
+ if (THIS_AS->m_cached && !THIS_AS->p_routeCache)
+ THIS_AS->p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
+
+ /* Add the loopback if needed */
+ if (routing_platf->p_loopback && as->p_hierarchy == SURF_ROUTING_BASE)
+ THIS_AS->addLoopback();
+
+ /* initialize graph indexes in nodes after graph has been built */
+ nodes = xbt_graph_get_nodes(THIS_AS->p_routeGraph);
+
+ xbt_dynar_foreach(nodes, cursor2, node) {
+ graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(node);
+ data->graph_id = cursor2;
+ }
+}
+
/* Utility functions */
xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id)
}
}
+
+void AsDijkstra::parseASroute(sg_platf_route_cbarg_t route)
+{
+ parseRoute(route);
+}
+
void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route)
{
char *src = (char*)(route->src);
int size;
} s_route_cache_element_t, *route_cache_element_t;
+/***********
+ * Classes *
+ ***********/
+class AsDijkstra;
+typedef AsDijkstra *AsDijkstraPtr;
+
class AsDijkstra : public AsGeneric {
public:
AsDijkstra();
void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat);
xbt_dynar_t getOnelinkRoutes();
void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat);
+ void parseASroute(sg_platf_route_cbarg_t route);
void parseRoute(sg_platf_route_cbarg_t route);
void end();
return a != b;
}
+void AsFloyd::parseASroute(sg_platf_route_cbarg_t route){
+ parseRoute(route);
+}
+
void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
{
char *src = (char*)(route->src);
void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
xbt_dynar_t getOneLinkRoutes();
+ void parseASroute(sg_platf_route_cbarg_t route);
void parseRoute(sg_platf_route_cbarg_t route);
void end();
//void parseASroute(sg_platf_route_cbarg_t route);
}
AsFull::AsFull(){
+ p_routingTable = 0;
}
AsFull::~AsFull(){
WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask_L07") {
if (!ptask_maxmin_system)
ptask_maxmin_system = lmm_system_new(1);
+ surf_workstation_model = NULL;
surf_network_model = new NetworkL07Model();
surf_cpu_model = new CpuL07Model();
routing_model_create(p_networkModel->createResource("__loopback__",
0.000015, NULL,
SURF_RESOURCE_ON, NULL,
SURF_LINK_FATPIPE, NULL));
+}
+WorkstationL07Model::~WorkstationL07Model() {
+ xbt_dict_free(&ptask_parallel_task_link_set);
+ delete surf_cpu_model;
+ delete surf_network_model;
+ ptask_host_count = 0;
+
+ if (ptask_maxmin_system) {
+ lmm_system_free(ptask_maxmin_system);
+ ptask_maxmin_system = NULL;
+ }
}
double WorkstationL07Model::shareResources(double now)
routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
static_cast<ResourcePtr>(
- surf_workstation_resource_priv(workstation_list[i])))->p_netElm,
+ workstation_list[i]))->p_netElm,
dynamic_cast<WorkstationL07Ptr>(
static_cast<ResourcePtr>(
- surf_workstation_resource_priv(workstation_list[j])))->p_netElm,
+ workstation_list[j]))->p_netElm,
&route,
&lat);
latency = MAX(latency, lat);
for (i = 0; i < workstation_nb; i++)
lmm_expand(ptask_maxmin_system,
static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(
- surf_workstation_resource_priv(workstation_list[i])))->p_cpu)->p_constraint,
+ static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
action->p_variable, computation_amount[i]);
for (i = 0; i < workstation_nb; i++) {
continue;
routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(
- surf_workstation_resource_priv(workstation_list[i])))->p_netElm,
+ static_cast<ResourcePtr>(workstation_list[i]))->p_netElm,
dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(
- surf_workstation_resource_priv(workstation_list[j])))->p_netElm,
+ static_cast<ResourcePtr>(workstation_list[j]))->p_netElm,
&route, NULL);
xbt_dynar_foreach(route, cpt, _link) {
/* Connect traces relative to cpu */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuL07Ptr host = (CpuL07Ptr) surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
+ CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
+ static_cast<ResourcePtr>(
+ surf_cpu_resource_priv(
+ surf_cpu_resource_by_name(elm))));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuL07Ptr host = (CpuL07Ptr) surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
+ CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
+ static_cast<ResourcePtr>(
+ surf_cpu_resource_priv(
+ surf_cpu_resource_by_name(elm))));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
}
-bool WorkstationL07::isUsed(){
+bool CpuL07::isUsed(){
+ return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+}
+
+bool LinkL07::isUsed(){
return lmm_constraint_used(ptask_maxmin_system, p_constraint);
}
if (p_communicationAmount[i * m_workstationNb + j] > 0) {
double lat = 0.0;
routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(
- surf_workstation_resource_priv(p_workstationList[i])))->p_netElm,
+ static_cast<ResourcePtr>(((void**)p_workstationList)[i]))->p_netElm,
dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(
- surf_workstation_resource_priv(p_workstationList[j])))->p_netElm,
+ static_cast<ResourcePtr>(((void**)p_workstationList)[j]))->p_netElm,
&route, &lat);
lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
class WorkstationL07Model : public WorkstationModel {
public:
WorkstationL07Model();
+ ~WorkstationL07Model();
double shareResources(double now);
void updateActionsState(double now, double delta);
class CpuL07Model : public CpuModel {
public:
CpuL07Model() : CpuModel("cpuL07") {};
+ ~CpuL07Model() {surf_cpu_model = NULL;};
ResourcePtr createResource(const char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
class NetworkL07Model : public NetworkCm02Model {
public:
NetworkL07Model() : NetworkCm02Model(0) {};
+ ~NetworkL07Model() {surf_network_model = NULL;};
ResourcePtr createResource(const char *name,
double bw_initial,
tmgr_trace_t bw_trace,
class WorkstationL07 : public WorkstationCLM03Lmm {
public:
WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
- bool isUsed();
+ //bool isUsed();
+ bool isUsed() {DIE_IMPOSSIBLE;};
void updateState(tmgr_trace_event_t event_type, double value, double date) {DIE_IMPOSSIBLE;};
ActionPtr execute(double size);
ActionPtr sleep(double duration);
class CpuL07 : public CpuLmm {
public:
CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties);
- bool isUsed() {DIE_IMPOSSIBLE;};
+ bool isUsed();
+ //bool isUsed() {DIE_IMPOSSIBLE;};
void updateState(tmgr_trace_event_t event_type, double value, double date);
e_surf_resource_state_t getState();
double getSpeed(double load);
class LinkL07 : public NetworkCm02LinkLmm {
public:
LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props);
- bool isUsed() {DIE_IMPOSSIBLE;};
+ bool isUsed();
void updateState(tmgr_trace_event_t event_type, double value, double date);
double getBandwidth();
double getLatency();