Repository navigation
Description
Tracks pull request NVlabs/cutile-rs#318 (NVlabs/cutile-rs#318) by @temotskipa, opened 2026-09-28: fix: standardize non-negative enum types for windows msvc. The branch was rebased onto cutile-rs main on 2026-10-07 and merges cleanly.
@temotskipa: that repository has moved here and is being archived, so the pull request is closed there, not rejected. If you want to continue the work, please recreate it against NVIDIA/cuda-rust. AGENTS.md in NVIDIA/cuda-rust has a "Transplanting a cutile-rs pull request" section that lets an agent do the replay (it fetches pull/318/head from NVlabs/cutile-rs, keeps your authorship and sign-off, and maps the moved paths).
Original description:
Summary
Standardizes non-negative CUDA enums generated in cuda-bindings/build.rs to ::core::ffi::c_uint (u32) across all platforms, enabling native compilation and execution on Windows MSVC. Also fixes minor Windows-specific test runner paths.
Root Cause
On Windows MSVC (x86_64-pc-windows-msvc), Clang adheres to the MSVC ABI where unscoped C enums default to signed c_int (i32). On Linux (System V AMD64 ABI), Clang maps enums with only non-negative values to c_uint (u32).
Because cuda-core (notably in src/simt/) directly consumes these enum constants (CUstream_flags_enum, CUlaunchAttributeID_enum, CUctx_flags_enum, CUevent_flags_enum, CUevent_wait_flags_enum, cudaError_enum, etc.) in APIs expecting u32 without explicit type casts, building on Windows MSVC previously failed with 18 type-mismatch compilation errors (expected u32, found i32). Previous PR #204 had patched a subset of calls in cudarc_shim.rs, but subsequent additions in simt/ re-introduced the issue for uncast enum constants.
Standardizing non-negative enums at the cuda-bindings generation level resolves the issue across the entire crate workspace without requiring ad-hoc casts across downstream crates.
Changes
cuda-bindings/build.rs: Post-process generatedtypes.rsto map non-negative CUDA enums (CUstream_flags_enum,CUlaunchAttributeID_enum,CUctx_flags_enum,CUevent_flags_enum,CUevent_wait_flags_enum,cudaError_enum,CUdevice_attribute_enum,CUfunction_attribute_enum,CUjit_option_enum) to::core::ffi::c_uint. Enums with negative values (e.g.,CUshared_carveout_enumwith-1) remain signed.cutile-compiler/src/cuda_tile_runtime_utils.rs: Usetileiras_executable_name()instead of hardcoded"tileiras"in path resolution tests.cutile-ir/tests/bytecode_validate.rs: Output toNULinstead of/dev/nullon Windows when runningtileiras.cutile-ir/tests/requirements.rs: Normalize CRLF line endings when validating documented requirement matrices.
Validation
- Native Windows (MSVC) Build: Entire workspace (
cuda-bindings,cuda-core,cuda-async,cutile-compiler,cutile-macro,cutile-ir,cutile,cutile-kernels,cutile-examples) compiles with 0 errors. - Unit Tests:
cargo test -p cutile-ir(all 63 unit tests, 2 determinism tests, 22 bytecode validation tests, 10 version tests, 89 per-op roundtrip tests pass)cargo test -p cutile-compiler --lib(all 132 tests pass)cargo test -p cuda-core --lib(all 45 tests pass)
- Formatting & Clippy:
cargo fmt --all -- --checkandcargo clippy --all-targetspass. - GPU Execution: Ran
cargo run -p cutile-examples --example saxpyon native Windows with NVIDIA GeForce RTX 4070 Ti and CUDA Toolkit 13.3; kernel JIT-compiled through nativetileiras.exeand executed successfully with verified outputs.
Activity
unistorm10 commentedon Nov 6, 2026
Confirming this against the published crates:
cutile 0.3.1(pulled in bycandle-core 0.11.1'scutilefeature, which pinscuda-core = 0.3.1/cuda-bindings 0.3.1) fails to compile on Windows 11 + MSVC 14.44 + CUDA 13.1 withcargo check: 17 errors incuda-core/src/simt/context.rs(cuStreamCreateWithPriority/cuStreamCreateflags expectedu32foundi32;CUctx_flags_enum_CU_CTX_SCHED_MASKwithu32 & i32/u32 | i32). Same versions build fine on Linux. Is a patched 0.3.x release planned once the PR lands, so downstream crates get the fix without a git patch? Thanks.fix: standardize non-negative enum types for windows msvc (NVIDIA#1473)