Introductory SYCL examples inside ROOT’s interpreter.
- Note
- This tutorial requires ROOT to be built with SYCL support enabled. Configure CMake with:
-Dexperimental_adaptivecpp=ON
to enable SYCL support in the interpreter.
This tutorial contains two examples:
#include <sycl/sycl.hpp>
#include <iostream>
#include <vector>
{
sycl::queue
q{sycl::cpu_selector_v};
std::cout <<
"Running on: " <<
q.get_device().get_info<sycl::info::device::name>() <<
"\n";
int *
sum = sycl::malloc_shared<int>(1,
q);
q.single_task([=] { *
sum =
a +
b; }).wait();
std::cout <<
"Sum = " << *
sum <<
'\n';
}
{
sycl::queue
q{sycl::default_selector_v};
std::vector<int> A(
N, 1), B(
N, 2),
C(
N);
int *
a = sycl::malloc_shared<int>(
N,
q);
int *
b = sycl::malloc_shared<int>(
N,
q);
int *
c = sycl::malloc_shared<int>(
N,
q);
std::copy(A.begin(), A.end(),
a);
std::copy(B.begin(), B.end(),
b);
q.parallel_for(
N, [=](sycl::id<1> i) {
c[i] =
a[i] +
b[i]; }).wait();
std::cout <<
"C[0] = " <<
C[0] <<
", C[N-1] = " <<
C[
N - 1] <<
"\n";
}
{
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
const_iterator begin() const
constexpr Double_t C()
Velocity of light in .
static uint64_t sum(uint64_t i)
- Author
- Devajith Valaparambil Sreeramaswamy (CERN)
Definition in file syclintro.C.