Skip to content

Commit b716cab

Browse files
authored
[SYCL] Fix linker error about undefined symbols (#2675)
In pre-C++17 context, static constexpr members must be defined at namespace scope even if member is initialized inside the class definition.
1 parent 3e11f37 commit b716cab

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

sycl/include/CL/sycl/half_type.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ template <> struct numeric_limits<cl::sycl::half> {
246246
static constexpr bool has_denorm_loss = false;
247247
static constexpr bool tinyness_before = false;
248248
static constexpr bool traps = false;
249-
static constexpr float half_min = 6.103515625e-05f;
250-
static constexpr float half_max = 65504.0f;
251-
static constexpr float half_eps = 9.765625e-04f;
252249
static constexpr int max_exponent10 = 4;
253250
static constexpr int max_exponent = 16;
254251
static constexpr int min_exponent10 = -4;
@@ -263,24 +260,24 @@ template <> struct numeric_limits<cl::sycl::half> {
263260
static constexpr float_round_style round_style = round_to_nearest;
264261

265262
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half(min)() noexcept {
266-
return half_min;
263+
return 6.103515625e-05f; // half minimum value
267264
}
268265

269266
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half(max)() noexcept {
270-
return half_max;
267+
return 65504.0f; // half maximum value
271268
}
272269

273270
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half lowest() noexcept {
274-
return -half_max;
271+
return -65504.0f; // -1*(half maximum value)
275272
}
276273

277274
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half epsilon() noexcept {
278-
return half_eps;
275+
return 9.765625e-04f; // half epsilon
279276
}
280277

281278
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half
282279
round_error() noexcept {
283-
return 0.5F;
280+
return 0.5f;
284281
}
285282

286283
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half infinity() noexcept {
@@ -297,7 +294,7 @@ template <> struct numeric_limits<cl::sycl::half> {
297294
}
298295

299296
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half denorm_min() noexcept {
300-
return 5.96046e-08F;
297+
return 5.96046e-08f;
301298
}
302299
};
303300

0 commit comments

Comments
 (0)