[FEA]: Infrastructure for codegen testing with `FileCheck`
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Area
Infrastructure
### Is your feature request related to a problem? Please describe.
Currently there is no unified way of creating and running codegen tests. All we have are separate directories with custom CMake that manually create the testing targets and set up the testing. It's the case for atomics and simd codegen testing.
The lack of unified way of adding codegen tests makes it really hard to add new codegen tests, because one must build all of the infrastructure by himself from scratch.
### Describe the solution you'd like
I'd like CCCL to have a common infrastructure for codegen testing. I'm imagining something like `cccl_add_codegen_test` CMake function that takes a source file and automatically sets up the test targets.
This target should support 2 code types to be tested - PTX and SASS. My idea is to move the checked code specification directly to the file, similarly to how `lit`'s behaviour can be modified using comments.
```cpp
// CODE: PTX (or SASS)
```
Similarly, the list of tested architectures should be moved from CMake to the file directly as:
```cpp
// ARCH: 100 80 103f // <--- archs sm_100, sm_80 and sm_103f
// ARCH: provides(103f) // <--- archs sm_103a, sm_103f
// ARCH: provides(80) // <--- archs sm_80...sm_newest
// ...
```
The `cccl_add_codegen_test` function should read all of these specifications and add compilation targets for relevant architectures to the specified code and add test targets that invoke the `FileCheck` with the right set of prefixes.
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by inspecting the existing custom CMake used for atomics and SIMD codegen testing, then review how those targets invoke FileCheck. The work is complete when a shared cccl_add_codegen_test entry point can read CODE and ARCH specifications from a source file and create the required PTX or SASS compilation and FileCheck targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100