--Master Function
function Master(...)
-simgrid.info("Hello from lua, I'm the master")
-for i,v in ipairs(arg) do
- simgrid.info("Got "..v)
-end
-
-nb_task = arg[1];
-comp_size = arg[2];
-comm_size = arg[3];
-slave_count = arg[4];
-
-if (#arg ~= 4) then
- error("Argc should be 4");
-end
-simgrid.info("Argc="..(#arg).." (should be 4)")
-
--- Dispatch the tasks
-
-for i=1,nb_task do
- tk = simgrid.task.new("Task "..i,comp_size,comm_size);
- local task_name = simgrid.task.get_name(tk)
- alias = "slave "..(i%slave_count);
- simgrid.info("Master sending '" .. task_name .."' To '" .. alias .."'");
- simgrid.task.send(tk,alias); -- C user data set to NULL
- simgrid.info("Master done sending '".. task_name .."' To '" .. alias .."'");
-end
-
--- Sending Finalize Message To Others
-
-simgrid.info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.");
-for i=0,slave_count-1 do
- alias = "slave "..i;
- simgrid.info("Master: sending finalize to "..alias);
- finalize = simgrid.task.new("finalize",comp_size,comm_size);
- simgrid.task.send(finalize,alias)
-end
+ if #arg ~= 4 then
+ error("Wrong number of arguments (got " .. #arg ..
+ ", expected 4: nb_tasks comp_size comm_size slave_count)")
+ end
+
+ simgrid.info("Hello from lua, I'm the master")
+ for i,v in ipairs(arg) do
+ simgrid.info("Got " .. v)
+ end
+
+ local nb_task, comp_size, comm_size, slave_count = unpack(arg)
+
+ simgrid.info("Argc=" .. (#arg) .. " (should be 4)")
+
+ -- Dispatch the tasks
+
+ for i = 1, nb_task do
+ task = simgrid.task.new("Task " .. i, comp_size, comm_size);
+ local task_name = simgrid.task.get_name(task)
+ alias = "slave " .. (i%slave_count);
+ simgrid.info("Master sending '" .. task_name .. "' To '" .. alias .. "'");
+ simgrid.task.send(task, alias); -- C user data set to NULL
+ simgrid.info("Master done sending '" .. task_name .. "' To '" .. alias .. "'");
+ end
+
+ -- Sending Finalize Message To Others
+
+ simgrid.info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.");
+ for i = 0, slave_count-1 do
+ alias = "slave " .. i;
+ simgrid.info("Master: sending finalize to " .. alias);
+ finalize = simgrid.task.new("finalize", comp_size, comm_size);
+ simgrid.task.send(finalize, alias)
+ end
simgrid.info("Master: Everything's done.");
end
-
--end_of_master
require "simgrid"
dofile 'platform.lua'
-dofile 'deploy.lua'
+--dofile 'deploy.lua'
--Rutform.lua'
+dofile 'master.lua'
+dofile 'slave.lua'
+ --dofile 'deploy.lua'
+ simgrid.application("deployb.xml")
simgrid.run()
simgrid.info("Simulation's over.See you.")
-
-- Slave Function ---------------------------------------------------------
function Slave(...)
-local my_mailbox="slave "..arg[1]
-simgrid.info("Hello from lua, I'm a poor slave with mbox: "..my_mailbox)
+ if #arg ~= 1 then
+ error("Wrong number of arguments (got " .. #arg .. ", expected 1: slave_id)")
+ end
-while true do
+ local my_mailbox = "slave " .. arg[1]
+ simgrid.info("Hello from lua, I'm a poor slave with mbox: " .. my_mailbox)
- local tk = simgrid.task.recv(my_mailbox);
- if (simgrid.task.get_name(tk) == "finalize") then
- simgrid.info("Slave '" ..my_mailbox.."' got finalize msg");
- break
- end
- --local tk_name = simgrid.task.get_name(tk)
- simgrid.info("Slave '" ..my_mailbox.."' processing "..simgrid.task.get_name(tk))
- simgrid.task.execute(tk)
- simgrid.info("Slave '" ..my_mailbox.."': task "..simgrid.task.get_name(tk) .. " done")
-end -- while
+ while true do
+
+ local task = simgrid.task.recv(my_mailbox);
+ --print(task)
+ local task_name = task:get_name()
+ if (task_name == "finalize") then
+ simgrid.info("Slave '" .. my_mailbox .. "' got finalize msg");
+ break
+ end
+ --local tk_name = simgrid.task.get_name(tk)
+ simgrid.info("Slave '" .. my_mailbox .. "' processing " .. task_name)
+ simgrid.task.execute(task)
+ simgrid.info("Slave '" .. my_mailbox .. "': task " .. task_name .. " done")
+ end -- while
-simgrid.info("Slave '" ..my_mailbox.."': I'm Done . See You !!");
+ simgrid.info("Slave '" .. my_mailbox .. "': I'm Done . See You !!");
end
-- end_of_slave
sg_platf_init();
sg_platf_begin();
surf_parse_init_callbacks();
+
+ storage_register_callbacks();
routing_register_callbacks();
+ gpu_register_callbacks();
+
return 0;
}
//get power_scale
lua_pushstring(L, "power_scale");
lua_gettable(L, -2);
- host.power_scale = lua_tonumber(L, -1);
+ if(!lua_isnumber(L,-1)) host.power_scale = 1;// Default value
+ else host.power_scale = lua_tonumber(L, -1);
lua_pop(L, 1);
//get power_trace
//get state_initial value
lua_pushstring(L, "state_initial");
lua_gettable(L, -2);
- if (lua_tonumber(L, -1))
+ if (!lua_isnumber(L,-1) || lua_tonumber(L, -1))
link.state = SURF_RESOURCE_ON;
else
link.state = SURF_RESOURCE_OFF;
#include "surf/surfxml_parse.h" /* to override surf_parse and bypass the parser */
int console_add_route(lua_State *L) {
- static int AX_ptr = 0;
- static int surfxml_bufferstack_size = 2048;
+ s_sg_platf_route_cbarg_t route;
+ memset(&route,0,sizeof(route));
/* allocating memory for the buffer, I think 2kB should be enough */
surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size);
- const char*src;
- const char*dst;
int is_symmetrical;
- xbt_dynar_t links;
- unsigned int cursor;
- char *link_id;
if (! lua_istable(L, -1)) {
XBT_ERROR("Bad Arguments to create a route, Should be a table with named arguments");
lua_pushstring(L,"src");
lua_gettable(L,-2);
- src = lua_tostring(L, -1);
+ route.src = lua_tostring(L, -1);
lua_pop(L,1);
lua_pushstring(L,"dest");
lua_gettable(L,-2);
- dst = lua_tostring(L, -1);
+ route.dst = lua_tostring(L, -1);
lua_pop(L,1);
lua_pushstring(L,"links");
lua_gettable(L,-2);
- links = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
- if (xbt_dynar_is_empty(links))
- xbt_dynar_push_as(links,char*,xbt_strdup(lua_tostring(L, -1)));
+ route.link_list = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
+ if (xbt_dynar_is_empty(route.link_list))
+ xbt_dynar_push_as(route.link_list,char*,xbt_strdup(lua_tostring(L, -1)));
lua_pop(L,1);
lua_pushstring(L,"symmetrical");
is_symmetrical = lua_tointeger(L, -1);
lua_pop(L,1);
+ route.gw_src = NULL;
+ route.gw_dst = NULL;
+
/* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
* Et ouais mon pote. That's the way it goes. F34R.
*/
- SURFXML_BUFFER_SET(route_src, src);
- SURFXML_BUFFER_SET(route_dst, dst);
if (is_symmetrical)
- A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_YES;
+ route.symmetrical = TRUE;
else
- A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
- SURFXML_START_TAG(route);
-
- xbt_dynar_foreach(links,cursor,link_id) {
- SURFXML_BUFFER_SET(link___ctn_id, link_id);
- A_surfxml_link___ctn_direction = A_surfxml_link___ctn_direction_NONE;
- SURFXML_START_TAG(link___ctn);
- SURFXML_END_TAG(link___ctn);
- }
- SURFXML_END_TAG(route);
-
- xbt_dynar_free(&links);
- free(surfxml_bufferstack);
+ route.symmetrical = FALSE;
+ sg_platf_new_route(&route);
+
return 0;
}