-/*
- * surf.c
- *
- * Created on: Nov 27, 2009
- * Author: Lucas Schnorr
- * License: 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.
- *
- * Copyright (c) 2009 The SimGrid team.
- */
+/* Copyright (c) 2010. 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. */
#include "instr/private.h"
xbt_dict_cursor_t cursor = NULL;
unsigned int cursor_ar = 0;
char *key, *value, *res;
- char resource[200];
+ char *resource;
/* get all resources from last_platform_variables */
- xbt_dynar_t resources = xbt_dynar_new(sizeof(char)*200, xbt_free);
+ xbt_dynar_t resources = xbt_dynar_new(sizeof(char*), xbt_free);
xbt_dict_foreach(last_platform_variables, cursor, key, value) {
res = strsplit (key, 0, VARIABLE_SEPARATOR);
char *aux = strsplit (key, 1, VARIABLE_SEPARATOR);
if (strcmp (aux, "Time") == 0){ //only need to add one of three
- xbt_dynar_push (resources, xbt_strdup(res));
+ char *var_cpy = xbt_strdup (res);
+ xbt_dynar_push (resources, &var_cpy);
}
free (aux);
free (res);
{
/* check if we have to set it to 0 */
if (!xbt_dict_get_or_null (platform_variables, resource)){
- xbt_dynar_t array = xbt_dynar_new(100*sizeof(char), xbt_free);
- xbt_dynar_push (array, xbt_strdup(variable));
+ xbt_dynar_t array = xbt_dynar_new(sizeof(char*), xbt_free);
+ char *var_cpy = xbt_strdup(variable);
+ xbt_dynar_push (array, &var_cpy);
if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
xbt_dict_set (platform_variables, resource, array, xbt_dynar_free_voidp);
}else{
xbt_dynar_t array = xbt_dict_get (platform_variables, resource);
unsigned int i;
- char cat[100];
+ char* cat;
int flag = 0;
xbt_dynar_foreach (array, i, cat) {
if (strcmp(variable, cat)==0){
}
}
if (flag==0){
- xbt_dynar_push (array, strdup(variable));
+ char *var_cpy = xbt_strdup(variable);
+ xbt_dynar_push (array, &var_cpy);
if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
}
}
if (lastvariable == NULL){
__TRACE_surf_check_variable_set_to_zero (now, variable, resource);
pajeAddVariable (now, variable, resource, valuestr);
- xbt_dict_set (last_platform_variables, xbt_strdup (timekey), xbt_strdup (nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (valuekey), xbt_strdup (valuestr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (variablekey), xbt_strdup (variable), xbt_free);
+ char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+ char *valuestr_cpy = xbt_strdup (valuestr);
+ char *variable_cpy = xbt_strdup (variable);
+ xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
}else{
char *lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
char *lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
if (atof(lasttime) == now){ /* lastime == now */
/* check if lastvalue equals valuestr */
if (atof(lastvalue) == value){ /* lastvalue == value (good, just advance time) */
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), xbt_free);
+ char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+ xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
}else{ /* value has changed */
/* value has changed, subtract previous value, add new one */
pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup(valuekey), xbt_strdup(valuestr), xbt_free);
+ char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+ char *valuestr_cpy = xbt_strdup (valuestr);
+ xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
}
}else{ /* lasttime != now */
/* the last time is different from new starting time, subtract to lasttime and add from nowstr */
pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup(valuekey), xbt_strdup(valuestr), xbt_free);
+ char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+ char *valuestr_cpy = xbt_strdup (valuestr);
+ xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
}
}else{ /* variable has changed */
pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
__TRACE_surf_check_variable_set_to_zero (now, variable, resource);
pajeAddVariable (now, variable, resource, valuestr);
- xbt_dict_set (last_platform_variables, xbt_strdup (timekey), xbt_strdup (nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (valuekey), xbt_strdup (valuestr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (variablekey), xbt_strdup (variable), xbt_free);
+ char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+ char *valuestr_cpy = xbt_strdup (valuestr);
+ char *variable_cpy = xbt_strdup (variable);
+ xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+ xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
}
}
return;
if (value == 0) return;
if (!xbt_dict_get_or_null (created_links, name)){
- TRACE_surf_missing_link ();
+ TRACE_surf_link_missing ();
return;
}
lat_ptr = xbt_new (double, 1);
*bw_ptr = bw;
*lat_ptr = lat;
- xbt_dict_set (link_bandwidth, xbt_strdup(name), bw_ptr, xbt_free);
- xbt_dict_set (link_latency, xbt_strdup(name), lat_ptr, xbt_free);
+ xbt_dict_set (link_bandwidth, name, bw_ptr, xbt_free);
+ xbt_dict_set (link_latency, name, lat_ptr, xbt_free);
}
void TRACE_surf_host_declaration (char *name, double power)
{
if (!IS_TRACING) return;
+ pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
+ xbt_dict_set (host_containers, name, xbt_strdup("1"), xbt_free);
if (IS_TRACING_PLATFORM){
- pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
- xbt_dict_set (host_containers, xbt_strdup(name), xbt_strdup("1"), xbt_free);
+ __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "power", name, power);
}
- __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "power", name, power);
}
-void TRACE_surf_routing_full_parse_end (char *link_name, int src, int dst)
+void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst)
{
if (!IS_TRACING) return;
char srcidstr[100], dstidstr[100];
//if (IS_TRACING_PLATFORM) pajeEndLink (SIMIX_get_clock()+0.1, "edge", "platform", "route", dstname, key);
double *bw = xbt_dict_get (link_bandwidth, link_name);
double *lat = xbt_dict_get (link_latency, link_name);
- if (IS_TRACING_PLATFORM) pajeCreateContainerWithBandwidthLatencySrcDst (SIMIX_get_clock(), link_name, "LINK", "platform", link_name, *bw, *lat, srcname, dstname);
- __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "bandwidth", link_name, *bw);
- __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "latency", link_name, *lat);
- xbt_dict_set (created_links, xbt_strdup(link_name), xbt_strdup ("1"), xbt_free);
+ pajeCreateContainerWithBandwidthLatencySrcDst (SIMIX_get_clock(), link_name, "LINK", "platform", link_name, *bw, *lat, srcname, dstname);
+ if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "bandwidth", link_name, *bw);
+ if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "latency", link_name, *lat);
+ xbt_dict_set (created_links, link_name, xbt_strdup ("1"), xbt_free);
}
}
__TRACE_surf_set_resource_variable (date, "latency", resource, latency);
}
-void TRACE_surf_define_host_id (const char *name, int host_id)
+void TRACE_surf_host_define_id (const char *name, int host_id)
{
if (!IS_TRACING) return;
char strid[100];
snprintf (strid, 100, "%d", host_id);
- xbt_dict_set (hosts_id, strdup(name), strdup(strid), free);
- xbt_dict_set (hosts_id, strdup(strid), strdup(name), free);
+ xbt_dict_set (hosts_id, name, strdup(strid), free);
+ xbt_dict_set (hosts_id, strid, strdup(name), free);
}
/* to trace gtnets */
snprintf (key, 100, "%p", action);
snprintf (aux, 100, "%d", src);
- xbt_dict_set (gtnets_src, xbt_strdup(key), xbt_strdup(aux), xbt_free);
+ xbt_dict_set (gtnets_src, key, xbt_strdup(aux), xbt_free);
snprintf (aux, 100, "%d", dst);
- xbt_dict_set (gtnets_dst, xbt_strdup(key), xbt_strdup(aux), xbt_free);
+ xbt_dict_set (gtnets_dst, key, xbt_strdup(aux), xbt_free);
}
int TRACE_surf_gtnets_get_src (void *action)
xbt_dict_remove (gtnets_dst, key);
}
-void TRACE_surf_missing_link (void)
+void TRACE_surf_link_missing (void)
{
CRITICAL0("The trace cannot be done because "
"the platform you are using contains "
/* get all host from host_containers */
xbt_dict_foreach(host_containers, cursor, key, value) {
- if (IS_TRACING_PLATFORM) pajeDestroyContainer (MSG_get_clock(), "HOST", key);
+ pajeDestroyContainer (MSG_get_clock(), "HOST", key);
}
}
-void TRACE_surf_vivaldi_parse_host (char *host, double x, double y, double h)
+void TRACE_surf_host_vivaldi_parse (char *host, double x, double y, double h)
{
if (!IS_TRACING || !IS_TRACING_PLATFORM) return;