From 374068a699b2a2a499f36ca687d33eec9deccf05 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Tue, 12 Nov 2019 16:54:07 +0100 Subject: [PATCH 1/3] Disable handle_local_exceptions in device code --- .../util/detail/handle_local_exceptions.hpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/libs/algorithms/include/hpx/parallel/util/detail/handle_local_exceptions.hpp b/libs/algorithms/include/hpx/parallel/util/detail/handle_local_exceptions.hpp index 6bf85954b72c..8642afba50a8 100644 --- a/libs/algorithms/include/hpx/parallel/util/detail/handle_local_exceptions.hpp +++ b/libs/algorithms/include/hpx/parallel/util/detail/handle_local_exceptions.hpp @@ -10,6 +10,7 @@ #define HPX_PARALLEL_UTIL_DETAIL_HANDLE_LOCAL_EXCEPTIONS_OCT_03_2014_0142PM #include +#include #include #include #include @@ -30,6 +31,9 @@ namespace hpx { namespace parallel { namespace util { namespace detail { // std::bad_alloc has to be handled separately HPX_NORETURN static void call(std::exception_ptr const& e) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else try { std::rethrow_exception(e); @@ -42,11 +46,15 @@ namespace hpx { namespace parallel { namespace util { namespace detail { { throw exception_list(e); } +#endif } static void call( std::exception_ptr const& e, std::list& errors) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else try { std::rethrow_exception(e); @@ -59,12 +67,16 @@ namespace hpx { namespace parallel { namespace util { namespace detail { { errors.push_back(e); } +#endif } template static void call(std::vector> const& workitems, std::list& errors, bool throw_errors = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else for (hpx::future const& f : workitems) { if (f.has_exception()) @@ -73,6 +85,7 @@ namespace hpx { namespace parallel { namespace util { namespace detail { if (throw_errors && !errors.empty()) throw exception_list(std::move(errors)); +#endif } /////////////////////////////////////////////////////////////////////// @@ -80,6 +93,9 @@ namespace hpx { namespace parallel { namespace util { namespace detail { static void call(std::vector> const& workitems, std::list& errors, bool throw_errors = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else for (hpx::shared_future const& f : workitems) { if (f.has_exception()) @@ -88,6 +104,7 @@ namespace hpx { namespace parallel { namespace util { namespace detail { if (throw_errors && !errors.empty()) throw exception_list(std::move(errors)); +#endif } template @@ -95,6 +112,9 @@ namespace hpx { namespace parallel { namespace util { namespace detail { std::list& errors, Cleanup&& cleanup, bool throw_errors = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else bool has_exception = false; std::exception_ptr bad_alloc_exception; for (hpx::future& f : workitems) @@ -135,6 +155,7 @@ namespace hpx { namespace parallel { namespace util { namespace detail { if (throw_errors && !errors.empty()) throw exception_list(std::move(errors)); +#endif } }; @@ -144,46 +165,66 @@ namespace hpx { namespace parallel { namespace util { namespace detail { /////////////////////////////////////////////////////////////////////// HPX_NORETURN static void call(std::exception_ptr const&) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else hpx::terminate(); +#endif } HPX_NORETURN static void call( std::exception_ptr const&, std::list&) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else hpx::terminate(); +#endif } template static void call(std::vector> const& workitems, std::list&, bool = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else for (hpx::future const& f : workitems) { if (f.has_exception()) hpx::terminate(); } +#endif } template static void call(std::vector> const& workitems, std::list&, bool = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else for (hpx::shared_future const& f : workitems) { if (f.has_exception()) hpx::terminate(); } +#endif } template static void call(std::vector> const& workitems, std::list&, Cleanup&&, bool = true) { +#if defined(HPX_COMPUTE_DEVICE_CODE) + HPX_ASSERT(false); +#else for (hpx::future const& f : workitems) { if (f.has_exception()) hpx::terminate(); } +#endif } }; }}}} // namespace hpx::parallel::util::detail From bde31e3645b16f90c973c74b68d136c4a7e654f2 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Tue, 12 Nov 2019 16:55:32 +0100 Subject: [PATCH 2/3] Use CUDA assert function in device code --- libs/assertion/include/hpx/assertion.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/assertion/include/hpx/assertion.hpp b/libs/assertion/include/hpx/assertion.hpp index 6c43ed59fa24..881fdc658904 100644 --- a/libs/assertion/include/hpx/assertion.hpp +++ b/libs/assertion/include/hpx/assertion.hpp @@ -7,6 +7,7 @@ // Make HPX inspect tool happy: // hpxinspect:noinclude:HPX_ASSERT // hpxinspect:noinclude:HPX_ASSERT_MSG +// hpxinspect:noassert_macro // Note: There are no include guards. This is intentional. @@ -16,6 +17,9 @@ #include #include +#if defined(HPX_COMPUTE_DEVICE_CODE) +#include +#endif #include #include @@ -61,8 +65,13 @@ namespace hpx { namespace assertion { /**/ #if defined(HPX_DEBUG) +#if defined(HPX_COMPUTE_DEVICE_CODE) +#define HPX_ASSERT(expr) assert(expr) +#define HPX_ASSERT_MSG(expr, msg) HPX_ASSERT(expr) +#else #define HPX_ASSERT(expr) HPX_ASSERT_(expr, std::string()) #define HPX_ASSERT_MSG(expr, msg) HPX_ASSERT_(expr, msg) +#endif #define HPX_NOEXCEPT_WITH_ASSERT #else #define HPX_ASSERT(expr) From 435f935523164a482f3eb8578565973f3c9f41e0 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Tue, 12 Nov 2019 16:56:22 +0100 Subject: [PATCH 3/3] Change register_* calls from hpx::applier to hpx::threads namespace --- src/util/interval_timer.cpp | 2 +- src/util/one_size_heap_list.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/interval_timer.cpp b/src/util/interval_timer.cpp index ee0670b02782..68712a5474b0 100644 --- a/src/util/interval_timer.cpp +++ b/src/util/interval_timer.cpp @@ -250,7 +250,7 @@ namespace hpx { namespace util { namespace detail // lock here would be the right thing but leads to crashes and hangs // at shutdown. //util::unlock_guard > ul(l); - id = hpx::applier::register_thread_plain( + id = hpx::threads::register_thread_plain( util::bind_front(&interval_timer::evaluate, this->shared_from_this()), description_.c_str(), threads::suspended, true, diff --git a/src/util/one_size_heap_list.cpp b/src/util/one_size_heap_list.cpp index c3277ccc118c..6b95e69c75e2 100644 --- a/src/util/one_size_heap_list.cpp +++ b/src/util/one_size_heap_list.cpp @@ -157,7 +157,7 @@ namespace hpx { namespace util { if (nullptr == threads::get_self_ptr()) { - hpx::applier::register_work_nullary( + hpx::threads::register_work_nullary( util::bind_front(&one_size_heap_list::free, this, p, count), "one_size_heap_list::free"); return true;