From ae7b97e49ebca15dfe00e0f463d1573a7bd44cc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20B=C3=A9daride?= Date: Tue, 8 Jan 2013 17:06:36 +0100 Subject: [PATCH 1/1] Fix lua deploy --- examples/lua/console/deploy.lua | 7 ++- examples/lua/console/master_slave_bypass.lua | 4 +- examples/lua/console/platform.lua | 46 ++++++++++---------- examples/lua/console/slave.lua | 6 +-- examples/lua/masterslave/master_slave.lua | 8 ++-- include/simgrid/simix.h | 2 + src/bindings/lua/lua_platf.c | 8 ++-- src/bindings/lua/simgrid_lua.c | 8 ++++ src/simix/smx_deployment.c | 9 ++-- 9 files changed, 54 insertions(+), 44 deletions(-) diff --git a/examples/lua/console/deploy.lua b/examples/lua/console/deploy.lua index 26e34fc533..5d46da3374 100644 --- a/examples/lua/console/deploy.lua +++ b/examples/lua/console/deploy.lua @@ -1,11 +1,10 @@ dofile 'master.lua' dofile 'slave.lua' + + simgrid.init_application(); --Set Application simgrid.host.set_function{host="Tremblay",fct="Master",args="20,550000000,1000000,4"}; - simgrid.host.set_function{host="Bourassa",fct="Slave",args="0"}; simgrid.host.set_function{host="Jupiter",fct="Slave",args="1"}; simgrid.host.set_function{host="Fafard",fct="Slave",args="2"}; simgrid.host.set_function{host="Ginette",fct="Slave",args="3"}; - - --Save Application - simgrid.msg_register_application(); + simgrid.host.set_function{host="Bourassa",fct="Slave",args="0"}; diff --git a/examples/lua/console/master_slave_bypass.lua b/examples/lua/console/master_slave_bypass.lua index 3f3fd9c191..55a79d532c 100644 --- a/examples/lua/console/master_slave_bypass.lua +++ b/examples/lua/console/master_slave_bypass.lua @@ -1,10 +1,8 @@ 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.") diff --git a/examples/lua/console/platform.lua b/examples/lua/console/platform.lua index 60e66b9df0..6e0f88b249 100644 --- a/examples/lua/console/platform.lua +++ b/examples/lua/console/platform.lua @@ -15,31 +15,31 @@ for i=10,0,-1 do simgrid.platf.link_new{id=i,bandwidth=252750+ i*768,latency=0.000270544+i*0.087}; end -simgrid.platf.route_new{src="Tremblay",dest="Jupiter",links="1",symmetrical=0}; -simgrid.platf.route_new{src="Tremblay",dest="Fafard",links="0,1,2,3,4,8",symmetrical=0}; -simgrid.platf.route_new{src="Tremblay",dest="Ginette",links="3,4,5",symmetrical=0}; -simgrid.platf.route_new{src="Tremblay",dest="Bourassa",links="0,1,3,2,4,6,7",symmetrical=0}; - -simgrid.platf.route_new{src="Jupiter",dest="Tremblay",links="1",symmetrical=0}; -simgrid.platf.route_new{src="Jupiter",dest="Fafard",links="0,1,2,3,4,8,9",symmetrical=0}; -simgrid.platf.route_new{src="Jupiter",dest="Ginette",links="3,4,5,9",symmetrical=0}; -simgrid.platf.route_new{src="Jupiter",dest="Bourassa",links="0,1,2,3,4,6,7,9",symmetrical=0}; +simgrid.platf.route_new{src="Tremblay",dest="Jupiter",links="1"}; +simgrid.platf.route_new{src="Tremblay",dest="Fafard",links="0,1,2,3,4,8"}; +simgrid.platf.route_new{src="Tremblay",dest="Ginette",links="3,4,5"}; +simgrid.platf.route_new{src="Tremblay",dest="Bourassa",links="0,1,3,2,4,6,7"}; + +simgrid.platf.route_new{src="Jupiter",dest="Tremblay",links="1"}; +simgrid.platf.route_new{src="Jupiter",dest="Fafard",links="0,1,2,3,4,8,9"}; +simgrid.platf.route_new{src="Jupiter",dest="Ginette",links="3,4,5,9"}; +simgrid.platf.route_new{src="Jupiter",dest="Bourassa",links="0,1,2,3,4,6,7,9"}; -simgrid.platf.route_new{src="Fafard",dest="Tremblay",links="0,1,2,3,4,8",symmetrical=0}; -simgrid.platf.route_new{src="Fafard",dest="Jupiter",links="0,1,2,3,4,8,9",symmetrical=0}; -simgrid.platf.route_new{src="Fafard",dest="Ginette",links="0,1,2,5,8",symmetrical=0}; -simgrid.platf.route_new{src="Fafard",dest="Bourassa",links="6,7,8",symmetrical=0}; +simgrid.platf.route_new{src="Fafard",dest="Tremblay",links="0,1,2,3,4,8"}; +simgrid.platf.route_new{src="Fafard",dest="Jupiter",links="0,1,2,3,4,8,9"}; +simgrid.platf.route_new{src="Fafard",dest="Ginette",links="0,1,2,5,8"}; +simgrid.platf.route_new{src="Fafard",dest="Bourassa",links="6,7,8"}; -simgrid.platf.route_new{src="Ginette",dest="Tremblay",links="3,4,5",symmetrical=0}; -simgrid.platf.route_new{src="Ginette",dest="Jupiter",links="3,4,5,9",symmetrical=0}; -simgrid.platf.route_new{src="Ginette",dest="Fafard",links="0,1,2,5,8",symmetrical=0}; -simgrid.platf.route_new{src="Ginette",dest="Bourassa",links="0,1,2,5,6,7",symmetrical=0}; - -simgrid.platf.route_new{src="Bourassa",dest="Tremblay",links="0,1,3,2,4,6,7",symmetrical=0}; -simgrid.platf.route_new{src="Bourassa",dest="Jupiter",links="0,1,2,3,4,6,7,9",symmetrical=0}; -simgrid.platf.route_new{src="Bourassa",dest="Fafard",links="6,7,8",symmetrical=0}; -simgrid.platf.route_new{src="Bourassa",dest="Ginette",links="0,1,2,5,6,7",symmetrical=0}; +simgrid.platf.route_new{src="Ginette",dest="Tremblay",links="3,4,5"}; +simgrid.platf.route_new{src="Ginette",dest="Jupiter",links="3,4,5,9"}; +simgrid.platf.route_new{src="Ginette",dest="Fafard",links="0,1,2,5,8"}; +simgrid.platf.route_new{src="Ginette",dest="Bourassa",links="0,1,2,5,6,7"}; + +simgrid.platf.route_new{src="Bourassa",dest="Tremblay",links="0,1,3,2,4,6,7"}; +simgrid.platf.route_new{src="Bourassa",dest="Jupiter",links="0,1,2,3,4,6,7,9"}; +simgrid.platf.route_new{src="Bourassa",dest="Fafard",links="6,7,8"}; +simgrid.platf.route_new{src="Bourassa",dest="Ginette",links="0,1,2,5,6,7"}; simgrid.platf.AS_close(); - + simgrid.platf.close(); diff --git a/examples/lua/console/slave.lua b/examples/lua/console/slave.lua index 2073530c4c..816fbda5df 100644 --- a/examples/lua/console/slave.lua +++ b/examples/lua/console/slave.lua @@ -15,14 +15,14 @@ function Slave(...) local task = simgrid.task.recv(my_mailbox); --print(task) local task_name = task:get_name() - if (task_name == "finalize") then + if (task:get_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.info("Slave '" .. my_mailbox .. "' processing " .. task:get_name()) simgrid.task.execute(task) - simgrid.info("Slave '" .. my_mailbox .. "': task " .. task_name .. " done") + simgrid.info("Slave '" .. my_mailbox .. "': task " .. task:get_name() .. " done") end -- while simgrid.info("Slave '" .. my_mailbox .. "': I'm Done . See You !!"); diff --git a/examples/lua/masterslave/master_slave.lua b/examples/lua/masterslave/master_slave.lua index 984dba7344..0e74608f06 100644 --- a/examples/lua/masterslave/master_slave.lua +++ b/examples/lua/masterslave/master_slave.lua @@ -1,11 +1,11 @@ -dofile 'master.lua' -dofile 'slave.lua' +dofile '../console/master.lua' +dofile '../console/slave.lua' -- Simulation Code ---------------------------------------------------------- require "simgrid" -simgrid.platform(arg[1] or "../../msg/small_platform.xml") -simgrid.application(arg[2] or "../deploy.xml") +simgrid.platform(arg[1]) +simgrid.application(arg[2]) simgrid.run() simgrid.info("Simulation's over. See you.") -- end-of-master-slave diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 1faa39c608..cdb0a2acfd 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -246,7 +246,9 @@ XBT_PUBLIC(void) SIMIX_create_environment(const char *file); XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code); XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code); XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name); +XBT_PUBLIC(void) SIMIX_init_application(void); XBT_PUBLIC(void) SIMIX_launch_application(const char *file); + XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host, const char *process_function, xbt_dynar_t arguments, diff --git a/src/bindings/lua/lua_platf.c b/src/bindings/lua/lua_platf.c index 7514c7121d..777a664b44 100644 --- a/src/bindings/lua/lua_platf.c +++ b/src/bindings/lua/lua_platf.c @@ -41,9 +41,8 @@ static const luaL_reg platf_functions[] = { int console_open(lua_State *L) { sg_platf_init(); sg_platf_begin(); - surf_parse_init_callbacks(); - - storage_register_callbacks(); + + storage_register_callbacks(); routing_register_callbacks(); gpu_register_callbacks(); @@ -365,7 +364,7 @@ int console_set_function(lua_State *L) { //get args lua_pushstring(L,"args"); lua_gettable(L, -2); - args = xbt_str_split_quoted( lua_tostring(L,-1) ); + args = xbt_str_split_str( lua_tostring(L,-1) , ","); lua_pop(L, 1); // FIXME: hackish to go under MSG that way @@ -375,6 +374,7 @@ int console_set_function(lua_State *L) { return -1; } + // FIXME: use sg_platf_new_process directly (warning: find a way to check hostname) MSG_set_function(host_id, function_id, args); return 0; diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 748a9bf8f8..8c44001c3b 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -158,6 +158,13 @@ static int msg_register_application(lua_State * L) return 0; } +static int console_init_application(lua_State *L) { + MSG_function_register_default(run_lua_code); + SIMIX_init_application(); + return 0; +} + + static const luaL_Reg simgrid_functions[] = { {"create_environment", create_environment}, {"launch_application", launch_application}, @@ -172,6 +179,7 @@ static const luaL_Reg simgrid_functions[] = { {"msg_register_platform", msg_register_platform}, {"sd_register_platform", sd_register_platform}, {"msg_register_application", msg_register_application}, + {"init_application", console_init_application}, {NULL, NULL} }; diff --git a/src/simix/smx_deployment.c b/src/simix/smx_deployment.c index 5cb246b375..766658e230 100644 --- a/src/simix/smx_deployment.c +++ b/src/simix/smx_deployment.c @@ -76,6 +76,11 @@ static void parse_process(sg_platf_process_cbarg_t process) current_property_set = NULL; } +void SIMIX_init_application(void){ + surf_parse_reset_callbacks(); + sg_platf_process_add_cb(parse_process); +} + /** * \brief An application deployer. * @@ -98,9 +103,7 @@ void SIMIX_launch_application(const char *file) xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_launch_application."); - surf_parse_reset_callbacks(); - - sg_platf_process_add_cb(parse_process); + SIMIX_init_application(); surf_parse_open(file); TRY { -- 2.20.1