Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further cut include files
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 11 Apr 2018 07:21:16 +0000 (09:21 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 11 Apr 2018 22:52:12 +0000 (00:52 +0200)
19 files changed:
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/ConditionVariable.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Mutex.hpp
include/xbt/xbt_os_thread.h
src/include/xbt/parmap.hpp
src/kernel/context/ContextBoost.hpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextRaw.hpp
src/s4u/s4u_comm.cpp
src/s4u/s4u_mailbox.cpp
src/s4u/s4u_mutex.cpp
src/surf/cpu_cas01.hpp
src/surf/plugins/dirty_page_tracking.cpp
src/surf/plugins/host_dvfs.cpp
src/surf/plugins/host_energy.cpp
src/surf/plugins/host_load.cpp
src/surf/plugins/link_energy.cpp

index 25f2ede..a91b18b 100644 (file)
@@ -6,23 +6,11 @@
 #ifndef SIMGRID_S4U_ACTOR_HPP
 #define SIMGRID_S4U_ACTOR_HPP
 
-#include <atomic>
-#include <chrono>
-#include <functional>
-#include <memory>
-#include <stdexcept>
-#include <string>
-#include <type_traits>
-#include <utility>
-#include <vector>
-
+#include <simgrid/chrono.hpp>
 #include <xbt/Extendable.hpp>
 #include <xbt/functional.hpp>
-#include <xbt/string.hpp>
 #include <xbt/signal.hpp>
-
-#include <simgrid/chrono.hpp>
-#include <simgrid/s4u/forward.hpp>
+#include <xbt/string.hpp>
 
 namespace simgrid {
 namespace s4u {
index b39f8ba..be8ccf3 100644 (file)
@@ -6,14 +6,8 @@
 #ifndef SIMGRID_S4U_COMM_HPP
 #define SIMGRID_S4U_COMM_HPP
 
-#include <xbt/asserts.h>
-#include <xbt/base.h>
-#include <xbt/dynar.h>
-
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Activity.hpp>
-#include <simgrid/s4u/forward.hpp>
-#include <simgrid/simix.h>
 
 #include <atomic>
 #include <vector>
@@ -37,35 +31,10 @@ public:
    * The return value is the rank of the first finished CommPtr. */
   static int wait_any(std::vector<CommPtr> * comms) { return wait_any_for(comms, -1); }
   /*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
-  static int wait_any_for(std::vector<CommPtr> * comms_in, double timeout)
-  {
-    // Map to dynar<Synchro*>:
-    xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), [](void*ptr){
-      intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr);
-    });
-    for (auto const& comm : *comms_in) {
-      if (comm->state_ == Activity::State::inited)
-        comm->start();
-      xbt_assert(comm->state_ == Activity::State::started);
-      simgrid::kernel::activity::ActivityImpl* ptr = comm->pimpl_.get();
-      intrusive_ptr_add_ref(ptr);
-      xbt_dynar_push_as(comms, simgrid::kernel::activity::ActivityImpl*, ptr);
-    }
-    // Call the underlying simcall:
-    int idx = simcall_comm_waitany(comms, timeout);
-    xbt_dynar_free(&comms);
-    return idx;
-  }
+  static int wait_any_for(std::vector<CommPtr>* comms_in, double timeout);
 
   /*! take a vector s4u::CommPtr and return when all of them is finished. */
-  static void wait_all(std::vector<CommPtr> * comms)
-  {
-    // TODO: this should be a simcall or something
-    // TODO: we are missing a version with timeout
-    for (CommPtr comm : *comms) {
-      comm->wait();
-    }
-  }
+  static void wait_all(std::vector<CommPtr>* comms);
   /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
   static int test_any(std::vector<CommPtr> * comms);
 
@@ -78,7 +47,7 @@ public:
   /** Start the comm, and ignore its result. It can be completely forgotten after that. */
   Activity* detach(void (*cleanFunction)(void*))
   {
-    cleanFunction_ = cleanFunction;
+    clean_fun_ = cleanFunction;
     return detach();
   }
 
@@ -134,16 +103,16 @@ public:
 
 private:
   double rate_        = -1;
-  void* dstBuff_      = nullptr;
-  size_t dstBuffSize_ = 0;
-  void* srcBuff_      = nullptr;
-  size_t srcBuffSize_ = sizeof(void*);
+  void* dst_buff_       = nullptr;
+  size_t dst_buff_size_ = 0;
+  void* src_buff_       = nullptr;
+  size_t src_buff_size_ = sizeof(void*);
 
   /* FIXME: expose these elements in the API */
   int detached_ = 0;
-  int (*matchFunction_)(void*, void*, simgrid::kernel::activity::CommImpl*) = nullptr;
-  void (*cleanFunction_)(void*) = nullptr;
-  void (*copyDataFunction_)(smx_activity_t, void*, size_t) = nullptr;
+  int (*match_fun_)(void*, void*, simgrid::kernel::activity::CommImpl*) = nullptr;
+  void (*clean_fun_)(void*)                                             = nullptr;
+  void (*copy_data_function_)(smx_activity_t, void*, size_t)            = nullptr;
 
   smx_actor_t sender_   = nullptr;
   smx_actor_t receiver_ = nullptr;
@@ -151,7 +120,7 @@ private:
 
   std::atomic_int_fast32_t refcount_{0};
 };
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
 
 #endif /* SIMGRID_S4U_COMM_HPP */
index 1bd6e11..77811c0 100644 (file)
@@ -6,19 +6,10 @@
 #ifndef SIMGRID_S4U_COND_VARIABLE_HPP
 #define SIMGRID_S4U_COND_VARIABLE_HPP
 
-#include <chrono>
-#include <condition_variable>
-#include <future>
-#include <mutex>
-#include <utility> // std::swap
-
-#include <boost/intrusive_ptr.hpp>
-
-#include <xbt/base.h>
-
 #include <simgrid/chrono.hpp>
 #include <simgrid/s4u/Mutex.hpp>
-#include <simgrid/simix.h>
+
+#include <future>
 
 namespace simgrid {
 namespace s4u {
index b62467b..a023a74 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Activity.hpp>
-#include <simgrid/s4u/forward.hpp>
 
 #include <atomic>
 
index ce19858..f9cd035 100644 (file)
@@ -6,13 +6,8 @@
 #ifndef SIMGRID_S4U_MUTEX_HPP
 #define SIMGRID_S4U_MUTEX_HPP
 
-#include <mutex>
-#include <utility>
-
-#include <boost/intrusive_ptr.hpp>
-
-#include <simgrid/simix.h>
-#include <xbt/base.h>
+#include <simgrid/forward.h>
+#include <xbt/asserts.h>
 
 namespace simgrid {
 namespace s4u {
@@ -39,17 +34,10 @@ class XBT_PUBLIC Mutex {
   simgrid::kernel::activity::MutexImpl* mutex_;
   explicit Mutex(simgrid::kernel::activity::MutexImpl * mutex) : mutex_(mutex) {}
 
-  /* refcounting of the intrusive_ptr is delegated to the implementation object */
-  friend void intrusive_ptr_add_ref(Mutex* mutex)
-  {
-    xbt_assert(mutex);
-    SIMIX_mutex_ref(mutex->mutex_);
-  }
-  friend void intrusive_ptr_release(Mutex* mutex)
-  {
-    xbt_assert(mutex);
-    SIMIX_mutex_unref(mutex->mutex_);
-  }
+  /* refcounting */
+  friend void intrusive_ptr_add_ref(Mutex* mutex);
+  friend void intrusive_ptr_release(Mutex* mutex);
+
 public:
   using Ptr = boost::intrusive_ptr<Mutex>;
 
index 9c8c05e..a335514 100644 (file)
@@ -8,12 +8,13 @@
 #ifndef XBT_OS_THREAD_H
 #define XBT_OS_THREAD_H
 
-SG_BEGIN_DECL()
-
 #include <xbt/base.h>
+#include <xbt/function_types.h>
 
 #include <pthread.h>
 
+SG_BEGIN_DECL()
+
 typedef pthread_key_t xbt_os_thread_key_t;
 
 /** @addtogroup XBT_thread
index 3aeaf19..5f91ac4 100644 (file)
@@ -1,7 +1,6 @@
 /* A thread pool (C++ version).                                             */
 
-/* Copyright (c) 2004-2018 The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2018 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 "src/internal_config.h" // HAVE_FUTEX_H
 #include "src/kernel/context/Context.hpp"
-#include <atomic>
+
 #include <boost/optional.hpp>
-#include <simgrid/simix.h>
-#include <vector>
-#include <xbt/log.h>
-#include <xbt/parmap.h>
-#include <xbt/xbt_os_thread.h>
 
 #if HAVE_FUTEX_H
-#include <limits>
 #include <linux/futex.h>
 #include <sys/syscall.h>
 #endif
index 1ce2b1d..90d6cc7 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "Context.hpp"
 #include "src/internal_config.h"
-#include "src/simix/smx_private.hpp"
 
 namespace simgrid {
 namespace kernel {
index 85639e2..354d1e3 100644 (file)
@@ -4,8 +4,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "ContextRaw.hpp"
-
 #include "mc/mc.h"
+#include "src/simix/smx_private.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
index 2126f38..3ade710 100644 (file)
 #include <functional>
 #include <vector>
 
-#include <simgrid/simix.hpp>
 #include <xbt/parmap.hpp>
 #include <xbt/xbt_os_thread.h>
 
-#include "Context.hpp"
-#include "src/internal_config.h"
-#include "src/simix/smx_private.hpp"
-
 namespace simgrid {
 namespace kernel {
 namespace context {
index 693f062..cbbb9c4 100644 (file)
@@ -25,6 +25,35 @@ Comm::~Comm()
   }
 }
 
+int Comm::wait_any_for(std::vector<CommPtr>* comms_in, double timeout)
+{
+  // Map to dynar<Synchro*>:
+  xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), [](void* ptr) {
+    intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr);
+  });
+  for (auto const& comm : *comms_in) {
+    if (comm->state_ == Activity::State::inited)
+      comm->start();
+    xbt_assert(comm->state_ == Activity::State::started);
+    simgrid::kernel::activity::ActivityImpl* ptr = comm->pimpl_.get();
+    intrusive_ptr_add_ref(ptr);
+    xbt_dynar_push_as(comms, simgrid::kernel::activity::ActivityImpl*, ptr);
+  }
+  // Call the underlying simcall:
+  int idx = simcall_comm_waitany(comms, timeout);
+  xbt_dynar_free(&comms);
+  return idx;
+}
+
+void Comm::wait_all(std::vector<CommPtr>* comms)
+{
+  // TODO: this should be a simcall or something
+  // TODO: we are missing a version with timeout
+  for (CommPtr comm : *comms) {
+    comm->wait();
+  }
+}
+
 Activity* Comm::set_rate(double rate)
 {
   xbt_assert(state_ == State::inited);
@@ -35,44 +64,44 @@ Activity* Comm::set_rate(double rate)
 Activity* Comm::set_src_data(void* buff)
 {
   xbt_assert(state_ == State::inited);
-  xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
-  srcBuff_ = buff;
+  xbt_assert(dst_buff_ == nullptr, "Cannot set the src and dst buffers at the same time");
+  src_buff_ = buff;
   return this;
 }
 Activity* Comm::set_src_data_size(size_t size)
 {
   xbt_assert(state_ == State::inited);
-  srcBuffSize_ = size;
+  src_buff_size_ = size;
   return this;
 }
 Activity* Comm::set_src_data(void* buff, size_t size)
 {
   xbt_assert(state_ == State::inited);
 
-  xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
-  srcBuff_ = buff;
-  srcBuffSize_ = size;
+  xbt_assert(dst_buff_ == nullptr, "Cannot set the src and dst buffers at the same time");
+  src_buff_      = buff;
+  src_buff_size_ = size;
   return this;
 }
 Activity* Comm::set_dst_data(void** buff)
 {
   xbt_assert(state_ == State::inited);
-  xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
-  dstBuff_ = buff;
+  xbt_assert(src_buff_ == nullptr, "Cannot set the src and dst buffers at the same time");
+  dst_buff_ = buff;
   return this;
 }
 size_t Comm::get_dst_data_size()
 {
   xbt_assert(state_ == State::finished);
-  return dstBuffSize_;
+  return dst_buff_size_;
 }
 Activity* Comm::set_dst_data(void** buff, size_t size)
 {
   xbt_assert(state_ == State::inited);
 
-  xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
-  dstBuff_ = buff;
-  dstBuffSize_ = size;
+  xbt_assert(src_buff_ == nullptr, "Cannot set the src and dst buffers at the same time");
+  dst_buff_      = buff;
+  dst_buff_size_ = size;
   return this;
 }
 
@@ -80,13 +109,13 @@ Activity* Comm::start()
 {
   xbt_assert(state_ == State::inited);
 
-  if (srcBuff_ != nullptr) { // Sender side
-    pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
-                                cleanFunction_, copyDataFunction_, user_data_, detached_);
-  } else if (dstBuff_ != nullptr) { // Receiver side
+  if (src_buff_ != nullptr) { // Sender side
+    pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
+                                clean_fun_, copy_data_function_, user_data_, detached_);
+  } else if (dst_buff_ != nullptr) { // Receiver side
     xbt_assert(not detached_, "Receive cannot be detached");
-    pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dstBuff_, &dstBuffSize_, matchFunction_,
-                                copyDataFunction_, user_data_, rate_);
+    pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_,
+                                copy_data_function_, user_data_, rate_);
 
   } else {
     xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
@@ -114,11 +143,11 @@ Activity* Comm::wait(double timeout)
       return this;
 
     case State::inited: // It's not started yet. Do it in one simcall
-      if (srcBuff_ != nullptr) {
-        simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
-                          copyDataFunction_, user_data_, timeout);
+      if (src_buff_ != nullptr) {
+        simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
+                          copy_data_function_, user_data_, timeout);
       } else { // Receiver
-        simcall_comm_recv(receiver_, mailbox_->get_impl(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_,
+        simcall_comm_recv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_, copy_data_function_,
                           user_data_, timeout, rate_);
       }
       state_ = State::finished;
@@ -148,7 +177,7 @@ int Comm::test_any(std::vector<CommPtr>* comms)
 Activity* Comm::detach()
 {
   xbt_assert(state_ == State::inited, "You cannot detach communications once they are started (not implemented).");
-  xbt_assert(srcBuff_ != nullptr && srcBuffSize_ != 0, "You can only detach sends, not recvs");
+  xbt_assert(src_buff_ != nullptr && src_buff_size_ != 0, "You can only detach sends, not recvs");
   detached_ = true;
   return start();
 }
index b8d0cf1..8d98163 100644 (file)
@@ -80,8 +80,8 @@ s4u::CommPtr Mailbox::put_init(void* data, uint64_t simulatedSize)
 {
   s4u::CommPtr res = put_init();
   res->set_remaining(simulatedSize);
-  res->srcBuff_     = data;
-  res->srcBuffSize_ = sizeof(void*);
+  res->src_buff_      = data;
+  res->src_buff_size_ = sizeof(void*);
   return res;
 }
 s4u::CommPtr Mailbox::put_async(void* payload, uint64_t simulatedSize)
index 1fda582..09d3654 100644 (file)
@@ -40,5 +40,16 @@ MutexPtr Mutex::createMutex()
   return MutexPtr(&mutex->mutex(), false);
 }
 
+/* refcounting of the intrusive_ptr is delegated to the implementation object */
+void intrusive_ptr_add_ref(Mutex* mutex)
+{
+  xbt_assert(mutex);
+  SIMIX_mutex_ref(mutex->mutex_);
+}
+void intrusive_ptr_release(Mutex* mutex)
+{
+  xbt_assert(mutex);
+  SIMIX_mutex_unref(mutex->mutex_);
+}
 }
 }
index ae104a0..38a8195 100644 (file)
@@ -3,9 +3,8 @@
 /* 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 <xbt/base.h>
-
 #include "cpu_interface.hpp"
+#include "xbt/base.h"
 
 /***********
  * Classes *
index 39d879a..b14dbc6 100644 (file)
@@ -4,9 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/plugins/live_migration.h"
-#include "simgrid/s4u.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include <map>
 
 namespace simgrid {
 namespace vm {
index a57868b..9dac337 100644 (file)
@@ -5,18 +5,10 @@
 
 #include "simgrid/plugins/dvfs.h"
 #include "simgrid/plugins/load.h"
-#include "simgrid/simix.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/surf/cpu_interface.hpp"
+#include <xbt/config.hpp>
 
 #include <boost/algorithm/string.hpp>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <simgrid/s4u/Engine.hpp>
-#include <string>
-#include <utility>
-#include <vector>
-#include <xbt/config.hpp>
 
 /** @addtogroup SURF_plugin_load
 
index 44736f3..0b3ca1d 100644 (file)
@@ -5,17 +5,12 @@
 
 #include "simgrid/plugins/energy.h"
 #include "simgrid/plugins/load.h"
-#include "simgrid/simix.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
-
 #include "simgrid/s4u/Engine.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
-#include <string>
-#include <utility>
-#include <vector>
 
 /** @addtogroup plugin_energy
 
index 5f54170..039f23c 100644 (file)
@@ -4,17 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/plugins/load.h"
-#include "simgrid/simix.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/surf/cpu_interface.hpp"
-
-#include "simgrid/s4u/Engine.hpp"
-
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <string>
-#include <utility>
-#include <vector>
 
 /** @addtogroup plugin_load
 
index 062502b..74873ca 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
-#include <string>
 
 /** @addtogroup SURF_plugin_energy