Skip to content

fix: standardize non-negative enum types for windows msvc #1441

Closed

Description

@elibol

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

  1. cuda-bindings/build.rs: Post-process generated types.rs to 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_enum with -1) remain signed.
  2. cutile-compiler/src/cuda_tile_runtime_utils.rs: Use tileiras_executable_name() instead of hardcoded "tileiras" in path resolution tests.
  3. cutile-ir/tests/bytecode_validate.rs: Output to NUL instead of /dev/null on Windows when running tileiras.
  4. 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 -- --check and cargo clippy --all-targets pass.
  • GPU Execution: Ran cargo run -p cutile-examples --example saxpy on native Windows with NVIDIA GeForce RTX 4070 Ti and CUDA Toolkit 13.3; kernel JIT-compiled through native tileiras.exe and executed successfully with verified outputs.

Activity

  1. added
    cutile-rs
    on Oct 8, 2026
  2. unistorm10 commented on Nov 6, 2026

    @unistorm10

    Confirming this against the published crates: cutile 0.3.1 (pulled in by candle-core 0.11.1's cutile feature, which pins cuda-core = 0.3.1 / cuda-bindings 0.3.1) fails to compile on Windows 11 + MSVC 14.44 + CUDA 13.1 with cargo check: 17 errors in cuda-core/src/simt/context.rs (cuStreamCreateWithPriority / cuStreamCreate flags expected u32 found i32; CUctx_flags_enum_CU_CTX_SCHED_MASK with u32 & 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.

  3. added a commit that references this issue on Nov 11, 2026
    d9430b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cutile-rspost-migration-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions