Skip to content

Commit edbd483

Browse files
author
Yuuichi Asahi
committed
fix conflicts
1 parent 1528955 commit edbd483

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

common/src/KokkosFFT_utils.hpp

+41
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,54 @@
1414

1515
#if defined(KOKKOS_ENABLE_CXX17)
1616
#include <cstdlib>
17+
#define KOKKOSFFT_EXPECTS(expression, msg) \
18+
KokkosFFT::Impl::check_precondition((expression), msg, __FILE__, __LINE__, \
19+
__FUNCTION__)
1720
#else
1821
#include <source_location>
22+
#define KOKKOSFFT_EXPECTS(expression, msg) \
23+
KokkosFFT::Impl::check_precondition( \
24+
(expression), msg, std::source_location::current().file_name(), \
25+
std::source_location::current().line(), \
26+
std::source_location::current().function_name(), \
27+
std::source_location::current().column())
1928
#endif
2029

2130
namespace KokkosFFT {
2231
namespace Impl {
2332

33+
inline void check_precondition(const bool expression,
34+
[[maybe_unused]] const std::string& msg,
35+
[[maybe_unused]] const char* file_name, int line,
36+
[[maybe_unused]] const char* function_name,
37+
[[maybe_unused]] const int column = -1) {
38+
// Quick return if possible
39+
if (expression) return;
40+
41+
std::stringstream ss("file: ");
42+
if (column == -1) {
43+
// For C++ 17
44+
ss << file_name << '(' << line << ") `" << function_name << "`: " << msg
45+
<< '\n';
46+
} else {
47+
// For C++ 20 and later
48+
ss << file_name << '(' << line << ':' << column << ") `" << function_name
49+
<< "`: " << msg << '\n';
50+
}
51+
throw std::runtime_error(ss.str());
52+
}
53+
inline void check_precondition(const bool expression, const std::string& msg,
54+
const char* file_name, int line,
55+
const char* function_name) {
56+
std::stringstream ss("file: ");
57+
ss << file_name << '(' << line << ") `" << function_name << "`: " << msg
58+
<< '\n';
59+
if (!expression) {
60+
throw std::runtime_error(ss.str());
61+
}
62+
}
63+
#endif
64+
2465
template <typename ViewType>
2566
auto convert_negative_axis(ViewType, int _axis = -1) {
2667
static_assert(Kokkos::is_view<ViewType>::value,

0 commit comments

Comments
 (0)