Kseniya Tikhomirova 4cec4938c6
[SYCL] Add libsycl, a SYCL RT library implementation project (#144372)
This patch introduces libsycl, a SYCL runtime library implementation, as
a top-level LLVM runtime project.
SYCL spec:
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html

Commit contains the basic folder layout and CMake infrastructure to
build a dummy SYCL library.

This is part of the SYCL support upstreaming effort. The relevant RFCs
can be found here:


https://discourse.llvm.org/t/rfc-add-full-support-for-the-sycl-programming-model/74080
https://discourse.llvm.org/t/rfc-sycl-runtime-upstreaming/74479

Upcoming PRs:
- UR offloading library fetch & build 
- partial implementation of sycl::platform: requires offloading layer,
requires classes for backend loading & enumeration.

---------

Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Co-authored-by: Alexey Bader <alexey.bader@intel.com>
2025-07-31 11:28:39 -07:00

79 lines
1.9 KiB
ReStructuredText

=====================
SYCL runtime implementation
=====================
.. contents::
:local:
.. _index:
Current Status
========
The implementation is in the very early stages of upstreaming. The first milestone is to get
support for a simple SYCL application with device code using Unified Shared Memory:
.. code-block:: c++
#include <sycl/sycl.hpp>
class TestKernel;
int main() {
sycl::queue q;
const size_t dataSize = 32;
int *dataPtr = sycl::malloc_shared<int>(32, q);
for (int i = 0; i < dataSize; ++i)
dataPtr[i] = 0;
q.submit([&](sycl::handler &cgh) {
cgh.parallel_for<TestKernel>(
sycl::range<1>(dataSize),
[=](sycl::id<1> idx) { dataPtr[idx] = idx[0]; });
});
q.wait();
bool error = false;
for (int i = 0; i < dataSize; ++i)
if (dataPtr[i] != i) error = true;
free(dataPtr, q);
return error;
}
This requires at least partial support of the following functionality on the libsycl side:
* ``sycl::platform`` class
* ``sycl::device`` class
* ``sycl::context`` class
* ``sycl::queue`` class
* ``sycl::handler`` class
* ``sycl::id`` and ``sycl::range`` classes
* Unified shared memory allocation/deallocation
* Program manager, an internal component for retrieving and using device images from the multi-architectural binaries
Build steps
========
To build LLVM with libsycl runtime enabled the following script can be used.
.. code-block:: console
#!/bin/sh
build_llvm=`pwd`/build-llvm
installprefix=`pwd`/install
llvm=`pwd`
mkdir -p $build_llvm
mkdir -p $installprefix
cmake -G Ninja -S $llvm/llvm -B $build_llvm \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_INSTALL_PREFIX=$installprefix \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libsycl;libunwind" \
-DCMAKE_BUILD_TYPE=Release
ninja -C $build_llvm install