Skip to content

Commit

Permalink
Merge pull request #4209 from msimberg/fix-cuda-10
Browse files Browse the repository at this point in the history
Fix CUDA 10 build
  • Loading branch information
msimberg authored Nov 13, 2019
2 parents 96c989b + 435f935 commit 8174758
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define HPX_PARALLEL_UTIL_DETAIL_HANDLE_LOCAL_EXCEPTIONS_OCT_03_2014_0142PM

#include <hpx/config.hpp>
#include <hpx/assertion.hpp>
#include <hpx/async.hpp>
#include <hpx/errors.hpp>
#include <hpx/hpx_finalize.hpp>
Expand All @@ -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);
Expand All @@ -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<std::exception_ptr>& errors)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
try
{
std::rethrow_exception(e);
Expand All @@ -59,12 +67,16 @@ namespace hpx { namespace parallel { namespace util { namespace detail {
{
errors.push_back(e);
}
#endif
}

template <typename T>
static void call(std::vector<hpx::future<T>> const& workitems,
std::list<std::exception_ptr>& errors, bool throw_errors = true)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
for (hpx::future<T> const& f : workitems)
{
if (f.has_exception())
Expand All @@ -73,13 +85,17 @@ namespace hpx { namespace parallel { namespace util { namespace detail {

if (throw_errors && !errors.empty())
throw exception_list(std::move(errors));
#endif
}

///////////////////////////////////////////////////////////////////////
template <typename T>
static void call(std::vector<hpx::shared_future<T>> const& workitems,
std::list<std::exception_ptr>& errors, bool throw_errors = true)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
for (hpx::shared_future<T> const& f : workitems)
{
if (f.has_exception())
Expand All @@ -88,13 +104,17 @@ namespace hpx { namespace parallel { namespace util { namespace detail {

if (throw_errors && !errors.empty())
throw exception_list(std::move(errors));
#endif
}

template <typename T, typename Cleanup>
static void call(std::vector<hpx::future<T>>& workitems,
std::list<std::exception_ptr>& 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<T>& f : workitems)
Expand Down Expand Up @@ -135,6 +155,7 @@ namespace hpx { namespace parallel { namespace util { namespace detail {

if (throw_errors && !errors.empty())
throw exception_list(std::move(errors));
#endif
}
};

Expand All @@ -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<std::exception_ptr>&)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
hpx::terminate();
#endif
}

template <typename T>
static void call(std::vector<hpx::future<T>> const& workitems,
std::list<std::exception_ptr>&, bool = true)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
for (hpx::future<T> const& f : workitems)
{
if (f.has_exception())
hpx::terminate();
}
#endif
}

template <typename T>
static void call(std::vector<hpx::shared_future<T>> const& workitems,
std::list<std::exception_ptr>&, bool = true)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
for (hpx::shared_future<T> const& f : workitems)
{
if (f.has_exception())
hpx::terminate();
}
#endif
}

template <typename T, typename Cleanup>
static void call(std::vector<hpx::future<T>> const& workitems,
std::list<std::exception_ptr>&, Cleanup&&, bool = true)
{
#if defined(HPX_COMPUTE_DEVICE_CODE)
HPX_ASSERT(false);
#else
for (hpx::future<T> const& f : workitems)
{
if (f.has_exception())
hpx::terminate();
}
#endif
}
};
}}}} // namespace hpx::parallel::util::detail
Expand Down
9 changes: 9 additions & 0 deletions libs/assertion/include/hpx/assertion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -16,6 +17,9 @@
#include <hpx/assertion/source_location.hpp>
#include <hpx/preprocessor/stringize.hpp>

#if defined(HPX_COMPUTE_DEVICE_CODE)
#include <assert.h>
#endif
#include <string>
#include <type_traits>

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/util/interval_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_lock<mutex_type> > 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,
Expand Down
2 changes: 1 addition & 1 deletion src/util/one_size_heap_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8174758

Please sign in to comment.