4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package.
13 public class Master extends simgrid.msg.Process {
15 public void main(String[] args) throws JniException, NativeException {
17 Msg.info("Hello i'm the master");
19 int numberoftasks = Integer.valueOf(args[0]).intValue();
20 double taskComputeSize = Double.valueOf(args[1]).doubleValue();
21 double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
23 int slavecount = args.length - 3;
24 Host[] slaves = new Host[slavecount] ;
26 for (int i = 3; i < args.length; i++) {
28 slaves[i-3] = Host.getByName(args[i]);
29 } catch(HostNotFoundException e) {
30 Msg.info(e.toString());
31 Msg.info("Unknown host " + args[i] +". Stopping Now! " );
36 Msg.info("Got " + slavecount + " slave(s):");
37 for (int i = 0; i < slavecount; i++)
38 Msg.info("\t " + slaves[i].getName());
40 Msg.info("Got "+numberoftasks+" task(s) to process.");
42 for (int i = 0; i < numberoftasks; i++) {
43 CommTimeTask task = new CommTimeTask("Task_" + i ,taskComputeSize,taskCommunicateSize);
44 task.setTime(Msg.getClock());
45 slaves[i % slavecount].put(0,task);
47 // Msg.info("Send completed for the task " + task.getName() + " on the host " + slaves[i % slavecount].getName() + " [" + (i % slavecount) + "]");
50 Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
52 for (int i = 0; i < slavecount; i++) {
54 Msg.info("Finalize host " + slaves[i].getName() + " [" + i + "]");
55 slaves[i].put(0, new FinalizeTask());
58 Msg.info("All finalize messages have been dispatched. Goodbye now!");