A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reimplement splay/lua methods
[simgrid.git]
/
examples
/
lua
/
SimSplay
/
sim_splay.lua
diff --git
a/examples/lua/SimSplay/sim_splay.lua
b/examples/lua/SimSplay/sim_splay.lua
index
401c17d
..
79c8c9d
100644
(file)
--- a/
examples/lua/SimSplay/sim_splay.lua
+++ b/
examples/lua/SimSplay/sim_splay.lua
@@
-3,14
+3,14
@@
require "simgrid"
rpc = {}
log = {}
job = {}
rpc = {}
log = {}
job = {}
-event = {}
+event
s
= {}
os = {}
start = {}
os = {}
start = {}
+misc = {}
-- Splay global variables
job.me ={}
job.nodes = {}
job.list_type = "random"
-- Splay global variables
job.me ={}
job.nodes = {}
job.list_type = "random"
-
--Init nodes tables
function init_nodes()
for i= 1,simgrid.Host.number() do
--Init nodes tables
function init_nodes()
for i= 1,simgrid.Host.number() do
@@
-22,15
+22,18
@@
function init_jobs()
init_nodes()
end
init_nodes()
end
+
-- Job methods
function job.me.ip()
return simgrid.Host.getPropValue(simgrid.Host.self(),"ip");
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.me.port()
return simgrid.Host.getPropValue(simgrid.Host.self(),"port");
end
+
function job.position()
return simgrid.Host.getPropValue(simgrid.Host.self(),"position");
end
function job.position()
return simgrid.Host.getPropValue(simgrid.Host.self(),"position");
end
@@
-47,6
+50,10
@@
function rpc.call(node,call)
arg = "empty"
mailbox = node
arg = "empty"
mailbox = node
+ if type(node) == "table" then
+ mailbox = node.ip..":"..node.port
+ end
+
if type(call) == "table" then
func = call[1]
arg = call[2]
if type(call) == "table" then
func = call[1]
arg = call[2]
@@
-54,19
+61,30
@@
function rpc.call(node,call)
task_call = simgrid.Task.new("splay_task",10000,10000);
task_call['func_call_name'] = func;
task_call['func_call_arg'] = arg;
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
);
+
log:print("Sending Task to mailbox "..mailbox.." to call '"..func.."' with arg '"..arg.."'"
);
simgrid.Task.iSend(task_call,mailbox);
simgrid.Task.iSend(task_call,mailbox);
- call_function(func,arg)
+
end
end
+function rpc.server(port)
+ -- nothing really to do : no need to open Socket since it's a Simulation
+end
+
+
-- event Methods
-- event Methods
-function event.sleep(time)
+function event
s
.sleep(time)
my_mailbox = job.me.ip()..":"..job.me.port()
my_mailbox = job.me.ip()..":"..job.me.port()
- task = simgrid.Task.splay_recv(my_mailbox, time)
+ tk = simgrid.Task.splay_recv(my_mailbox, time)
+
+ if type(tk) == "table" then
+ call_function(task['func_call_name'],task['func_call_arg'])
+ else log:print("task type is :"..type(tk).." it must be table?!");
+ end
end
end
+
-- main func for each process, this is equivalent to the Deploiment file
-- main func for each process, this is equivalent to the Deploiment file
-function event.thread(main_func)
+function event
s
.thread(main_func)
dofile("platform_script.lua");
init_jobs()
end
dofile("platform_script.lua");
init_jobs()
end
@@
-79,13
+97,19
@@
end
-- Start Methods
function start.loop()
simgrid.run()
-- Start Methods
function start.loop()
simgrid.run()
- simgrid.clean()
+
--
simgrid.clean()
end
end
+
+-- Misc Methods
+function misc.between(a,b)
+ return a
+end
+
-- useful functions
function call_function(fct,arg)
_G[fct](arg)
end
-- useful functions
function call_function(fct,arg)
_G[fct](arg)
end
-function SPLAYschool()
- simgrid.info("Calling me...")
+function SPLAYschool(
arg
)
+ simgrid.info("Calling me..."
..arg
)
end
end