--- /dev/null
+require "simgrid"
+
+ simgrid.AS.new{id="AS0",mode="Full"};
+
+ simgrid.AS.addHost{AS="AS0",id="Tremblay",power=98095000};
+ simgrid.AS.addHost{AS="AS0",id="Jupiter",power=76296000};
+ simgrid.AS.addHost{AS="AS0",id="Fafard",power=76296000};
+
+ simgrid.Host.setProperty{host="Tremblay",prop_id="ip",prop_value="199.23.98.3"};
+ simgrid.Host.setProperty{host="Tremblay",prop_id="port",prop_value="65"};
+ simgrid.Host.setProperty{host="Jupiter",prop_id="ip",prop_value="199.23.98.4"};
+ simgrid.Host.setProperty{host="Jupiter",prop_id="port",prop_value="83"};
+ simgrid.Host.setProperty{host="Fafard",prop_id="ip",prop_value="199.23.98.5"};
+ simgrid.Host.setProperty{host="Fafard",prop_id="port",prop_value="76"};
+ -- create Links
+ for i=10,0,-1 do
+ simgrid.AS.addLink{AS="AS0",id=i,bandwidth=252750+ i*768,latency=0.000270544+i*0.087};
+ end
+ -- simgrid.Route.new(src_id,des_id,links_nb,links_list)
+ simgrid.AS.addRoute("AS0","Tremblay","Jupiter",{"1"});
+ simgrid.AS.addRoute("AS0","Tremblay","Fafard",{"0","1","2","3","4","8"});
+
+ simgrid.AS.addRoute("AS0","Jupiter","Tremblay",{"1"});
+ simgrid.AS.addRoute("AS0","Jupiter","Fafard",{"0","1","2","3","4","8","9"});
+
+ simgrid.AS.addRoute("AS0","Fafard","Tremblay",{"0","1","2","3","4","8"});
+ simgrid.AS.addRoute("AS0","Fafard","Jupiter",{"0","1","2","3","4","8","9"});
+
+
+ --Save Platform
+ simgrid.msg_register_platform();
+
+ --Set Application
+ simgrid.Host.setFunction{host="Tremblay",fct="SPLAYschool",args=""};
+ simgrid.Host.setFunction{host="Fafard",fct="SPLAYschool",args=""};
+ simgrid.Host.setFunction{host="Jupiter",fct="SPLAYschool",args=""};
+
+ --Save Application
+ simgrid.msg_register_application();
+
+
--- /dev/null
+require "simgrid"
+-- Splay global modules
+rpc = {}
+log = {}
+job = {}
+event = {}
+os = {}
+start = {}
+-- Splay global variables
+job.me ={}
+job.nodes = {}
+job.list_type = "random"
+
+--Init nodes tables
+function init_nodes()
+ for i= 1,simgrid.Host.number() do
+ job.nodes[i] = simgrid.Host.getPropValue(simgrid.Host.at(i),"ip")..":"..simgrid.Host.getPropValue(simgrid.Host.at(i),"port");
+ end
+end
+
+function init_jobs()
+ init_nodes()
+end
+
+-- Job methods
+function job.me.ip()
+ return simgrid.Host.getPropValue(simgrid.Host.self(),"ip");
+end
+
+function job.me.port()
+ return simgrid.Host.getPropValue(simgrid.Host.self(),"port");
+end
+
+function job.position()
+ return simgrid.Host.getPropValue(simgrid.Host.self(),"position");
+end
+
+-- log Methods
+function log:print(msg)
+ simgrid.info(msg);
+end
+
+-- rpc Methods
+function rpc.call(node,call)
+ --init_nodes();
+ func = "empty"
+ arg = "empty"
+ mailbox = node
+
+ if type(call) == "table" then
+ func = call[1]
+ arg = call[2]
+ end
+ task_call = simgrid.Task.new("splay_task",10000,10000);
+ task_call['func_call_name'] = func;
+ task_call['func_call_arg'] = arg;
+ --log:print("Sending Task to mailbox "..mailbox.." to call "..func.." with arg "..arg);
+ simgrid.Task.iSend(task_call,mailbox);
+ call_function(func,arg)
+end
+
+-- event Methods
+function event.sleep(time)
+ my_mailbox = job.me.ip()..":"..job.me.port()
+ task = simgrid.Task.splay_recv(my_mailbox, time)
+end
+
+-- main func for each process, this is equivalent to the Deploiment file
+function event.thread(main_func)
+ dofile("platform_script.lua");
+ init_jobs()
+end
+
+-- OS methods
+function os.exit()
+ simgrid.Host.destroy(simgrid.Host.self());
+end
+
+-- Start Methods
+function start.loop()
+ simgrid.run()
+ simgrid.clean()
+end
+-- useful functions
+function call_function(fct,arg)
+ _G[fct](arg)
+end
+
+function SPLAYschool()
+ simgrid.info("Calling me...")
+end
--- /dev/null
+../../../lib/libsimgrid.so
\ No newline at end of file
--- /dev/null
+dofile 'sim_splay.lua'
+
+function SPLAYschool()
+ log:print("My ip is :" ..job.me.ip())
+ event.sleep(5)
+ rpc.call(job.nodes[3],{"call_me","Helloooooow"})
+ event.sleep(5)
+ os.exit()
+end
+
+function call_me(position)
+ log:print("I received an RPC from node "..position);
+end
+
+event.thread("SPLAYschool")
+start.loop()
+
+
+
p Tracing multiple categories master/slave application
-$ $SG_TEST_EXENV ${bindir:=.}/tracing/categories$EXEEXT --cfg=tracing:1 --cfg=tracing/filename:tracing/categories.trace --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1 --cfg=triva/categorized:tracing/categories.cat.plist --cfg=triva/uncategorized:tracing/categories.uncat.plist ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
+$ $SG_TEST_EXENV ${bindir:=.}/tracing/categories$EXEEXT --cfg=tracing:1 --cfg=tracing/buffer:1 --cfg=tracing/filename:tracing/categories.trace --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1 --cfg=triva/categorized:tracing/categories.cat.plist --cfg=triva/uncategorized:tracing/categories.uncat.plist ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'tracing/categories.trace'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to '1'
p Tracing master/slave application
-$ $SG_TEST_EXENV ${bindir:=.}/tracing/ms$EXEEXT --cfg=tracing:1 --cfg=tracing/filename:tracing/ms.trace --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1 --cfg=triva/categorized:tracing/ms.cat.plist --cfg=triva/uncategorized:tracing/ms.uncat.plist --log=instr_paje.thres:debug --log=instr_paje_trace.thres:debug "--log=root.fmt:[%10.6r]%e\(%i:%P@%h\)%e%m%n" ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
+$ $SG_TEST_EXENV ${bindir:=.}/tracing/ms$EXEEXT --cfg=tracing:1 --cfg=tracing/buffer:1 --cfg=tracing/buffer:1 --cfg=tracing/filename:tracing/ms.trace --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1 --cfg=triva/categorized:tracing/ms.cat.plist --cfg=triva/uncategorized:tracing/ms.uncat.plist --log=instr_paje.thres:debug --log=instr_paje_trace.thres:debug "--log=root.fmt:[%10.6r]%e\(%i:%P@%h\)%e%m%n" ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
> [ 0.000000] (0:@) Configuration change: Set 'tracing' to '1'
+> [ 0.000000] (0:@) Configuration change: Set 'tracing/buffer' to '1'
+> [ 0.000000] (0:@) Configuration change: Set 'tracing/buffer' to '1'
> [ 0.000000] (0:@) Configuration change: Set 'tracing/filename' to 'tracing/ms.trace'
> [ 0.000000] (0:@) Configuration change: Set 'tracing/categorized' to '1'
> [ 0.000000] (0:@) Configuration change: Set 'tracing/uncategorized' to '1'
p Tracing processes
-$ $SG_TEST_EXENV ${bindir:=.}/tracing/procmig$EXEEXT --cfg=tracing:1 --cfg=tracing/filename:tracing/procmig.trace --cfg=tracing/msg/process:1 ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/procmig-deploy.xml
+$ $SG_TEST_EXENV ${bindir:=.}/tracing/procmig$EXEEXT --cfg=tracing:1 --cfg=tracing/buffer:1 --cfg=tracing/filename:tracing/procmig.trace --cfg=tracing/msg/process:1 ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/procmig-deploy.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'tracing/procmig.trace'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/msg/process' to '1'
> [Fafard:emigrant:(1) 2.020551] [msg_test/INFO] Migrating to Tremblay
p Tracing tasks
-$ $SG_TEST_EXENV ${bindir:=.}/tracing/tasks$EXEEXT --cfg=tracing:1 --cfg=tracing/msg/task:1 --cfg=tracing/filename:tracing/tasks.trace ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
+$ $SG_TEST_EXENV ${bindir:=.}/tracing/tasks$EXEEXT --cfg=tracing:1 --cfg=tracing/buffer:1 --cfg=tracing/msg/task:1 --cfg=tracing/filename:tracing/tasks.trace ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/msg/task' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'tracing/tasks.trace'
> [Tremblay:master:(1) 0.000000] [msg_test/INFO] master 20 50000000.000000 1000000.000000 5
p Tracing communications among processes of a master/slave application
-$ $SG_TEST_EXENV ${bindir:=.}/tracing/volume$EXEEXT --cfg=tracing:1 --cfg=tracing/filename:tracing/volume.trace --cfg=tracing/msg/volume:1 ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
+$ $SG_TEST_EXENV ${bindir:=.}/tracing/volume$EXEEXT --cfg=tracing:1 --cfg=tracing/buffer:1 --cfg=tracing/filename:tracing/volume.trace --cfg=tracing/msg/volume:1 ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/deployment.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'tracing/volume.trace'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/msg/volume' to '1'
> [206.701532] [msg_test/INFO] Simulation time 206.702
double value, const char *what);
XBT_PUBLIC(const char *) TRACE_node_name (xbt_node_t node);
XBT_PUBLIC(xbt_graph_t) TRACE_platform_graph (void);
+XBT_PUBLIC(void) TRACE_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
XBT_PUBLIC(void) TRACE_user_link_variable(double time, const char *resource,
const char *variable,
double value, const char *what);
static void create_host(const char *id, double power_peak, double power_sc,
const char *power_tr,int core,int state_init,
- const char *state_tr)
+ const char *state_tr,xbt_dict_t properties)
{
double power_scale = 1.0;
int core_nb = 1; //default value
surf_host_create_resource(xbt_strdup(id), power_peak, power_scale,
power_trace, core_nb, state_initial, state_trace,
- current_property_set);
- current_property_set = NULL;
+ properties);
}
/**
host->state_initial = state_initial;
host->state_trace = state_trace;
host->function = NULL;
+ host->properties = xbt_dict_new();
xbt_dynar_push(current_as->host_list_d, &host);
return 0;
{
p_AS_attr p_as;
p_host_attr p_host;
- const char *host;
- const char *function;
+ unsigned int i,j;
+ const char *host_id ;
+ const char *function_id;
const char *args;
char * tmp_arg;
- unsigned int i,j;
if (lua_istable(L, -1)) {
// get Host id
lua_pushstring(L, "host");
lua_gettable(L, -2);
- host = lua_tostring(L, -1);
+ host_id = lua_tostring(L, -1);
lua_pop(L, 1);
// get Function Name
lua_pushstring(L, "fct");
lua_gettable(L, -2);
- function = lua_tostring(L, -1);
+ function_id = lua_tostring(L, -1);
lua_pop(L, 1);
//get args
lua_pushstring(L,"args");
xbt_dynar_foreach(as_list_d, i, p_as)
{
xbt_dynar_foreach(p_as->host_list_d, j, p_host) {
- if (p_host->id == host) {
- p_host->function = function;
+ if (p_host->id == host_id) {
+ p_host->function = function_id;
p_host->args_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
// split & fill the args list
tmp_arg = strtok((char*)args,",");
}
}
}
- XBT_ERROR("Host : %s Not Found !!", host);
+ XBT_ERROR("Host : %s Not Found !!", host_id);
return 1;
+}
+
+static int Host_set_property(lua_State* L)
+{
+ p_AS_attr p_as;
+ p_host_attr p_host;
+ unsigned int i,j;
+ const char* host_id ="";
+ const char* prop_id = "";
+ const char* prop_value = "";
+ if (lua_istable(L, -1)) {
+ // get Host id
+ lua_pushstring(L, "host");
+ lua_gettable(L, -2);
+ host_id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ // get Function Name
+ lua_pushstring(L, "prop_id");
+ lua_gettable(L, -2);
+ prop_id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ //get args
+ lua_pushstring(L,"prop_value");
+ lua_gettable(L, -2);
+ prop_value = lua_tostring(L,-1);
+ lua_pop(L, 1);
+ }
+ xbt_dynar_foreach(as_list_d, i, p_as)
+ {
+ xbt_dynar_foreach(p_as->host_list_d, j, p_host) {
+ if (p_host->id == host_id) {
+ xbt_dict_set(p_host->properties, prop_id, xbt_strdup(prop_value), free);
+ }
+ }
+ }
+ return 1;
+
}
/*
* surf parse bypass platform
xbt_dynar_foreach(p_as->host_list_d, j, p_host){
create_host(p_host->id, p_host->power_peak, p_host->power_scale,
p_host->power_trace, p_host->core, p_host->state_initial,
- p_host->state_trace);
- //add to routing model host list
- surf_route_add_host((char *) p_host->id);
+ p_host->state_trace, p_host->properties);
+
+
+ //add to routing model host list
+ surf_route_add_host((char *) p_host->id);
}
// add associated Links
xbt_dynar_foreach(p_as->link_list_d, j, p_link){
return Host_set_function(L);
}
+int console_host_set_property(lua_State *L)
+{
+ return Host_set_property(L);
+}
+
int console_parse_platform()
{
return surf_parse_bypass_platform();
static int Task_send(lua_State * L)
{
//stackDump("send ",L);
- m_task_t tk = checkTask(L, -2);
- const char *mailbox = luaL_checkstring(L, -1);
+ m_task_t tk = checkTask(L, 1);
+ const char *mailbox = luaL_checkstring(L, 2);
lua_pop(L, 1); // remove the string so that the task is on top of it
MSG_task_set_data(tk, L); // Copy my stack into the task, so that the receiver can copy the lua task directly
MSG_error_t res = MSG_task_send(tk, mailbox);
return 1;
}
+static int Task_recv_with_timeout(lua_State * L)
+{
+ m_task_t tk = NULL;
+ const char *mailbox = luaL_checkstring(L, -2);
+ int timeout = luaL_checknumber(L, -1);
+ MSG_error_t res = MSG_task_receive_with_timeout(&tk, mailbox, timeout);
+
+ lua_State *sender_stack = MSG_task_get_data(tk);
+ lua_xmove(sender_stack, L, 1); // copy the data directly from sender's stack
+ MSG_task_set_data(tk, NULL);
+
+ if (res != MSG_OK)
+ switch (res) {
+ case MSG_TIMEOUT:
+ XBT_ERROR("MSG_task_receive failed : Timeout");
+ break;
+ case MSG_TRANSFER_FAILURE:
+ XBT_ERROR("MSG_task_receive failed : Transfer Failure");
+ break;
+ case MSG_HOST_FAILURE:
+ XBT_ERROR("MSG_task_receive failed : Host Failure ");
+ break;
+ default:
+ XBT_ERROR
+ ("MSG_task_receive failed : Unexpected error , please report this bug");
+ break;
+ }
+
+ return 1;
+}
+
+/**
+ * Static Binding for the Splay methods : event.sleep :
+ * it use MSG_task_irecv with MSG_comm_wait
+ */
+static int Task_splay_irecv(lua_State *L)
+{
+ m_task_t task = NULL;
+ msg_comm_t comm = NULL; //current communication to receive
+ const char *mailbox = luaL_checkstring(L, -2);
+ double timeout = luaL_checknumber(L, -1);
+ comm = MSG_task_irecv(&task, mailbox);
+ MSG_comm_wait(comm, timeout);
+ if (MSG_comm_get_status(comm) == MSG_OK)
+ {
+ lua_State *sender_stack = MSG_task_get_data(task);
+ lua_xmove(sender_stack, L, 1); // copy the data directly from sender's stack
+ MSG_task_set_data(task, NULL);
+ MSG_comm_destroy(comm);
+ }
+
+ return 1;
+}
+
+static int Task_splay_isend(lua_State *L)
+{
+ m_task_t tk = checkTask(L, 1);
+ const char *mailbox = luaL_checkstring(L, 2);
+ lua_pop(L, 1); // remove the string so that the task is on top of it
+ MSG_task_set_data(tk, L); // Copy my stack into the task, so that the receiver can copy the lua task directly
+ MSG_task_isend(tk, mailbox);
+
+ return 1;
+}
+
static const luaL_reg Task_methods[] = {
{"new", Task_new},
{"name", Task_get_name},
{"destroy", Task_destroy},
{"send", Task_send},
{"recv", Task_recv},
+ {"recv_timeout",Task_recv_with_timeout},
+ {"splay_recv",Task_splay_irecv},
+ {"iSend",Task_splay_isend},
{0, 0}
};
XBT_DEBUG("Getting Host from name...");
m_host_t msg_host = MSG_get_host_by_name(name);
if (!msg_host) {
- luaL_error(L, "null Host : MSG_get_host_by_name failled");
+ luaL_error(L, "null Host : MSG_get_host_by_name failed");
}
lua_newtable(L); /* create a table, put the userdata on top of it */
m_host_t *lua_host = (m_host_t *) lua_newuserdata(L, sizeof(m_host_t));
static int Host_self(lua_State * L)
{
- m_host_t host = MSG_host_self();
- lua_newtable(L);
- m_host_t *lua_host =(m_host_t *)lua_newuserdata(L,sizeof(m_host_t));
- *lua_host = host;
- luaL_getmetatable(L, HOST_MODULE_NAME);
- lua_setmetatable(L, -2);
- lua_setfield(L, -2, "__simgrid_host");
- return 1;
+ m_host_t host = MSG_host_self();
+ lua_newtable(L);
+ m_host_t *lua_host =(m_host_t *)lua_newuserdata(L,sizeof(m_host_t));
+ *lua_host = host;
+ luaL_getmetatable(L, HOST_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_host");
+ return 1;
}
return 1;
}
+static int Host_sleep(lua_State *L)
+{
+ int time = luaL_checknumber(L, -1);
+ MSG_process_sleep(time);
+ return 1;
+}
+
+static int Host_destroy(lua_State *L)
+{
+ m_host_t ht = checkHost(L, -1);
+ __MSG_host_destroy(ht);
+ return 1;
+}
+
/* ********************************************************************************* */
/* lua_stub_generator functions */
/* ********************************************************************************* */
lua_pop(L, 1);
//add to the process list
xbt_dynar_push(process_list, &process);
-
return 0;
-
}
{"number", Host_number},
{"at", Host_at},
{"self",Host_self},
- {"getPropValue",Host_get_property_value},
+ {"getPropValue", Host_get_property_value},
+ {"sleep", Host_sleep},
+ {"destroy",Host_destroy},
// Bypass XML Methods
{"setFunction", console_set_function},
+ {"setProperty", console_host_set_property},
{0, 0}
};
//deployment attribute
const char *function;
xbt_dynar_t args_list;
+ xbt_dict_t properties;
} host_attr, *p_host_attr;
int console_add_route(lua_State*);
int console_add_AS(lua_State*);
int console_set_function(lua_State*);
+int console_host_set_property(lua_State*);
int console_parse_platform(void);
int console_parse_application(void);
#define OPT_TRACING_MSG_PROCESS "tracing/msg/process"
#define OPT_TRACING_MSG_VOLUME "tracing/msg/volume"
#define OPT_TRACING_FILENAME "tracing/filename"
-#define OPT_TRACING_PLATFORM_METHOD "tracing/platform/method"
+#define OPT_TRACING_BUFFER "tracing/buffer"
#define OPT_TRIVA_UNCAT_CONF "triva/uncategorized"
#define OPT_TRIVA_CAT_CONF "triva/categorized"
TRACE_is_enabled();
}
-char *TRACE_get_filename(void)
+int TRACE_buffer (void)
{
- return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME);
+ return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_BUFFER) &&
+ TRACE_is_enabled();
}
-char *TRACE_get_platform_method(void)
+char *TRACE_get_filename(void)
{
- return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD);
+ return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME);
}
char *TRACE_get_triva_uncat_conf (void)
xbt_cfgelm_int, &default_tracing_uncategorized, 0, 1,
NULL, NULL);
- /* platform method */
- char *default_tracing_platform_method = xbt_strdup("a");
- xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD,
- "Tracing method used to register categorized resource behavior.",
- xbt_cfgelm_string, &default_tracing_platform_method, 1,
- 1, NULL, NULL);
-
/* msg task */
int default_tracing_msg_task = 0;
xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_TASK,
xbt_cfgelm_int, &default_tracing_msg_volume, 0, 1,
NULL, NULL);
+ /* msg volume (experimental) */
+ int default_buffer = 0;
+ xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_BUFFER,
+ "Buffer trace events to put them in temporal order.",
+ xbt_cfgelm_int, &default_buffer, 0, 1,
+ NULL, NULL);
+
/* Triva graph configuration for uncategorized tracing */
char *default_triva_uncat_conf_file = xbt_strdup ("");
xbt_cfg_register(&_surf_cfg_set, OPT_TRIVA_UNCAT_CONF,
" this simulator do not use tracing categories and resource use have to be\n"
" traced.",
detailed);
- print_line (OPT_TRACING_PLATFORM_METHOD, "Change the resource utilization tracing method",
- " It changes the way resource utilization (categorized or not) is traced\n"
- " inside the simulation core. Method 'a' (default) traces all updates defined\n"
- " by the CPU/network model of a given resource. Depending on the interface used\n"
- " by this simulator (MSG, SMPI, SimDAG), the default method can generate large\n"
- " trace files. Method 'b' tries to make smaller tracefiles using clever updates,\n"
- " without losing details of resource utilization. Method 'c' generates even\n"
- " smaller files by doing time integration during the simulation, but it loses\n"
- " precision. If this last method is used, the smallest timeslice used in the\n"
- " tracefile analysis must be bigger than the smaller resource utilization. If\n"
- " unsure, do not change this option.",
- detailed);
print_line (OPT_TRACING_FILENAME, "Filename to register traces",
" A file with this name will be created to register the simulation. The file\n"
" is in the Paje format and can be analyzed using Triva or Paje visualization\n"
" This experimental option only has effect if this simulator is MSG-based.\n"
" It traces the communication volume of MSG send/receive.",
detailed);
+ print_line (OPT_TRACING_BUFFER, "Buffer events to put them in temporal order",
+ " This option put some events in a time-ordered buffer using the insertion\n"
+ " sort algorithm. The process of acquiring and releasing locks to access this\n"
+ " buffer and the cost of the sorting algorithm make this process slow. The\n"
+ " simulator performance can be severely impacted if this option is activated,\n"
+ " but you are sure to get a trace file with events sorted.",
+ detailed);
print_line (OPT_TRIVA_UNCAT_CONF, "Generate graph configuration for Triva",
" This option can be used in all types of simulators build with SimGrid\n"
" to generate a uncategorized resource utilization graph to be used as\n"
return instr_routing_platform_graph ();
}
+void TRACE_platform_graph_export_graphviz (xbt_graph_t g, const char *filename)
+{
+ instr_routing_platform_graph_export_graphviz (g, filename);
+}
+
#endif /* HAVE_TRACING */
/* internal do the instrumentation module */
static void insert_into_buffer (paje_event_t tbi)
{
+ if (TRACE_buffer() == 0){
+ tbi->print (tbi);
+ tbi->free (tbi);
+ return;
+ }
XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%ld)", __FUNCTION__, tbi->event_type, tbi->timestamp, xbt_dynar_length(buffer));
unsigned int i;
#include "msg/msg.h"
#include "simdag/private.h"
#include "simix/private.h"
+#include "xbt/graph_private.h"
typedef enum {
TYPE_VARIABLE,
int TRACE_msg_task_is_enabled(void);
int TRACE_msg_process_is_enabled(void);
int TRACE_msg_volume_is_enabled(void);
+int TRACE_buffer (void);
char *TRACE_get_filename(void);
-char *TRACE_get_platform_method(void);
char *TRACE_get_triva_uncat_conf (void);
char *TRACE_get_triva_cat_conf (void);
void TRACE_global_init(int *argc, char **argv);
void instr_new_user_host_variable_type (const char *new_typename, const char *color);
int instr_platform_traced (void);
xbt_graph_t instr_routing_platform_graph (void);
+void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
#endif /* HAVE_TRACING */
//to check if variables were previously set to 0, otherwise paje won't simulate them
static xbt_dict_t platform_variables; /* host or link name -> array of categories */
-//B
-static xbt_dict_t method_b_dict;
-
-//C
-static xbt_dict_t method_c_dict;
-
-//resource utilization tracing method
-static void (*TRACE_method_alloc) (void) = NULL;
-static void (*TRACE_method_release) (void) = NULL;
-static void (*TRACE_method_start) (smx_action_t action) = NULL;
-static void (*TRACE_method_event) (smx_action_t action, double now,
- double delta, const char *variable,
- const char *resource, double value) =
- NULL;
-static void (*TRACE_method_end) (smx_action_t action) = NULL;
-
//used by all methods
static void __TRACE_surf_check_variable_set_to_zero(double now,
const char *variable,
/* end of check */
}
-#define A_METHOD
-//A
-static void __TRACE_A_alloc(void)
-{
-}
-static void __TRACE_A_release(void)
-{
-}
-
-static void __TRACE_A_start(smx_action_t action)
-{
-}
+/*
static void __TRACE_A_event(smx_action_t action, double now, double delta,
const char *variable, const char *resource,
double value)
new_pajeAddVariable(now, container, type, value);
new_pajeSubVariable(now + delta, container, type, value);
}
+*/
-static void __TRACE_A_end(smx_action_t action)
+static void instr_event (double now, double delta, type_t variable, container_t resource, double value)
{
+ __TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name);
+ new_pajeAddVariable(now, resource, variable, value);
+ new_pajeSubVariable(now + delta, resource, variable, value);
}
-#define B_METHOD
-//B
-
-static void __TRACE_B_alloc(void)
-{
- method_b_dict = xbt_dict_new();
-}
-
-static void __TRACE_B_release(void)
-{
- char *key, *time;
- xbt_dict_cursor_t cursor = NULL;
- xbt_dict_foreach(method_b_dict, cursor, key, time) {
- char resource[INSTR_DEFAULT_STR_SIZE];
- char variable[INSTR_DEFAULT_STR_SIZE];
- char what[INSTR_DEFAULT_STR_SIZE];
- sscanf (key, "%s %s %s", resource, variable, what);
- if (strcmp(what, "time")==0){
- char key_value[INSTR_DEFAULT_STR_SIZE];
- snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable);
- char *value = xbt_dict_get_or_null (method_b_dict, key_value);
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(atof(time), container, type, atof(value));
- }
- }
- xbt_dict_free(&method_b_dict);
-}
-
-static void __TRACE_B_start(smx_action_t action)
-{
-}
-
-static void __TRACE_B_event(smx_action_t action, double now, double delta,
- const char *variable, const char *resource,
- double value)
-{
- char key_time[INSTR_DEFAULT_STR_SIZE];
- char key_value[INSTR_DEFAULT_STR_SIZE];
- char nowstr[INSTR_DEFAULT_STR_SIZE];
- char valuestr[INSTR_DEFAULT_STR_SIZE];
- char nowdeltastr[INSTR_DEFAULT_STR_SIZE];
-
- snprintf (key_time, INSTR_DEFAULT_STR_SIZE, "%s %s time", resource, variable);
- snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable);
- snprintf (nowstr, INSTR_DEFAULT_STR_SIZE, "%f", now);
- snprintf (valuestr, INSTR_DEFAULT_STR_SIZE, "%f", value);
- snprintf (nowdeltastr, INSTR_DEFAULT_STR_SIZE, "%f", now+delta);
-
- char *lasttimestr = xbt_dict_get_or_null(method_b_dict, key_time);
- char *lastvaluestr = xbt_dict_get_or_null(method_b_dict, key_value);
- if (lasttimestr == NULL){
- __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeAddVariable(now, container, type, value);
- xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free);
- }else{
- double lasttime = atof (lasttimestr);
- double lastvalue = atof (lastvaluestr);
-
- if (lastvalue == value){
- double dif = fabs(now - lasttime);
- if (dif < 0.000001){
- //perfect, just go on
- }else{
- //time changed, have to update
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(lasttime, container, type, lastvalue);
- new_pajeAddVariable(now, container, type, value);
- }
- }else{
- //value changed, have to update
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(lasttime, container, type, lastvalue);
- new_pajeAddVariable(now, container, type, value);
- }
- xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free);
- }
- return;
-}
-
-static void __TRACE_B_end(smx_action_t action)
-{
-}
-
-#define C_METHOD
-//C
-static void __TRACE_C_alloc(void)
-{
- method_c_dict = xbt_dict_new();
-}
-
-static void __TRACE_C_release(void)
-{
- xbt_dict_free(&method_c_dict);
-}
-
-static void __TRACE_C_start(smx_action_t action)
-{
- char key[100];
- snprintf(key, 100, "%p", action);
-
- //check if exists
- if (xbt_dict_get_or_null(method_c_dict, key)) {
- xbt_dict_remove(method_c_dict, key); //should never execute here, but it does
- }
- xbt_dict_set(method_c_dict, key, xbt_dict_new(), xbt_free);
-}
-
-static void __TRACE_C_event(smx_action_t action, double now, double delta,
- const char *variable, const char *resource,
- double value)
-{
- char key[100];
- snprintf(key, 100, "%p", action);
-
- xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key);
- //setting start time
- if (!xbt_dict_get_or_null(action_dict, "start")) {
- char start_time[100];
- snprintf(start_time, 100, "%f", now);
- xbt_dict_set(action_dict, "start", xbt_strdup(start_time), xbt_free);
- }
- //updating end time
- char end_time[100];
- snprintf(end_time, 100, "%f", now + delta);
- xbt_dict_set(action_dict, "end", xbt_strdup(end_time), xbt_free);
-
- //accumulate the value resource-variable
- char res_var[300];
- snprintf(res_var, 300, "%s %s", resource, variable);
- double current_value_f;
- char *current_value = xbt_dict_get_or_null(action_dict, res_var);
- if (current_value) {
- current_value_f = atof(current_value);
- current_value_f += value * delta;
- } else {
- current_value_f = value * delta;
- }
- char new_current_value[100];
- snprintf(new_current_value, 100, "%f", current_value_f);
- xbt_dict_set(action_dict, res_var, xbt_strdup(new_current_value),
- xbt_free);
-}
-
-static void __TRACE_C_end(smx_action_t action)
-{
- char key[100];
- snprintf(key, 100, "%p", action);
-
- xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key);
- double start_time = atof(xbt_dict_get(action_dict, "start"));
- double end_time = atof(xbt_dict_get(action_dict, "end"));
-
- xbt_dict_cursor_t cursor = NULL;
- char *action_dict_key, *action_dict_value;
- xbt_dict_foreach(action_dict, cursor, action_dict_key, action_dict_value) {
- char resource[100], variable[100];
- if (sscanf(action_dict_key, "%s %s", resource, variable) != 2)
- continue;
- __TRACE_surf_check_variable_set_to_zero(start_time, variable,
- resource);
- if (end_time - start_time != 0) {
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- double val = atof(action_dict_value) / (end_time - start_time);
- new_pajeSubVariable(start_time, container, type, val);
- new_pajeAddVariable(end_time, container, type, val);
- }
- }
- xbt_dict_remove(method_c_dict, key);
-}
-
-#define RESOURCE_UTILIZATION_INTERFACE
/*
* TRACE_surf_link_set_utilization: entry point from SimGrid
*/
XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
container_t container = getContainerByName (resource);
type_t type = getVariableType("bandwidth_used", NULL, container->type);
- TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value);
+ instr_event (now, delta, type, container, value);
}
//trace categorized utilization
XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
container_t container = getContainerByName (resource);
type_t type = getVariableType(category_type, NULL, container->type);
- TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value);
+ instr_event (now, delta, type, container, value);
}
return;
}
XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
container_t container = getContainerByName (resource);
type_t type = getVariableType("power_used", NULL, container->type);
- TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value);
+ instr_event (now, delta, type, container, value);
}
//trace categorized utilization
XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
container_t container = getContainerByName (resource);
type_t type = getVariableType(category_type, NULL, container->type);
- TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value);
+ instr_event (now, delta, type, container, value);
}
return;
}
-/*
- * __TRACE_surf_resource_utilization_*: entry points from tracing functions
- */
-void TRACE_surf_resource_utilization_start(smx_action_t action)
-{
- if (!TRACE_is_active())
- return;
- XBT_DEBUG("START %p", action);
- TRACE_method_start(action);
-}
-
-void TRACE_surf_resource_utilization_event(smx_action_t action, double now,
- double delta,
- const char *variable,
- const char *resource,
- double value)
-{
- if (!TRACE_is_active())
- return;
- XBT_DEBUG("EVENT %p [%f - %f] %s %s %f", action, now, now+delta, resource, variable, value);
- TRACE_method_event(action, now, delta, variable, resource, value);
-}
-
-void TRACE_surf_resource_utilization_end(smx_action_t action)
+void TRACE_surf_resource_utilization_alloc()
{
- if (!TRACE_is_active())
- return;
- TRACE_method_end(action);
- XBT_DEBUG("END %p", action);
+ platform_variables = xbt_dict_new();
}
void TRACE_surf_resource_utilization_release()
{
- if (!TRACE_is_active())
- return;
- TRACE_method_release();
-}
-
-static void __TRACE_define_method(char *method)
-{
- if (!strcmp(method, "a")) {
- TRACE_method_alloc = __TRACE_A_alloc;
- TRACE_method_release = __TRACE_A_release;
- TRACE_method_start = __TRACE_A_start;
- TRACE_method_event = __TRACE_A_event;
- TRACE_method_end = __TRACE_A_end;
- } else if (!strcmp(method, "c")) {
- TRACE_method_alloc = __TRACE_C_alloc;
- TRACE_method_release = __TRACE_C_release;
- TRACE_method_start = __TRACE_C_start;
- TRACE_method_event = __TRACE_C_event;
- TRACE_method_end = __TRACE_C_end;
- } else { //default is B
- TRACE_method_alloc = __TRACE_B_alloc;
- TRACE_method_release = __TRACE_B_release;
- TRACE_method_start = __TRACE_B_start;
- TRACE_method_event = __TRACE_B_event;
- TRACE_method_end = __TRACE_B_end;
- }
-}
-
-void TRACE_surf_resource_utilization_alloc()
-{
- platform_variables = xbt_dict_new();
- __TRACE_define_method(TRACE_get_platform_method());
- TRACE_method_alloc();
}
#endif /* HAVE_TRACING */
#ifdef HAVE_TRACING
#include "surf/surf_private.h"
#include "surf/network_private.h"
+#include "xbt/graph.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_routing, instr, "Tracing platform hierarchy");
return ret;
}
+void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename)
+{
+ unsigned int cursor = 0;
+ xbt_node_t node = NULL;
+ xbt_edge_t edge = NULL;
+ FILE *file = NULL;
+
+ file = fopen(filename, "w");
+ xbt_assert(file, "Failed to open %s \n", filename);
+
+ if (g->directed)
+ fprintf(file, "digraph test {\n");
+ else
+ fprintf(file, "graph test {\n");
+
+ fprintf(file, " graph [overlap=scale]\n");
+
+ fprintf(file, " node [shape=box, style=filled]\n");
+ fprintf(file,
+ " node [width=.3, height=.3, style=filled, color=skyblue]\n\n");
+
+ xbt_dynar_foreach(g->nodes, cursor, node) {
+ fprintf(file, " \"%s\";\n", TRACE_node_name(node));
+ }
+ xbt_dynar_foreach(g->edges, cursor, edge) {
+ const char *src_s = TRACE_node_name (edge->src);
+ const char *dst_s = TRACE_node_name (edge->dst);
+ if (g->directed)
+ fprintf(file, " \"%s\" -> \"%s\";\n", src_s, dst_s);
+ else
+ fprintf(file, " \"%s\" -- \"%s\";\n", src_s, dst_s);
+ }
+ fprintf(file, "}\n");
+ fclose(file);
+
+}
+
#endif /* HAVE_TRACING */
void TRACE_smx_host_execute(smx_action_t act)
{
if (!TRACE_is_active()) return;
- TRACE_surf_resource_utilization_start(act);
return;
}
void TRACE_smx_action_communicate(smx_action_t act, smx_process_t proc)
{
if (!TRACE_is_active()) return;
- TRACE_surf_resource_utilization_start(act);
return;
}
void TRACE_smx_action_destroy(smx_action_t act)
{
if (!TRACE_is_active()) return;
- TRACE_surf_resource_utilization_end(act);
return;
}
if (graph == NULL){
XBT_INFO ("%s expects --cfg=tracing:1", argv[0]);
}else{
- xbt_graph_export_graphviz(graph, graphvizFile, &TRACE_node_name, NULL);
+ TRACE_platform_graph_export_graphviz (graph, graphvizFile);
XBT_INFO ("Output is in file %s", graphvizFile);
}
MSG_clean();