From 645536eb0c043a5ad50c27b4280c2291328a2c41 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Fri, 3 Nov 2023 07:59:26 -0700 Subject: [PATCH 1/4] [NFC] Drop legacy get/setElement helpers SYCL 2020 introduced `operator[]` to `vec` class and we can use it directly instead of going through the helper. --- tests/common/common.h | 1 - tests/common/common_vec.h | 32 +-- .../hierarchical_non_uniform_local_range.cpp | 5 +- util/math_helper.h | 5 +- util/math_reference.cpp | 4 +- util/math_reference.h | 66 +++-- util/math_vector.h | 257 ------------------ 7 files changed, 51 insertions(+), 319 deletions(-) delete mode 100644 util/math_vector.h diff --git a/tests/common/common.h b/tests/common/common.h index 4eff5583e..a3229128f 100644 --- a/tests/common/common.h +++ b/tests/common/common.h @@ -27,7 +27,6 @@ #include #include "../../util/conversion.h" -#include "../../util/math_vector.h" #include "../../util/proxy.h" #include "../../util/sycl_enums.h" #include "../../util/test_base.h" diff --git a/tests/common/common_vec.h b/tests/common/common_vec.h index 7b764f1bb..196a70251 100644 --- a/tests/common/common_vec.h +++ b/tests/common/common_vec.h @@ -27,7 +27,6 @@ #include "../../util/accuracy.h" #include "../../util/math_reference.h" -#include "../../util/math_vector.h" #include "../../util/proxy.h" #include "../../util/test_base.h" #include "../../util/type_traits.h" @@ -61,7 +60,7 @@ template bool check_vector_values(sycl::vec vector, vecType* vals) { for (int i = 0; i < numOfElems; i++) { - if ((vals[i] != getElement(vector, i))) { + if ((vals[i] != vector[i])) { return false; } } @@ -77,7 +76,7 @@ typename std::enable_if::value, bool>::type check_vector_values_div(sycl::vec vector, vecType *vals) { for (int i = 0; i < numOfElems; i++) { - vecType vectorValue = getElement(vector, i); + vecType vectorValue = vector[i]; if (vals[i] == vectorValue) continue; const vecType ulpsExpected = 2.5; // Min Accuracy for x / y @@ -115,7 +114,7 @@ bool check_single_vector_op(vectorType vector1, lambdaFunc lambda) { return false; } for (int i = 0; i < vecSize; i++) { - if (getElement(vector1, i) != getElement(vector2, i)) { + if (vector1[i] != vector2[i]) { return false; } } @@ -130,8 +129,7 @@ template sycl::vec convert_vec(sycl::vec inputVec) { sycl::vec resVec; for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(inputVec, i); - setElement(resVec, i, convertType(elem)); + resVec[i] = convertType(inputVec[i]); } return resVec; } @@ -143,8 +141,7 @@ sycl::vec rte(sycl::vec inputVec) { sycl::vec roundedVec = reference::rint(inputVec); sycl::vec resVec; for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(roundedVec, i); - setElement(resVec, i, static_cast(elem)); + resVec[i] = static_cast(roundedVec[i]); } return resVec; } @@ -158,8 +155,7 @@ sycl::vec rtz(sycl::vec inputVec) { sycl::vec roundedVec = reference::trunc(inputVec); sycl::vec resVec; for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(roundedVec, i); - setElement(resVec, i, static_cast(elem)); + resVec[i] = static_cast(roundedVec[i]); } return resVec; } @@ -173,8 +169,7 @@ sycl::vec rtp(sycl::vec inputVec) { sycl::vec roundedVec = reference::ceil(inputVec); sycl::vec resVec; for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(roundedVec, i); - setElement(resVec, i, static_cast(elem)); + resVec[i] = static_cast(roundedVec[i]); } return resVec; } @@ -188,8 +183,7 @@ sycl::vec rtn(sycl::vec inputVec) { sycl::vec roundedVec = reference::floor(inputVec); sycl::vec resVec; for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(roundedVec, i); - setElement(resVec, i, static_cast(elem)); + resVec[i] = static_cast(roundedVec[i]); } return resVec; } @@ -205,8 +199,8 @@ void handleFPToUnsignedConv(sycl::vec& inputVec) { if constexpr (is_sycl_floating_point::value && std::is_unsigned_v) { for (size_t i = 0; i < N; ++i) { - vecType elem = getElement(inputVec, i); - if (elem < 0) setElement(inputVec, i, -elem); + vecType elem = inputVec[i]; + if (elem < 0) inputVec[i] = -elem; } } } @@ -383,15 +377,15 @@ bool check_as_result(sycl::vec inputVec, sycl::vec asVec) { vecType tmp_ptr[N]; for (size_t i = 0; i < N; ++i) { - tmp_ptr[i] = getElement(inputVec, i); + tmp_ptr[i] = inputVec[i]; } asType exp_ptr[asN]; for (size_t i = 0; i < asN; ++i) { - exp_ptr[i] = getElement(asVec, i); + exp_ptr[i] = asVec[i]; } std::memcpy(exp_ptr, tmp_ptr, std::min(sizeof(exp_ptr), sizeof(tmp_ptr))); for (size_t i = 0; i < asN; ++i) { - if (exp_ptr[i] != getElement(asVec, i)) { + if (exp_ptr[i] != asVec[i]) { return false; } } diff --git a/tests/hierarchical/hierarchical_non_uniform_local_range.cpp b/tests/hierarchical/hierarchical_non_uniform_local_range.cpp index 9111163e6..99bd4e65a 100644 --- a/tests/hierarchical/hierarchical_non_uniform_local_range.cpp +++ b/tests/hierarchical/hierarchical_non_uniform_local_range.cpp @@ -28,7 +28,6 @@ *******************************************************************************/ #include "../common/common.h" -#include "../../util/math_vector.h" #define TEST_NAME hierarchical_non_uniform_local_range @@ -41,12 +40,12 @@ using namespace sycl_cts; void check_expected(const std::vector &data, unsigned local_id, unsigned idx, int dim, bool set, util::logger &log) { int expected = set ? local_id : -1; - if (getElement(data[idx], dim - 1) != expected) { + if (data[idx][dim - 1] != expected) { std::string errorMessage = std::string("Value for global id ") + std::to_string(idx) + std::string(" for dim = ") + std::to_string(dim) + std::string(" was not correct (") + - std::to_string(getElement(data[idx], dim - 1)) + + std::to_string(data[idx][dim - 1]) + std::string(" instead of ") + std::to_string(expected) + ")"; FAIL(log, errorMessage); } diff --git a/util/math_helper.h b/util/math_helper.h index 980295715..3953050a7 100644 --- a/util/math_helper.h +++ b/util/math_helper.h @@ -29,7 +29,6 @@ #include "../util/stl.h" #include "./../oclmath/mt19937.h" -#include "./math_vector.h" namespace sycl_cts { /** math utility functions @@ -92,7 +91,7 @@ T getElement(const T &f, int) { * extract an individual element. */ template T getElement(sycl::vec &f, int ix) { - return getComponent()(f, ix); + return f[ix]; } // FIXME: hipSYCL does not support marray @@ -107,7 +106,7 @@ T getElement(sycl::marray &f, size_t ix) { template void setElement(sycl::vec &f, int ix, T value) { - setComponent()(f, ix, value); + f[ix] = value; } template diff --git a/util/math_reference.cpp b/util/math_reference.cpp index c91dd427a..64235677c 100644 --- a/util/math_reference.cpp +++ b/util/math_reference.cpp @@ -579,7 +579,9 @@ sycl::vec cross_t(sycl::vec a, sycl::vec b) { temp_res[1] = av[2] * bv[0] - av[0] * bv[2]; temp_res[2] = av[0] * bv[1] - av[1] * bv[0]; temp_res[3] = 0.0; - for (int i = 0; i < N; i++) setElement(res, i, temp_res[i]); + for (int i = 0; i < N; i++) res[i] = temp_res[i]; + + return res; } diff --git a/util/math_reference.h b/util/math_reference.h index d029cdb6d..31cc039c4 100644 --- a/util/math_reference.h +++ b/util/math_reference.h @@ -208,7 +208,7 @@ bool any(T x) { template int any(sycl::vec a) { for (int i = 0; i < N; i++) { - if (any(getElement(a, i)) == 1) return true; + if (any(a[i]) == 1) return true; } return false; } @@ -230,7 +230,7 @@ bool all(T x) { template int all(sycl::vec a) { for (int i = 0; i < N; i++) { - if (all(getElement(a, i)) == 0) return false; + if (all(a[i]) == 0) return false; } return true; } @@ -263,10 +263,10 @@ sycl::vec select(sycl::vec a, sycl::vec b, sycl::vec c) { sycl::vec res; for (int i = 0; i < N; i++) { - if (any(getElement(c, i)) == 1) - setElement(res, i, getElement(b, i)); + if (any(c[i]) == 1) + res[i] = b[i]; else - setElement(res, i, getElement(a, i)); + res[i] = a[i]; } return res; } @@ -365,9 +365,9 @@ sycl_cts::resultRef> clamp(sycl::vec a, T b, T c) { sycl::vec res; std::map undefined; for (int i = 0; i < N; i++) { - sycl_cts::resultRef element = clamp(getElement(a, i), b, c); + sycl_cts::resultRef element = clamp(a[i], b, c); if (element.undefined.empty()) - setElement(res, i, element.res); + res[i] = element.res; else undefined[i] = true; } @@ -715,9 +715,9 @@ sycl_cts::resultRef> mix(sycl::vec a, sycl::vec b, sycl::vec res; std::map undefined; for (int i = 0; i < N; i++) { - sycl_cts::resultRef element = mix(getElement(a, i), getElement(b, i), c); + sycl_cts::resultRef element = mix(a[i], b[i], c); if (element.undefined.empty()) - setElement(res, i, element.res); + res[i] = element.res; else undefined[i] = true; } @@ -764,7 +764,7 @@ template sycl::vec step(T a, sycl::vec b) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, step(a, getElement(b, i))); + res[i] = step(a, b[i]); } return res; } @@ -798,9 +798,9 @@ sycl_cts::resultRef> smoothstep(T a, T b, sycl::vec c) { sycl::vec res; std::map undefined; for (int i = 0; i < N; i++) { - sycl_cts::resultRef element = smoothstep(a, b, getElement(c, i)); + sycl_cts::resultRef element = smoothstep(a, b, c[i]); if (element.undefined.empty()) - setElement(res, i, element.res); + res[i] = element.res; else undefined[i] = true; } @@ -1032,8 +1032,8 @@ sycl::vec fract(sycl::vec a, sycl::vec *b) { sycl::vec resPtr; for (int i = 0; i < N; i++) { T value; - setElement(res, i, fract(getElement(a, i), &value)); - setElement(resPtr, i, value); + res[i] = fract(a[i], &value); + resPtr[i] = value; } *b = resPtr; return res; @@ -1061,8 +1061,8 @@ sycl::vec frexp(sycl::vec a, sycl::vec *b) { sycl::vec resPtr; for (int i = 0; i < N; i++) { int value; - setElement(res, i, frexp(getElement(a, i), &value)); - setElement(resPtr, i, value); + res[i] = frexp(a[i], &value); + resPtr[i] = value; } *b = resPtr; return res; @@ -1095,7 +1095,7 @@ template sycl::vec ilogb(sycl::vec a) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, ilogb(getElement(a, i))); + res[i] = ilogb(a[i]); } return res; } @@ -1116,8 +1116,7 @@ template sycl::vec ldexp(sycl::vec a, sycl::vec b) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, - ldexp(getElement(a, i), getElement(b, i))); + res[i] = ldexp(a[i], b[i]); } return res; } @@ -1136,7 +1135,7 @@ template sycl::vec ldexp(sycl::vec a, int b) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, ldexp(getElement(a, i), b)); + res[i] = ldexp(a[i], b); } return res; } @@ -1166,8 +1165,8 @@ sycl::vec lgamma_r(sycl::vec a, sycl::vec *b) { sycl::vec resPtr; for (int i = 0; i < N; i++) { int value; - setElement(res, i, lgamma_r(getElement(a, i), &value)); - setElement(resPtr, i, value); + res[i] = lgamma_r(a[i], &value); + resPtr[i] = value; } *b = resPtr; return res; @@ -1249,8 +1248,8 @@ sycl::vec modf(sycl::vec a, sycl::vec *b) { sycl::vec resPtr; for (int i = 0; i < N; i++) { T value; - setElement(res, i, modf(getElement(a, i), &value)); - setElement(resPtr, i, value); + res[i] = modf(a[i], &value); + resPtr[i] = value; } *b = resPtr; return res; @@ -1324,8 +1323,7 @@ template sycl::vec pown(sycl::vec a, sycl::vec b) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, - pown(getElement(a, i), getElement(b, i))); + res[i] = pown(a[i], b[i]); } return res; } @@ -1378,9 +1376,8 @@ sycl::vec remquo(sycl::vec a, sycl::vec b, sycl::vec resPtr; for (int i = 0; i < N; i++) { int value; - setElement(res, i, - remquo(getElement(a, i), getElement(b, i), &value)); - setElement(resPtr, i, value); + res[i] = remquo(a[i], b[i], &value); + resPtr[i] = value; } *c = resPtr; return res; @@ -1414,8 +1411,7 @@ template sycl::vec rootn(sycl::vec a, sycl::vec b) { sycl::vec res; for (int i = 0; i < N; i++) { - setElement(res, i, - rootn(getElement(a, i), getElement(b, i))); + res[i] = rootn(a[i], b[i]); } return res; } @@ -1451,8 +1447,8 @@ sycl::vec sincos(sycl::vec a, sycl::vec *b) { sycl::vec resPtr; for (int i = 0; i < N; i++) { T value; - setElement(res, i, sincos(getElement(a, i), &value)); - setElement(resPtr, i, value); + res[i] = sincos(a[i], &value); + resPtr[i] = value; } *b = resPtr; return res; @@ -1557,7 +1553,7 @@ template T dot(sycl::vec a, sycl::vec b) { T res = 0; for (int i = 0; i < N; i++) - res += getElement(a, i) * getElement(b, i); + res += a[i] * b[i]; return res; } // FIXME: hipSYCL does not support marray @@ -1591,7 +1587,7 @@ sycl::vec normalize(sycl::vec a) { T len_a = reference::length(a); if (len_a == 0) return sycl::vec(0); for (int i = 0; i < N; i++) - setElement(res, i, getElement(a, i) / len_a); + res[i] = a[i] / len_a; return res; } // FIXME: hipSYCL does not support marray diff --git a/util/math_vector.h b/util/math_vector.h deleted file mode 100644 index 4c7a946af..000000000 --- a/util/math_vector.h +++ /dev/null @@ -1,257 +0,0 @@ -/******************************************************************************* -// -// SYCL 2020 Conformance Test Suite -// -// Copyright (c) 2017-2022 Codeplay Software LTD. All Rights Reserved. -// Copyright (c) 2022 The Khronos Group Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -*******************************************************************************/ - -#ifndef SYCL_CONFORMANCE_SUITE_MATH_VECTOR_H -#define SYCL_CONFORMANCE_SUITE_MATH_VECTOR_H - -#define CASE_GET_ELEMENT(NUM, COMPONENT) \ - case NUM: \ - return f.s##COMPONENT(); - -#define CASE_SET_ELEMENT(NUM, COMPONENT, VALUE) \ - case NUM: \ - f.s##COMPONENT() = VALUE; \ - break; - -template -struct getComponent { - T &operator()(sycl::vec &f, int number) = delete; -}; - -template -struct getComponent { - static constexpr int dim = 1; - T operator()(sycl::vec &f, int number) { - switch (number) { - CASE_GET_ELEMENT(0, 0); - default: - return T(0); - } - } -}; - -template -struct getComponent { - static constexpr int dim = 2; - T operator()(sycl::vec &f, int number) { - switch (number) { - CASE_GET_ELEMENT(0, 0); - CASE_GET_ELEMENT(1, 1); - default: - return T(0); - } - } -}; - -template -struct getComponent { - static constexpr int dim = 3; - T operator()(sycl::vec &f, int number) { - switch (number) { - CASE_GET_ELEMENT(0, 0); - CASE_GET_ELEMENT(1, 1); - CASE_GET_ELEMENT(2, 2); - default: - return T(0); - } - } -}; - -template -struct getComponent { - static constexpr int dim = 4; - T operator()(sycl::vec &f, int number) const { - switch (number) { - CASE_GET_ELEMENT(0, 0) - CASE_GET_ELEMENT(1, 1); - CASE_GET_ELEMENT(2, 2); - CASE_GET_ELEMENT(3, 3); - default: - return T(0); - } - } -}; - -template -struct getComponent { - static constexpr int dim = 8; - T operator()(sycl::vec &f, int number) const { - switch (number) { - CASE_GET_ELEMENT(0, 0) - CASE_GET_ELEMENT(1, 1); - CASE_GET_ELEMENT(2, 2); - CASE_GET_ELEMENT(3, 3); - CASE_GET_ELEMENT(4, 4); - CASE_GET_ELEMENT(5, 5); - CASE_GET_ELEMENT(6, 6); - CASE_GET_ELEMENT(7, 7); - default: - return T(0); - } - } -}; - -template -struct getComponent { - static constexpr int dim = 16; - T operator()(sycl::vec &f, int number) const { - switch (number) { - CASE_GET_ELEMENT(0, 0) - CASE_GET_ELEMENT(1, 1); - CASE_GET_ELEMENT(2, 2); - CASE_GET_ELEMENT(3, 3); - CASE_GET_ELEMENT(4, 4); - CASE_GET_ELEMENT(5, 5); - CASE_GET_ELEMENT(6, 6); - CASE_GET_ELEMENT(7, 7); - CASE_GET_ELEMENT(8, 8); - CASE_GET_ELEMENT(9, 9); - CASE_GET_ELEMENT(10, A); - CASE_GET_ELEMENT(11, B); - CASE_GET_ELEMENT(12, C); - CASE_GET_ELEMENT(13, D); - CASE_GET_ELEMENT(14, E); - CASE_GET_ELEMENT(15, F); - default: - return T(0); - } - } -}; - -template -struct setComponent { - T &operator()(sycl::vec &f, int number) const = delete; -}; - -template -struct setComponent { - static constexpr int dim = 1; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - default: - break; - } - } -}; - -template -struct setComponent { - static constexpr int dim = 2; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - CASE_SET_ELEMENT(1, 1, value); - default: - break; - } - } -}; - -template -struct setComponent { - static constexpr int dim = 3; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - CASE_SET_ELEMENT(1, 1, value); - CASE_SET_ELEMENT(2, 2, value); - default: - break; - } - } -}; - -template -struct setComponent { - static constexpr int dim = 4; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - CASE_SET_ELEMENT(1, 1, value); - CASE_SET_ELEMENT(2, 2, value); - CASE_SET_ELEMENT(3, 3, value); - default: - break; - } - } -}; - -template -struct setComponent { - static constexpr int dim = 8; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - CASE_SET_ELEMENT(1, 1, value); - CASE_SET_ELEMENT(2, 2, value); - CASE_SET_ELEMENT(3, 3, value); - CASE_SET_ELEMENT(4, 4, value); - CASE_SET_ELEMENT(5, 5, value); - CASE_SET_ELEMENT(6, 6, value); - CASE_SET_ELEMENT(7, 7, value); - default: - break; - } - } -}; - -template -struct setComponent { - static constexpr int dim = 16; - void operator()(sycl::vec &f, int number, T value) const { - switch (number) { - CASE_SET_ELEMENT(0, 0, value) - CASE_SET_ELEMENT(1, 1, value); - CASE_SET_ELEMENT(2, 2, value); - CASE_SET_ELEMENT(3, 3, value); - CASE_SET_ELEMENT(4, 4, value); - CASE_SET_ELEMENT(5, 5, value); - CASE_SET_ELEMENT(6, 6, value); - CASE_SET_ELEMENT(7, 7, value); - CASE_SET_ELEMENT(8, 8, value); - CASE_SET_ELEMENT(9, 9, value); - CASE_SET_ELEMENT(10, A, value); - CASE_SET_ELEMENT(11, B, value); - CASE_SET_ELEMENT(12, C, value); - CASE_SET_ELEMENT(13, D, value); - CASE_SET_ELEMENT(14, E, value); - CASE_SET_ELEMENT(15, F, value); - default: - break; - } - } -}; - -#undef CASE_GET_ELEMENT -#undef CASE_SET_ELEMENT - -template -T getElement(sycl::vec f, int ix) { - return getComponent()(f, ix); -} - -template -void setElement(sycl::vec &f, int ix, T value) { - setComponent()(f, ix, value); -} - -#endif // SYCL_CONFORMANCE_SUITE_MATH_VECTOR_H From 3fa3f8ca5ef864b6613eb5337b83489f4baba20d Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 6 Nov 2023 02:07:09 -0800 Subject: [PATCH 2/4] Apply clang-format --- tests/hierarchical/hierarchical_non_uniform_local_range.cpp | 3 +-- util/math_reference.cpp | 1 - util/math_reference.h | 6 ++---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/hierarchical/hierarchical_non_uniform_local_range.cpp b/tests/hierarchical/hierarchical_non_uniform_local_range.cpp index 99bd4e65a..37da071ce 100644 --- a/tests/hierarchical/hierarchical_non_uniform_local_range.cpp +++ b/tests/hierarchical/hierarchical_non_uniform_local_range.cpp @@ -44,8 +44,7 @@ void check_expected(const std::vector &data, unsigned local_id, std::string errorMessage = std::string("Value for global id ") + std::to_string(idx) + std::string(" for dim = ") + std::to_string(dim) + - std::string(" was not correct (") + - std::to_string(data[idx][dim - 1]) + + std::string(" was not correct (") + std::to_string(data[idx][dim - 1]) + std::string(" instead of ") + std::to_string(expected) + ")"; FAIL(log, errorMessage); } diff --git a/util/math_reference.cpp b/util/math_reference.cpp index 64235677c..c7ea1006d 100644 --- a/util/math_reference.cpp +++ b/util/math_reference.cpp @@ -581,7 +581,6 @@ sycl::vec cross_t(sycl::vec a, sycl::vec b) { temp_res[3] = 0.0; for (int i = 0; i < N; i++) res[i] = temp_res[i]; - return res; } diff --git a/util/math_reference.h b/util/math_reference.h index 31cc039c4..162ddc5e1 100644 --- a/util/math_reference.h +++ b/util/math_reference.h @@ -1552,8 +1552,7 @@ T dot(T p0, T p1) { template T dot(sycl::vec a, sycl::vec b) { T res = 0; - for (int i = 0; i < N; i++) - res += a[i] * b[i]; + for (int i = 0; i < N; i++) res += a[i] * b[i]; return res; } // FIXME: hipSYCL does not support marray @@ -1586,8 +1585,7 @@ sycl::vec normalize(sycl::vec a) { sycl::vec res; T len_a = reference::length(a); if (len_a == 0) return sycl::vec(0); - for (int i = 0; i < N; i++) - res[i] = a[i] / len_a; + for (int i = 0; i < N; i++) res[i] = a[i] / len_a; return res; } // FIXME: hipSYCL does not support marray From ed9d1d216f3ec021438c0be333446bfab5d5b8e0 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 6 Nov 2023 02:07:25 -0800 Subject: [PATCH 3/4] Fix accessor_legacy compilation --- tests/accessor_legacy/accessor_api_utility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/accessor_legacy/accessor_api_utility.h b/tests/accessor_legacy/accessor_api_utility.h index 59dfc13df..7118b6ed4 100644 --- a/tests/accessor_legacy/accessor_api_utility.h +++ b/tests/accessor_legacy/accessor_api_utility.h @@ -677,7 +677,7 @@ template bool check_elems_equal(const sycl::vec& actual, const sycl::vec& expected) { for (int i = 0; i < N; i++) { - if (!check_elems_equal(getElement(actual, i), getElement(expected, i))) { + if (!check_elems_equal(actual[i], expected[i])) { return false; } } @@ -691,7 +691,7 @@ bool check_elems_equal(const sycl::vec& actual, template bool check_elems_equal(const sycl::vec& actual, const T1& expected) { for (int i = 0; i < N; i++) { - if (!check_elems_equal(getElement(actual, i), expected)) { + if (!check_elems_equal(actual[i], expected)) { return false; } } From 0e69b77f769a7dbdd9a8ae7ee682630d5566b2e7 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 6 Nov 2023 04:18:25 -0800 Subject: [PATCH 4/4] Fix math_builtin_api build --- tests/math_builtin_api/math_builtin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/math_builtin_api/math_builtin.h b/tests/math_builtin_api/math_builtin.h index 1f76d6e01..9f30eb89b 100644 --- a/tests/math_builtin_api/math_builtin.h +++ b/tests/math_builtin_api/math_builtin.h @@ -139,7 +139,7 @@ bool verify(sycl_cts::util::logger& log, sycl::vec a, sycl::vec b = r.res; for (int i = 0; i < sycl_cts::math::numElements(a); i++) if (r.undefined.find(i) == r.undefined.end() && - !verify(log, getElement(a, i), getElement(b, i), accuracy, comment)) + !verify(log, a[i], b[i], accuracy, comment)) return false; return true; }