From a14791b7288177a49b6e8b06677d59faac0a175e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 27 Feb 2022 19:01:06 +0100 Subject: [PATCH] Kill popping_{enum,generated} --- src/simix/popping.cpp | 40 ++++++++++++++++ src/simix/popping_enum.hpp | 30 ------------ src/simix/popping_generated.cpp | 66 -------------------------- src/simix/popping_private.hpp | 13 +++++- src/simix/simcalls.py | 80 -------------------------------- tools/cmake/DefinePackages.cmake | 5 -- 6 files changed, 52 insertions(+), 182 deletions(-) delete mode 100644 src/simix/popping_enum.hpp delete mode 100644 src/simix/popping_generated.cpp diff --git a/src/simix/popping.cpp b/src/simix/popping.cpp index b32b3948f4..2e7e046bee 100644 --- a/src/simix/popping.cpp +++ b/src/simix/popping.cpp @@ -3,11 +3,51 @@ /* 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/s4u/Host.hpp" +#include "src/kernel/actor/ActorImpl.hpp" +#include "src/kernel/actor/SimcallObserver.hpp" +#include "src/kernel/context/Context.hpp" #include "src/simix/popping_private.hpp" #include "xbt/log.h" XBT_LOG_NEW_DEFAULT_CATEGORY(simix, "transmuting from user request into kernel handlers"); +constexpr std::array simcall_names{{ + "Simcall::NONE", + "Simcall::RUN_KERNEL", + "Simcall::RUN_BLOCKING", +}}; + +/** @private + * @brief (in kernel mode) unpack the simcall and activate the handler + * + * This function is generated from src/simix/simcalls.in + */ +void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered) +{ + XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_)); + if (simcall_.observer_ != nullptr) + simcall_.observer_->prepare(times_considered); + if (context_->wannadie()) + return; + switch (simcall_.call_) { + case simgrid::simix::Simcall::RUN_KERNEL: + SIMIX_run_kernel(simcall_.code_); + simcall_answer(); + break; + + case simgrid::simix::Simcall::RUN_BLOCKING: + SIMIX_run_blocking(simcall_.code_); + break; + + case simgrid::simix::Simcall::NONE: + throw std::invalid_argument( + simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s", get_cname(), get_host()->get_cname())); + default: + THROW_IMPOSSIBLE; + } +} + void SIMIX_run_kernel(std::function const* code) { (*code)(); diff --git a/src/simix/popping_enum.hpp b/src/simix/popping_enum.hpp deleted file mode 100644 index a89500b741..0000000000 --- a/src/simix/popping_enum.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/**********************************************************************/ -/* File generated by src/simix/simcalls.py from src/simix/simcalls.in */ -/* */ -/* DO NOT EVER CHANGE THIS FILE */ -/* */ -/* change simcalls specification in src/simix/simcalls.in */ -/* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved. */ -/**********************************************************************/ - -/* - * Note that the name comes from http://en.wikipedia.org/wiki/Popping - * Indeed, the control flow is doing a strange dance in there. - * - * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :) - */ - -namespace simgrid { -namespace simix { -/** - * @brief All possible simcalls. - */ -enum class Simcall { - NONE, - RUN_KERNEL, - RUN_BLOCKING, -}; - -constexpr int NUM_SIMCALLS = 3; -} // namespace simix -} // namespace simgrid diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp deleted file mode 100644 index dd6ce75523..0000000000 --- a/src/simix/popping_generated.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**********************************************************************/ -/* File generated by src/simix/simcalls.py from src/simix/simcalls.in */ -/* */ -/* DO NOT EVER CHANGE THIS FILE */ -/* */ -/* change simcalls specification in src/simix/simcalls.in */ -/* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved. */ -/**********************************************************************/ - -/* - * Note that the name comes from http://en.wikipedia.org/wiki/Popping - * Indeed, the control flow is doing a strange dance in there. - * - * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :) - */ - -#include -#include -#include -#if SIMGRID_HAVE_MC -#include "src/mc/mc_forward.hpp" -#endif -#include "src/kernel/activity/ConditionVariableImpl.hpp" -#include "src/kernel/actor/SimcallObserver.hpp" -#include "src/kernel/context/Context.hpp" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); - -using simgrid::simix::Simcall; -/** @brief Simcalls' names (generated from src/simix/simcalls.in) */ -constexpr std::array simcall_names{{ - "Simcall::NONE", - "Simcall::RUN_KERNEL", - "Simcall::RUN_BLOCKING", -}}; - -/** @private - * @brief (in kernel mode) unpack the simcall and activate the handler - * - * This function is generated from src/simix/simcalls.in - */ -void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered) -{ - XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_)); - if (simcall_.observer_ != nullptr) - simcall_.observer_->prepare(times_considered); - if (context_->wannadie()) - return; - switch (simcall_.call_) { - case Simcall::RUN_KERNEL: - SIMIX_run_kernel(simcall_.code_); - simcall_answer(); - break; - - case Simcall::RUN_BLOCKING: - SIMIX_run_blocking(simcall_.code_); - break; - - case Simcall::NONE: - throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s", - get_cname(), - sg_host_get_name(get_host()))); - default: - THROW_IMPOSSIBLE; - } -} diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index 4e918a5ed8..73ef058847 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -13,7 +13,18 @@ #include /********************************* Simcalls *********************************/ -#include "popping_enum.hpp" /* Definition of Simcall, with one value per simcall */ +namespace simgrid { +namespace simix { +/** All possible simcalls. */ +enum class Simcall { + NONE, + RUN_KERNEL, + RUN_BLOCKING, +}; +constexpr int NUM_SIMCALLS = 3; +/** @brief Simcalls' names */ +} // namespace simix +} // namespace simgrid XBT_PUBLIC_DATA const std::array simcall_names; /* Name of each simcall */ diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 9c2a0b5fc5..5d47f0fad4 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -63,9 +63,6 @@ class Simcall: return False return True - def enum(self): - return ' %s,' % (self.name.upper()) - def string(self): return ' "Simcall::%s",' % self.name.upper() @@ -224,83 +221,6 @@ def main(): print("Some checks fail!") sys.exit(1) - # - # popping_enum.hpp - # - fd = header("popping_enum.hpp") - fd.write('namespace simgrid {\n') - fd.write('namespace simix {\n') - fd.write('/**\n') - fd.write(' * @brief All possible simcalls.\n') - fd.write(' */\n') - fd.write('enum class Simcall {\n') - fd.write(' NONE,\n') - - handle(fd, Simcall.enum, simcalls, simcalls_dict) - - fd.write('};\n') - fd.write('\n') - fd.write('constexpr int NUM_SIMCALLS = ' + str(1 + len(simcalls)) + ';\n') - fd.write('} // namespace simix\n') - fd.write('} // namespace simgrid\n') - fd.close() - - # - # popping_generated.cpp - # - - fd = header("popping_generated.cpp") - - fd.write('#include \n') - fd.write('#include \n') - fd.write('#include \n') - fd.write('#if SIMGRID_HAVE_MC\n') - fd.write('#include "src/mc/mc_forward.hpp"\n') - fd.write('#endif\n') - fd.write('#include "src/kernel/activity/ConditionVariableImpl.hpp"\n') - fd.write('#include "src/kernel/actor/SimcallObserver.hpp"\n') - fd.write('#include "src/kernel/context/Context.hpp"\n') - - fd.write('\n') - fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);\n\n') - - fd.write('using simgrid::simix::Simcall;') - fd.write('\n') - fd.write('/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n') - fd.write('constexpr std::array simcall_names{{\n') - - fd.write(' "Simcall::NONE",\n') - handle(fd, Simcall.string, simcalls, simcalls_dict) - - fd.write('}};\n\n') - - fd.write('/** @private\n') - fd.write(' * @brief (in kernel mode) unpack the simcall and activate the handler\n') - fd.write(' *\n') - fd.write(' * This function is generated from src/simix/simcalls.in\n') - fd.write(' */\n') - fd.write('void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered)\n') - fd.write('{\n') - fd.write(' XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_));\n') - fd.write(' if (simcall_.observer_ != nullptr)\n') - fd.write(' simcall_.observer_->prepare(times_considered);\n') - - fd.write(' if (context_->wannadie())\n') - fd.write(' return;\n') - fd.write(' switch (simcall_.call_) {\n') - - handle(fd, Simcall.case, simcalls, simcalls_dict) - - fd.write(' case Simcall::NONE:\n') - fd.write(' throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",\n') - fd.write(' get_cname(),\n') - fd.write(' sg_host_get_name(get_host())));\n') - fd.write(' default:\n') - fd.write(' THROW_IMPOSSIBLE;\n') - fd.write(' }\n') - fd.write('}\n') - - fd.close() if __name__ == '__main__': main() diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 9d8235cf0c..3a406bb3b5 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -25,8 +25,6 @@ set(EXTRA_DIST src/simix/simcalls.in src/simix/simcalls.py src/simix/popping_private.hpp - src/simix/popping_generated.cpp - src/simix/popping_enum.hpp src/smpi/colls/coll_tuned_topo.hpp src/smpi/colls/colls_private.hpp src/smpi/colls/smpi_mvapich2_selector_stampede.hpp @@ -376,7 +374,6 @@ set(PLUGINS_SRC src/plugins/vm/VmLiveMigration.hpp ) -set(SIMIX_GENERATED_SRC src/simix/popping_generated.cpp ) set(SIMIX_SRC src/kernel/future.cpp src/simix/libsmx.cpp @@ -418,8 +415,6 @@ set(SIMIX_SRC src/kernel/actor/SimcallObserver.hpp src/kernel/actor/SynchroObserver.cpp src/kernel/actor/SynchroObserver.hpp - - ${SIMIX_GENERATED_SRC} ) # Boost context may not be available -- 2.20.1