Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #177 from Takishipp/sd_exit
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 2 Jun 2017 08:56:33 +0000 (10:56 +0200)
committerGitHub <noreply@github.com>
Fri, 2 Jun 2017 08:56:33 +0000 (10:56 +0200)
Use automated call to sd_exit

55 files changed:
.gitignore
CMakeLists.txt
ChangeLog
examples/java/dht/chord/Node.java
examples/java/dht/kademlia/Answer.java
examples/msg/app-bittorrent/peer.c
examples/msg/cloud-two-tasks/cloud-two-tasks.c
examples/msg/energy-vm/energy-vm.c
examples/msg/mc/bugged1.c
examples/msg/mc/bugged1_liveness.c
examples/msg/mc/bugged2.c
examples/msg/mc/bugged3.c
include/simgrid/forward.h
include/simgrid/msg.h
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Mutex.hpp
include/simgrid/s4u/VirtualMachine.hpp
include/simgrid/s4u/forward.hpp
include/simgrid/simix.h
include/xbt/config.h
src/bindings/java/jmsg_vm.cpp
src/bindings/java/jmsg_vm.h
src/bindings/java/org/simgrid/msg/VM.java
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/CommImpl.cpp
src/msg/msg_gos.cpp
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_comm.cpp
src/simix/ActorImpl.cpp
src/simix/smx_network.cpp
src/simix/smx_synchro_private.h
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp
src/surf/host_clm03.cpp
src/surf/network_interface.cpp
src/surf/network_ns3.cpp
src/surf/plugins/host_energy.cpp
src/surf/ptask_L07.cpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/msg/CMakeLists.txt
teshsuite/msg/cloud-sharing/cloud-sharing.c [new file with mode: 0644]
teshsuite/msg/cloud-sharing/cloud-sharing.tesh [new file with mode: 0644]
teshsuite/msg/host_on_off_processes/host_on_off_processes.c
teshsuite/msg/task_listen_from/task_listen_from.cpp [new file with mode: 0644]
teshsuite/msg/task_listen_from/task_listen_from.tesh [new file with mode: 0644]
tools/cmake/Java.cmake
tools/cmake/MakeLib.cmake
tools/simgrid.supp

index c5eea27..f1b3b52 100644 (file)
@@ -122,7 +122,6 @@ doc/msg-tuto-src/masterworker3
 doc/msg-tuto-src/masterworker4
 examples/msg/actions-comm/actions-comm
 examples/msg/actions-storage/actions-storage
-examples/msg/async-yield/async-yield
 examples/msg/async-wait/async-wait
 examples/msg/async-waitall/async-waitall
 examples/msg/async-waitany/async-waitany
@@ -155,6 +154,7 @@ examples/msg/process-join/process-join
 examples/msg/process-migration/process-migration
 examples/msg/process-startkilltime/process-startkilltime
 examples/msg/process-suspend/process-suspend
+examples/msg/process-yield/process-yield
 examples/msg/app-masterworker/app-masterworker
 examples/msg/mc/bugged1
 examples/msg/mc/bugged1_liveness
@@ -248,6 +248,7 @@ teshsuite/mc/dwarf-expression/dwarf-expression
 teshsuite/mc/random-bug/random-bug
 teshsuite/mc/mutex-handling/mutex-handling
 teshsuite/mc/mutex-handling/without-mutex-handling
+teshsuite/msg/cloud-sharing/cloud-sharing
 teshsuite/msg/concurrent_rw/concurrent_rw
 teshsuite/msg/get_sender/get_sender
 teshsuite/msg/host_on_off/host_on_off
@@ -259,6 +260,7 @@ teshsuite/msg/pid/pid
 teshsuite/msg/process/process
 teshsuite/msg/storage_client_server/storage_client_server
 teshsuite/msg/task_destroy_cancel/task_destroy_cancel
+teshsuite/msg/task_listen_from/task_listen_from
 teshsuite/msg/trace_integration/trace_integration
 teshsuite/simdag/availability/availability
 teshsuite/simdag/basic-link-test/basic-link-test
index 8fede4c..58d7dbb 100644 (file)
@@ -156,10 +156,6 @@ if(NOT PYTHONINTERP_FOUND)
   message(FATAL_ERROR "Please install Python (version 3 or higher).")
 endif()
 
-if (APPLE)
-  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
-  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-endif()
 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
 
 ### Compute the include paths
index 449c17d..8562356 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ SimGrid (3.16) UNRELEASED
  Portability status:
   - FreeBSD: Disable SMPI mmap privatization, switch automatically to dlopen.
   - Mac, BSD: dlopen+thread broken, switch automatically to raw contexts.
+  - Java JAR file should be finally fully working on Mac OSX too.
 
  XML platforms: Switch to platform v4.1 format.
  * This is (mainly) a backward compatible change: v4 are valid v4.1 files
@@ -25,6 +26,9 @@ SimGrid (3.16) UNRELEASED
     simulation round, s/he has to allocate and free a dynar and use it as argument 
     to this function. The former SD_simulate (double how_long) now returns void.
 
+ Virtual Machines
+  - Allow multicore VMs, along with the correct sharing computations
+
  MSG
   - The netzone are now available from the MSG API. 
     The old names still work, but are now deprecated.
index 1817ab3..87c4e50 100644 (file)
@@ -330,9 +330,9 @@ public class Node extends Process {
 
   // Performs a find successor request to a random id.
   private void randomLookup() {
-    int id = 1337;
-    //Msg.info("Making a lookup request for id " + id);
-    findSuccessor(id);
+    int dest = 1337;
+    //Msg.info("Making a lookup request for id " + dest);
+    findSuccessor(dest);
   }
 
   /**
index c339c3b..7a34831 100644 (file)
@@ -59,7 +59,7 @@ public class Answer {
 
   /* Returns if the destination has been found */
   public boolean destinationFound() {
-    if (nodes.size() < 1) {
+    if (nodes.isEmpty()) {
       return false;
     }
     Contact tail = nodes.get(0);
index 40a8256..959e523 100644 (file)
@@ -454,7 +454,7 @@ void remove_current_piece(peer_t peer, connection_t remote_peer, unsigned int cu
 void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
 {
   for (int i = 0; i < FILE_PIECES; i++) {
-    if ((bitfield & (1U << i))) {
+    if (bitfield & (1U << i)) {
       peer->pieces_count[i]++;
     }
   }
index c9afd7c..6ba0ebe 100644 (file)
@@ -62,9 +62,9 @@ static int master_main(int argc, char *argv[])
   launch_computation_worker(vm0);
 
   while(MSG_get_clock()<100) {
-  if (atask != NULL)
-    XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
-  MSG_process_sleep(1);
+    if (atask != NULL)
+      XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
+    MSG_process_sleep(1);
   }
 
   MSG_process_sleep(10000);
@@ -73,23 +73,13 @@ static int master_main(int argc, char *argv[])
   return 1;
 }
 
-static void launch_master(msg_host_t host)
-{
-  const char *pr_name = "master_";
-  char **argv = xbt_new(char *, 2);
-  argv[0] = xbt_strdup(pr_name);
-  argv[1] = NULL;
-
-  MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
-}
-
 int main(int argc, char *argv[]){
   MSG_init(&argc, argv);
 
   xbt_assert(argc == 2);
   MSG_create_environment(argv[1]);
 
-  launch_master(MSG_host_by_name("Fafard"));
+  MSG_process_create("master_", master_main, NULL, MSG_host_by_name("Fafard"));
 
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
index 0ec0344..68ca470 100644 (file)
@@ -25,9 +25,9 @@ static int dvfs(int argc, char *argv[])
 
   /* Host 1 */
   XBT_INFO("Creating and starting two VMs");
-  msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 2048, 10, 50);
+  msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 1, 2048, 10, 50);
   MSG_vm_start(vm_host1);
-  msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 2048, 10, 50);
+  msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 1, 2048, 10, 50);
   MSG_vm_start(vm_host3);
 
   XBT_INFO("Create two tasks on Host1: one inside a VM, the other directly on the host");
index 77e429b..d85f899 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-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. */
index fda0554..47107f0 100644 (file)
@@ -1,14 +1,13 @@
-/* Copyright (c) 2012-2015. 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. */
 
-/***************** Centralized Mutual Exclusion Algorithm *********************/
-/* This example implements a centralized mutual exclusion algorithm.          */
-/* Bug : CS requests of client 1 not satisfied                                      */
-/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok)            */
-/******************************************************************************/
+/***************** Centralized Mutual Exclusion Algorithm *******************/
+/* This example implements a centralized mutual exclusion algorithm.        */
+/* Bug : CS requests of client 1 not satisfied                              */
+/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok)          */
+/****************************************************************************/
 
 #ifdef GARBAGE_STACK
 #include <sys/stat.h>
@@ -38,8 +37,9 @@ static void garbage_stack(void) {
 
 static int coordinator(int argc, char *argv[])
 {
-  int CS_used = 0;   
-  msg_task_t task = NULL, answer = NULL; 
+  int CS_used          = 0;
+  msg_task_t task      = NULL;
+  msg_task_t answer    = NULL;
   xbt_dynar_t requests = xbt_dynar_new(sizeof(char *), NULL);
   char *req;
 
@@ -88,7 +88,8 @@ static int client(int argc, char *argv[])
   int my_pid = MSG_process_get_PID(MSG_process_self());
 
   char *my_mailbox = xbt_strdup(argv[1]);
-  msg_task_t grant = NULL, release = NULL;
+  msg_task_t grant   = NULL;
+  msg_task_t release = NULL;
 
   while(1){
     XBT_INFO("Ask the request");
index 9087da3..90dba11 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2015. 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. */
@@ -19,16 +18,15 @@ static int server(int argc, char *argv[])
 {
   msg_task_t task1 = NULL;
   msg_task_t task2 = NULL;
-  long val1, val2;
 
   MSG_task_receive(&task1, "mymailbox");
-  val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
+  long val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
   MSG_task_destroy(task1);
   task1 = NULL;
   XBT_INFO("Received %lu", val1);
 
   MSG_task_receive(&task2, "mymailbox");
-  val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
+  long val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
   MSG_task_destroy(task2);
   task2 = NULL;
   XBT_INFO("Received %lu", val2);
index 3d8d736..879c37d 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-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. */
@@ -21,7 +20,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(bugged3, "this example");
 
 static int server(int argc, char *argv[])
 {
-  msg_task_t task1,task2;
+  msg_task_t task1 = NULL;
+  msg_task_t task2 = NULL;
 
   msg_comm_t comm1 = MSG_task_irecv(&task1, "mymailbox1");
   msg_comm_t comm2 = MSG_task_irecv(&task2, "mymailbox2");
index 9515436..ff78fe3 100644 (file)
@@ -9,21 +9,11 @@
 
 #ifdef __cplusplus
 
+#include "s4u/forward.hpp"
 #include "xbt/base.h"
 #include <boost/intrusive_ptr.hpp>
 
 namespace simgrid {
-namespace s4u {
-class Actor;
-class Comm;
-class Host;
-class Link;
-class Mailbox;
-class NetZone;
-
-XBT_PUBLIC(void) intrusive_ptr_release(Comm* c);
-XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c);
-}
 namespace kernel {
 namespace activity {
 class ActivityImpl;
index 9a6efb7..98580d4 100644 (file)
@@ -491,8 +491,9 @@ XBT_PUBLIC(void) MSG_vm_set_params(msg_vm_t vm, vm_params_t params);
 
 // TODO add VDI later
 XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
+XBT_PUBLIC(msg_vm_t) MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
 XBT_PUBLIC(msg_vm_t)
-MSG_vm_create(msg_host_t ind_pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity);
+MSG_vm_create(msg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity);
 
 XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
 
index 665f2c8..ab1dd5e 100644 (file)
@@ -119,13 +119,13 @@ public:
   /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
   kernel::routing::NetPoint* pimpl_netpoint = nullptr;
 
-  /*** Called on each newly created object */
+  /*** Called on each newly created host */
   static simgrid::xbt::signal<void(Host&)> onCreation;
-  /*** Called just before destructing an object */
+  /*** Called just before destructing an host */
   static simgrid::xbt::signal<void(Host&)> onDestruction;
-  /*** Called when the machine is turned on or off */
+  /*** Called when the machine is turned on or off (called AFTER the change) */
   static simgrid::xbt::signal<void(Host&)> onStateChange;
-  /*** Called when the speed of the machine is changed
+  /*** Called when the speed of the machine is changed (called AFTER the change)
    * (either because of a pstate switch or because of an external load event coming from the profile) */
   static simgrid::xbt::signal<void(Host&)> onSpeedChange;
 };
index 05199bd..0d1f227 100644 (file)
@@ -37,7 +37,7 @@ XBT_PUBLIC_CLASS Mutex {
   friend ConditionVariable;
   friend simgrid::simix::MutexImpl;
   simgrid::simix::MutexImpl* mutex_;
-  Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {}
+  explicit Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {}
 
   /* refcounting of the intrusive_ptr is delegated to the implementation object */
   friend void intrusive_ptr_add_ref(Mutex* mutex)
index 2085fae..d9d3ba7 100644 (file)
@@ -35,7 +35,7 @@ XBT_PUBLIC_CLASS VirtualMachine : public s4u::Host
 {
 
 public:
-  explicit VirtualMachine(const char* name, s4u::Host* hostPm);
+  explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
 
   // No copy/move
   VirtualMachine(VirtualMachine const&) = delete;
index 10c8d85..cc29359 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-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. */
@@ -7,6 +7,7 @@
 #define SIMGRID_S4U_FORWARD_HPP
 
 #include <boost/intrusive_ptr.hpp>
+#include <xbt/base.h>
 
 namespace simgrid {
 namespace s4u {
@@ -19,12 +20,16 @@ class Comm;
 using CommPtr = boost::intrusive_ptr<Comm>;
 class Engine;
 class Host;
+class Link;
 class Mailbox;
 using MailboxPtr = boost::intrusive_ptr<Mailbox>;
 class Mutex;
+class NetZone;
 
 class Storage;
 
+XBT_PUBLIC(void) intrusive_ptr_release(Comm* c);
+XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c);
 }
 }
 
index 78dbe75..64f9aac 100644 (file)
@@ -110,8 +110,6 @@ typedef enum {
 
 /* Process creation/destruction callbacks */
 typedef void (*void_pfn_smxprocess_t) (smx_actor_t);
-/* for auto-restart function */
-typedef void (*void_pfn_sghost_t) (sg_host_t);
 
 extern int smx_context_stack_size;
 extern int smx_context_stack_size_was_set;
@@ -226,8 +224,6 @@ XBT_PUBLIC(smx_activity_t) SIMIX_comm_get_send_match(smx_mailbox_t mbox, int (*m
 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro);
-XBT_PUBLIC(smx_activity_t) SIMIX_comm_ref(smx_activity_t comm);
-XBT_PUBLIC(void) SIMIX_comm_unref(smx_activity_t comm);
 
 /******************************************************************************/
 /*                            SIMIX simcalls                                  */
index fa0b5d4..1131871 100644 (file)
@@ -12,8 +12,6 @@
 #include <stdarg.h>
 #include <xbt/dynar.h>
 
-SG_BEGIN_DECL()
-
 /** @addtogroup XBT_config
  *  @brief Changing the configuration of SimGrid components (grounding feature)
  *
@@ -67,6 +65,8 @@ typedef simgrid::config::Config* xbt_cfg_t;
 typedef void* xbt_cfg_t;
 #endif
 
+SG_BEGIN_DECL()
+
 XBT_PUBLIC(void) xbt_cfg_set_parse(const char *options);
 
 /* Set the value of the cell \a name in \a cfg with the provided value.*/
index fc5da71..d7e9ea1 100644 (file)
@@ -65,20 +65,21 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm
   MSG_vm_set_bound(vm, bound);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname,
-                                                      jint jramsize, jint jmig_netspeed, jint jdp_intensity)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm, jobject jHost, jstring jname,
+                                                      jint coreAmount, jint jramsize, jint jmig_netspeed,
+                                                      jint jdp_intensity)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  msg_host_t host = jhost_get_native(env, jHost);
 
   const char* name = env->GetStringUTFChars(jname, 0);
-  msg_vm_t vm = MSG_vm_create(host, name, static_cast<int>(jramsize), static_cast<int>(jmig_netspeed),
-                              static_cast<int>(jdp_intensity));
+  msg_vm_t vm      = MSG_vm_create(host, name, static_cast<int>(coreAmount), static_cast<int>(jramsize),
+                              static_cast<int>(jmig_netspeed), static_cast<int>(jdp_intensity));
   env->ReleaseStringUTFChars(jname, name);
 
-  jvm_bind(env, jvm, vm);
-  jvm = env->NewWeakGlobalRef(jvm);
+  jvm_bind(env, jVm, vm);
+  jVm = env->NewWeakGlobalRef(jVm);
   // We use the extension level of the host, even if that's somehow disturbing
-  vm->extension_set(JAVA_HOST_LEVEL, (void*)jvm);
+  vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm);
 }
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg)
index 19da959..d6fec6c 100644 (file)
@@ -38,7 +38,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isResuming(JNIEnv* env, jobject j
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv* env, jobject jvm, jdouble bound);
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname,
-                                                      jint jramsize, jint dprate, jint mig_netspeed);
+                                                      jint coreAmount, jint jramsize, jint dprate, jint mig_netspeed);
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclass cls, jstring jname);
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeFinalize(JNIEnv* env, jobject jvm);
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_start(JNIEnv* env, jobject jvm);
index 8338a79..99f3a3a 100644 (file)
@@ -11,10 +11,18 @@ public class VM extends Host {
        // No need to declare a new bind variable: we use the one inherited from the super class Host
 
        private Host currentHost; 
+       private int coreAmount = 1;
 
        /** Create a `basic' VM (i.e. 1GB of RAM, other values are not taken into account). */
        public VM(Host host, String name) {
-               this(host,name,1024, 0, 0);
+               this(host,name, /*coreAmount*/1, 1024, 0, 0);
+       }
+       
+       public VM(Host host, String name, int coreAmount) {
+               this(host,name, coreAmount, 1024, 0, 0);
+       }
+       public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){
+               this(host, name, /*coreAmount*/1, ramSize, migNetSpeed, dpIntensity);
        }
 
        /**
@@ -25,11 +33,12 @@ public class VM extends Host {
         * @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;))
         * @param dpIntensity (dirty page percentage according to migNetSpeed, [0-100], if you don't know put zero ;))
         */
-       public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){
+       public VM(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity){
                super();
                super.name = name;
                this.currentHost = host; 
-               create(host, name, ramSize, migNetSpeed, dpIntensity);
+               this.coreAmount = coreAmount;
+               create(host, name, coreAmount, ramSize, migNetSpeed, dpIntensity);
        }
 
        /** Retrieve the list of all existing VMs */
@@ -68,13 +77,18 @@ public class VM extends Host {
        /** Returns whether the given VM is currently suspended */      
        public native int isSuspended();
 
+       /** Returns the amount of virtual CPUs provided */
+       public int getCoreAmount() {
+               return coreAmount;
+       }
+       
        /**
         * Natively implemented method create the VM.
         * @param ramSize size of the RAM that should be allocated (in MB)
         * @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;))
         * @param dpIntensity (dirty page intensity, a percentage of migNetSpeed [0-100],  if you don't know put zero ;))
         */
-       private native void create(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity);
+       private native void create(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity);
 
 
        /**
index 08e2a63..77e6570 100644 (file)
@@ -10,18 +10,16 @@ simgrid::kernel::activity::ActivityImpl::~ActivityImpl() = default;
 
 void simgrid::kernel::activity::ActivityImpl::ref()
 {
-  refcount++;
+  // Atomic operation! Do not split in two instructions!
+  xbt_assert(refcount_ != 0);
+  refcount_++;
 }
 
-bool simgrid::kernel::activity::ActivityImpl::unref()
+void simgrid::kernel::activity::ActivityImpl::unref()
 {
-  xbt_assert(refcount > 0,
-      "This activity has a negative refcount! You can only call test() or wait() once per activity.");
-
-  refcount--;
-  if (refcount>0)
-    return false;
-  delete this;
-
-  return true;
+  xbt_assert(refcount_ > 0,
+             "This activity has a negative refcount! You can only call test() or wait() once per activity.");
+  refcount_--;
+  if (refcount_ == 0)
+    delete this;
 }
index 13c284a..e144296 100644 (file)
@@ -34,28 +34,21 @@ namespace activity {
     // boost::intrusive_ptr<Activity> support:
     friend void intrusive_ptr_add_ref(ActivityImpl * activity)
     {
-      // Atomic operation! Do not split in two instructions!
-      auto previous = (activity->refcount_)++;
-      xbt_assert(previous != 0);
-      (void)previous;
+      activity->ref();
     }
 
     friend void intrusive_ptr_release(ActivityImpl * activity)
     {
-      // Atomic operation! Do not split in two instructions!
-      auto count = --(activity->refcount_);
-      if (count == 0)
-        delete activity;
+      activity->unref();
     }
 
-    /** @brief Increase the refcount */
+    /** @brief Increases the refcount */
     void ref();
-    /** @brief Reduce the refcount; returns true if the object was destroyed */
-    bool unref();
+    /** @brief Reduces the refcount */
+    void unref();
 
   private:
     std::atomic_int_fast32_t refcount_{1};
-    int refcount = 1;
   };
 }}} // namespace simgrid::kernel::activity
 
index 58182ea..85ccbea 100644 (file)
@@ -62,7 +62,7 @@ void simgrid::kernel::activity::CommImpl::cancel()
   if (state == SIMIX_WAITING) {
     mbox->remove(this);
     state = SIMIX_CANCELED;
-    SIMIX_comm_unref(this);
+    this->unref();
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
              && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
@@ -124,6 +124,6 @@ void simgrid::kernel::activity::CommImpl::post()
   /* if there are simcalls associated with the synchro, then answer them */
   if (not simcalls.empty()) {
     SIMIX_comm_finish(this);
-    SIMIX_comm_unref(this);
+    this->unref();
   }
 }
index 3f416bc..3e2eda2 100644 (file)
@@ -270,7 +270,6 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d
     simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
     XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
     (*task)->simdata->setNotUsed();
-    SIMIX_comm_unref((*task)->simdata->comm);
   }
   catch (xbt_ex& e) {
     switch (e.category) {
@@ -490,7 +489,7 @@ int MSG_comm_test(msg_comm_t comm)
     if (finished && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
-      SIMIX_comm_unref(comm->s_comm);
+      comm->s_comm->unref();
     }
   }
   catch (xbt_ex& e) {
@@ -558,7 +557,7 @@ int MSG_comm_testany(xbt_dynar_t comms)
     if (status == MSG_OK && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
-      SIMIX_comm_unref(comm->s_comm);
+      comm->s_comm->unref();
     }
   }
 
@@ -587,7 +586,7 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
 {
   try {
     simcall_comm_wait(comm->s_comm, timeout);
-    SIMIX_comm_unref(comm->s_comm);
+    comm->s_comm->unref();
 
     if (comm->task_received != nullptr) {
       /* I am the receiver */
@@ -672,7 +671,7 @@ int MSG_comm_waitany(xbt_dynar_t comms)
   if (comm->task_received != nullptr) {
     /* I am the receiver */
     (*comm->task_received)->simdata->setNotUsed();
-    SIMIX_comm_unref(comm->s_comm);
+    comm->s_comm->unref();
   }
 
   return finished_index;
@@ -800,7 +799,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl
       simcall_set_category(comm, task->category);
     t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(comm);
     simcall_comm_wait(comm, timeout);
-    SIMIX_comm_unref(comm);
+    comm->unref();
   }
   catch (xbt_ex& e) {
     switch (e.category) {
@@ -874,7 +873,7 @@ int MSG_task_listen_from(const char *alias)
   if (not comm)
     return -1;
 
-  return MSG_process_get_PID( static_cast<msg_task_t>(comm->src_data)->simdata->sender );
+  return MSG_process_get_PID(static_cast<msg_task_t>(comm->src_buff)->simdata->sender);
 }
 
 /** \ingroup msg_task_usage
index 4ba7663..8d59a21 100644 (file)
@@ -58,7 +58,8 @@ void MSG_vm_get_params(msg_vm_t vm, vm_params_t params)
 /* **** Check state of a VM **** */
 static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state)
 {
-  return static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() == state;
+  simgrid::s4u::VirtualMachine* castedVm = static_cast<simgrid::s4u::VirtualMachine*>(vm);
+  return castedVm->pimpl_vm_ != nullptr && castedVm->pimpl_vm_->getState() == state;
 }
 
 /** @brief Returns whether the given VM has just created, not running.
@@ -98,11 +99,12 @@ int MSG_vm_is_suspended(msg_vm_t vm)
  *  @ingroup msg_VMs*
  *  @param pm        Physical machine that will host the VM
  *  @param name      Must be unique
+ *  @param coreAmount Must be >= 1
  *  @param ramsize   [TODO]
  *  @param mig_netspeed Amount of Mbyte/s allocated to the migration (cannot be larger than net_cap). Use 0 if unsure.
  *  @param dp_intensity Dirty page percentage according to migNetSpeed, [0-100]. Use 0 if unsure.
  */
-msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity)
+msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity)
 {
   simgrid::vm::VmHostExt::ensureVmExtInstalled();
 
@@ -110,7 +112,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_net
   double host_speed = MSG_host_get_speed(pm);
   double update_speed = (static_cast<double>(dp_intensity)/100) * mig_netspeed;
 
-  msg_vm_t vm = MSG_vm_create_core(pm, name);
+  msg_vm_t vm = MSG_vm_create_multicore(pm, name, coreAmount);
   s_vm_params_t params;
   memset(&params, 0, sizeof(params));
   params.ramsize = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
@@ -128,7 +130,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_net
   return vm;
 }
 
-/** @brief Create a new VM object. The VM is not yet started. The resource of the VM is allocated upon MSG_vm_start().
+/** @brief Create a new VM object with the default parameters
  *  @ingroup msg_VMs*
  *
  * A VM is treated as a host. The name of the VM must be unique among all hosts.
@@ -138,7 +140,19 @@ msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name)
   xbt_assert(sg_host_by_name(name) == nullptr,
              "Cannot create a VM named %s: this name is already used by an host or a VM", name);
 
-  return new simgrid::s4u::VirtualMachine(name, pm);
+  return new simgrid::s4u::VirtualMachine(name, pm, 1);
+}
+/** @brief Create a new VM object with the default parameters, but with a specified amount of cores
+ *  @ingroup msg_VMs*
+ *
+ * A VM is treated as a host. The name of the VM must be unique among all hosts.
+ */
+msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount)
+{
+  xbt_assert(sg_host_by_name(name) == nullptr,
+             "Cannot create a VM named %s: this name is already used by an host or a VM", name);
+
+  return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
 }
 
 /** @brief Destroy a VM. Destroy the VM object from the simulation.
@@ -153,9 +167,6 @@ void MSG_vm_destroy(msg_vm_t vm)
   if (MSG_vm_is_running(vm))
     MSG_vm_shutdown(vm);
 
-  xbt_assert(MSG_vm_is_created(vm) || __MSG_vm_is_state(vm, SURF_VM_STATE_DESTROYED),
-             "shutdown the given VM before destroying it");
-
   /* Then, destroy the VM object */
   simgrid::simix::kernelImmediate([vm]() {
     vm->destroy();
@@ -171,7 +182,7 @@ void MSG_vm_destroy(msg_vm_t vm)
 /** @brief Start a vm (i.e., boot the guest operating system)
  *  @ingroup msg_VMs
  *
- *  If the VM cannot be started (because of memory overprovisionning), an exception is generated.
+ *  If the VM cannot be started (because of memory over-provisioning), an exception is generated.
  */
 void MSG_vm_start(msg_vm_t vm)
 {
index a678568..0a64e68 100644 (file)
@@ -38,7 +38,9 @@ simgrid::xbt::signal<void(simgrid::vm::VirtualMachineImpl*)> onVmStateChange;
 std::deque<s4u::VirtualMachine*> VirtualMachineImpl::allVms_;
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
- * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */
+ * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system.
+ * FIXME: add a configuration flag for this
+ */
 // const double virt_overhead = 0.95;
 const double virt_overhead = 1;
 
@@ -65,7 +67,7 @@ double VMModel::nextOccuringEvent(double now)
    *
    * Equation 1 was solved in the physical machine layer.
    * Equation 2 is solved in the virtual machine layer (here).
-   * X1 must be passed to the virtual machine laye as a constraint value.
+   * X1 must be passed to the virtual machine layer as a constraint value.
    **/
 
   /* iterate for all virtual machines */
@@ -73,7 +75,8 @@ double VMModel::nextOccuringEvent(double now)
     surf::Cpu* cpu = ws_vm->pimpl_cpu;
     xbt_assert(cpu, "cpu-less host");
 
-    double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->value;
+    double solved_value = ws_vm->pimpl_vm_->action_->getVariable()
+                              ->value; // this is X1 in comment above, what this VM got in the sharing on the PM
     XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->cname(), ws_vm->pimpl_vm_->getPm()->cname());
 
     // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
@@ -84,9 +87,9 @@ double VMModel::nextOccuringEvent(double now)
   }
 
   /* 2. Calculate resource share at the virtual machine layer. */
-  adjustWeightOfDummyCpuActions();
+  ignoreEmptyVmInPmLMM();
 
-  /* 3. Ready. Get the next occuring event */
+  /* 3. Ready. Get the next occurring event */
   return surf_cpu_model_vm->nextOccuringEvent(now);
 }
 
@@ -94,15 +97,16 @@ double VMModel::nextOccuringEvent(double now)
  * Resource *
  ************/
 
-VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM)
-    : HostImpl(piface), hostPM_(host_PM)
+VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
+                                       int coreAmount)
+    : HostImpl(piface), hostPM_(host_PM), coreAmount_(coreAmount)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(piface);
 
   /* We create cpu_action corresponding to a VM process on the host operating system. */
   /* TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
-  action_ = host_PM->pimpl_cpu->execution_start(0);
+  action_ = host_PM->pimpl_cpu->execution_start(0, coreAmount);
 
   /* Initialize the VM parameters */
   params_.ramsize = 0;
@@ -219,7 +223,7 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer)
       case SURF_VM_STATE_DESTROYED:
         stateName = "destroyed";
         break;
-      case SURF_VM_STATE_RUNNING:
+      default: /* SURF_VM_STATE_RUNNING or unexpected values */
         THROW_IMPOSSIBLE;
         break;
     }
@@ -264,7 +268,8 @@ void VirtualMachineImpl::setPm(s4u::Host* destination)
 
   /* Update vcpu's action for the new pm */
   /* create a cpu action bound to the pm model at the destination. */
-  surf::CpuAction* new_cpu_action = static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0));
+  surf::CpuAction* new_cpu_action =
+      static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->coreAmount_));
 
   if (action_->getRemainsNoUpdate() > 0)
     XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->getRemainsNoUpdate());
index d9b4ed6..d937176 100644 (file)
@@ -55,7 +55,7 @@ XBT_PUBLIC_CLASS VirtualMachineImpl : public surf::HostImpl
   friend simgrid::s4u::VirtualMachine;
 
 public:
-  explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host);
+  explicit VirtualMachineImpl(s4u::VirtualMachine * piface, s4u::Host * host, int coreAmount);
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
@@ -100,6 +100,7 @@ public:
 
 private:
   s_vm_params_t params_;
+  int coreAmount_;
 
 protected:
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
@@ -114,7 +115,7 @@ protected:
  */
 class VMModel : public surf::HostModel {
 public:
-  void adjustWeightOfDummyCpuActions() override{};
+  void ignoreEmptyVmInPmLMM() override{};
 
   double nextOccuringEvent(double now) override;
   void updateActionsState(double /*now*/, double /*delta*/) override{};
index 261f63a..070acd9 100644 (file)
@@ -13,11 +13,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_vm, "S4U virtual machines");
 namespace simgrid {
 namespace s4u {
 
-VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm) : Host(name)
+VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount)
+    : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, pm, coreAmount))
 {
   XBT_DEBUG("Create VM %s", name);
 
-  pimpl_vm_ = new vm::VirtualMachineImpl(this, pm);
   /* Currently, a VM uses the network resource of its physical host */
   pimpl_netpoint = pm->pimpl_netpoint;
   // Create a VCPU for this VM
@@ -56,7 +56,7 @@ VirtualMachine::~VirtualMachine()
 
 bool VirtualMachine::isMigrating()
 {
-  return pimpl_vm_->isMigrating;
+  return pimpl_vm_ && pimpl_vm_->isMigrating;
 }
 double VirtualMachine::getRamsize()
 {
index 4ecb4e6..d8c635b 100644 (file)
@@ -24,7 +24,7 @@ Comm::~Comm()
     xbt_backtrace_display_current();
   }
   if (pimpl_)
-    SIMIX_comm_unref(pimpl_);
+    pimpl_->unref();
 }
 
 s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan)
index 2930fc1..ad1998e 100644 (file)
@@ -111,7 +111,7 @@ void SIMIX_process_cleanup(smx_actor_t process)
       if (comm->detached)
         XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender");
       else
-        SIMIX_comm_unref(comm);
+        comm->unref();
     } else if (comm->dst_proc == process) {
       XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
           comm, (int)comm->state, comm->src_proc, comm->dst_proc);
@@ -121,7 +121,6 @@ void SIMIX_process_cleanup(smx_actor_t process)
         /* the comm will be freed right now, remove it from the sender */
         comm->src_proc->comms.remove(comm);
       }
-      // SIMIX_comm_unref(comm);
     } else {
       xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro);
     }
@@ -444,7 +443,7 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
       auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall);
       if (i != process->waiting_synchro->simcalls.end())
         process->waiting_synchro->simcalls.remove(&process->simcall);
-      SIMIX_comm_unref(comm);
+      comm->unref();
     } else if (sleep != nullptr) {
       SIMIX_process_sleep_destroy(process->waiting_synchro);
 
index 9ac82e3..b9e5ced 100644 (file)
@@ -58,7 +58,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
       XBT_DEBUG("Found a matching communication synchro %p", comm);
       if (remove_matching)
         deque->erase(it);
-      SIMIX_comm_ref(comm);
+      comm->ref();
 #if SIMGRID_HAVE_MC
       comm->mbox_cpy = comm->mbox;
 #endif
@@ -115,16 +115,17 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx
       //this mailbox is for small messages, which have to be sent right now
       other_comm->state   = SIMIX_READY;
       other_comm->dst_proc=mbox->permanent_receiver.get();
-      other_comm          = static_cast<simgrid::kernel::activity::CommImpl*>(SIMIX_comm_ref(other_comm));
+      other_comm->ref();
       mbox->done_comm_queue.push_back(other_comm);
-      XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, &(other_comm));
+      XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm);
 
     }else{
       mbox->push(this_comm);
     }
   } else {
     XBT_DEBUG("Receive already pushed");
-    SIMIX_comm_unref(this_comm);
+    this_comm->unref();
+    this_comm->unref();
 
     other_comm->state = SIMIX_READY;
     other_comm->type = SIMIX_COMM_READY;
@@ -192,6 +193,7 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
   //communication already done, get it inside the list of completed comms
   if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
 
+    this_synchro->unref();
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     //find a match in the list of already received comms
     other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
@@ -207,9 +209,10 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
         other_comm->state = SIMIX_DONE;
         other_comm->type = SIMIX_COMM_DONE;
         other_comm->mbox = nullptr;
+        other_comm->unref();
       }
-      SIMIX_comm_unref(other_comm);
-      SIMIX_comm_unref(this_synchro);
+      other_comm->unref();
+      this_synchro->unref();
     }
   } else {
     /* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */
@@ -232,8 +235,8 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
 
       other_comm->state = SIMIX_READY;
       other_comm->type = SIMIX_COMM_READY;
-      SIMIX_comm_unref(this_synchro);
-      SIMIX_comm_unref(this_synchro);
+      this_synchro->unref();
+      this_synchro->unref();
     }
     dst_proc->comms.push_back(other_comm);
   }
@@ -292,9 +295,9 @@ smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int t
   }
 
   if(other_synchro)
-    SIMIX_comm_unref(other_synchro);
+    other_synchro->unref();
 
-  SIMIX_comm_unref(this_comm);
+  this_comm->unref();
   return other_synchro;
 }
 
@@ -718,18 +721,3 @@ void SIMIX_comm_copy_data(smx_activity_t synchro)
   /* (this function might be called from both communication ends) */
   comm->copied = 1;
 }
-
-/** Increase the refcount for this comm */
-smx_activity_t SIMIX_comm_ref(smx_activity_t comm)
-{
-  if (comm != nullptr)
-    intrusive_ptr_add_ref(comm);
-  return comm;
-}
-
-/** Decrease the refcount for this comm */
-void SIMIX_comm_unref(smx_activity_t comm)
-{
-  if (comm != nullptr)
-    intrusive_ptr_release(comm);
-}
index 37b5f13..c263d25 100644 (file)
@@ -32,9 +32,8 @@ public:
   friend void intrusive_ptr_add_ref(MutexImpl* mutex)
   {
     // Atomic operation! Do not split in two instructions!
-    auto previous = (mutex->refcount_)++;
+    XBT_ATTRIB_UNUSED auto previous = (mutex->refcount_)++;
     xbt_assert(previous != 0);
-    (void) previous;
   }
   friend void intrusive_ptr_release(MutexImpl* mutex)
   {
index b8ca1e8..0833a45 100644 (file)
@@ -25,7 +25,7 @@ namespace surf {
  * constraint (capacity) of the VM in the PM layer. If the VM does not have any
  * active task, the dummy CPU action must be deactivated, so that the VM does
  * not get any CPU share in the PM layer. */
-void HostModel::adjustWeightOfDummyCpuActions()
+void HostModel::ignoreEmptyVmInPmLMM()
 {
   /* iterate for all virtual machines */
   for (s4u::VirtualMachine* ws_vm : vm::VirtualMachineImpl::allVms_) {
@@ -38,12 +38,11 @@ void HostModel::adjustWeightOfDummyCpuActions()
       /* some tasks exist on this VM */
       XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
 
-      /* FIXME: we should use lmm_update_variable_weight() ? */
       /* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */
       ws_vm->pimpl_vm_->action_->setPriority(1);
 
     } else {
-      /* no task exits on this VM */
+      /* no task exist on this VM */
       XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
 
       ws_vm->pimpl_vm_->action_->setPriority(0);
index 4d7c3ea..0693655 100644 (file)
@@ -48,7 +48,7 @@ class HostModel : public Model {
 public:
   HostModel() : Model() {}
 
-  virtual void adjustWeightOfDummyCpuActions();
+  virtual void ignoreEmptyVmInPmLMM();
   virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount,
                                       double rate);
 };
index 5bf8fe0..7d4e26e 100644 (file)
@@ -113,7 +113,8 @@ void CpuCas01::onSpeedChange() {
   while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
     CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
 
-    lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
+    lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
+                              action->requestedCore() * speed_.scale * speed_.peak);
   }
 
   Cpu::onSpeedChange();
@@ -163,10 +164,15 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
   }
 }
 
+/** @brief Start a new execution on this CPU lasting @size flops and using one core */
 CpuAction *CpuCas01::execution_start(double size)
 {
   return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint());
 }
+CpuAction* CpuCas01::execution_start(double size, int requestedCores)
+{
+  return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint(), requestedCores);
+}
 
 CpuAction *CpuCas01::sleep(double duration)
 {
@@ -201,9 +207,10 @@ CpuAction *CpuCas01::sleep(double duration)
 /**********
  * Action *
  **********/
-
-CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint)
- : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
+CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint,
+                               int requestedCore)
+    : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
+    , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
     indexHeap_ = -1;
@@ -213,6 +220,16 @@ CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double sp
   lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
 }
 
+CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint)
+    : CpuCas01Action(model, cost, failed, speed, constraint, 1)
+{
+}
+
+int CpuCas01Action::requestedCore()
+{
+  return requestedCore_;
+}
+
 CpuCas01Action::~CpuCas01Action()=default;
 
 }
index 0955ce2..6309e17 100644 (file)
@@ -41,6 +41,7 @@ public:
   ~CpuCas01() override;
   void apply_event(tmgr_trace_event_t event, double value) override;
   CpuAction *execution_start(double size) override;
+  CpuAction* execution_start(double size, int requestedCore) override;
   CpuAction *sleep(double duration) override;
 
   bool isUsed() override;
@@ -58,8 +59,13 @@ class CpuCas01Action: public CpuAction {
   friend CpuAction *CpuCas01::execution_start(double size);
   friend CpuAction *CpuCas01::sleep(double duration);
 public:
+  CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, int coreAmount);
   CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint);
   ~CpuCas01Action() override;
+  int requestedCore();
+
+private:
+  int requestedCore_ = 1;
 };
 
 }
index c36600b..07aa7ab 100644 (file)
@@ -81,6 +81,19 @@ public:
    */
   virtual simgrid::surf::Action *execution_start(double size)=0;
 
+  /**
+   * @brief Execute some quantity of computation on more than one core
+   *
+   * @param size The value of the processing amount (in flop) needed to process
+   * @param requestedCores The desired amount of cores. Must be >= 1
+   * @return The CpuAction corresponding to the processing
+   */
+  virtual simgrid::surf::Action* execution_start(double size, int requestedCores)
+  {
+    THROW_UNIMPLEMENTED;
+    return nullptr;
+  }
+
   /**
    * @brief Make a process sleep for duration (in seconds)
    *
index 1712ea9..e11489f 100644 (file)
@@ -46,7 +46,7 @@ namespace simgrid {
 namespace surf {
 
 double HostCLM03Model::nextOccuringEvent(double now){
-  adjustWeightOfDummyCpuActions();
+  ignoreEmptyVmInPmLMM();
 
   double min_by_cpu = surf_cpu_model_pm->nextOccuringEvent(now);
   double min_by_net = surf_network_model->nextOccuringEventIsIdempotent() ? surf_network_model->nextOccuringEvent(now) : -1;
index c315bb1..81c55be 100644 (file)
@@ -30,25 +30,25 @@ namespace simgrid {
   int LinkImpl::linksCount()
   {
     return links->size();
+  }
+  /** @brief Returns a list of all existing links */
+  LinkImpl** LinkImpl::linksList()
+  {
+    LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
+    int i          = 0;
+    for (auto kv : *links) {
+      res[i] = kv.second;
+      i++;
     }
-    /** @brief Returns a list of all existing links */
-    LinkImpl** LinkImpl::linksList()
-    {
-      LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
-      int i          = 0;
-      for (auto kv : *links) {
-        res[i] = kv.second;
-        i++;
-      }
-      return res;
-    }
-    /** @brief destructor of the static data */
-    void LinkImpl::linksExit()
-    {
-      for (auto kv : *links)
-        (kv.second)->destroy();
-      delete links;
-    }
+    return res;
+  }
+  /** @brief destructor of the static data */
+  void LinkImpl::linksExit()
+  {
+    for (auto kv : *links)
+      (kv.second)->destroy();
+    delete links;
+  }
   }
 }
 
index aedde29..d78948c 100644 (file)
@@ -163,7 +163,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
 
   simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
     pt->extension_set<NetPointNs3>(new NetPointNs3());
-
+    XBT_VERB("SimGrid's %s is known as node %d within NS3", pt->cname(), pt->extension<NetPointNs3>()->node_num);
   });
   simgrid::surf::on_cluster.connect(&clusterCreation_cb);
   simgrid::s4u::onPlatformCreated.connect(&postparse_cb);
@@ -320,6 +320,7 @@ void NetworkNS3Action::resume() {
 std::list<LinkImpl*> NetworkNS3Action::links()
 {
   THROW_UNIMPLEMENTED;
+  return nullptr;
 }
 
 /* Test whether a flow is suspended */
index c1f8842..9a441b9 100644 (file)
@@ -137,7 +137,7 @@ void HostEnergy::update()
   double previous_energy = this->total_energy;
 
   double instantaneous_consumption;
-  if (host->isOff())
+  if (this->pstate == -1) // The host was off at the beginning of this time interval
     instantaneous_consumption = this->watts_off;
   else
     instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
@@ -148,10 +148,13 @@ void HostEnergy::update()
 
   this->total_energy = previous_energy + energy_this_step;
   this->last_updated = finish_time;
-  this->pstate       = host->pstate();
+
   XBT_DEBUG(
       "[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
       host->cname(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step);
+
+  /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
+  this->pstate = host->isOn() ? host->pstate() : -1;
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())
index 042c185..c960134 100644 (file)
@@ -316,7 +316,7 @@ void CpuL07::onSpeedChange() {
     Action* action = static_cast<Action*>(lmm_variable_id(var));
 
     lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
-    }
+  }
 
   Cpu::onSpeedChange();
 }
index 12611da..ac88aa5 100644 (file)
@@ -1102,7 +1102,7 @@ void surf_parse_open(const char *file)
   xbt_free(dir);
 
   surf_file_to_parse = surf_fopen(file, "r");
-  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file);
+  xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file);
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse__switch_to_buffer(surf_input_buffer);
   surf_parse_lineno = 1;
index 780d908..4b5ec93 100644 (file)
@@ -1,5 +1,5 @@
 # C examples
-foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
+foreach(x cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -9,7 +9,7 @@ foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_in
 endforeach()
 
 # CPP examples
-foreach(x task_destroy_cancel)
+foreach(x task_destroy_cancel task_listen_from)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -33,6 +33,6 @@ set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration
                                    ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml
                                    ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml    PARENT_SCOPE)
 
-foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel trace_integration)
+foreach(x cloud-sharing get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from trace_integration)
   ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
 endforeach()
diff --git a/teshsuite/msg/cloud-sharing/cloud-sharing.c b/teshsuite/msg/cloud-sharing/cloud-sharing.c
new file mode 100644 (file)
index 0000000..da63459
--- /dev/null
@@ -0,0 +1,117 @@
+/* Copyright (c) 2007-2015. 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. */
+
+#include "simgrid/msg.h"
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int computation_fun(int argc, char* argv[])
+{
+  msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL);
+
+  double clock_sta = MSG_get_clock();
+  MSG_task_execute(task);
+  double clock_end = MSG_get_clock();
+
+  XBT_INFO("Task took %gs to execute", clock_end - clock_sta);
+
+  MSG_task_destroy(task);
+
+  return 0;
+}
+
+static int master_main(int argc, char* argv[])
+{
+  msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
+  msg_host_t pm1 = MSG_host_by_name("node-1.acme.org");
+  xbt_assert(pm0, "Host node-0.acme.org does not seem to exist");
+
+  XBT_INFO("## Test 1 (started): check computation on normal PMs");
+
+  XBT_INFO("### Put a task on a PM");
+  MSG_process_create("compute", computation_fun, NULL, pm0);
+  MSG_process_sleep(2);
+
+  XBT_INFO("### Put two tasks on a PM");
+  MSG_process_create("compute", computation_fun, NULL, pm0);
+  MSG_process_create("compute", computation_fun, NULL, pm0);
+  MSG_process_sleep(2);
+
+  XBT_INFO("### Put a task on each PM");
+  MSG_process_create("compute", computation_fun, NULL, pm0);
+  MSG_process_create("compute", computation_fun, NULL, pm1);
+  MSG_process_sleep(2);
+
+  XBT_INFO("## Test 1 (ended)");
+
+  XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)");
+
+  XBT_INFO("### Put a VM on a PM, and put a task to the VM");
+  msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
+  MSG_vm_start(vm0);
+  MSG_process_create("compute", computation_fun, NULL, vm0);
+  MSG_process_sleep(2);
+  MSG_vm_destroy(vm0);
+
+  XBT_INFO("## Test 2 (ended)");
+
+  XBT_INFO(
+      "## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)");
+
+  XBT_INFO("### Put a VM on a PM, and put a task to the PM");
+  vm0 = MSG_vm_create_core(pm0, "VM0");
+  MSG_vm_start(vm0);
+  MSG_process_create("compute", computation_fun, NULL, pm0);
+  MSG_process_sleep(2);
+  MSG_vm_destroy(vm0);
+
+  XBT_INFO("## Test 3 (ended)");
+
+  XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for"
+           " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1");
+
+  XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
+  vm0          = MSG_vm_create_core(pm0, "VM0");
+  msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
+  MSG_vm_start(vm0);
+  MSG_vm_start(vm1);
+  MSG_process_create("compute", computation_fun, NULL, vm0);
+  MSG_process_create("compute", computation_fun, NULL, vm1);
+  MSG_process_sleep(2);
+  MSG_vm_destroy(vm0);
+  MSG_vm_destroy(vm1);
+
+  XBT_INFO("### Put a VM on each PM, and put a task to each VM");
+  vm0 = MSG_vm_create_core(pm0, "VM0");
+  vm1 = MSG_vm_create_core(pm1, "VM1");
+  MSG_vm_start(vm0);
+  MSG_vm_start(vm1);
+  MSG_process_create("compute", computation_fun, NULL, vm0);
+  MSG_process_create("compute", computation_fun, NULL, vm1);
+  MSG_process_sleep(2);
+  MSG_vm_destroy(vm0);
+  MSG_vm_destroy(vm1);
+  XBT_INFO("## Test 4 (ended)");
+
+  return 0;
+}
+
+int main(int argc, char* argv[])
+{
+  /* Get the arguments */
+  MSG_init(&argc, argv);
+
+  /* load the platform file */
+  const char* platform = "../../platforms/cluster.xml";
+  if (argc == 2)
+    platform = argv[1];
+  MSG_create_environment(platform);
+
+  msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
+  xbt_assert(pm0, "Host 'node-0.acme.org' not found");
+  MSG_process_create("master", master_main, NULL, pm0);
+
+  return MSG_main() != MSG_OK;
+}
diff --git a/teshsuite/msg/cloud-sharing/cloud-sharing.tesh b/teshsuite/msg/cloud-sharing/cloud-sharing.tesh
new file mode 100644 (file)
index 0000000..beb39ac
--- /dev/null
@@ -0,0 +1,29 @@
+#! ./tesh
+
+$ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=no_loc ${srcdir:=.}/../../../examples/platforms/cluster.xml
+> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ## Test 1 (started): check computation on normal PMs
+> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ### Put a task on a PM
+> [node-0.acme.org:compute:(2) 0.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 2.000000] [msg_test/INFO] ### Put two tasks on a PM
+> [node-0.acme.org:compute:(4) 2.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:compute:(3) 2.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:master:(1) 4.000000] [msg_test/INFO] ### Put a task on each PM
+> [node-0.acme.org:compute:(5) 4.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-1.acme.org:compute:(6) 4.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 1 (ended)
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the VM
+> [VM0:compute:(7) 6.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 2 (ended)
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the PM
+> [node-0.acme.org:compute:(8) 8.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 3 (ended)
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ### Put two VMs on a PM, and put a task to each VM
+> [VM0:compute:(9) 10.200000] [msg_test/INFO] Task took 0.2s to execute
+> [VM1:compute:(10) 10.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:master:(1) 12.000000] [msg_test/INFO] ### Put a VM on each PM, and put a task to each VM
+> [VM0:compute:(11) 12.100000] [msg_test/INFO] Task took 0.1s to execute
+> [VM1:compute:(12) 12.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 14.000000] [msg_test/INFO] ## Test 4 (ended)
index 83071fb..a76bd53 100644 (file)
@@ -176,7 +176,7 @@ static int test_launcher(int argc, char *argv[])
     msg_vm_t vm0;
     msg_process_t daemon;
 
-    vm0 = MSG_vm_create(jupiter, "vm0", 2048, 125, dpRate);
+    vm0 = MSG_vm_create(jupiter, "vm0", 1, 2048, 125, dpRate);
     MSG_vm_start(vm0);
 
     argvF = xbt_new(char*, 2);
diff --git a/teshsuite/msg/task_listen_from/task_listen_from.cpp b/teshsuite/msg/task_listen_from/task_listen_from.cpp
new file mode 100644 (file)
index 0000000..128b046
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 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 is the test case of GitHub's #121 */
+
+#include "simgrid/msg.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int tester(int argc, char* argv[])
+{
+  msg_task_t task = MSG_task_create("name", 0, 10, NULL);
+  msg_comm_t comm = MSG_task_isend(task, "mailbox");
+
+  XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"),
+           MSG_process_get_PID(MSG_process_self()));
+  XBT_INFO("MSG_task_listen returns()      %d (should return true, i.e. 1)", MSG_task_listen("mailbox"));
+
+  MSG_comm_destroy(comm);
+  MSG_task_destroy(task);
+
+  return 0;
+}
+
+int main(int argc, char* argv[])
+{
+  MSG_init(&argc, argv);
+  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+  MSG_create_environment(argv[1]);
+
+  MSG_process_create("tester", tester, NULL, MSG_get_host_by_name("Tremblay"));
+
+  return MSG_main();
+}
diff --git a/teshsuite/msg/task_listen_from/task_listen_from.tesh b/teshsuite/msg/task_listen_from/task_listen_from.tesh
new file mode 100644 (file)
index 0000000..32db934
--- /dev/null
@@ -0,0 +1,3 @@
+$ ./task_listen_from ${srcdir:=.}/../../../examples/platforms/small_platform.xml
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen_from returns() 1 (should return my pid, which is 1)
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen returns()      1 (should return true, i.e. 1)
index eb20402..0e77fab 100644 (file)
@@ -127,11 +127,47 @@ if(enable_lib_in_jar)
     
     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}      ${JAVA_NATIVE_PATH}/${LIBSIMGRID_SO}
     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO}
+  )
+
+if(WIN32)
+  add_custom_command(
+    TARGET simgrid-java_jar POST_BUILD
+    COMMENT "Add the windows-specific native libs into simgrid.jar..."
+    DEPENDS simgrid simgrid-java ${JAVALIBS}
+
     # There is no way to disable the dependency of mingw-64 on that lib, unfortunately nor to script cmake -E properly
     # So let's be brutal and copy it in any case (even on non-windows builds) from the location where chocolatey installs it.
     # The copy is only expected to work on the appveyor builder, but that's all we need right now
     # since our users are directed to download that file as nightly build.
     COMMAND ${CMAKE_COMMAND} -E copy_if_different C:/tools/mingw64/bin/libwinpthread-1.dll  ${JAVA_NATIVE_PATH}/libwinpthread-1.dll || true
+  )
+endif()
+
+if(APPLE)
+  add_custom_command(
+    TARGET simgrid-java_jar POST_BUILD
+    COMMENT "Add the apple-specific native libs into simgrid.jar..."
+    DEPENDS simgrid simgrid-java ${JAVALIBS}
+
+    # We need to fix the rpath of the simgrid-java library so that it
+    #    searches the simgrid library in the right location
+    #
+    # Since we don't officially install the lib before copying it in
+    # the jarfile, the lib is searched for where it was built. Given
+    # how we unpack it, we need to instruct simgrid-java to forget
+    # about the build path, and search in its current directory
+    # instead.
+    #
+    # This has to be done with the classical Apple tools, as follows:
+
+    COMMAND install_name_tool -change ${CMAKE_BINARY_DIR}/lib/libsimgrid.${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX} @loader_path/libsimgrid.dylib ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO}
+  )
+endif()
+
+  add_custom_command(
+    TARGET simgrid-java_jar POST_BUILD
+    COMMENT "Packing back the simgrid.jar with the native libs..."
+    DEPENDS simgrid simgrid-java ${JAVALIBS}
 
     COMMAND ${JAVA_ARCHIVE} -uvf ${SIMGRID_JAR}  ${JAVA_NATIVE_PATH}
     
index d7c456a..6f4cf6b 100644 (file)
@@ -4,10 +4,13 @@
 # See https://cmake.org/Wiki/CMake_RPATH_handling and Java.cmake
 set(MACOSX_RPATH ON)
 if(APPLE)
+  SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # When installed, use system path
+  set(CMAKE_SKIP_BUILD_RPATH FALSE)         # When executing from build tree, take the lib from the build path if exists
+  set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # When executing from build tree, take the lib from the system path if exists
+  
   # add the current location of libsimgrid-java.dynlib as a location for libsimgrid.dynlib
   # (useful when unpacking the native libraries from the jarfile)
-  set(CMAKE_INSTALL_RPATH "@loader_path/.")
-  SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+  set(CMAKE_INSTALL_RPATH "@loader_path/.;@rpath/.")
 endif()
 
 ###############################
index e9a7f4f..49ed161 100644 (file)
    Memcheck:Addr8
    fun:_Ux86_64_setcontext
 }
+
+# Java cruft
+{
+  JavaCruft 1
+  Memcheck:Addr4
+  ...
+  fun:_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread
+  fun:JVM_DoPrivileged
+  ...
+}
+{
+   JavaCruft 2
+   Memcheck:Cond
+   ...
+   fun:_ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask
+   ...
+}
+
+{
+   Somewhere within the Java conditions and monitors
+   Memcheck:Cond
+   fun:MarsagliaXORV
+   ...
+}