Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kinda working again: only a segfault at termination
[simgrid.git] / examples / commTime / Master.java
1 /*
2  * Master of a basic master/slave example in Java
3  *
4  * Copyright 2006,2007,2010 The SimGrid Team. All rights reserved. 
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. 
8  */
9
10 import simgrid.msg.*;
11
12 public class Master extends simgrid.msg.Process {
13    public void main(String[] args) throws MsgException {
14       if (args.length < 4) {
15          Msg.info("Master needs 4 arguments");
16          System.exit(1);
17       }
18       
19       int tasksCount = Integer.valueOf(args[0]).intValue();             
20       double taskComputeSize = Double.valueOf(args[1]).doubleValue();           
21       double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
22       
23       int slavesCount = Integer.valueOf(args[3]).intValue();
24       
25       Msg.info("Hello! Got "+  slavesCount + " slaves and "+tasksCount+" tasks to process");
26       
27       for (int i = 0; i < tasksCount; i++) {
28          Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize);
29          if (i%1000==0)
30            Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
31          task.send("slave_"+(i%slavesCount));
32       }
33       
34       Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
35       
36       for (int i = 0; i < slavesCount; i++) {
37          FinalizeTask task = new FinalizeTask();
38          task.send("slave_"+(i%slavesCount));
39       }
40       
41       Msg.info("Goodbye now!");
42     }
43 }