|
13 | 13 | #include <numeric>
|
14 | 14 | #include "KokkosFFT_traits.hpp"
|
15 | 15 |
|
16 |
| -#ifndef KOKKOS_ENABLE_CXX17 |
17 |
| -#include <source_location> |
18 |
| -#define KOKKOSFFT_EXPECTS(expression, msg) \ |
19 |
| - KokkosFFT::Impl::check_precondition((expression), msg, \ |
20 |
| - std::source_location::current()) |
21 |
| -#else |
| 16 | +#if defined(KOKKOS_ENABLE_CXX17) |
22 | 17 | #include <cstdlib>
|
23 | 18 | #define KOKKOSFFT_EXPECTS(expression, msg) \
|
24 | 19 | KokkosFFT::Impl::check_precondition((expression), msg, __FILE__, __LINE__, \
|
25 | 20 | __FUNCTION__)
|
| 21 | +#else |
| 22 | +#include <source_location> |
| 23 | +#define KOKKOSFFT_EXPECTS(expression, msg) \ |
| 24 | + KokkosFFT::Impl::check_precondition((expression), msg, \ |
| 25 | + std::source_location::current()) |
26 | 26 | #endif
|
27 | 27 |
|
28 | 28 | namespace KokkosFFT {
|
29 | 29 | namespace Impl {
|
30 | 30 |
|
31 |
| -#ifndef KOKKOS_ENABLE_CXX17 |
| 31 | +#if defined(KOKKOS_ENABLE_CXX17) |
32 | 32 | inline void check_precondition(const bool expression, const std::string& msg,
|
33 |
| - std::source_location location) { |
| 33 | + const char* file_name, int line, |
| 34 | + const char* function_name) { |
34 | 35 | std::stringstream ss("file: ");
|
35 |
| - ss << location.file_name() << '(' << location.line() << ':' |
36 |
| - << location.column() << ") `" << location.function_name() << "`: " << msg |
| 36 | + ss << file_name << '(' << line << ") `" << function_name << "`: " << msg |
37 | 37 | << '\n';
|
38 |
| - |
39 | 38 | if (!expression) {
|
40 | 39 | throw std::runtime_error(ss.str());
|
41 | 40 | }
|
42 | 41 | }
|
43 | 42 | #else
|
44 | 43 | inline void check_precondition(const bool expression, const std::string& msg,
|
45 |
| - const char* file_name, int line, |
46 |
| - const char* function_name) { |
| 44 | + std::source_location location) { |
47 | 45 | std::stringstream ss("file: ");
|
48 |
| - ss << file_name << '(' << line << ") `" << function_name << "`: " << msg |
| 46 | + ss << location.file_name() << '(' << location.line() << ':' |
| 47 | + << location.column() << ") `" << location.function_name() << "`: " << msg |
49 | 48 | << '\n';
|
| 49 | + |
50 | 50 | if (!expression) {
|
51 | 51 | throw std::runtime_error(ss.str());
|
52 | 52 | }
|
53 | 53 | }
|
54 | 54 | #endif
|
55 |
| - |
56 | 55 | template <typename ViewType>
|
57 | 56 | auto convert_negative_axis(ViewType, int _axis = -1) {
|
58 | 57 | static_assert(Kokkos::is_view<ViewType>::value,
|
59 | 58 | "convert_negative_axis: ViewType is not a Kokkos::View.");
|
60 | 59 | int rank = static_cast<int>(ViewType::rank());
|
61 | 60 |
|
62 | 61 | KOKKOSFFT_EXPECTS(_axis >= -rank && _axis < rank,
|
63 |
| - "axis should be in [-rank, rank-1]"); |
| 62 | + "Axis must be in [-rank, rank-1]"); |
64 | 63 |
|
65 | 64 | int axis = _axis < 0 ? rank + _axis : _axis;
|
66 | 65 | return axis;
|
|
0 commit comments