Skip to content

using the "magic_get" trick to infer a type's structured binding size - #4875

Merged
ericniebler merged 1 commit into
NVIDIA:mainfrom
ericniebler:structured-binding-size-from-magic-get-trick
Jun 2, 2025
Merged

ericniebler merged 1 commit into
NVIDIA:mainfrom
ericniebler:structured-binding-size-from-magic-get-trick

Conversation

@ericniebler

Copy link
Copy Markdown
Contributor

Description

std::execution uses structured bindings for de-structuring a sender expression. there is no way in portable c++ to ask a type what size of structured binding it requires, or even if it can be used to initialize a structured binding at all.

in ustdex, i have worked around this with a structured_binding_size variable template, which needs to be specialized for a sender type if you want that type to be introspect-able.

in this pr, i augment that with the "magic_get" trick to infer the number of fields that a plain struct has. this makes senders introspect-able without needing to specialize structured_binding_size.

struct S0
{};
struct S1
{
  int a;
};
struct S2
{
  int a, b;
};

static_assert(cuda::experimental::execution::structured_binding_size<S0> == 0);
static_assert(cuda::experimental::execution::structured_binding_size<S1> == 1);
static_assert(cuda::experimental::execution::structured_binding_size<S2> == 2);

Checklist

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

@copy-pr-bot

copy-pr-bot Bot commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jun 2, 2025
@ericniebler

Copy link
Copy Markdown
Contributor Author

/ok to test c14376c

@ericniebler
ericniebler marked this pull request as ready for review June 2, 2025 21:34
@ericniebler
ericniebler requested a review from a team as a code owner June 2, 2025 21:34
@ericniebler
ericniebler requested a review from pciolkosz June 2, 2025 21:34
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jun 2, 2025
@github-actions

github-actions Bot commented Jun 2, 2025

Copy link
Copy Markdown
Contributor
🟩 CI finished in 27m 28s: Pass: 100%/30 | Total: 3h 17m | Avg: 6m 35s | Max: 13m 05s | Hits: 90%/14798
  • 🟩 cudax: Pass: 100%/26 | Total: 3h 00m | Avg: 6m 56s | Max: 13m 05s | Hits: 90%/14798

    🟩 cpu
      🟩 amd64              Pass: 100%/22  | Total:  2h 40m | Avg:  7m 17s | Max: 13m 05s | Hits:  90%/12430 
      🟩 arm64              Pass: 100%/4   | Total: 20m 07s | Avg:  5m 01s | Max:  5m 32s | Hits:  90%/2368  
    🟩 ctk
      🟩 12.0               Pass: 100%/3   | Total: 22m 03s | Avg:  7m 21s | Max: 12m 44s | Hits:  87%/1481  
      🟩 12.9               Pass: 100%/23  | Total:  2h 38m | Avg:  6m 53s | Max: 13m 05s | Hits:  90%/13317 
    🟩 cudacxx
      🟩 nvcc12.0           Pass: 100%/3   | Total: 22m 03s | Avg:  7m 21s | Max: 12m 44s | Hits:  87%/1481  
      🟩 nvcc12.9           Pass: 100%/23  | Total:  2h 38m | Avg:  6m 53s | Max: 13m 05s | Hits:  90%/13317 
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/26  | Total:  3h 00m | Avg:  6m 56s | Max: 13m 05s | Hits:  90%/14798 
    🟩 cxx
      🟩 Clang14            Pass: 100%/2   | Total: 10m 28s | Avg:  5m 14s | Max:  5m 59s | Hits:  90%/1188  
      🟩 Clang15            Pass: 100%/1   | Total:  5m 04s | Avg:  5m 04s | Max:  5m 04s | Hits:  90%/592   
      🟩 Clang16            Pass: 100%/1   | Total:  5m 27s | Avg:  5m 27s | Max:  5m 27s | Hits:  90%/592   
      🟩 Clang17            Pass: 100%/1   | Total:  5m 15s | Avg:  5m 15s | Max:  5m 15s | Hits:  90%/592   
      🟩 Clang18            Pass: 100%/1   | Total:  4m 55s | Avg:  4m 55s | Max:  4m 55s | Hits:  90%/592   
      🟩 Clang19            Pass: 100%/4   | Total: 24m 21s | Avg:  6m 05s | Max:  9m 45s | Hits:  92%/2368  
      🟩 GCC10              Pass: 100%/2   | Total: 10m 16s | Avg:  5m 08s | Max:  5m 26s | Hits:  90%/1188  
      🟩 GCC11              Pass: 100%/1   | Total:  5m 29s | Avg:  5m 29s | Max:  5m 29s | Hits:  90%/592   
      🟩 GCC12              Pass: 100%/1   | Total:  5m 45s | Avg:  5m 45s | Max:  5m 45s | Hits:  90%/592   
      🟩 GCC13              Pass: 100%/8   | Total: 57m 08s | Avg:  7m 08s | Max: 12m 43s | Hits:  92%/4736  
      🟩 MSVC14.39          Pass: 100%/1   | Total: 12m 44s | Avg: 12m 44s | Max: 12m 44s | Hits:  75%/293   
      🟩 MSVC14.43          Pass: 100%/1   | Total: 13m 05s | Avg: 13m 05s | Max: 13m 05s | Hits:  75%/293   
      🟩 NVHPC25.5          Pass: 100%/2   | Total: 20m 29s | Avg: 10m 14s | Max: 10m 21s | Hits:  87%/1180  
    🟩 cxx_family
      🟩 Clang              Pass: 100%/10  | Total: 55m 30s | Avg:  5m 33s | Max:  9m 45s | Hits:  91%/5924  
      🟩 GCC                Pass: 100%/12  | Total:  1h 18m | Avg:  6m 33s | Max: 12m 43s | Hits:  91%/7108  
      🟩 MSVC               Pass: 100%/2   | Total: 25m 49s | Avg: 12m 54s | Max: 13m 05s | Hits:  75%/586   
      🟩 NVHPC              Pass: 100%/2   | Total: 20m 29s | Avg: 10m 14s | Max: 10m 21s | Hits:  87%/1180  
    🟩 gpu
      🟩 h100               Pass: 100%/2   | Total: 17m 42s | Avg:  8m 51s | Max: 12m 43s | Hits:  94%/1184  
      🟩 rtx2080            Pass: 100%/24  | Total:  2h 42m | Avg:  6m 46s | Max: 13m 05s | Hits:  90%/13614 
    🟩 jobs
      🟩 Build              Pass: 100%/23  | Total:  2h 25m | Avg:  6m 19s | Max: 13m 05s | Hits:  89%/13022 
      🟩 Test               Pass: 100%/3   | Total: 34m 51s | Avg: 11m 37s | Max: 12m 43s | Hits:  99%/1776  
    🟩 sm
      🟩 90                 Pass: 100%/3   | Total: 22m 02s | Avg:  7m 20s | Max: 12m 43s | Hits:  93%/1776  
      🟩 90a                Pass: 100%/1   | Total:  5m 00s | Avg:  5m 00s | Max:  5m 00s | Hits:  90%/592   
    🟩 std
      🟩 17                 Pass: 100%/4   | Total: 24m 36s | Avg:  6m 09s | Max: 10m 21s | Hits:  89%/2366  
      🟩 20                 Pass: 100%/22  | Total:  2h 35m | Avg:  7m 05s | Max: 13m 05s | Hits:  90%/12432 
    
  • 🟩 packaging: Pass: 100%/4 | Total: 17m 11s | Avg: 4m 17s | Max: 5m 22s

    🟩 cpu
      🟩 amd64              Pass: 100%/4   | Total: 17m 11s | Avg:  4m 17s | Max:  5m 22s
    🟩 ctk
      🟩 12.0               Pass: 100%/2   | Total:  7m 26s | Avg:  3m 43s | Max:  3m 49s
      🟩 12.9               Pass: 100%/2   | Total:  9m 45s | Avg:  4m 52s | Max:  5m 22s
    🟩 cudacxx
      🟩 nvcc12.0           Pass: 100%/2   | Total:  7m 26s | Avg:  3m 43s | Max:  3m 49s
      🟩 nvcc12.9           Pass: 100%/2   | Total:  9m 45s | Avg:  4m 52s | Max:  5m 22s
    🟩 cudacxx_family
      🟩 nvcc               Pass: 100%/4   | Total: 17m 11s | Avg:  4m 17s | Max:  5m 22s
    🟩 cxx
      🟩 Clang14            Pass: 100%/1   | Total:  3m 49s | Avg:  3m 49s | Max:  3m 49s
      🟩 Clang19            Pass: 100%/1   | Total:  5m 22s | Avg:  5m 22s | Max:  5m 22s
      🟩 GCC12              Pass: 100%/1   | Total:  3m 37s | Avg:  3m 37s | Max:  3m 37s
      🟩 GCC13              Pass: 100%/1   | Total:  4m 23s | Avg:  4m 23s | Max:  4m 23s
    🟩 cxx_family
      🟩 Clang              Pass: 100%/2   | Total:  9m 11s | Avg:  4m 35s | Max:  5m 22s
      🟩 GCC                Pass: 100%/2   | Total:  8m 00s | Avg:  4m 00s | Max:  4m 23s
    🟩 gpu
      🟩 rtx2080            Pass: 100%/4   | Total: 17m 11s | Avg:  4m 17s | Max:  5m 22s
    🟩 jobs
      🟩 Test               Pass: 100%/4   | Total: 17m 11s | Avg:  4m 17s | Max:  5m 22s
    

👃 Inspect Changes

Modifications in project?

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

Modifications in project or dependencies?

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

🏃‍ Runner counts (total jobs: 30)

# Runner
17 linux-amd64-cpu16
6 linux-amd64-gpu-rtx2080-latest-1
4 linux-arm64-cpu16
2 windows-amd64-cpu16
1 linux-amd64-gpu-h100-latest-1

@ericniebler
ericniebler merged commit a7c64ae into NVIDIA:main Jun 2, 2025
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants