From edbd4836d959861f6b1724acd1273c690a23acf1 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Tue, 30 Jul 2024 01:58:05 +0900 Subject: [PATCH] fix conflicts --- common/src/KokkosFFT_utils.hpp | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index b7ff0c67..00bd6764 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -14,13 +14,54 @@ #if defined(KOKKOS_ENABLE_CXX17) #include +#define KOKKOSFFT_EXPECTS(expression, msg) \ + KokkosFFT::Impl::check_precondition((expression), msg, __FILE__, __LINE__, \ + __FUNCTION__) #else #include +#define KOKKOSFFT_EXPECTS(expression, msg) \ + KokkosFFT::Impl::check_precondition( \ + (expression), msg, std::source_location::current().file_name(), \ + std::source_location::current().line(), \ + std::source_location::current().function_name(), \ + std::source_location::current().column()) #endif namespace KokkosFFT { namespace Impl { +inline void check_precondition(const bool expression, + [[maybe_unused]] const std::string& msg, + [[maybe_unused]] const char* file_name, int line, + [[maybe_unused]] const char* function_name, + [[maybe_unused]] const int column = -1) { + // Quick return if possible + if (expression) return; + + std::stringstream ss("file: "); + if (column == -1) { + // For C++ 17 + ss << file_name << '(' << line << ") `" << function_name << "`: " << msg + << '\n'; + } else { + // For C++ 20 and later + ss << file_name << '(' << line << ':' << column << ") `" << function_name + << "`: " << msg << '\n'; + } + throw std::runtime_error(ss.str()); +} +inline void check_precondition(const bool expression, const std::string& msg, + const char* file_name, int line, + const char* function_name) { + std::stringstream ss("file: "); + ss << file_name << '(' << line << ") `" << function_name << "`: " << msg + << '\n'; + if (!expression) { + throw std::runtime_error(ss.str()); + } +} +#endif + template auto convert_negative_axis(ViewType, int _axis = -1) { static_assert(Kokkos::is_view::value,