1 -- Copyright (c) 2011-2012, 2014. The SimGrid Team.
2 -- All rights reserved.
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.
10 error("Wrong number of arguments (got " .. #arg ..
11 ", expected 4: nb_tasks comp_size comm_size slave_count)")
14 simgrid.info("Hello from lua, I'm the master")
16 local nb_task, comp_size, comm_size, slave_count = unpack(arg)
21 local task = simgrid.task.new("Task " .. i, comp_size, comm_size)
22 local task_name = task:get_name()
23 local alias = "slave " .. (i % slave_count)
24 simgrid.info("Sending '" .. task_name .. "' to '" .. alias .."'")
25 task:send(alias) -- C user data set to NULL
26 simgrid.info("Done sending '".. task_name .. "' to '" .. alias .."'")
29 -- Sending Finalize Message To Others
31 simgrid.info("All tasks have been dispatched. Let's tell everybody the computation is over.")
32 for i = 0, slave_count - 1 do
33 local alias = "slave " .. i
34 simgrid.info("Sending finalize to '" .. alias .. "'")
35 local finalize = simgrid.task.new("finalize", comp_size, comm_size)
38 simgrid.info("Everything's done.")