Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Doc] Added description for the boost context factory
[simgrid.git] / examples / lua / splaySim / master.lua
1 -- Copyright (c) 2011, 2014. The SimGrid Team.
2 -- All rights reserved.
3
4 -- This program is free software; you can redistribute it and/or modify it
5 -- under the terms of the license (GNU LGPL) which comes with this package.
6
7 --Master Function
8 function Master(...) 
9
10 simgrid.info("Hello from lua, I'm the master")
11 for i,v in ipairs(arg) do
12     simgrid.info("Got "..v)
13 end
14
15 nb_task = arg[1];
16 comp_size = arg[2];
17 comm_size = arg[3];
18 slave_count = arg[4]
19
20 if (#arg ~= 4) then
21     error("Argc should be 4");
22 end
23 simgrid.info("Argc="..(#arg).." (should be 4)")
24
25 -- Dispatch the tasks
26
27 for i=1,nb_task do
28   tk = simgrid.task.new("Task "..i,comp_size,comm_size);
29   alias = "slave "..(i%slave_count);
30   simgrid.info("Master sending  '" .. simgrid.task.get_name(tk) .."' To '" .. alias .."'");
31   simgrid.task.send(tk,alias); -- C user data set to NULL
32   simgrid.info("Master done sending '".. simgrid.task.get_name(tk) .."' To '" .. alias .."'");
33 end
34
35 -- Sending Finalize Message To Others
36
37 simgrid.info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.");
38 for i=0,slave_count-1 do
39   alias = "slave "..i;
40   simgrid.info("Master: sending finalize to "..alias);
41   finalize = simgrid.task.new("finalize",comp_size,comm_size);
42   simgrid.task.send(finalize,alias)
43 end
44   simgrid.info("Master: Everything's done.");
45 end
46
47 -- end_of_master