[llvm] [Offload][UnitTests] Build device code as C++ (PR #151714)

Leandro Lacerda via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 03:50:33 PDT 2025


leandrolcampos wrote:

Hi @RossBrunton,

The primary C++ feature I need is templates, specifically for the new conformance tests in `offload/unittests/Conformance`. To test dozens of math functions from the GPU C library, I need to create many structurally identical kernel wrappers.

Without C++, the main alternative would be to use C preprocessor macros to generate this boilerplate. By compiling as C++, I can instead use a single, type-safe variadic template helper. The intent is not to add complex C++ logic to the kernels themselves, but only to use templates as a safer and more maintainable alternative to macros.

To be clear, this use of templates will be confined to the new conformance tests, that share the same CMake function `add_offload_test_device_code` with the Offload API unit tests.

https://github.com/llvm/llvm-project/pull/151714


More information about the llvm-commits mailing list