在 MacOS 中使用 SYCL 1.2

Using SYCL 1.2 in MacOS

我想开始使用SYCL,但目前我发现需要安装ComputeCpp,而且它只支持Ubuntu、CentOS 和Windows。在 MacOS Catalina 上使用 SYCL 有哪些替代方案?

ComputeCpp 是几个 SYCL 实现之一,完整列表是 here

None 的实现目前支持 macOS,这主要是因为 Apple 计划放弃对 OpenCL 的支持,只提供对 Metal 作为其硬件接口的支持。但是,您可以使用 Linux 双启动您的 Apple 机器,并使用它来开发任何 SYCL 实现(包括 ComputeCpp)。

总结

目前支持 MacOS 多个 SYCL 实现,尽管它们仅支持 CPU 台设备。

GPU 设备支持不可用,因为 Apple 不支持 Linux 或 Windows 上可用的后端依赖项。

详情

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应该有详细信息。

我们做了一些工作让英特尔 DPC++ 在 MacOS 上构建(参见 Issue #258) but it’s not there yet. Issue #982 正在跟踪 MacOS 支持。

我经常在虚拟机内的 Mac 笔记本电脑上为 Linux 使用所有 SYCL 编译器,但这仍然是 CPU-only 执行。

可能性

MacOS 上 SYCL 的 GPU 支持最有前途的途径需要转换为 Metal Shader Language (MSL), because Apple OpenCL doesn’t support SPIR-V. This can be done with SPIRV-Cross,但据我所知,没有人在任何 SYCL 编译器中实现它。

请注意,将内核从 SPIR-V 转换为 MSL 只是部分答案。另一个要求是对内核加载等的运行时支持。其中一些问题在 https://github.com/bobpepin/opencl-osx 中很明显,尽管这只是一个问题陈述,而不是解决方案。

如果 Apple 支持 CUDA(不太可能,基于 https://gizmodo.com/apple-and-nvidia-are-over-1840015246),那么 hipSYCL 或 DPC++ 的 PTX 后端可能会工作,但我不知道有任何尝试使用较旧的 Mac支持(编辑)CUDA。