#include <utility>
#include <memory>
#include <functional>
+#include <future>
+#include <type_traits>
#include <xbt/function_types.h>
#include <simgrid/simix.h>
+XBT_PUBLIC(void) simcall_run_kernel(std::function<void()> const& code);
+
namespace simgrid {
namespace simix {
+template<class F>
+typename std::result_of<F()>::type kernel(F&& code)
+{
+ typedef typename std::result_of<F()>::type R;
+ std::promise<R> promise;
+ simcall_run_kernel([&]{
+ try {
+ promise.set_value(code());
+ }
+ catch(...) {
+ promise.set_exception(std::current_exception());
+ }
+ });
+ return promise.get_future().get();
+}
+
class Context;
class ContextFactory;
/* 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 <functional>
+
#include "src/mc/mc_replay.h"
#include "smx_private.h"
#include "src/mc/mc_forward.h"
return simcall_BODY_storage_get_content(storage);
}
-
+void simcall_run_kernel(std::function<void()> const& code)
+{
+ return simcall_BODY_run_kernel((void*) &code);
+}
#ifdef HAVE_MC
break;
}
}
+
+void SIMIX_run_kernel(void* code)
+{
+ std::function<void()>* function = (std::function<void()>*) code;
+ (*function)();
+}
\ No newline at end of file
static inline void simcall_set_category__set__category(smx_simcall_t simcall, const char* arg) {
simcall->args[1].cc = arg;
}
+
+static inline void* simcall_run_kernel__get__code(smx_simcall_t simcall) {
+ return simcall->args[0].dp;
+}
+static inline void simcall_run_kernel__set__code(smx_simcall_t simcall, void* arg) {
+ simcall->args[0].dp = arg;
+}
#ifdef HAVE_LATENCY_BOUND_TRACKING
static inline smx_synchro_t simcall_comm_is_latency_bounded__get__comm(smx_simcall_t simcall) {
#include "smx_private.h"
#include "src/mc/mc_forward.h"
#include "xbt/ex.h"
+#include <simgrid/simix.hpp>
inline static void simcall_BODY_host_on(sg_host_t host) {
smx_process_t self = SIMIX_process_self();
}
}
+
+inline static void simcall_BODY_run_kernel(void* code) {
+ smx_process_t self = SIMIX_process_self();
+
+ /* Go to that function to follow the code flow through the simcall barrier */
+ if (0) SIMIX_run_kernel(code);
+ /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
+
+ self->simcall.call = SIMCALL_RUN_KERNEL;
+ memset(&self->simcall.result, 0, sizeof(self->simcall.result));
+ memset(self->simcall.args, 0, sizeof(self->simcall.args));
+ self->simcall.args[0].dp = (void*) code;
+ if (self != simix_global->maestro_process) {
+ XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
+ SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
+ SIMIX_process_yield(self);
+ } else {
+ SIMIX_simcall_handle(&self->simcall, 0);
+ }
+
+ }
#ifdef HAVE_LATENCY_BOUND_TRACKING
inline static int simcall_BODY_comm_is_latency_bounded(smx_synchro_t comm) {
SIMCALL_ASR_GET_PROPERTIES,
SIMCALL_MC_RANDOM,
SIMCALL_SET_CATEGORY,
+ SIMCALL_RUN_KERNEL,
#ifdef HAVE_LATENCY_BOUND_TRACKING
SIMCALL_COMM_IS_LATENCY_BOUNDED,
#endif
"SIMCALL_ASR_GET_PROPERTIES",
"SIMCALL_MC_RANDOM",
"SIMCALL_SET_CATEGORY",
+ "SIMCALL_RUN_KERNEL",
#ifdef HAVE_LATENCY_BOUND_TRACKING
"SIMCALL_COMM_IS_LATENCY_BOUNDED",
#endif
SIMIX_simcall_answer(simcall);
break;
+case SIMCALL_RUN_KERNEL:
+ SIMIX_run_kernel( simcall->args[0].dp);
+ SIMIX_simcall_answer(simcall);
+ break;
+
#ifdef HAVE_LATENCY_BOUND_TRACKING
case SIMCALL_COMM_IS_LATENCY_BOUNDED:
simcall->result.i = SIMIX_comm_is_latency_bounded((smx_synchro_t) simcall->args[0].dp);
XBT_PRIVATE void SIMIX_simcall_handle(smx_simcall_t, int);
XBT_PRIVATE void SIMIX_simcall_exit(smx_synchro_t);
XBT_PRIVATE const char *SIMIX_simcall_name(e_smx_simcall_t kind);
+XBT_PRIVATE void SIMIX_run_kernel(void* code);
SG_END_DECL()
Func H asr_get_properties (void*, xbt_dict_t) (name, const char*)
Func H mc_random (int) (min, int) (max, int)
Proc - set_category (void) (synchro, void*, smx_synchro_t) (category, const char*)
+Proc - run_kernel (void) (code, void*)
## HAVE_LATENCY_BOUND_TRACKING
Func - comm_is_latency_bounded (int) (comm, void*, smx_synchro_t)
## HAVE_MC
fd.write('#include "smx_private.h"\n')
fd.write('#include "src/mc/mc_forward.h"\n')
fd.write('#include "xbt/ex.h"\n')
+ fd.write('#include <simgrid/simix.hpp>\n')
handle(fd, Simcall.body, simcalls, simcalls_dict)
fd.close()
teshsuite/simdag/network/p2p/CMakeLists.txt
teshsuite/simdag/partask/CMakeLists.txt
teshsuite/simdag/platforms/CMakeLists.txt
+ teshsuite/simix/CMakeLists.txt
teshsuite/simix/check_defaults/CMakeLists.txt
teshsuite/simix/stack_overflow/CMakeLists.txt
teshsuite/smpi/CMakeLists.txt