From f2f122157520d07735f0553ccdf0c690a0588ec4 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk <21087696+oleksandr-pavlyk@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:23:45 -0600 Subject: [PATCH] Fix build of dpctl with sycl nightly from 2025-01-18 The failure was caused by TwoOffsets_FixedDimStridedIndexer not being device copyable, consequence of not being trivially copyable, consequence of using const class members contrary to C++ coding guidelines. https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.html This change adheres to the guidelines by removing const qualifier in class members. This change also avoids unnecessary copy in constructors of fixed-dim-strided-indexers that take container arguments by values. --- .../libtensor/include/utils/offset_utils.hpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/dpctl/tensor/libtensor/include/utils/offset_utils.hpp b/dpctl/tensor/libtensor/include/utils/offset_utils.hpp index 1438def12a..b8ae599142 100644 --- a/dpctl/tensor/libtensor/include/utils/offset_utils.hpp +++ b/dpctl/tensor/libtensor/include/utils/offset_utils.hpp @@ -617,8 +617,8 @@ struct NthStrideOffset template struct FixedDimStridedIndexer { - FixedDimStridedIndexer(const std::array _shape, - const std::array _strides, + FixedDimStridedIndexer(const std::array &_shape, + const std::array &_strides, ssize_t _offset) : _ind(_shape), strides(_strides), starting_offset(_offset) { @@ -642,15 +642,15 @@ template struct FixedDimStridedIndexer private: dpctl::tensor::strides::CIndexer_array _ind; - const std::array strides; + std::array strides; ssize_t starting_offset; }; template struct TwoOffsets_FixedDimStridedIndexer { - TwoOffsets_FixedDimStridedIndexer(const std::array _shape, - const std::array _strides1, - const std::array _strides2, + TwoOffsets_FixedDimStridedIndexer(const std::array &_shape, + const std::array &_strides1, + const std::array &_strides2, ssize_t _offset1, ssize_t _offset2) : _ind(_shape), strides1(_strides1), strides2(_strides2), @@ -684,21 +684,22 @@ template struct TwoOffsets_FixedDimStridedIndexer private: dpctl::tensor::strides::CIndexer_array _ind; - const std::array strides1; - const std::array strides2; + std::array strides1; + std::array strides2; ssize_t starting_offset1; ssize_t starting_offset2; }; template struct ThreeOffsets_FixedDimStridedIndexer { - ThreeOffsets_FixedDimStridedIndexer(const std::array _shape, - const std::array _strides1, - const std::array _strides2, - const std::array _strides3, - ssize_t _offset1, - ssize_t _offset2, - ssize_t _offset3) + ThreeOffsets_FixedDimStridedIndexer( + const std::array &_shape, + const std::array &_strides1, + const std::array &_strides2, + const std::array &_strides3, + ssize_t _offset1, + ssize_t _offset2, + ssize_t _offset3) : _ind(_shape), strides1(_strides1), strides2(_strides2), strides3(_strides3), starting_offset1(_offset1), starting_offset2(_offset2), starting_offset3(_offset3) @@ -738,9 +739,9 @@ template struct ThreeOffsets_FixedDimStridedIndexer private: dpctl::tensor::strides::CIndexer_array _ind; - const std::array strides1; - const std::array strides2; - const std::array strides3; + std::array strides1; + std::array strides2; + std::array strides3; ssize_t starting_offset1; ssize_t starting_offset2; ssize_t starting_offset3;