Skip to content

Commit

Permalink
Made the code SYCL2020 compatible.
Browse files Browse the repository at this point in the history
Using <sycl/sycl.hpp> as the main SYCL include, and picking
up all types from the ::sycl namespace.
  • Loading branch information
krasznaa committed Nov 19, 2024
1 parent 73265b0 commit 1a599e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions math/common/include/algebra/math/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// SYCL include(s).
#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>
#endif

// System include(s).
Expand All @@ -22,7 +22,7 @@ namespace algebra::math {

/// Namespace to pick up math functions from
#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
namespace math_ns = cl::sycl;
namespace math_ns = ::sycl;
#else
namespace math_ns = std;
#endif // SYCL
Expand Down
27 changes: 13 additions & 14 deletions tests/accelerator/sycl/common/execute_sycl_test.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2020-2022 CERN for the benefit of the ACTS project
* (c) 2020-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// SYCL include(s).
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

// System include(s).
#include <cstddef>

/// Execute a test functor using SYCL, on @c arraySizes threads
template <class FUNCTOR, class... ARGS>
void execute_sycl_test(cl::sycl::queue& queue, std::size_t arraySizes,
void execute_sycl_test(::sycl::queue& queue, std::size_t arraySizes,
ARGS... args) {

// Submit a kernel that would run the specified functor.
Expand All @@ -25,17 +25,16 @@ void execute_sycl_test(cl::sycl::queue& queue, std::size_t arraySizes,
// Unfortunately the FUNCTOR class is too complicated, and DPC++ dies
// on it. While providing a unique simple class for every template
// specialisation is also pretty impossible. :-(
h.parallel_for(cl::sycl::range<1>(arraySizes),
[=](cl::sycl::item<1> id) {
// Find the current index that we need to
// process.
const std::size_t i = id[0];
if (i >= arraySizes) {
return;
}
// Execute the test functor for this index.
FUNCTOR()(i, args...);
});
h.parallel_for(::sycl::range<1>(arraySizes), [=](::sycl::item<1> id) {
// Find the current index that we need to
// process.
const std::size_t i = id[0];
if (i >= arraySizes) {
return;
}
// Execute the test functor for this index.
FUNCTOR()(i, args...);
});
})
.wait_and_throw();
}
16 changes: 8 additions & 8 deletions tests/accelerator/sycl/common/test_sycl_basics.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2020-2023 CERN for the benefit of the ACTS project
* (c) 2020-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -21,7 +21,7 @@
#include <gtest/gtest.h>

// SYCL include(s).
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

/// Test case class, to be specialised for the different plugins
template <typename T>
Expand All @@ -33,7 +33,7 @@ class test_sycl_basics : public test_basics_base<T> {

protected:
/// Queue to be used by all of the tests.
cl::sycl::queue m_queue;
::sycl::queue m_queue;
/// Memory resource for all of the tests.
vecmem::sycl::shared_memory_resource m_resource{&m_queue};
};
Expand All @@ -45,7 +45,7 @@ TYPED_TEST_P(test_sycl_basics, vector_2d_ops) {
// Don't run the test at double precision, if the SYCL device doesn't
// support it.
if ((typeid(typename TypeParam::scalar) == typeid(double)) &&
(this->m_queue.get_device().has(cl::sycl::aspect::fp64) == false)) {
(this->m_queue.get_device().has(::sycl::aspect::fp64) == false)) {
GTEST_SKIP();
}

Expand All @@ -69,7 +69,7 @@ TYPED_TEST_P(test_sycl_basics, vector_3d_ops) {
// Don't run the test at double precision, if the SYCL device doesn't
// support it.
if ((typeid(typename TypeParam::scalar) == typeid(double)) &&
(this->m_queue.get_device().has(cl::sycl::aspect::fp64) == false)) {
(this->m_queue.get_device().has(::sycl::aspect::fp64) == false)) {
GTEST_SKIP();
}

Expand Down Expand Up @@ -101,7 +101,7 @@ TYPED_TEST_P(test_sycl_basics, matrix64_ops) {
// Don't run the test at double precision, if the SYCL device doesn't
// support it.
if ((typeid(typename TypeParam::scalar) == typeid(double)) &&
(this->m_queue.get_device().has(cl::sycl::aspect::fp64) == false)) {
(this->m_queue.get_device().has(::sycl::aspect::fp64) == false)) {
GTEST_SKIP();
}

Expand All @@ -123,7 +123,7 @@ TYPED_TEST_P(test_sycl_basics, matrix22_ops) {
// Don't run the test at double precision, if the SYCL device doesn't
// support it.
if ((typeid(typename TypeParam::scalar) == typeid(double)) &&
(this->m_queue.get_device().has(cl::sycl::aspect::fp64) == false)) {
(this->m_queue.get_device().has(::sycl::aspect::fp64) == false)) {
GTEST_SKIP();
}

Expand All @@ -145,7 +145,7 @@ TYPED_TEST_P(test_sycl_basics, transform3) {
// Don't run the test at double precision, if the SYCL device doesn't
// support it.
if ((typeid(typename TypeParam::scalar) == typeid(double)) &&
(this->m_queue.get_device().has(cl::sycl::aspect::fp64) == false)) {
(this->m_queue.get_device().has(::sycl::aspect::fp64) == false)) {
GTEST_SKIP();
}

Expand Down

0 comments on commit 1a599e5

Please sign in to comment.