diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index d1adbf2ea..9d2dab4f0 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -16,8 +16,10 @@ #pragma once +#include #include #include +#include #include diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 1c669822c..5d8b340ab 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -16,8 +16,6 @@ #pragma once -#include - #include #include @@ -245,24 +243,3 @@ class out_of_range : public std::out_of_range { assert(status__ == cudaSuccess); \ } while (0) #endif - -/** - * @brief Assertion that logs a CRITICAL log message on failure. - */ -#ifdef NDEBUG -#define RMM_LOGGING_ASSERT(_expr) (void)0 -#elif SPDLOG_ACTIVE_LEVEL < SPDLOG_LEVEL_OFF -#define RMM_LOGGING_ASSERT(_expr) \ - do { \ - bool const success = (_expr); \ - if (!success) { \ - RMM_LOG_CRITICAL( \ - "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ - rmm::logger().flush(); \ - /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ - assert(success); \ - } \ - } while (0) -#else -#define RMM_LOGGING_ASSERT(_expr) assert((_expr)); -#endif diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp new file mode 100644 index 000000000..321bddab8 --- /dev/null +++ b/include/rmm/detail/logging_assert.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// Only include if needed in RMM_LOGGING_ASSERT below. The +// logger can be extremely expensive to compile, so we want to avoid including +// it. +#if !defined(NDEBUG) +#include +#include +#include +#endif + +/** + * @brief Assertion that logs a CRITICAL log message on failure. + */ +#ifdef NDEBUG +#define RMM_LOGGING_ASSERT(_expr) (void)0 +#elif SPDLOG_ACTIVE_LEVEL < SPDLOG_LEVEL_OFF +#define RMM_LOGGING_ASSERT(_expr) \ + do { \ + bool const success = (_expr); \ + if (!success) { \ + RMM_LOG_CRITICAL( \ + "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ + rmm::logger().flush(); \ + /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ + assert(success); \ + } \ + } while (0) +#else +#define RMM_LOGGING_ASSERT(_expr) assert((_expr)); +#endif diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 67babfdc5..e16fbaf7c 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include #include diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 302c925f9..d8da58493 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index b3686f78a..4954415c3 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 465c0653f..8955fd958 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 3feac1213..0bbdc7468 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index e804cf0ea..2af720d3f 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include