private Main() {
throw new IllegalAccessError("Utility class");
}
+ protected static final int TASK_COUNT = 3;
public static void main(String[] args) throws HostNotFoundException {
Msg.init(args);
-/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2017. 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. */
this.timeVal = 0;
}
- public PingPongTask(String name, double computeDuration, double messageSize) {
+ public PingPongTask(String name, double computeDuration, double messageSize, double timeVal) {
super(name,computeDuration,messageSize);
- }
-
- public void setTime(double timeVal) {
- this.timeVal = timeVal;
+
+ this.timeVal = timeVal;
}
public double getTime() {
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2017. 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. */
import org.simgrid.msg.Task;
public class Receiver extends Process {
- private static final double COMM_SIZE_BW = 100000000;
- public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
- super(hostname, name, args);
- }
-
- public void main(String[] args) throws MsgException {
- Msg.info("hello!");
-
- Msg.info("try to get a task");
-
- PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
- double timeGot = Msg.getClock();
- double timeSent = task.getTime();
-
- Msg.info("Got at time "+ timeGot);
- Msg.info("Was sent at time "+timeSent);
- double time = timeSent;
-
- double communicationTime = timeGot - time;
- Msg.info("Communication time : " + communicationTime);
- Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
- Msg.info("goodbye!");
- }
+ private static final double COMM_SIZE_BW = 100000000;
+ public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
+ super(hostname, name, args);
+ }
+
+ public void main(String[] args) throws MsgException {
+ for (int i = 0 ; i<Main.TASK_COUNT; i++) {
+ Msg.info("Wait for a task");
+
+ PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
+ double timeGot = Msg.getClock();
+ double timeSent = task.getTime();
+
+ Msg.info("Got one that was sent at time "+ timeSent);
+
+ double communicationTime = timeGot - timeSent;
+ Msg.info("Communication time : " + communicationTime);
+ Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
+ }
+ Msg.info("Done.");
+ }
}
\ No newline at end of file
- /* Copyright (c) 2006-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2017. 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. */
import org.simgrid.msg.Process;
public class Sender extends Process {
- private static final double COMM_SIZE_LAT = 1;
+ private static final double COMM_SIZE_LAT = 1;
- public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
- super(hostname,name,args);
- }
+ public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
+ super(hostname,name,args);
+ }
- public void main(String[] args) throws MsgException {
- Msg.info("hello!");
+ public void main(String[] args) throws MsgException {
+ Msg.info("Host count: " + args.length);
- int hostCount = args.length;
+ for (int i = 0 ; i<Main.TASK_COUNT; i++) {
- Msg.info("host count: " + hostCount);
- String[] mailboxes = new String[hostCount];
- double time;
- double computeDuration = 0;
- PingPongTask task;
+ for(int pos = 0; pos < args.length ; pos++) {
+ String hostname = Host.getByName(args[pos]).getName(); // Make sure that this host exists
- for(int pos = 0; pos < args.length ; pos++) {
- try {
- mailboxes[pos] = Host.getByName(args[pos]).getName();
- } catch (HostNotFoundException e) {
- e.printStackTrace();
- Msg.info("Invalid deployment file: " + e.toString());
- }
- }
+ double time = Msg.getClock();
+ Msg.info("sender time: " + time);
- for (int pos = 0; pos < hostCount; pos++) {
- time = Msg.getClock();
-
- Msg.info("sender time: " + time);
-
- task = new PingPongTask("no name",computeDuration,COMM_SIZE_LAT);
- task.setTime(time);
-
- task.send(mailboxes[pos]);
- }
-
- Msg.info("goodbye!");
- }
+ PingPongTask task = new PingPongTask("no name", /* Duration: 0 flops */ 0, COMM_SIZE_LAT, time);
+ task.send(hostname);
+ }
+ }
+ Msg.info("Done.");
+ }
}
\ No newline at end of file
#! tesh
-! output sort 19
-
$ java -classpath ${classpath:=.} app/pingpong/Main ${srcdir:=.}/../platforms/small_platform.xml
> [0.000000] [java/INFO] Using regular java threads.
-> [1.048882] [java/INFO] MSG_main finished; Cleaning up the simulation...
-> [Boivin:Receiver:(2) 0.000000] [java/INFO] hello!
-> [Boivin:Receiver:(2) 0.000000] [java/INFO] try to get a task
-> [Boivin:Receiver:(2) 1.048882] [java/INFO] Got at time 1.0488818628325232
-> [Boivin:Receiver:(2) 1.048882] [java/INFO] Was sent at time 0.0
+> [Jacquelin:Sender:(1) 0.000000] [java/INFO] Host count: 1
+> [Jacquelin:Sender:(1) 0.000000] [java/INFO] sender time: 0.0
+> [Boivin:Receiver:(2) 0.000000] [java/INFO] Wait for a task
+> [Boivin:Receiver:(2) 1.048882] [java/INFO] Got one that was sent at time 0.0
> [Boivin:Receiver:(2) 1.048882] [java/INFO] Communication time : 1.0488818628325232
> [Boivin:Receiver:(2) 1.048882] [java/INFO] --- bw 9.533962169004269E7 ----
-> [Boivin:Receiver:(2) 1.048882] [java/INFO] goodbye!
-> [Jacquelin:Sender:(1) 0.000000] [java/INFO] hello!
-> [Jacquelin:Sender:(1) 0.000000] [java/INFO] host count: 1
-> [Jacquelin:Sender:(1) 0.000000] [java/INFO] sender time: 0.0
-> [Jacquelin:Sender:(1) 1.048882] [java/INFO] goodbye!
+> [Boivin:Receiver:(2) 1.048882] [java/INFO] Wait for a task
+> [Jacquelin:Sender:(1) 1.048882] [java/INFO] sender time: 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Got one that was sent at time 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Communication time : 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] --- bw 9.533962169004269E7 ----
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Wait for a task
+> [Jacquelin:Sender:(1) 2.097764] [java/INFO] sender time: 2.0977637256650463
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Got one that was sent at time 2.0977637256650463
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Communication time : 1.0488818628325234
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] --- bw 9.533962169004266E7 ----
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Done.
+> [Jacquelin:Sender:(1) 3.146646] [java/INFO] Done.
+> [3.146646] [java/INFO] MSG_main finished; Cleaning up the simulation...
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. 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. */
class Main {
public static final double TASK_COMP_SIZE = 10;
public static final double TASK_COMM_SIZE = 10;
- public static final int NHOSTS = 2;
+ public static final int NHOSTS = 6;
private Main() {
throw new IllegalAccessError("Utility class");
+ hosts.length + " hosts");
System.exit(42);
}
- Msg.info("Start "+ NHOSTS +" hosts");
new Master(hosts[0],"Master",hosts).start();
+
/* Execute the simulation */
Msg.run();
}
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. 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. */
import org.simgrid.msg.Task;
import org.simgrid.msg.VM;
-//import eu.plumbr.api.Plumbr;
-
public class Master extends Process {
private Host[] hosts;
public void main(String[] args) throws MsgException {
int workersCount = Main.NHOSTS;
- for (int step = 1; step <= 1/*00000*/ ; step++) {
- //Plumbr.startTransaction("Migration");
+ for (int step = 1; step <= 50 ; step++) {
ArrayList<VM> vms = new ArrayList<>();
// Create one VM per host and bind a process inside each one.
for (int i = 0; i < workersCount; i++) {
Msg.info("Launched " + vms.size() + " VMs");
- Msg.info("Send a first batch of work to everyone");
+ Msg.info("Send some work to everyone");
workBatch(workersCount,"WK:"+step+":");
Msg.info("Suspend all VMs, wait a while, resume them, migrate them and shut them down.");
- for (int i = 0; i < vms.size(); i++) {
- Msg.verb("Suspend "+vms.get(i).getName());
- vms.get(i).suspend();
+ for (VM vm : vms) {
+ Msg.verb("Suspend "+vm.getName());
+ vm.suspend();
}
- Msg.verb("Wait a while");
+ Msg.verb("Wait a while, and resume all VMs.");
waitFor(2);
-
- Msg.verb("Resume all VMs.");
- for (int i = 0; i < vms.size(); i++) {
- vms.get(i).resume();
- }
+ for (VM vm : vms)
+ vm.resume();
+
Msg.verb("Sleep long enough for everyone to be done with previous batch of work");
waitFor(1000*step - Msg.getClock());
vms.get(i).migrate(hosts[3]);
}
- Msg.verb("Let's shut down the simulation and kill everyone.");
+ Msg.verb("Let's kill everyone.");
- for (int i = 0; i < vms.size(); i++) {
- vms.get(i).destroy();
- }
+ for (VM vm : vms)
+ vm.destroy();
Msg.info("XXXXXXXXXXXXXXX Step "+step+" done.");
-// Plumbr.endTransaction();
}
}
-/* Copyright (c) 2012-2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. 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. */
public void main(String[] args) throws MsgException {
Msg.verb(this.getName() +" is listening on "+ getName());
while(true) {
- Task task =null;
+ Task task = null;
try {
task = Task.receive(getName());
- if (task == null)
- break;
} catch (MsgException e) {
- Msg.debug("Received failed. I'm done. See you!");
+ Msg.info("Received failed. I'm done. See you!");
+ exit();
}
- Msg.verb("Received \"" + task.getName() + "\". Processing it.");
+ Msg.verb("Received '" + task.getName() + "'. Processing it.");
task.execute();
- Msg.verb(this.getName() +" executed task (" + task.getName()+")");
+ Msg.verb("Done executing task '" + task.getName() +"'");
}
}
}
#! tesh
-! output sort 19
-
-$ java -classpath ${classpath:=.} cloud/masterworker/Main ${srcdir:=.}/../platforms/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=java.thres:verbose
+$ java -classpath ${classpath:=.} cloud/masterworker/Main ${srcdir:=.}/../platforms/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Using regular java threads.
-> [ 0.000000] (0:maestro@) Start 2 hosts
-> [ 0.000000] (1:Master@Boivin) create VM0-s1-0
-> [ 0.000000] (1:Master@Boivin) Put Worker WK:1:0 on VM0-s1-0
-> [ 0.000000] (2:WK:1:0@VM0-s1-0) WK:1:0 is listening on WK:1:0
-> [ 0.000000] (1:Master@Boivin) create VM0-s1-1
-> [ 0.000000] (1:Master@Boivin) Put Worker WK:1:1 on VM0-s1-1
-> [ 0.000000] (3:WK:1:1@VM0-s1-1) WK:1:1 is listening on WK:1:1
-> [ 0.000000] (1:Master@Boivin) Launched 2 VMs
-> [ 0.000000] (1:Master@Boivin) Send a first batch of work to everyone
-> [ 0.000000] (1:Master@Boivin) Sending to WK:1:0
-> [ 0.090194] (2:WK:1:0@VM0-s1-0) Received "Task WK:1:0". Processing it.
-> [ 0.090194] (1:Master@Boivin) Sending to WK:1:1
-> [ 0.090194] (2:WK:1:0@VM0-s1-0) WK:1:0 executed task (Task WK:1:0)
-> [ 0.754233] (3:WK:1:1@VM0-s1-1) Received "Task WK:1:1". Processing it.
-> [ 0.754233] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
-> [ 0.754233] (1:Master@Boivin) Suspend VM0-s1-0
-> [ 0.754233] (1:Master@Boivin) Suspend VM0-s1-1
-> [ 0.754233] (1:Master@Boivin) Wait a while
-> [ 2.754233] (1:Master@Boivin) Resume all VMs.
-> [ 2.754233] (1:Master@Boivin) Sleep long enough for everyone to be done with previous batch of work
-> [ 2.754234] (3:WK:1:1@VM0-s1-1) WK:1:1 executed task (Task WK:1:1)
-> [1000.000000] (1:Master@Boivin) Migrate everyone to Ginette
-> [1000.000000] (1:Master@Boivin) Migrate VM0-s1-0 from Bourassato Ginette
-> [1100.157755] (1:Master@Boivin) Migrate VM0-s1-1 from Fafardto Ginette
-> [1242.754111] (1:Master@Boivin) Let's shut down the simulation and kill everyone.
-> [1242.754111] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 1 done.
-> [1242.754111] (0:maestro@) MSG_main finished; Cleaning up the simulation...
+> [ 0.000000] (1:Master@Boivin) Launched 6 VMs
+> [ 0.000000] (1:Master@Boivin) Send some work to everyone
+> [ 2.186532] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [1971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 1 done.
+> [1971.662691] (1:Master@Boivin) Launched 6 VMs
+> [1971.662691] (1:Master@Boivin) Send some work to everyone
+> [1973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [2971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 2 done.
+> [2971.662691] (1:Master@Boivin) Launched 6 VMs
+> [2971.662691] (1:Master@Boivin) Send some work to everyone
+> [2973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [3971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 3 done.
+> [3971.662691] (1:Master@Boivin) Launched 6 VMs
+> [3971.662691] (1:Master@Boivin) Send some work to everyone
+> [3973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [4971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 4 done.
+> [4971.662691] (1:Master@Boivin) Launched 6 VMs
+> [4971.662691] (1:Master@Boivin) Send some work to everyone
+> [4973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [5971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 5 done.
+> [5971.662691] (1:Master@Boivin) Launched 6 VMs
+> [5971.662691] (1:Master@Boivin) Send some work to everyone
+> [5973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [6971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 6 done.
+> [6971.662691] (1:Master@Boivin) Launched 6 VMs
+> [6971.662691] (1:Master@Boivin) Send some work to everyone
+> [6973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [7971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 7 done.
+> [7971.662691] (1:Master@Boivin) Launched 6 VMs
+> [7971.662691] (1:Master@Boivin) Send some work to everyone
+> [7973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [8971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 8 done.
+> [8971.662691] (1:Master@Boivin) Launched 6 VMs
+> [8971.662691] (1:Master@Boivin) Send some work to everyone
+> [8973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [9971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 9 done.
+> [9971.662691] (1:Master@Boivin) Launched 6 VMs
+> [9971.662691] (1:Master@Boivin) Send some work to everyone
+> [9973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [10971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 10 done.
+> [10971.662691] (1:Master@Boivin) Launched 6 VMs
+> [10971.662691] (1:Master@Boivin) Send some work to everyone
+> [10973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [11971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 11 done.
+> [11971.662691] (1:Master@Boivin) Launched 6 VMs
+> [11971.662691] (1:Master@Boivin) Send some work to everyone
+> [11973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [12971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 12 done.
+> [12971.662691] (1:Master@Boivin) Launched 6 VMs
+> [12971.662691] (1:Master@Boivin) Send some work to everyone
+> [12973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [13971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 13 done.
+> [13971.662691] (1:Master@Boivin) Launched 6 VMs
+> [13971.662691] (1:Master@Boivin) Send some work to everyone
+> [13973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [14971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 14 done.
+> [14971.662691] (1:Master@Boivin) Launched 6 VMs
+> [14971.662691] (1:Master@Boivin) Send some work to everyone
+> [14973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [15971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 15 done.
+> [15971.662691] (1:Master@Boivin) Launched 6 VMs
+> [15971.662691] (1:Master@Boivin) Send some work to everyone
+> [15973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [16971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 16 done.
+> [16971.662691] (1:Master@Boivin) Launched 6 VMs
+> [16971.662691] (1:Master@Boivin) Send some work to everyone
+> [16973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [17971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 17 done.
+> [17971.662691] (1:Master@Boivin) Launched 6 VMs
+> [17971.662691] (1:Master@Boivin) Send some work to everyone
+> [17973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [18971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 18 done.
+> [18971.662691] (1:Master@Boivin) Launched 6 VMs
+> [18971.662691] (1:Master@Boivin) Send some work to everyone
+> [18973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [19971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 19 done.
+> [19971.662691] (1:Master@Boivin) Launched 6 VMs
+> [19971.662691] (1:Master@Boivin) Send some work to everyone
+> [19973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [20971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 20 done.
+> [20971.662691] (1:Master@Boivin) Launched 6 VMs
+> [20971.662691] (1:Master@Boivin) Send some work to everyone
+> [20973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [21971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 21 done.
+> [21971.662691] (1:Master@Boivin) Launched 6 VMs
+> [21971.662691] (1:Master@Boivin) Send some work to everyone
+> [21973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [22971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 22 done.
+> [22971.662691] (1:Master@Boivin) Launched 6 VMs
+> [22971.662691] (1:Master@Boivin) Send some work to everyone
+> [22973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [23971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 23 done.
+> [23971.662691] (1:Master@Boivin) Launched 6 VMs
+> [23971.662691] (1:Master@Boivin) Send some work to everyone
+> [23973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [24971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 24 done.
+> [24971.662691] (1:Master@Boivin) Launched 6 VMs
+> [24971.662691] (1:Master@Boivin) Send some work to everyone
+> [24973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [25971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 25 done.
+> [25971.662691] (1:Master@Boivin) Launched 6 VMs
+> [25971.662691] (1:Master@Boivin) Send some work to everyone
+> [25973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [26971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 26 done.
+> [26971.662691] (1:Master@Boivin) Launched 6 VMs
+> [26971.662691] (1:Master@Boivin) Send some work to everyone
+> [26973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [27971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 27 done.
+> [27971.662691] (1:Master@Boivin) Launched 6 VMs
+> [27971.662691] (1:Master@Boivin) Send some work to everyone
+> [27973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [28971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 28 done.
+> [28971.662691] (1:Master@Boivin) Launched 6 VMs
+> [28971.662691] (1:Master@Boivin) Send some work to everyone
+> [28973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [29971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 29 done.
+> [29971.662691] (1:Master@Boivin) Launched 6 VMs
+> [29971.662691] (1:Master@Boivin) Send some work to everyone
+> [29973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [30971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 30 done.
+> [30971.662691] (1:Master@Boivin) Launched 6 VMs
+> [30971.662691] (1:Master@Boivin) Send some work to everyone
+> [30973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [31971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 31 done.
+> [31971.662691] (1:Master@Boivin) Launched 6 VMs
+> [31971.662691] (1:Master@Boivin) Send some work to everyone
+> [31973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [32971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 32 done.
+> [32971.662691] (1:Master@Boivin) Launched 6 VMs
+> [32971.662691] (1:Master@Boivin) Send some work to everyone
+> [32973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [33971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 33 done.
+> [33971.662691] (1:Master@Boivin) Launched 6 VMs
+> [33971.662691] (1:Master@Boivin) Send some work to everyone
+> [33973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [34971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 34 done.
+> [34971.662691] (1:Master@Boivin) Launched 6 VMs
+> [34971.662691] (1:Master@Boivin) Send some work to everyone
+> [34973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [35971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 35 done.
+> [35971.662691] (1:Master@Boivin) Launched 6 VMs
+> [35971.662691] (1:Master@Boivin) Send some work to everyone
+> [35973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [36971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 36 done.
+> [36971.662691] (1:Master@Boivin) Launched 6 VMs
+> [36971.662691] (1:Master@Boivin) Send some work to everyone
+> [36973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [37971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 37 done.
+> [37971.662691] (1:Master@Boivin) Launched 6 VMs
+> [37971.662691] (1:Master@Boivin) Send some work to everyone
+> [37973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [38971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 38 done.
+> [38971.662691] (1:Master@Boivin) Launched 6 VMs
+> [38971.662691] (1:Master@Boivin) Send some work to everyone
+> [38973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [39971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 39 done.
+> [39971.662691] (1:Master@Boivin) Launched 6 VMs
+> [39971.662691] (1:Master@Boivin) Send some work to everyone
+> [39973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [40971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 40 done.
+> [40971.662691] (1:Master@Boivin) Launched 6 VMs
+> [40971.662691] (1:Master@Boivin) Send some work to everyone
+> [40973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [41971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 41 done.
+> [41971.662691] (1:Master@Boivin) Launched 6 VMs
+> [41971.662691] (1:Master@Boivin) Send some work to everyone
+> [41973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [42971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 42 done.
+> [42971.662691] (1:Master@Boivin) Launched 6 VMs
+> [42971.662691] (1:Master@Boivin) Send some work to everyone
+> [42973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [43971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 43 done.
+> [43971.662691] (1:Master@Boivin) Launched 6 VMs
+> [43971.662691] (1:Master@Boivin) Send some work to everyone
+> [43973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [44971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 44 done.
+> [44971.662691] (1:Master@Boivin) Launched 6 VMs
+> [44971.662691] (1:Master@Boivin) Send some work to everyone
+> [44973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [45971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 45 done.
+> [45971.662691] (1:Master@Boivin) Launched 6 VMs
+> [45971.662691] (1:Master@Boivin) Send some work to everyone
+> [45973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [46971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 46 done.
+> [46971.662691] (1:Master@Boivin) Launched 6 VMs
+> [46971.662691] (1:Master@Boivin) Send some work to everyone
+> [46973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [47971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 47 done.
+> [47971.662691] (1:Master@Boivin) Launched 6 VMs
+> [47971.662691] (1:Master@Boivin) Send some work to everyone
+> [47973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [48971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 48 done.
+> [48971.662691] (1:Master@Boivin) Launched 6 VMs
+> [48971.662691] (1:Master@Boivin) Send some work to everyone
+> [48973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [49971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 49 done.
+> [49971.662691] (1:Master@Boivin) Launched 6 VMs
+> [49971.662691] (1:Master@Boivin) Send some work to everyone
+> [49973.849223] (1:Master@Boivin) Suspend all VMs, wait a while, resume them, migrate them and shut them down.
+> [50971.662691] (1:Master@Boivin) XXXXXXXXXXXXXXX Step 50 done.
+> [50971.662691] (0:maestro@) MSG_main finished; Cleaning up the simulation...
-/* Copyright (c) 2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2014-2017. 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. */
}
public void main(String[] strings) throws MsgException {
- Host host0 = null;
- Host host1 = null;
- try {
- /* get hosts 1 and 2*/
- host0 = Host.getByName("PM0");
- host1 = Host.getByName("PM1");
- }catch (HostNotFoundException e) {
- e.printStackTrace();
- }
+ Host host0 = Host.getByName("PM0");
+ Host host1 = Host.getByName("PM1");
List<VM> vms = new ArrayList<>();
vm1.start();
/* Collocated VMs */
- int collocatedSrc = 6;
int[] vmSrcLoad = {
80,
0,
};
XVM tmp;
- for (int i=1 ; i<= collocatedSrc ; i++){
+ for (int i=1 ; i<= vmSrcLoad.length ; i++){
tmp = new XVM(host0, "vm"+i,
2048, // Ramsize,
125, // Net bandwidth,
80,
};
- for (int i=1 ; i <= collocatedDst ; i++){
- tmp = new XVM(host1, "vm"+(i+collocatedSrc),
+ for (int i=1 ; i <= vmDstLoad.length ; i++){
+ tmp = new XVM(host1, "vm"+(i+vmSrcLoad.length),
2048, // Ramsize,
125, // Net bandwidth,
dpRate // Memory intensity
~xbt_ex() override;
/** Category (what went wrong) */
- xbt_errcat_t category;
+ xbt_errcat_t category = unknown_error;
/** Why did it went wrong */
- int value;
+ int value = 0;
};
/* 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. */
-#include <functional>
-#include <utility>
-
#include "JavaContext.hpp"
#include "jxbt_utilities.h"
#include "src/simix/smx_private.h"
#include "xbt/ex.hpp"
+#include <functional>
+#include <utility>
+
extern "C" JavaVM* __java_vm;
XBT_LOG_NEW_DEFAULT_CATEGORY(java, "MSG for Java(TM)");
// (as the ones created for the VM migration). The Java exception will not be catched anywhere.
// Bad things happen currently if these actors get killed, unfortunately.
jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError",
- bprintf("Process %s killed from file JavaContext.cpp)", this->process()->name.c_str()));
+ std::string("Process ") + this->process()->cname() + " killed from file JavaContext.cpp");
// (remember that throwing a java exception from C does not break the C execution path.
// Instead, it marks the exception to be raised when returning to the Java world and
env->SetLongField(jprocess, jprocess_field_Process_bind, (intptr_t)process);
}
-jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
-{
- jstring jname = (jstring) env->GetObjectField(jprocess, jprocess_field_Process_name);
- return (jstring) env->NewGlobalRef(jname);
-}
-
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls) {
jclass jprocess_class_Process = env->FindClass("org/simgrid/msg/Process");
xbt_assert(jprocess_class_Process, "Native initialization of msg/Process failed. Please report that bug");
jobject jprocess = jprocess_ref(jprocess_arg, env);
/* Actually build the MSG process */
- jstring jname = jprocess_get_name(jprocess_arg, env);
+ jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
const char* name = env->GetStringUTFChars(jname, 0);
msg_process_t process = MSG_process_create_from_stdfunc(
name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
/*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
-
env->ReleaseStringUTFChars(jname, name);
+
/* bind the java process instance to the native process */
jprocess_bind(jprocess, process, env);
const char *name = env->GetStringUTFChars((jstring)jname, 0);
const char *property = MSG_process_get_property_value(process, name);
- if (!property) {
+ if (!property)
return nullptr;
- }
jobject jproperty = env->NewStringUTF(property);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls)
{
- msg_process_t process = MSG_process_self();
- jobject jprocess;
-
- if (!process) {
- jxbt_throw_jni(env, xbt_strdup("MSG_process_self() failed"));
- return nullptr;
- }
-
- jprocess = jprocess_from_native(process);
-
+ jobject jprocess = jprocess_from_native(MSG_process_self());
if (!jprocess)
jxbt_throw_jni(env, xbt_strdup("SIMIX_process_get_jprocess() failed"));
}
/* try to resume the process */
- msg_error_t rv = MSG_process_resume(process);
-
- jxbt_check_res("MSG_process_resume()", rv, MSG_OK, bprintf("unexpected error , please report this bug"));
+ msg_error_t res = MSG_process_resume(process);
+ jxbt_check_res("MSG_process_resume()", res, MSG_OK, bprintf("unexpected error , please report this bug"));
}
+
JNIEXPORT void
JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
- msg_process_t process = jprocess_to_native(jprocess, env);
- xbt_ex_t e;
-
- int auto_restart = jauto_restart == JNI_TRUE ? 1 : 0;
+ msg_process_t process = jprocess_to_native(jprocess, env);
if (!process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
- try {
- MSG_process_auto_restart_set(process,auto_restart);
- }
- catch (xbt_ex& e) {
- // Nothing to do
- }
+ MSG_process_auto_restart_set(process, (jauto_restart == JNI_TRUE));
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobject jprocess) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
-
try {
MSG_process_kill(process);
} catch (xbt_ex& ex) {
- XBT_VERB("This process just killed itself.");
+ XBT_VERB("Process %s just committed a suicide", MSG_process_get_name(process));
+ xbt_assert(process == MSG_process_self(),
+ "Killing a process should not raise an exception if it's not a suicide. Please report that bug.");
}
}
/** Extract the native instance from the java one */
msg_process_t jprocess_to_native(jobject jprocess, JNIEnv* env);
-/** Get the name of a java instance. */
-jstring jprocess_get_name(jobject jprocess, JNIEnv* env);
-
/** Initialize the native world, called from the Java world at startup */
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jtask, jstring jname,
jdouble jflopsAmount, jdouble jbytesAmount)
{
- msg_task_t task; /* the native task to create */
const char *name = nullptr; /* the name of the task */
- if (jflopsAmount < 0) {
- jxbt_throw_illegal(env, bprintf("Task flopsAmount (%f) cannot be negative", static_cast<double>(jflopsAmount)));
- return;
- }
-
- if (jbytesAmount < 0) {
- jxbt_throw_illegal(env, bprintf("Task bytesAmount (%f) cannot be negative", static_cast<double>(jbytesAmount)));
- return;
- }
-
- if (jname) {
- /* get the C string from the java string */
+ if (jname)
name = env->GetStringUTFChars(jname, 0);
- }
-
- /* create the task */
- task = MSG_task_create(name, static_cast<double>(jflopsAmount), static_cast<double>(jbytesAmount), nullptr);
+ msg_task_t task = MSG_task_create(name, static_cast<double>(jflopsAmount), static_cast<double>(jbytesAmount), jtask);
if (jname)
env->ReleaseStringUTFChars(jname, name);
- /* sets the task name */
- env->SetObjectField(jtask, jtask_field_Task_name, jname);
+
/* bind & store the task */
jtask_bind(jtask, task, env);
- MSG_task_set_data(task, jtask);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jobject jtask, jstring jname,
jobjectArray jhosts, jdoubleArray jcomputeDurations_arg,
jdoubleArray jmessageSizes_arg)
{
- msg_task_t task; /* the native parallel task to create */
- const char *name; /* the name of the task */
- int host_count;
- msg_host_t *hosts;
- double *computeDurations;
- double *messageSizes;
- jdouble *jcomputeDurations;
- jdouble *jmessageSizes;
- jobject jhost;
- int index;
-
- if (!jcomputeDurations_arg) {
- jxbt_throw_null(env, xbt_strdup("Parallel task flops amounts cannot be null"));
- return;
- }
-
- if (!jmessageSizes_arg) {
- jxbt_throw_null(env, xbt_strdup("Parallel task bytes amounts cannot be null"));
- return;
- }
-
- if (!jname) {
- jxbt_throw_null(env, xbt_strdup("Parallel task name cannot be null"));
- return;
- }
-
- host_count = static_cast<int>(env->GetArrayLength(jhosts));
-
- hosts = xbt_new0(msg_host_t, host_count);
- computeDurations = xbt_new0(double, host_count);
- messageSizes = xbt_new0(double, host_count * host_count);
+ int host_count = static_cast<int>(env->GetArrayLength(jhosts));
- jcomputeDurations = env->GetDoubleArrayElements(jcomputeDurations_arg, 0);
- jmessageSizes = env->GetDoubleArrayElements(jmessageSizes_arg, 0);
-
- for (index = 0; index < host_count; index++) {
- jhost = env->GetObjectArrayElement(jhosts, index);
+ jdouble* jcomputeDurations = env->GetDoubleArrayElements(jcomputeDurations_arg, 0);
+ msg_host_t* hosts = xbt_new0(msg_host_t, host_count);
+ double* computeDurations = xbt_new0(double, host_count);
+ for (int index = 0; index < host_count; index++) {
+ jobject jhost = env->GetObjectArrayElement(jhosts, index);
hosts[index] = jhost_get_native(env, jhost);
computeDurations[index] = jcomputeDurations[index];
}
- for (index = 0; index < host_count * host_count; index++) {
+ env->ReleaseDoubleArrayElements(jcomputeDurations_arg, jcomputeDurations, 0);
+
+ jdouble* jmessageSizes = env->GetDoubleArrayElements(jmessageSizes_arg, 0);
+ double* messageSizes = xbt_new0(double, host_count* host_count);
+ for (int index = 0; index < host_count * host_count; index++) {
messageSizes[index] = jmessageSizes[index];
}
-
- env->ReleaseDoubleArrayElements(jcomputeDurations_arg, jcomputeDurations, 0);
env->ReleaseDoubleArrayElements(jmessageSizes_arg, jmessageSizes, 0);
/* get the C string from the java string */
- name = env->GetStringUTFChars(jname, 0);
-
- task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, nullptr);
-
+ const char* name = env->GetStringUTFChars(jname, 0);
+ msg_task_t task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, jtask);
env->ReleaseStringUTFChars(jname, name);
- /* sets the task name */
- env->SetObjectField(jtask, jtask_field_Task_name, jname);
+
/* associate the java task object and the native task */
jtask_bind(jtask, task, env);
-
- MSG_task_set_data(task, (void *) jtask);
-
- if (!MSG_task_get_data(task))
- jxbt_throw_jni(env, "global ref allocation failed");
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_cancel(JNIEnv * env, jobject jtask)
MSG_task_set_bytes_amount(task, static_cast<double>(dataSize));
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_send(JNIEnv * env,jobject jtask, jstring jalias, jdouble jtimeout)
-{
- msg_error_t rv;
- const char *alias = env->GetStringUTFChars(jalias, 0);
-
- msg_task_t task = jtask_to_native(jtask, env);
-
- if (!task) {
- env->ReleaseStringUTFChars(jalias, alias);
- jxbt_throw_notbound(env, "task", jtask);
- return;
- }
-
- /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
- MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
- rv = MSG_task_send_with_timeout(task, alias, static_cast<double>(jtimeout));
- env->ReleaseStringUTFChars(jalias, alias);
-
- if (rv != MSG_OK) {
- jmsg_throw_status(env, rv);
- }
-}
-
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobject jtask, jstring jalias,
jdouble jtimeout,jdouble maxrate)
{
- msg_error_t rv;
- const char *alias = env->GetStringUTFChars(jalias, 0);
-
msg_task_t task = jtask_to_native(jtask, env);
-
if (!task) {
- env->ReleaseStringUTFChars(jalias, alias);
jxbt_throw_notbound(env, "task", jtask);
return;
}
- /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
+ /* Add a global ref into the Ctask so that the receiver can use it */
MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
- rv = MSG_task_send_with_timeout_bounded(task, alias, static_cast<double>(jtimeout), static_cast<double>(maxrate));
+
+ const char* alias = env->GetStringUTFChars(jalias, 0);
+ msg_error_t res =
+ MSG_task_send_with_timeout_bounded(task, alias, static_cast<double>(jtimeout), static_cast<double>(maxrate));
env->ReleaseStringUTFChars(jalias, alias);
- if (rv != MSG_OK) {
- jmsg_throw_status(env, rv);
- }
+ if (res != MSG_OK)
+ jmsg_throw_status(env, res);
}
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls, jstring jalias, jdouble jtimeout,
- jobject jhost)
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass cls, jstring jalias, jdouble jtimeout)
{
msg_task_t task = nullptr;
- msg_host_t host = nullptr;
-
- if (jhost) {
- host = jhost_get_native(env, jhost);
-
- if (!host) {
- jxbt_throw_notbound(env, "host", jhost);
- return nullptr;
- }
- }
const char *alias = env->GetStringUTFChars(jalias, 0);
- msg_error_t rv = MSG_task_receive_ext(&task, alias, (double) jtimeout, host);
+ msg_error_t rv = MSG_task_receive_ext(&task, alias, (double)jtimeout, /*host*/ nullptr);
env->ReleaseStringUTFChars(jalias, alias);
if (env->ExceptionOccurred())
return nullptr;
env->DeleteGlobalRef(jtask_global);
MSG_task_set_data(task, nullptr);
-
return (jobject) jtask_local;
}
return jcomm;
}
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv * env, jclass cls, jstring jalias,
- jdouble jtimeout, jobject jhost, jdouble rate)
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv* env, jclass cls, jstring jalias,
+ jdouble jtimeout, jdouble rate)
{
- msg_error_t rv;
- msg_task_t *task = xbt_new(msg_task_t,1);
- *task = nullptr;
-
- msg_host_t host = nullptr;
-
- if (jhost) {
- host = jhost_get_native(env, jhost);
-
- if (!host) {
- jxbt_throw_notbound(env, "host", jhost);
- return nullptr;
- }
- }
+ msg_task_t task = nullptr;
const char *alias = env->GetStringUTFChars(jalias, 0);
- rv = MSG_task_receive_ext_bounded(task, alias, static_cast<double>(jtimeout), host, static_cast<double>(rate));
+ msg_error_t res = MSG_task_receive_ext_bounded(&task, alias, static_cast<double>(jtimeout), /*host*/ nullptr,
+ static_cast<double>(rate));
if (env->ExceptionOccurred())
return nullptr;
- if (rv != MSG_OK) {
- jmsg_throw_status(env,rv);
+ if (res != MSG_OK) {
+ jmsg_throw_status(env, res);
return nullptr;
}
- jobject jtask_global = (jobject) MSG_task_get_data(*task);
+ jobject jtask_global = (jobject)MSG_task_get_data(task);
/* Convert the global ref into a local ref so that the JVM can free the stuff */
jobject jtask_local = env->NewLocalRef(jtask_global);
env->DeleteGlobalRef(jtask_global);
- MSG_task_set_data(*task, nullptr);
+ MSG_task_set_data(task, nullptr);
env->ReleaseStringUTFChars(jalias, alias);
- xbt_free(task);
-
return (jobject) jtask_local;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount(JNIEnv* env, jobject jtask, jdouble computationAmount);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount(JNIEnv* env, jobject jtask, jdouble dataSize);
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_send(JNIEnv* env, jobject jtask, jstring jalias, jdouble jtimeout);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv* env, jobject jtask, jstring jalias,
jdouble jtimeout, jdouble maxrate);
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass cls, jstring jalias, jdouble jtimeout,
- jobject jhost);
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass cls, jstring jalias, jdouble jtimeout);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv* env, jclass cls, jstring jmailbox);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv* env, jclass cls, jstring jalias,
- jdouble jtimeout, jobject jhost, jdouble rate);
+ jdouble jtimeout, jdouble rate);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv* env, jclass cls, jstring jmailbox,
jdouble rate);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv* env, jobject jtask, jstring jmailbox);
* This value has to be ≥ 0.
*/
public Task(String name, double flopsAmount, double bytesAmount) {
+ if (flopsAmount<0)
+ throw new IllegalArgumentException("Task flopsAmount (" + flopsAmount + ") cannot be negative");
+ if (bytesAmount<0)
+ throw new IllegalArgumentException("Task bytesAmount (" + bytesAmount + ") cannot be negative");
+
create(name, flopsAmount, bytesAmount);
+
+ this.name = name;
this.messageSize = bytesAmount;
}
/**
* the destination of the communications.
*/
public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) {
+ if (flopsAmount == null)
+ throw new NullPointerException("Parallel task flops amounts is null");
+ if (bytesAmount == null)
+ throw new NullPointerException("Parallel task bytes amounts is null");
+ if (hosts == null)
+ throw new NullPointerException("Host list is null");
+ if (name == null)
+ throw new NullPointerException("Parallel task name is null");
+
parallelCreate(name, hosts, flopsAmount, bytesAmount);
+ this.name = name;
}
/**
* @throws HostFailureException
* @throws TransferFailureException
*/
- public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
+ public void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
+ sendBounded(mailbox, timeout, -1);
+ }
/** Sends the task on the specified mailbox (capping the sending rate to \a maxrate)
*
* @throws TimeoutException
*/
public void sendBounded(String mailbox, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
- sendBounded(mailbox,-1,maxrate);
+ sendBounded(mailbox, -1, maxrate);
}
* @return a Comm handler
*/
public static native Comm irecv(String mailbox);
- /**
- * Retrieves next task from the mailbox identified by the specified name
- *
- * @param mailbox
- * @return a Task
- */
-
- public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
- return receive(mailbox, -1.0, null);
- }
-
- /**
- * Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
- *
- * @param mailbox
- * @param timeout
- * @return a Task
- */
- public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
- return receive(mailbox, timeout, null);
- }
/**
- * Retrieves next task sent by a given host on the mailbox identified by the specified alias
+ * Retrieves next task on the mailbox identified by the specified alias
*
* @param mailbox
- * @param host
* @return a Task
*/
- public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
- return receive(mailbox, -1.0, host);
+ public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
+ return receive(mailbox, -1.0);
}
/**
- * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
+ * Retrieves next task on the mailbox identified by the specified alias (wait at most \a timeout seconds)
*
* @param mailbox
* @param timeout
- * @param host
* @return a Task
*/
- public static native Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
+ public static native Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
/**
* Starts listening for receiving a task from an asynchronous communication with a capped rate
*/
public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
- return receiveBounded(mailbox, -1.0, null, rate);
+ return receiveBounded(mailbox, -1.0, rate);
}
/**
* @param timeout
* @return a Task
*/
- public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
- return receiveBounded(mailbox, timeout, null, rate);
- }
-
- /**
- * Retrieves next task sent by a given host on the mailbox identified by the specified alias with a capped rate
- *
- * @param mailbox
- * @param host
- * @return a Task
- */
-
- public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
- return receiveBounded(mailbox, -1.0, host, rate);
- }
-
- /**
- * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
- * with a capped rate
- *
- * @param mailbox
- * @param timeout
- * @param host
- * @return a Task
- */
- public static native Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
+ public static native Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
msg_process_t sender = nullptr;
msg_process_t receiver = nullptr;
msg_host_t source = nullptr;
- double priority = 0.0;
- double bound = 0.0; /* Capping for CPU resource */
- double rate = 0.0; /* Capping for network resource */
+
+ double priority = 1.0;
+ double bound = 0.0; /* Capping for CPU resource, or 0 for no capping */
+ double rate = -1; /* Capping for network resource, or -1 for no capping*/
bool isused = false; /* Indicates whether the task is used in SIMIX currently */
int host_nb = 0; /* ==0 if sequential task; parallel task if not */
task->data = data;
/* Simulator Data */
- simdata->compute = nullptr;
- simdata->comm = nullptr;
simdata->bytes_amount = message_size;
simdata->flops_amount = flop_amount;
- simdata->sender = nullptr;
- simdata->receiver = nullptr;
- simdata->source = nullptr;
- simdata->priority = 1.0;
- simdata->bound = 0;
- simdata->rate = -1.0;
- simdata->isused = 0;
-
- simdata->host_nb = 0;
- simdata->host_list = nullptr;
- simdata->flops_parallel_amount = nullptr;
- simdata->bytes_parallel_amount = nullptr;
+
TRACE_msg_task_create(task);
return task;