Skip to content

Commit 3382895

Browse files
[test] Fix error aspect fp64 is not supported in tests of std::complex (#2029)
1 parent 60e06bd commit 3382895

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

test/support/test_complex.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <type_traits>
2727
#include <cassert>
28+
#include <limits>
2829

2930
#if !_PSTL_MSVC_LESS_THAN_CPP20_COMPLEX_CONSTEXPR_BROKEN
3031
# define STD_COMPLEX_TESTS_STATIC_ASSERT(arg) static_assert(arg)
@@ -121,11 +122,8 @@ run_test()
121122

122123
namespace TestUtils
123124
{
124-
// This constant was declared to avoid the substitution and evaluation of the macro INFINITY
125-
// inside Kernel code. Since the implementation of INFINITY macro is not regulated, there are
126-
// cases where temporary expressions of type double are used to calculate the value of INFINITY.
127-
// This lead to an error on devices where the double type is not supported.
128-
static constexpr float infinity_val = INFINITY;
125+
template <typename T>
126+
static constexpr float infinity_val = std::numeric_limits<T>::infinity();
129127

130128
// Run test in Kernel as single task
131129
template <typename TFncDoubleHasSupportInRuntime, typename TFncDoubleHasntSupportInRuntime>

test/xpu_api/numerics/complex.number/complex.transcendentals/acos.pass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ template <class T>
2929
void
3030
test()
3131
{
32-
test(dpl::complex<T>(TestUtils::infinity_val, 1), dpl::complex<T>(0, -TestUtils::infinity_val));
32+
test(dpl::complex<T>(TestUtils::infinity_val<T>, 1), dpl::complex<T>(0, -TestUtils::infinity_val<T>));
3333
}
3434

3535
void test_edges()

test/xpu_api/numerics/complex.number/complex.transcendentals/acosh.pass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ template <class T>
2929
void
3030
test()
3131
{
32-
test(dpl::complex<T>(TestUtils::infinity_val, 1), dpl::complex<T>(TestUtils::infinity_val, 0));
32+
test(dpl::complex<T>(TestUtils::infinity_val<T>, 1), dpl::complex<T>(TestUtils::infinity_val<T>, 0));
3333
}
3434

3535
void test_edges()

test/xpu_api/numerics/complex.number/complex.transcendentals/log.pass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ template <class T>
2929
void
3030
test()
3131
{
32-
test(dpl::complex<T>(0, 0), dpl::complex<T>(-TestUtils::infinity_val, 0));
32+
test(dpl::complex<T>(0, 0), dpl::complex<T>(-TestUtils::infinity_val<T>, 0));
3333
}
3434

3535
void test_edges()

test/xpu_api/numerics/complex.number/complex.transcendentals/log10.pass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ template <class T>
2929
void
3030
test()
3131
{
32-
test(dpl::complex<T>(0, 0), dpl::complex<T>(-TestUtils::infinity_val, 0));
32+
test(dpl::complex<T>(0, 0), dpl::complex<T>(-TestUtils::infinity_val<T>, 0));
3333
}
3434

3535
void test_edges()

0 commit comments

Comments
 (0)