Skip to content

Commit

Permalink
Fix "loop not vectorized" warning when running with newer icpx compil…
Browse files Browse the repository at this point in the history
…er (#2818)

Co-authored-by: Anatoly Volkov <117643568+avolkov-intel@users.noreply.github.com>
  • Loading branch information
Vika-F and avolkov-intel committed Jun 24, 2024
1 parent c3d61d3 commit 89a5667
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cpp/oneapi/dal/table/backend/csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*******************************************************************************/

#include "oneapi/dal/backend/common.hpp"
#include "oneapi/dal/table/backend/csr_kernels.hpp"
#include "oneapi/dal/table/backend/convert.hpp"

Expand Down Expand Up @@ -411,6 +412,12 @@ bool is_sorted(sycl::queue& queue,

sycl::buffer<std::int64_t, 1> count_buf(&count_descending_pairs, sycl::range<1>(1));

const auto count_m1 = count - 1LL;
const auto wg_size = dal::backend::device_max_wg_size(queue);
const size_t count_m1_unsigned = static_cast<size_t>(count_m1);

const size_t wg_count = (count_m1 + wg_size - 1) / wg_size;

// count the number of pairs of the subsequent elements in the data array that are sorted
// in desccending order using sycl::reduction
queue
Expand All @@ -419,10 +426,11 @@ bool is_sorted(sycl::queue& queue,
auto count_descending_reduction =
sycl::reduction(count_buf, cgh, sycl::ext::oneapi::plus<std::int64_t>());

cgh.parallel_for(sycl::range<1>{ dal::detail::integral_cast<std::size_t>(count - 1) },
cgh.parallel_for(sycl::nd_range<1>{ wg_count * wg_size, wg_size },
count_descending_reduction,
[=](sycl::id<1> i, auto& count_descending) {
if (data[i] > data[i + 1])
[=](sycl::nd_item<1> idx, auto& count_descending) {
const auto i = idx.get_global_id(0);
if (i < count_m1_unsigned && data[i + 1] < data[i])
count_descending.combine(1);
});
})
Expand Down

0 comments on commit 89a5667

Please # to comment.