Skip to content

Fix enum parsing for CUstreamAtomicReductionDataType_enum#4

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1765997022-fix-enum-parsing
Open

Fix enum parsing for CUstreamAtomicReductionDataType_enum#4
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1765997022-fix-enum-parsing

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Description

closes NVIDIA#1312

This PR fixes the parse_headers function in cuda_bindings/setup.py to properly extract CUstreamAtomicReductionDataType_enum from CUDA headers, eliminating the manual workaround.

Root cause: pyclibrary's CParser fails to parse enums when their values use unsigned literal shift syntax (e.g., 1u<<0). In CUDA 13.x headers, CUatomicCapability_enum uses 1u<<0 syntax, and CUstreamAtomicReductionDataType_enum references those values with bitwise OR expressions, causing the parser to fail.

Fix:

  1. Add a replace pattern "1u<<": "1<<" to normalize unsigned literal shifts before parsing
  2. Add safety net to extract enum tag names from defs["types"] keys that start with "enum " prefix (pyclibrary sometimes stores enums there instead of defs["enums"])

Validation: Tested against actual CUDA 13.1.0 headers downloaded from NVIDIA's redistribution server, confirming the enum is now correctly extracted.

Checklist for human review

  • Verify the 1u<< replacement doesn't affect other header parsing unexpectedly
  • Confirm CI passes with CUDA 13.x headers

Checklist

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

Link to Devin run: https://app.devin.ai/sessions/349f9751c64e4be08f02bb35be35eb52
Requested by: Shawn Azman (shawn@cognition.ai) (@ShawnAzman)

Add replace pattern to handle unsigned literal shift syntax (1u<<) that
pyclibrary fails to parse. Also add safety net to extract enum tag names
from defs['types'] keys that start with 'enum ' prefix.

This eliminates the manual workaround that was previously needed to add
CUstreamAtomicReductionDataType_enum to found_types.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: cuda_bindings/setup.py parse_headers fails to extract some enum types

1 participant