X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d947ff7466b473eeec602007934f8336a9b17f3c..767d7bdbc801f6ec69833f72c66ae1975dc8c754:/examples/lua/console/master.lua diff --git a/examples/lua/console/master.lua b/examples/lua/console/master.lua index 2ce311816e..379a79a326 100644 --- a/examples/lua/console/master.lua +++ b/examples/lua/console/master.lua @@ -1,26 +1,32 @@ +-- Copyright (c) 2011, 2013-2014. The SimGrid Team. +-- All rights reserved. + +-- This program is free software; you can redistribute it and/or modify it +-- under the terms of the license (GNU LGPL) which comes with this package. + --Master Function -function Master(...) +function Master(...) - if #arg ~= 4 then - error("Wrong number of arguments (got " .. #arg .. - ", expected 4: nb_tasks comp_size comm_size slave_count)") + if select("#", ...) ~= 4 then + error("Wrong number of arguments (got " .. select("#", ...) .. + ", 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 + for i,v in ipairs({...}) do simgrid.info("Got " .. v) end - local nb_task, comp_size, comm_size, slave_count = unpack(arg) + local nb_task, comp_size, comm_size, slave_count = select(1, ...) - simgrid.info("Argc=" .. (#arg) .. " (should be 4)") + simgrid.info("Argc=" .. select("#", ...) .. " (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); + alias = "slave " .. string.format("%d",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 .. "'");