Skip to content

Commit 90f3524

Browse files
authored
SYCL: fixing issues revealed with icpx 2025 (kokkos#2669)
* SYCL: fixing issues revealed with icpx 2025 Removing some volatile attributes in spgemm and fixing issue with reduction update variable initialization which would cause access out of bound and segfaults. Signed-off-by: Luc Berger-Vergiat <[email protected]> * Fixing test and applying clang-format Signed-off-by: Luc Berger-Vergiat <[email protected]> --------- Signed-off-by: Luc Berger-Vergiat <[email protected]>
1 parent 61b2e93 commit 90f3524

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

blas/impl/KokkosBlas1_iamax_impl.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ struct V_Iamax_Functor {
6161
if (val > maxval) lmaxloc = i;
6262
}
6363

64-
KOKKOS_INLINE_FUNCTION void init(value_type& update) const {
65-
update = Kokkos::reduction_identity<typename RV::value_type>::max() + 1;
66-
}
64+
KOKKOS_INLINE_FUNCTION void init(value_type& update) const { update = 1; }
6765

6866
KOKKOS_INLINE_FUNCTION void join(value_type& update, const value_type& source) const {
6967
mag_type source_val = IPT::norm(m_x(source - 1));

blas/unit_test/Test_Blas1_iamax.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
1414
//
1515
//@HEADER
16+
1617
#include <gtest/gtest.h>
1718
#include <Kokkos_Core.hpp>
1819
#include <Kokkos_Random.hpp>
@@ -22,9 +23,9 @@
2223
namespace Test {
2324
template <class ViewTypeA, class Device>
2425
void impl_test_iamax(int N) {
25-
typedef typename ViewTypeA::non_const_value_type ScalarA;
26-
typedef Kokkos::ArithTraits<ScalarA> AT;
27-
typedef typename AT::mag_type mag_type;
26+
using ScalarA = typename ViewTypeA::non_const_value_type;
27+
using AT = Kokkos::ArithTraits<ScalarA>;
28+
using mag_type = typename AT::mag_type;
2829
using size_type = typename ViewTypeA::size_type;
2930

3031
view_stride_adapter<ViewTypeA> a("X", N);

sparse/impl/KokkosSparse_spgemm_impl_compression.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,14 +573,11 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
573573
if (overall_num_unsuccess) {
574574
// then we allocate second level memory using memory pool.
575575
if (!l2_allocated) {
576-
volatile nnz_lno_t *tmp = NULL;
576+
nnz_lno_t *tmp = NULL;
577577
while (tmp == NULL) {
578578
Kokkos::single(
579579
Kokkos::PerThread(teamMember),
580-
[&](volatile nnz_lno_t *&memptr) {
581-
memptr = (volatile nnz_lno_t *)(memory_space.allocate_chunk(row_ind));
582-
},
583-
tmp);
580+
[&](nnz_lno_t *&memptr) { memptr = (nnz_lno_t *)(memory_space.allocate_chunk(row_ind)); }, tmp);
584581
}
585582
globally_used_hash_indices = (nnz_lno_t *)tmp;
586583
hm2.hash_begins = (nnz_lno_t *)(globally_used_hash_indices + pow2_hash_size);

sparse/impl/KokkosSparse_spgemm_impl_symbolic.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,12 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
455455
if (overall_num_unsuccess) {
456456
// printf("row:%d\n", row_index);
457457
if (!is_global_alloced) {
458-
volatile nnz_lno_t *tmp = NULL;
459-
size_t tid = get_thread_id(row_index);
458+
nnz_lno_t *tmp = NULL;
459+
size_t tid = get_thread_id(row_index);
460460
while (tmp == NULL) {
461461
Kokkos::single(
462462
Kokkos::PerThread(teamMember),
463-
[&](volatile nnz_lno_t *&memptr) { memptr = (volatile nnz_lno_t *)(m_space.allocate_chunk(tid)); },
464-
tmp);
463+
[&](nnz_lno_t *&memptr) { memptr = (nnz_lno_t *)(m_space.allocate_chunk(tid)); }, tmp);
465464
}
466465
is_global_alloced = true;
467466

@@ -1000,13 +999,12 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
1000999
if (overall_num_unsuccess) {
10011000
// printf("row:%d\n", row_index);
10021001
if (!is_global_alloced) {
1003-
volatile nnz_lno_t *tmp = NULL;
1004-
size_t tid = get_thread_id(row_index);
1002+
nnz_lno_t *tmp = NULL;
1003+
size_t tid = get_thread_id(row_index);
10051004
while (tmp == NULL) {
10061005
Kokkos::single(
10071006
Kokkos::PerThread(teamMember),
1008-
[&](volatile nnz_lno_t *&memptr) { memptr = (volatile nnz_lno_t *)(m_space.allocate_chunk(tid)); },
1009-
tmp);
1007+
[&](nnz_lno_t *&memptr) { memptr = (nnz_lno_t *)(m_space.allocate_chunk(tid)); }, tmp);
10101008
}
10111009
is_global_alloced = true;
10121010

0 commit comments

Comments
 (0)