The LLVM project is an open source compiler framework that supports code-generation for many hardware platforms. Major platform vendors produce toolchains based on the LLVM Project due to its permissive free software license model as well as the modular design which allows reuse of code optimisation and code generation components across different hardware platforms. Arm is supporting the open source LLVM community in areas that target the Arm architecture. You can read the blog on accelerating open source LLVM development for more information on the project.
Arm is actively working with The Khronos Group to help refine and define open standards and also help to improve the open source tooling ecosystem. One of the key building blocks of this ecosystem push has been the formation of the Khronos OpenCL Tooling Subgroup that has been focused on developing and enhancing open source tools and components. These tools, targeted at embedded systems and heterogeneous computation applications, will be accessible to everyone in the OpenCL ecosystem.
At the 7th annual International Workshop on OpenCL (IWOCL) gathering of OpenCL, SYCL, and SPIR developers, researchers, and suppliers, one of the announced enhancements was C++ for OpenCL support in Clang. Arm has been a leading contributor to this and is actively developing it in upstream Clang. IWOCL is rapidly growing year on year, and the engagement of the OpenCL working group is another addition that will aid the community by solving their problems and headaches, all via open source tooling.
The Clang project provides a compiler frontend and tooling infrastructure for languages in the C family (C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
The OpenCL Tooling Sub Group has been actively working on frontend support for all OpenCL C language versions (including backwards compatibility) in Clang. Recently, experimental support for C++ in OpenCL has started to be implemented in Clang 9.0 supporting features from both OpenCL C 2.0 and C++17. This new OpenCL language mode can be activated by passing -std=c++ to Clang. Standard OpenCL C code can be parsed with this new mode, as well as the additional C++ features. This work enables existing OpenCL C applications to incrementally transition to using C++ capabilities. The C++ for OpenCL in Clang frontend is compatible with any OpenCL 2.0 drivers with SPIR-V ingestion. Developers can access early evaluation of this new OpenCL functionality and provide feedback through the Compiler Explorer.
To get more of an idea how all of this fits together, , along with SPIR targets and translation. The main takeaway is that you can load on existing drivers, so you don’t have to wait for this support to arrive in the future.
Developers can target generating SPIR-V 1.0/1.2 using SPIRV-LLVM Translator or end binary for upstream targets available in LLVM. These two formats can be directly loaded into existing drivers with OpenCL 2.0 capabilities. In the future, drivers are expected to be extended to include the functionality to take full advantage of new language (avoid requiring workaround for global constructors in the application side).
Like with any project our work doesn’t suddenly stop at a certain release. In September, experimental C++ support will appear in Clang 9.0. However, initial support will only combine features existing in both languages and new features are likely to be built on top this initial work in the next releases. There are also plans to update drivers to provide online compilation from C++ in the near future. I hope to explain further updates in greater detail here on the Arm Community.
We invite you to use these resources in your projects but to also provide us with the most useful asset a developer can give, feedback! You can submit bug reports on Bugzilla or get in touch with us directly right here on the Arm Community
[CTAToken URL = "https://clang.llvm.org" target="_blank" text="Learn about Clang" class ="green"]