From: Frederic Suter Date: Fri, 1 Apr 2016 09:15:49 +0000 (+0200) Subject: make a REAL and simple dsend test X-Git-Tag: v3_13~180^2~12^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/01ee20dfb947f561d4d517b5799fc997cc0beda9?hp=93f0ec84901a004b957e0967b2a7da62e40469eb make a REAL and simple dsend test --- diff --git a/.gitignore b/.gitignore index 5242aee8be..2f8b7eb449 100644 --- a/.gitignore +++ b/.gitignore @@ -974,7 +974,7 @@ examples/java/app/bittorrent/java_app_bittorrent_compiled examples/java/app/centralizedmutex/java_app_centralizedmutex_compiled examples/java/app/masterworker/java_app_masterworker_compiled examples/java/app/pingpong/java_app_pingpong_compiled -examples/java/async/java_async_compiled +examples/java/async/dsend/java_async_dsend_compiled examples/java/dht/chord/java_dht_chord_compiled examples/java/dht/kademlia/java_dht_kademlia_compiled examples/java/cloud/masterworker/java_cloud_masterworker_compiled diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index 5cb858aa07..bcc30d75ef 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -14,6 +14,9 @@ set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/app/pingpong) set(app_pingpong_sources ${srcdir}/Main.java ${srcdir}/PingPongTask.java ${srcdir}/Receiver.java ${srcdir}/Sender.java) +set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/async/dsend) +set(async_dsend_sources ${srcdir}/Main.java ${srcdir}/Receiver.java ${srcdir}/Sender.java) + set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/cloud/masterworker) set(cloud_masterworker_sources ${srcdir}/Main.java ${srcdir}/Master.java ${srcdir}/Worker.java) @@ -64,9 +67,9 @@ set(process_suspend_sources ${srcdir}/Main.java ${srcdir}/DreamMaster.java set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/task/priority) set(task_priority_sources ${srcdir}/Main.java ${srcdir}/Test.java) -foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong cloud_migration cloud_masterworker - dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage process_kill process_migration - process_startkilltime process_suspend task_priority trace_pingpong) +foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong async_dsend + cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage + process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong) string (REPLACE "_" "/" example_dir ${example}) if(enable_java) add_custom_command( @@ -84,9 +87,9 @@ foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpo set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}/${example}.tesh) endforeach() -set(examples_src ${examples_src} PARENT_SCOPE) -set(tesh_files ${tesh_files} PARENT_SCOPE) -set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/generate.py PARENT_SCOPE) +set(examples_src ${examples_src} PARENT_SCOPE) +set(tesh_files ${tesh_files} PARENT_SCOPE) +set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/generate.py PARENT_SCOPE) set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/app/masterworker/README ${CMAKE_CURRENT_SOURCE_DIR}/cloud/migration/README PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/bittorrent.xml @@ -98,9 +101,9 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/bi ${CMAKE_CURRENT_SOURCE_DIR}/task/priority/priority.xml PARENT_SCOPE) if(enable_java) - foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong cloud_migration cloud_masterworker - dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage process_kill process_migration - process_startkilltime process_suspend task_priority trace_pingpong) + foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong async_dsend + cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage + process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong) string (REPLACE "_" "/" example_dir ${example}) ADD_TESH(java-${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh) endforeach() diff --git a/examples/java/async/CMakeLists.txt b/examples/java/async/CMakeLists.txt deleted file mode 100644 index 4167099fd9..0000000000 --- a/examples/java/async/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -set(example java_async) -set(sources ${CMAKE_CURRENT_SOURCE_DIR}/AsyncTest.java ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.java - ${CMAKE_CURRENT_SOURCE_DIR}/Forwarder.java ${CMAKE_CURRENT_SOURCE_DIR}/Master.java - ${CMAKE_CURRENT_SOURCE_DIR}/Slave.java) - -if(enable_java) - add_custom_command( - COMMENT "Building ${example}..." - OUTPUT ${example}_compiled - DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR} - COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources} - COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled - COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled - ) - add_custom_target(${example} ALL DEPENDS ${example}_compiled) - ADD_TESH(java-async --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/async/async.tesh) -endif() - - -set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/async.tesh PARENT_SCOPE) -set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/asyncDeployment.xml PARENT_SCOPE) -set(examples_src ${examples_src} ${sources} PARENT_SCOPE) -set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/README PARENT_SCOPE) diff --git a/examples/java/async/FinalizeTask.java b/examples/java/async/FinalizeTask.java deleted file mode 100644 index 39b1a4f9b6..0000000000 --- a/examples/java/async/FinalizeTask.java +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (c) 2006-2014, 2016. 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. */ - -package async; -import org.simgrid.msg.Task; - -public class FinalizeTask extends Task { - public FinalizeTask() { - super("finalize",0,0); - } -} diff --git a/examples/java/async/Forwarder.java b/examples/java/async/Forwarder.java deleted file mode 100644 index 965bb8c72f..0000000000 --- a/examples/java/async/Forwarder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2006-2014, 2016. 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. */ - -package async; -import org.simgrid.msg.Msg; -import org.simgrid.msg.Host; -import org.simgrid.msg.Task; -import org.simgrid.msg.Process; -import org.simgrid.msg.MsgException; - -public class Forwarder extends Process { - public Forwarder(Host host, String name, String[]args) { - super(host,name,args); - } - - public void main(String[] args) throws MsgException { - if (args.length < 3) { - Msg.info("Forwarder needs 3 arguments (input mailbox, first output mailbox, last one)"); - Msg.info("Got "+args.length+" instead"); - System.exit(1); - } - int input = Integer.valueOf(args[0]).intValue(); - int firstOutput = Integer.valueOf(args[1]).intValue(); - int lastOutput = Integer.valueOf(args[2]).intValue(); - - int taskCount = 0; - int slavesCount = lastOutput - firstOutput + 1; - Msg.info("Receiving on 'slave_"+input+"'"); - while(true) { - Task task = Task.receive("slave_"+input); - - if (task instanceof FinalizeTask) { - Msg.info("Got a finalize task. Let's forward (asynchronously) that we're done, and then sleep 20 seconds"+ - " so that nobody gets a message from a terminated process."); - - for (int cpt = firstOutput; cpt<=lastOutput; cpt++) { - Task tf = new FinalizeTask(); - tf.dsend("slave_"+cpt); - } - waitFor(20); - break; - } - int dest = firstOutput + (taskCount % slavesCount); - - Msg.info("Sending \"" + task.getName() + "\" to \"slave_" + dest + "\""); - task.send("slave_"+dest); - - taskCount++; - } - - Msg.info("I'm done. See you!"); - } -} - diff --git a/examples/java/async/Master.java b/examples/java/async/Master.java deleted file mode 100644 index 19e66ea9ff..0000000000 --- a/examples/java/async/Master.java +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) 2006-2014, 2016. 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. */ - -package async; -import java.util.ArrayList; - -import org.simgrid.msg.Msg; -import org.simgrid.msg.Comm; -import org.simgrid.msg.Host; -import org.simgrid.msg.Task; -import org.simgrid.msg.Process; -import org.simgrid.msg.MsgException; - -public class Master extends Process { - public Master(Host host, String name, String[]args) { - super(host,name,args); - } - - 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"); - ArrayList comms = new ArrayList(); - - for (int i = 0; i < tasksCount; i++) { - Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); - Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\""); - Comm comm = task.isend("slave_"+(i%slavesCount)); - comms.add(comm); - } - - while (comms.size() > 0) { - for (int i = 0; i < comms.size(); i++) { - try { - if (comms.get(i).test()) { - comms.remove(i); - i--; - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - waitFor(1); - } - Msg.info("All tasks have been dispatched. Let's tell (asynchronously) everybody the computation is over,"+ - " and sleep 20s so that nobody gets a message from a terminated process."); - - for (int i = 0; i < slavesCount; i++) { - FinalizeTask task = new FinalizeTask(); - task.dsend("slave_"+(i%slavesCount)); - } - waitFor(20); - - Msg.info("Goodbye now!"); - } -} diff --git a/examples/java/async/README b/examples/java/async/README deleted file mode 100644 index 0d6dcc2dcb..0000000000 --- a/examples/java/async/README +++ /dev/null @@ -1,24 +0,0 @@ -This is another version of the master/slaves example, using asynchronous communications. - -There is 3 kind of processes: - * Master: creates some tasks, and dispatches them to its slaves - * Forwarder: get tasks from master, and dispatch them further - * Slave: get tasks from either master or forwarder, and run them - -At the end of the execution: - - the master sends FinalizeTask to every known slave to stop them, - using dsend instead of send. That's non-blocking with no way to - know if/when the communication succeeds. It is intended for - communications where you don't care to know whether your message got - received or not. The process then sleeps 20 seconds because we have - a strange bug for now when the receiver gets a message from a - terminated process. This should not be the case, actually, that's a - JAVA specific bug, but I don't really have the time to dig in right - now. - - - On reception of FT, forwarders dsend FT to every slave, and stop - after a little while. - - On reception of FinalizeTask, slaves stop. - -Other non-blocking primitives will get used here as soon as they are -added to the bindings. \ No newline at end of file diff --git a/examples/java/async/Slave.java b/examples/java/async/Slave.java deleted file mode 100644 index 3d32d2a0e2..0000000000 --- a/examples/java/async/Slave.java +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2006-2007, 2010, 2013-2014, 2016. 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. */ - -package async; -import org.simgrid.msg.Msg; -import org.simgrid.msg.Comm; -import org.simgrid.msg.Host; -import org.simgrid.msg.Task; -import org.simgrid.msg.Process; -import org.simgrid.msg.HostFailureException; -import org.simgrid.msg.TaskCancelledException; -import org.simgrid.msg.TimeoutException; -import org.simgrid.msg.TransferFailureException; - -public class Slave extends Process { - public Slave(Host host, String name, String[]args) { - super(host,name,args); - } - - 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(); - Comm comm = null; - boolean slaveFinished = false; - while(!slaveFinished) { - try { - if (comm == null) { - Msg.info("Receiving on 'slave_" + num + "'"); - comm = Task.irecv("slave_" + num); - } else { - if (comm.test()) { - Task task = comm.getTask(); - - if (task instanceof FinalizeTask) { - comm = null; - break; - } - Msg.info("Received a task"); - Msg.info("Received \"" + task.getName() + "\". Processing it."); - try { - task.execute(); - } catch (TaskCancelledException e) { - - } - comm = null; - } else { - waitFor(1); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - Msg.info("Received Finalize. I'm done. See you!"); - waitFor(20); - } -} \ No newline at end of file diff --git a/examples/java/async/async.tesh b/examples/java/async/async.tesh deleted file mode 100644 index 8a33bbb201..0000000000 --- a/examples/java/async/async.tesh +++ /dev/null @@ -1,56 +0,0 @@ -#! tesh - -! output sort 19 -! timeout 30 -$ java -classpath ${classpath:=.} async/AsyncTest ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/async/asyncDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (0:maestro@) Using regular java threads. -> [ 0.000000] (10:async.Slave@Robert) Receiving on 'slave_8' -> [ 0.000000] (11:async.Slave@Sirois) Receiving on 'slave_9' -> [ 0.000000] (12:async.Slave@Monique) Receiving on 'slave_10' -> [ 0.000000] (1:async.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process -> [ 0.000000] (1:async.Master@Jacquelin) Sending "Task_0" to "slave_0" -> [ 0.000000] (1:async.Master@Jacquelin) Sending "Task_1" to "slave_1" -> [ 0.000000] (1:async.Master@Jacquelin) Sending "Task_2" to "slave_2" -> [ 0.000000] (1:async.Master@Jacquelin) Sending "Task_3" to "slave_3" -> [ 0.000000] (1:async.Master@Jacquelin) Sending "Task_4" to "slave_4" -> [ 0.000000] (2:async.Forwarder@Jackson) Receiving on 'slave_0' -> [ 0.000000] (3:async.Forwarder@Casavant) Receiving on 'slave_1' -> [ 0.000000] (4:async.Slave@iRMX) Receiving on 'slave_2' -> [ 0.000000] (5:async.Slave@Bousquet) Receiving on 'slave_3' -> [ 0.000000] (6:async.Slave@Soucy) Receiving on 'slave_4' -> [ 0.000000] (7:async.Slave@Kuenning) Receiving on 'slave_5' -> [ 0.000000] (8:async.Slave@Browne) Receiving on 'slave_6' -> [ 0.000000] (9:async.Slave@Stephen) Receiving on 'slave_7' -> [ 0.851467] (2:async.Forwarder@Jackson) Sending "Task_0" to "slave_7" -> [ 1.357014] (3:async.Forwarder@Casavant) Sending "Task_1" to "slave_9" -> [ 2.000000] (11:async.Slave@Sirois) Received a task -> [ 2.000000] (11:async.Slave@Sirois) Received "Task_1". Processing it. -> [ 2.000000] (5:async.Slave@Bousquet) Received a task -> [ 2.000000] (5:async.Slave@Bousquet) Received "Task_3". Processing it. -> [ 2.000000] (6:async.Slave@Soucy) Received a task -> [ 2.000000] (6:async.Slave@Soucy) Received "Task_4". Processing it. -> [ 2.000364] (6:async.Slave@Soucy) Receiving on 'slave_4' -> [ 2.000437] (11:async.Slave@Sirois) Receiving on 'slave_9' -> [ 2.001165] (5:async.Slave@Bousquet) Receiving on 'slave_3' -> [ 4.000000] (4:async.Slave@iRMX) Received a task -> [ 4.000000] (4:async.Slave@iRMX) Received "Task_2". Processing it. -> [ 4.000000] (9:async.Slave@Stephen) Received a task -> [ 4.000000] (9:async.Slave@Stephen) Received "Task_0". Processing it. -> [ 4.000728] (4:async.Slave@iRMX) Receiving on 'slave_2' -> [ 4.000728] (9:async.Slave@Stephen) Receiving on 'slave_7' -> [ 5.000000] (1:async.Master@Jacquelin) All tasks have been dispatched. Let's tell (asynchronously) everybody the computation is over, and sleep 20s so that nobody gets a message from a terminated process. -> [ 5.851463] (2:async.Forwarder@Jackson) Got a finalize task. Let's forward (asynchronously) that we're done, and then sleep 20 seconds so that nobody gets a message from a terminated process. -> [ 6.000000] (7:async.Slave@Kuenning) Received Finalize. I'm done. See you! -> [ 6.000000] (8:async.Slave@Browne) Received Finalize. I'm done. See you! -> [ 6.357007] (3:async.Forwarder@Casavant) Got a finalize task. Let's forward (asynchronously) that we're done, and then sleep 20 seconds so that nobody gets a message from a terminated process. -> [ 7.000364] (6:async.Slave@Soucy) Received Finalize. I'm done. See you! -> [ 7.000437] (11:async.Slave@Sirois) Received Finalize. I'm done. See you! -> [ 7.001165] (5:async.Slave@Bousquet) Received Finalize. I'm done. See you! -> [ 8.000000] (12:async.Slave@Monique) Received Finalize. I'm done. See you! -> [ 9.000000] (10:async.Slave@Robert) Received Finalize. I'm done. See you! -> [ 9.000728] (4:async.Slave@iRMX) Received Finalize. I'm done. See you! -> [ 9.000728] (9:async.Slave@Stephen) Received Finalize. I'm done. See you! -> [ 25.000000] (1:async.Master@Jacquelin) Goodbye now! -> [ 25.851463] (2:async.Forwarder@Jackson) I'm done. See you! -> [ 26.357007] (3:async.Forwarder@Casavant) I'm done. See you! -> [ 29.000728] (0:maestro@) MSG_main finished; Cleaning up the simulation... diff --git a/examples/java/async/asyncDeployment.xml b/examples/java/async/asyncDeployment.xml deleted file mode 100644 index 7ef4d13b62..0000000000 --- a/examples/java/async/asyncDeployment.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/java/async/AsyncTest.java b/examples/java/async/dsend/Main.java similarity index 51% rename from examples/java/async/AsyncTest.java rename to examples/java/async/dsend/Main.java index 0c6d1fecde..09d441af23 100644 --- a/examples/java/async/AsyncTest.java +++ b/examples/java/async/dsend/Main.java @@ -4,25 +4,30 @@ /* 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. */ -package async; +package async.dsend; import org.simgrid.msg.Msg; +import org.simgrid.msg.Host; import org.simgrid.msg.NativeException; +import org.simgrid.msg.HostNotFoundException; -public class AsyncTest { - public static void main(String[] args) throws NativeException { +public class Main { + public static void main(String[] args) throws NativeException, HostNotFoundException { Msg.init(args); - if (args.length < 2) { - Msg.info("Usage : AsyncTest platform_file deployment_file"); - Msg.info("example : AsyncTest ../platforms/platform.xml asyncDeployment.xml"); + if (args.length < 1) { + Msg.info("Usage : Main platform_file"); + Msg.info("example : Main ../platforms/small_platform.xml"); System.exit(1); } /* construct the platform and deploy the application */ Msg.createEnvironment(args[0]); - Msg.deployApplication(args[1]); - + Host[] hosts = Host.all(); + new Sender(hosts[0],"Sender").start(); + for (int i=1; i < hosts.length; i++){ + new Receiver(hosts[i], "Receiver").start(); + } /* execute the simulation. */ Msg.run(); } diff --git a/examples/java/async/dsend/Receiver.java b/examples/java/async/dsend/Receiver.java new file mode 100644 index 0000000000..4f6c3f0a9d --- /dev/null +++ b/examples/java/async/dsend/Receiver.java @@ -0,0 +1,28 @@ +/* Copyright (c) 2006-2007, 2010, 2013-2014, 2016. 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. */ + +package async.dsend; +import org.simgrid.msg.Msg; +import org.simgrid.msg.Comm; +import org.simgrid.msg.Host; +import org.simgrid.msg.Task; +import org.simgrid.msg.Process; +import org.simgrid.msg.HostFailureException; +import org.simgrid.msg.TaskCancelledException; +import org.simgrid.msg.TimeoutException; +import org.simgrid.msg.TransferFailureException; + +public class Receiver extends Process { + public Receiver (Host host, String name) { + super(host,name); + } + + public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException { + Msg.info("Receiving on '"+ getHost().getName() + "'"); + Task.receive(getHost().getName()); + Msg.info("Received a task. I'm done. See you!"); + } +} \ No newline at end of file diff --git a/examples/java/async/dsend/Sender.java b/examples/java/async/dsend/Sender.java new file mode 100644 index 0000000000..d80429af6f --- /dev/null +++ b/examples/java/async/dsend/Sender.java @@ -0,0 +1,43 @@ +/* Copyright (c) 2006-2014, 2016. 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. */ + +package async.dsend; +import java.util.ArrayList; + +import org.simgrid.msg.Msg; +import org.simgrid.msg.Comm; +import org.simgrid.msg.Host; +import org.simgrid.msg.Task; +import org.simgrid.msg.Process; +import org.simgrid.msg.MsgException; + +public class Sender extends Process { + public Sender (Host host, String name){ + super(host,name); + } + + public void main(String[] args) throws MsgException { + double taskComputeSize =0; + double taskCommunicateSize = 5000000; + Host[] hosts = Host.all(); + int receiverCount = hosts.length - 1; + + Msg.info("Hello! Got "+ receiverCount + " receivers to contact"); + + for (int i = 1; i <= receiverCount; i++) { + Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); + Msg.info("Sending \"" + task.getName()+ "\" to \"" + hosts[i].getName() + "\""); + task.dsend(hosts[i].getName()); + } + + Msg.info("All tasks have been (asynchronously) dispatched."+ + " Let's sleep for 10s so that nobody gets a message from a terminated process."); + + waitFor(10); + + Msg.info("Goodbye now!"); + } +} diff --git a/examples/java/async/dsend/async_dsend.tesh b/examples/java/async/dsend/async_dsend.tesh new file mode 100644 index 0000000000..484f90b38e --- /dev/null +++ b/examples/java/async/dsend/async_dsend.tesh @@ -0,0 +1,22 @@ +#! tesh + +! output sort 19 +! timeout 30 +$ java -classpath ${classpath:=.} async/dsend/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] (1:Sender@Fafard) Hello! Got 4 receivers to contact +> [ 0.000000] (1:Sender@Fafard) Sending "Task_1" to "Tremblay" +> [ 0.000000] (1:Sender@Fafard) Sending "Task_2" to "Bourassa" +> [ 0.000000] (1:Sender@Fafard) Sending "Task_3" to "Jupiter" +> [ 0.000000] (1:Sender@Fafard) Sending "Task_4" to "Ginette" +> [ 0.000000] (1:Sender@Fafard) All tasks have been (asynchronously) dispatched. Let's sleep for 10s so that nobody gets a message from a terminated process. +> [ 0.000000] (2:Receiver@Tremblay) Receiving on 'Tremblay' +> [ 0.000000] (3:Receiver@Bourassa) Receiving on 'Bourassa' +> [ 0.000000] (4:Receiver@Jupiter) Receiving on 'Jupiter' +> [ 0.000000] (5:Receiver@Ginette) Receiving on 'Ginette' +> [ 1.947550] (3:Receiver@Bourassa) Received a task. I'm done. See you! +> [ 2.084248] (5:Receiver@Ginette) Received a task. I'm done. See you! +> [ 2.432373] (2:Receiver@Tremblay) Received a task. I'm done. See you! +> [ 2.690554] (4:Receiver@Jupiter) Received a task. I'm done. See you! +> [ 10.000000] (0:maestro@) MSG_main finished; Cleaning up the simulation... +> [ 10.000000] (1:Sender@Fafard) Goodbye now! diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index eee8900fee..f217ec67e6 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -924,7 +924,6 @@ set(txt_files # Add your CMakeLists file here to see your subdir built. set(CMAKEFILES_TXT examples/java/CMakeLists.txt - examples/java/async/CMakeLists.txt examples/msg/CMakeLists.txt examples/msg/cloud/CMakeLists.txt examples/msg/mc/CMakeLists.txt