Skip to content

Commit 39b6672

Browse files
[SYCL][NFC] Fix compilation of reduction.hpp with gcc 8.4 (#7484)
GCC 8.4 emits the following error: ``` include/sycl/reduction.hpp: In lambda function: include/sycl/reduction.hpp:2318:31: error: lambda capture of ‘NumArgs’ is not a constant expression if constexpr (NumArgs == 2) { ``` Fixed it by removing the lambda used to initialize `OneElemSize` variable.
1 parent 9a2c4fe commit 39b6672

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

sycl/include/sycl/reduction.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,16 +2314,15 @@ void reduction_parallel_for(handler &CGH, range<Dims> Range,
23142314

23152315
// Before running the kernels, check that device has enough local memory
23162316
// to hold local arrays required for the tree-reduction algorithm.
2317-
size_t OneElemSize = [&]() {
2318-
if constexpr (NumArgs == 2) {
2319-
using Reduction = std::tuple_element_t<0, decltype(ReduTuple)>;
2320-
constexpr bool IsTreeReduction =
2321-
!Reduction::has_fast_reduce && !Reduction::has_fast_atomics;
2322-
return IsTreeReduction ? sizeof(typename Reduction::result_type) : 0;
2323-
} else {
2324-
return reduGetMemPerWorkItem(ReduTuple, ReduIndices);
2325-
}
2326-
}();
2317+
size_t OneElemSize;
2318+
if constexpr (NumArgs == 2) {
2319+
using Reduction = std::tuple_element_t<0, decltype(ReduTuple)>;
2320+
constexpr bool IsTreeReduction =
2321+
!Reduction::has_fast_reduce && !Reduction::has_fast_atomics;
2322+
OneElemSize = IsTreeReduction ? sizeof(typename Reduction::result_type) : 0;
2323+
} else {
2324+
OneElemSize = reduGetMemPerWorkItem(ReduTuple, ReduIndices);
2325+
}
23272326

23282327
uint32_t NumConcurrentWorkGroups =
23292328
#ifdef __SYCL_REDUCTION_NUM_CONCURRENT_WORKGROUPS

0 commit comments

Comments
 (0)