/* initialize the MSG simulation. Must be done before anything else (even logging). */
Msg.init(args);
- if(args.length < 2) {
+ if(args.length == 0) {
+ Msg.createEnvironment("basic_platform.xml");
+ Msg.deployApplication("basic_deployment.xml");
+
+ } else if (args.length < 2) {
+
Msg.info("Usage : Basic platform_file deployment_file");
Msg.info("example : Basic basic_platform.xml basic_deployment.xml");
System.exit(1);
- }
+ } else {
/* construct the platform and deploy the application */
Msg.createEnvironment(args[0]);
Msg.deployApplication(args[1]);
-
+ }
+
/* execute the simulation. */
Msg.run();
}
import simgrid.msg.*;
public class Master extends simgrid.msg.Process {
- public void main(String[] args) throws MsgException {
- if (args.length < 4) {
- Msg.info("Master needs 4 arguments");
- System.exit(1);
- }
-
- int tasksCount = Integer.valueOf(args[0]).intValue();
- double taskComputeSize = Double.valueOf(args[1]).doubleValue();
- double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
-
- int slavesCount = Integer.valueOf(args[3]).intValue();
-
- Msg.info("Hello! Got "+ slavesCount + " slaves and "+tasksCount+" tasks to process");
-
- for (int i = 0; i < tasksCount; i++) {
- Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize);
- Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
- task.send("slave_"+(i%slavesCount));
- }
-
- Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
-
- for (int i = 0; i < slavesCount; i++) {
- FinalizeTask task = new FinalizeTask();
- task.send("slave_"+(i%slavesCount));
- }
-
- Msg.info("Goodbye now!");
- }
+ public void main(String[] args) throws MsgException {
+ if (args.length < 4) {
+ Msg.info("Master needs 4 arguments");
+ System.exit(1);
+ }
+
+ int tasksCount = Integer.valueOf(args[0]).intValue();
+ double taskComputeSize = Double.valueOf(args[1]).doubleValue();
+ double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
+
+ int slavesCount = Integer.valueOf(args[3]).intValue();
+
+ Msg.info("Hello! Got "+ slavesCount + " slaves and "+tasksCount+" tasks to process");
+
+ for (int i = 0; i < tasksCount; i++) {
+ Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize);
+ //Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
+ task.send("slave_"+(i%slavesCount));
+ }
+
+ Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
+
+ for (int i = 0; i < slavesCount; i++) {
+ FinalizeTask task = new FinalizeTask();
+ task.send("slave_"+(i%slavesCount));
+ }
+
+ Msg.info("Goodbye now!");
+ }
}
* under the terms of the license (GNU LGPL) which comes with this package.
*/
-import simgrid.msg.*;
+import simgrid.msg.HostFailureException;
+import simgrid.msg.Msg;
+import simgrid.msg.Task;
+import simgrid.msg.TaskCancelledException;
+import simgrid.msg.TimeoutException;
+import simgrid.msg.TransferFailureException;
public class Slave extends simgrid.msg.Process {
- public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
- if (args.length < 1) {
- Msg.info("Slave needs 1 argument (its number)");
- System.exit(1);
- }
+ public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
+ if (args.length < 1) {
+ Msg.info("Slave needs 1 argument (its number)");
+ System.exit(1);
+ }
- int num = Integer.valueOf(args[0]).intValue();
- Msg.info("Receiving on 'slave_"+num+"'");
-
- while(true) {
- Task task = Task.receive("slave_"+num);
-
- if (task instanceof FinalizeTask) {
- break;
- }
- Msg.info("Received \"" + task.getName() + "\". Processing it.");
- try {
- task.execute();
- } catch (TaskCancelledException e) {
-
- }
- Msg.info("\"" + task.getName() + "\" done ");
- }
-
- Msg.info("Received Finalize. I'm done. See you!");
- }
+ int num = Integer.valueOf(args[0]).intValue();
+ //Msg.info("Receiving on 'slave_"+num+"'");
+
+ while(true) {
+ Task task = Task.receive("slave_"+num);
+
+ if (task instanceof FinalizeTask) {
+ break;
+ }
+ Msg.info("Received \"" + task.getName() + "\". Processing it.");
+ try {
+ task.execute();
+ } catch (TaskCancelledException e) {
+
+ }
+ // Msg.info("\"" + task.getName() + "\" done ");
+ }
+
+ //Msg.info("Received Finalize. I'm done. See you!");
+ }
}
\ No newline at end of file