79 lines · plain
1=====================2SYCL runtime implementation3=====================4 5.. contents::6 :local:7 8.. _index:9 10Current Status11========12 13The implementation is in the very early stages of upstreaming. The first milestone is to get14support for a simple SYCL application with device code using Unified Shared Memory:15 16.. code-block:: c++17 18 #include <sycl/sycl.hpp>19 20 class TestKernel;21 22 int main() {23 sycl::queue q;24 25 const size_t dataSize = 32;26 int *dataPtr = sycl::malloc_shared<int>(32, q);27 for (int i = 0; i < dataSize; ++i)28 dataPtr[i] = 0;29 30 q.submit([&](sycl::handler &cgh) {31 cgh.parallel_for<TestKernel>(32 sycl::range<1>(dataSize),33 [=](sycl::id<1> idx) { dataPtr[idx] = idx[0]; });34 });35 q.wait();36 37 bool error = false;38 for (int i = 0; i < dataSize; ++i)39 if (dataPtr[i] != i) error = true;40 41 free(dataPtr, q);42 43 return error;44 }45 46This requires at least partial support of the following functionality on the libsycl side:47 * ``sycl::platform`` class48 * ``sycl::device`` class49 * ``sycl::context`` class50 * ``sycl::queue`` class51 * ``sycl::handler`` class52 * ``sycl::id`` and ``sycl::range`` classes53 * Unified shared memory allocation/deallocation54 * Program manager, an internal component for retrieving and using device images from the multi-architectural binaries55 56Build steps57========58 59To build LLVM with libsycl runtime enabled the following script can be used.60 61.. code-block:: console62 63 #!/bin/sh64 65 build_llvm=`pwd`/build-llvm66 installprefix=`pwd`/install67 llvm=`pwd`68 mkdir -p $build_llvm69 mkdir -p $installprefix70 71 cmake -G Ninja -S $llvm/llvm -B $build_llvm \72 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \73 -DLLVM_INSTALL_UTILS=ON \74 -DCMAKE_INSTALL_PREFIX=$installprefix \75 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libsycl;libunwind" \76 -DCMAKE_BUILD_TYPE=Release77 78 ninja -C $build_llvm install79