Search code examples
macossycl

Using SYCL 1.2 in MacOS


I want to start using SYCL, but so far I found that one needs to install ComputeCpp and it only supports Ubuntu, CentOS, and Windows. What are the alternatives for using SYCL on MacOS Catalina?


Solution

  • Summary

    Multiple SYCL implementation support MacOS today, although they only support CPU devices.

    GPU device support is not available because Apple does not support the back-end dependencies available on Linux or Windows.

    Details

    triSYCL supports MacOS but only CPU execution. I use it frequently. You may need to switch C++ compilers since the native toolchain might not work. https://github.com/triSYCL/triSYCL

    hipSYCL also supports CPU execution and should work on MacOS. Pull request #271 should have details.

    We did some work to get Intel DPC++ to build on MacOS (see Issue #258) but it’s not there yet. Issue #982 is tracking MacOS support.

    I routinely use all the SYCL compilers for Linux on my Mac laptop inside of virtual machines but that is still CPU-only execution.

    Possibilities

    The most promising route to GPU support of SYCL on MacOS requires translating to Metal Shader Language (MSL), because Apple OpenCL doesn’t support SPIR-V. This can be done with SPIRV-Cross but nobody has implemented it in any SYCL compiler as far as I know.

    Note that translating kernels from SPIR-V to MSL is only part of the answer. The other requirement is runtime support for kernel loading, etc. Some of these issues are apparent in https://github.com/bobpepin/opencl-osx, although this is merely a problem statement, not a solution.

    If Apple were to support CUDA (unlikely, based on https://gizmodo.com/apple-and-nvidia-are-over-1840015246), then the PTX back-ends of hipSYCL or DPC++ might work, but I am not aware of any attempts along these lines with older Macs that support(ed) CUDA.