From 01da882090f45a9fe4520629f030d12f02451d4f Mon Sep 17 00:00:00 2001 From: schnorr Date: Fri, 30 Jul 2010 12:00:46 +0000 Subject: [PATCH 1/1] comment some tracing functions git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8074 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/instr/surf_instr.c | 82 ++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/src/instr/surf_instr.c b/src/instr/surf_instr.c index ca683f5d96..70e03a4ed6 100644 --- a/src/instr/surf_instr.c +++ b/src/instr/surf_instr.c @@ -14,8 +14,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(tracing_surf,tracing,"Tracing Surf"); static xbt_dict_t hosts_id; static xbt_dict_t created_links; -static xbt_dict_t link_bandwidth; -static xbt_dict_t link_latency; +static xbt_dict_t link_bandwidth; //name(char*) -> bandwidth(double) +static xbt_dict_t link_latency; //name(char*) -> latency(double) static xbt_dict_t host_containers; static xbt_dict_t last_platform_variables; /* to control the amount of add/sub variables events: @@ -292,20 +292,36 @@ void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, return; } +/* + * TRACE_surf_link_declaration (name, bandwidth, latency): this function + * saves the bandwidth and latency of a link identified by name. This + * information is used in the future to create the link container in the trace. + * + * caller: net_link_new (from each network model) + * main: save bandwidth and latency information + * return: void + */ void TRACE_surf_link_declaration (char *name, double bw, double lat) { - double *bw_ptr, *lat_ptr; if (!IS_TRACING) return; - //if (IS_TRACING_PLATFORM) pajeCreateContainerWithBandwidthLatency (SIMIX_get_clock(), name, "LINK", "platform", name, bw, lat); - //save bw and lat information for this link - bw_ptr = xbt_new (double, 1); - lat_ptr = xbt_new (double, 1); + + double *bw_ptr = xbt_malloc(sizeof(double)); + double *lat_ptr = xbt_malloc(sizeof(double)); *bw_ptr = bw; *lat_ptr = lat; xbt_dict_set (link_bandwidth, name, bw_ptr, xbt_free); xbt_dict_set (link_latency, name, lat_ptr, xbt_free); } +/* + * TRACE_surf_host_declaration (name, power): this function + * saves the power of a host identified by name. This information + * is used to create the host container in the trace. + * + * caller: cpu_new (from each cpu model) + router parser + * main: create HOST containers, set initial power value + * return: void + */ void TRACE_surf_host_declaration (char *name, double power) { if (!IS_TRACING) return; @@ -316,19 +332,26 @@ void TRACE_surf_host_declaration (char *name, double power) } } +/* + * TRACE_surf_link_save_endpoints (link_name, src, dst): this function + * creates the container of a link identified by link_name. It gets + * bandwidth and latency information from the dictionaries previously + * filled. The end points are obtained from the hosts_id dictionary. + * + * caller: end of parsing + * main: create LINK containers, set initial bandwidth and latency values + * return: void + */ void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst) { char srcidstr[100], dstidstr[100]; char key[100]; - char *srcname = NULL; - char *dstname = NULL; - double *bw = 0; - double *lat = 0; + if (!IS_TRACING) return; snprintf (srcidstr, 100, "%d", src); snprintf (dstidstr, 100, "%d", dst); - srcname = xbt_dict_get (hosts_id, srcidstr); - dstname = xbt_dict_get (hosts_id, dstidstr); + char *srcname = xbt_dict_get (hosts_id, srcidstr); + char *dstname = xbt_dict_get (hosts_id, dstidstr); snprintf (key, 100, "l%d-%d", src, dst); if (strcmp (link_name, "__loopback__")==0 || @@ -337,10 +360,8 @@ void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst) } if (!xbt_dict_get_or_null (created_links, link_name)){ - //if (IS_TRACING_PLATFORM) pajeStartLink (SIMIX_get_clock(), "edge", "platform", "route", srcname, key); - //if (IS_TRACING_PLATFORM) pajeEndLink (SIMIX_get_clock()+0.1, "edge", "platform", "route", dstname, key); - bw = xbt_dict_get (link_bandwidth, link_name); - lat = xbt_dict_get (link_latency, link_name); + char *bw = xbt_dict_get (link_bandwidth, link_name); + char *lat = xbt_dict_get (link_latency, link_name); 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); @@ -348,6 +369,24 @@ void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst) } } +/* + * TRACE_surf_host_define_id (name, host_id): This function relates + * the name of the host with its id, as generated by the called and + * passed as second parameter. + * + * caller: host parser, router parser + * main: save host_id + * return: void + */ +void TRACE_surf_host_define_id (const char *name, int host_id) +{ + char strid[100]; + if (!IS_TRACING) return; + snprintf (strid, 100, "%d", host_id); + xbt_dict_set (hosts_id, name, strdup(strid), free); + xbt_dict_set (hosts_id, strid, strdup(name), free); +} + void TRACE_surf_host_set_power (double date, char *resource, double power) { __TRACE_surf_set_resource_variable (date, "power", resource, power); @@ -363,15 +402,6 @@ void TRACE_surf_link_set_latency (double date, char *resource, double latency) __TRACE_surf_set_resource_variable (date, "latency", resource, latency); } -void TRACE_surf_host_define_id (const char *name, int host_id) -{ - char strid[100]; - if (!IS_TRACING) return; - snprintf (strid, 100, "%d", host_id); - xbt_dict_set (hosts_id, name, strdup(strid), free); - xbt_dict_set (hosts_id, strid, strdup(name), free); -} - /* to trace gtnets */ void TRACE_surf_gtnets_communicate (void *action, int src, int dst) { -- 2.20.1