Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CCCL C headers to be compileable by C compiler #3885

Merged

Conversation

oleksandr-pavlyk
Copy link
Contributor

Description

closes gh-3882

This change ensures that cccl/c/parallel headers are compileable by C compiler.

  1. Corrected typedef struct and typedef enum so that C types have the same names as C++. That is typedef struct name {...} otherName; was changed to typedef struct name {...} name;

  2. noexcept qualifier was removed from function declarations.

  3. Implementation was changed to move noexcept implementations into a namespace, and implement publicly declared functions as thin shims calling these noexcept functions from a namespace.

  4. Adds c/parallel/test/test_header.c This is a C file which includes all public headers, and contains a trivial int main(void) function. The file is compiled using C compiler to produce an object file. Hence it does not result in a dedicate test to run, but any non C-compliant changes to these headers would break test compilation step.

    N.B.: Every new header file must be included in test_headers.c file for it to be tested.

  5. Piggy-backing on this PR, added runtime error condition checking in test_main.cpp to verify that cudaSetDevice call did not report an error.

  6. Modified cccl/c/parallel CMake project list of languages to include C.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

This change ensures that cccl/c/parallel headers are compilable by C compiler.

1. Corrected typedef struct and typedef enum so that C types have the same
   names as C++.  That is `typdef struct name {...} otherName;` was changed to
   `typedef struct name {...} name;`
2. `noexcept` qualifier was removed from function declarations.
3. Implementation was changed to move `noexcept` implementations into
   a namespace, and implement publicly declared functions as thin
   shims calling these noexcept functions from a namespace.
4. Adds c/parallel/test/test_header.c
   This is a C file which includes all public headers, and contains
   a trivial `int main(void)` function.
   The file is compiled using C compiler to produce an object file.
   Hence it does not result in a dedicate test to run, but any
   non C-compliant changes to these headers would break test
   compilation step.

   N.B.: Every new header file must be included in `test_headers.c`
   file for it to be tested.

5. Piggy-backing on this PR, added runtime error condition checking
   in test_main.cpp to verify that `cudaSetDevice` call did not
   report an error.

6. Modified cccl/c/parallel CMake project list of languages to include
   C.
Copy link
Contributor

🟩 CI finished in 45m 24s: Pass: 100%/3 | Total: 50m 27s | Avg: 16m 49s | Max: 35m 19s | Hits: 91%/308
  • 🟩 cccl_c_parallel: Pass: 100%/2 | Total: 15m 08s | Avg: 7m 34s | Max: 12m 39s | Hits: 91%/308

    🟩 cpu
      🟩 amd64              Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 ctk
      🟩 12.8               Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 cudacxx
      🟩 nvcc12.8           Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 cxx
      🟩 GCC13              Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 cxx_family
      🟩 GCC                Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 gpu
      🟩 rtx2080            Pass: 100%/2   | Total: 15m 08s | Avg:  7m 34s | Max: 12m 39s | Hits:  91%/308   
    🟩 jobs
      🟩 Build              Pass: 100%/1   | Total:  2m 29s | Avg:  2m 29s | Max:  2m 29s | Hits:  83%/154   
      🟩 Test               Pass: 100%/1   | Total: 12m 39s | Avg: 12m 39s | Max: 12m 39s | Hits:  98%/154   
    
  • 🟩 python: Pass: 100%/1 | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s

    🟩 cpu
      🟩 amd64              Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 ctk
      🟩 12.8               Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 cudacxx
      🟩 nvcc12.8           Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 cxx
      🟩 GCC13              Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 cxx_family
      🟩 GCC                Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 gpu
      🟩 rtx2080            Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    🟩 jobs
      🟩 Test               Pass: 100%/1   | Total: 35m 19s | Avg: 35m 19s | Max: 35m 19s
    

👃 Inspect Changes

Modifications in project?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
python
+/- CCCL C Parallel Library
Catch2Helper

Modifications in project or dependencies?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
+/- python
+/- CCCL C Parallel Library
Catch2Helper

🏃‍ Runner counts (total jobs: 3)

# Runner
2 linux-amd64-gpu-rtx2080-latest-1
1 linux-amd64-cpu16

@leofang
Copy link
Member

leofang commented Feb 20, 2025

Thanks for catching and fixing the bug, Sasha!

…unction

Instead simply remove use of noexcept in C++ definitions of these functions
per Bernhard's suggestion
Copy link
Contributor

🟩 CI finished in 38m 59s: Pass: 100%/3 | Total: 59m 13s | Avg: 19m 44s | Max: 38m 26s | Hits: 97%/308
  • 🟩 cccl_c_parallel: Pass: 100%/2 | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits: 97%/308

    🟩 cpu
      🟩 amd64              Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 ctk
      🟩 12.8               Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 cudacxx
      🟩 nvcc12.8           Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 cxx
      🟩 GCC13              Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 cxx_family
      🟩 GCC                Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 gpu
      🟩 rtx2080            Pass: 100%/2   | Total: 20m 47s | Avg: 10m 23s | Max: 18m 16s | Hits:  97%/308   
    🟩 jobs
      🟩 Build              Pass: 100%/1   | Total:  2m 31s | Avg:  2m 31s | Max:  2m 31s | Hits:  95%/154   
      🟩 Test               Pass: 100%/1   | Total: 18m 16s | Avg: 18m 16s | Max: 18m 16s | Hits:  98%/154   
    
  • 🟩 python: Pass: 100%/1 | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s

    🟩 cpu
      🟩 amd64              Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 ctk
      🟩 12.8               Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 cudacxx
      🟩 nvcc12.8           Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 cxx
      🟩 GCC13              Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 cxx_family
      🟩 GCC                Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 gpu
      🟩 rtx2080            Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    🟩 jobs
      🟩 Test               Pass: 100%/1   | Total: 38m 26s | Avg: 38m 26s | Max: 38m 26s
    

👃 Inspect Changes

Modifications in project?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
python
+/- CCCL C Parallel Library
Catch2Helper

Modifications in project or dependencies?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
+/- python
+/- CCCL C Parallel Library
Catch2Helper

🏃‍ Runner counts (total jobs: 3)

# Runner
2 linux-amd64-gpu-rtx2080-latest-1
1 linux-amd64-cpu16

@oleksandr-pavlyk oleksandr-pavlyk merged commit fd0cd24 into NVIDIA:main Feb 21, 2025
17 of 20 checks passed
@oleksandr-pavlyk oleksandr-pavlyk deleted the cccl-c-parallel-use-from-c branch February 21, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEA]: cccl/c/parallel headers should be compileable by C compiler
4 participants