Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 22 Jan 2019 21:21:37 +0000 (22:21 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 22 Jan 2019 21:21:37 +0000 (22:21 +0100)
.appveyor.yml
CMakeLists.txt
src/bindings/python/simgrid_python.cpp
src/kernel/context/Context.cpp
src/simix/ActorImpl.cpp
teshsuite/s4u/pid/pid.cpp

index fe234b7..976c6c1 100644 (file)
@@ -34,16 +34,18 @@ install:
 # Lua 
 #- choco install lua53
 # We need python v3
-- cmd: SET PATH=C:\Python35-x64;%PATH% # We need python v3
+- cmd: SET PATH=C:\Python37-x64;%PATH% # We need python v3
 # Use the mingw-w64 provided by Appveyor (must be placed before Perl in the path)
 - cmd: SET PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin\;%PATH%
 # Work around a bug on appveyor where the default sh is not the one I expect
 - rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe"
+# We need pybind11. SimGrid will pick it automatically if the subdir is here
+- cmd: git clone --depth=1 https://github.com/pybind/pybind11.git
 
 build_script:
 - cmake -G "MinGW Makefiles" -Denable_lua=OFF -Denable_documentation=OFF -Denable_java=ON -Denable_smpi=OFF -Denable_mallocators=OFF -Denable_lto=OFF .
-- mingw32-make.exe VERBOSE=1 java-all # Only the Java parts
-- ctest --output-on-failure -R java
+- mingw32-make.exe VERBOSE=1 java-all python-bindings # Only the Java and Python parts
+- ctest --output-on-failure -R java python
 
 artifacts:
 - path: simgrid.jar
index 8fbcead..50d67d5 100644 (file)
@@ -773,14 +773,30 @@ endif()
 
 # Python binding (with pybind11)
 ################
-
 # Our usage of pybind11::overload_cast mandates C++14
 get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
-if ("cxx_std_14" IN_LIST known_features)
-  find_package(pybind11 2.2.0)
+
+if("cxx_std_14" IN_LIST known_features)
+
+  if(EXISTS ${CMAKE_HOME_DIRECTORY}/pybind11) # Try to use a local copy of pybind11, if any
+    message(STATUS "Use the internal copy of pybind11 (using C++14).")
+    add_subdirectory(${CMAKE_HOME_DIRECTORY}/pybind11)
+    set(pybind11_FOUND ON)
+    
+    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/pybind11/tools/)
+    set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
+    find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)
+    
+  else()
+    find_package(pybind11 2.2.0)
+  endif()
+  
   if(NOT PYTHONLIBS_FOUND)
+    message(STATUS "Python libs not found. Turn pybind11 off.")
+
     set(pybind11_FOUND OFF)
   endif()
+  
 else()
   message(STATUS "No support for C++14 detected, don't even search for pybind11.")
   set(pybind11_FOUND OFF)
index 05d124e..2f48be6 100644 (file)
@@ -3,8 +3,14 @@
 /* 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. */
 
+#ifdef _WIN32
+#warning Try to work around https://bugs.python.org/issue11566
+#include <cmath>
+#define hypot _hypot // Must come before pybind11 when compiling with MinGW32-64 (https://bugs.python.org/issue11566)
+#endif
+
 #include <pybind11/functional.h>
-#include <pybind11/pybind11.h> // Must be first
+#include <pybind11/pybind11.h> // Must come before our own stuff
 #include <pybind11/stl.h>
 
 #include "src/kernel/context/Context.hpp"
index 385753e..06e5402 100644 (file)
@@ -5,8 +5,10 @@
 
 #include "mc/mc.h"
 
+#include "simgrid/s4u/Host.hpp"
 #include "src/kernel/context/Context.hpp"
 #include "src/simix/smx_private.hpp"
+#include "src/surf/surf_interface.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
@@ -81,11 +83,18 @@ Context::~Context()
 
 void Context::stop()
 {
+  actor_->finished_ = true;
+
+  if (actor_->auto_restart_ && actor_->host_->is_off()) {
+    XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
+              actor_->get_cname());
+    watched_hosts.insert(actor_->host_->get_cname());
+  }
+
   if (this->cleanup_func_)
     this->cleanup_func_(this->actor_);
-  this->actor_->suspended_ = false;
 
-  this->iwannadie = false;
+  this->iwannadie = false; // don't let the yield call ourself -- Context::stop()
   simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->actor_); });
   this->iwannadie = true;
 }
index 37547d7..8071b9c 100644 (file)
@@ -741,22 +741,10 @@ void SIMIX_process_yield(smx_actor_t self)
   XBT_DEBUG("Control returned to me: '%s'", self->get_cname());
 
   if (self->context_->iwannadie) {
-    XBT_DEBUG("I wanna die!");
-    self->finished_ = true;
-    /* execute the on_exit functions */
-    SIMIX_process_on_exit_runall(self);
-
-    if (self->auto_restart_ && self->host_->is_off() &&
-        watched_hosts.find(self->host_->get_cname()) == watched_hosts.end()) {
-      XBT_DEBUG("Push host %s to watched_hosts because it's off and %s needs to restart", self->host_->get_cname(),
-                self->get_cname());
-      watched_hosts.insert(self->host_->get_cname());
-    }
 
     XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host_->get_cname());
     self->context_->stop();
-    xbt_backtrace_display_current();
-    xbt_die("I should be dead by now.");
+    THROW_IMPOSSIBLE;
   }
 
   if (self->suspended_) {
index fa70184..4891a38 100644 (file)
@@ -12,7 +12,7 @@ static void sendpid()
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
   int pid                          = simgrid::s4u::this_actor::get_pid();
   double comm_size                 = 100000;
-  simgrid::s4u::this_actor::on_exit([](int, void* pid) { XBT_INFO("Process \"%d\" killed.", *(int*)pid); }, &pid);
+  simgrid::s4u::this_actor::on_exit([pid](int, void*) { XBT_INFO("Process \"%d\" killed.", pid); }, nullptr);
 
   XBT_INFO("Sending pid of \"%d\".", pid);
   mailbox->put(&pid, comm_size);