Repository navigation
fix(cutile-rs): instantiate pointer-bound type parameters as pointers - #1657
Open
veljjanoski wants to merge 1 commit into
Open
veljjanoski wants to merge 1 commit into
veljjanoski wants to merge 1 commit into
Conversation
Signed-off-by: Daniel Veljjanoski <danielveljanoski@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
PointerTilemethod result with no expected type, such as the receiver of another method call or a call argument, failed to compile with "return type is missing a compiled tile type" (#1596). Its type is derived inside the inlined method fromPointerTile<P, R>, withPbound to* mut f32.TypeInstanceStructuredType::instantiatetreated a bound type parameter as an element type, likeT, so the pointer dropped out and the Tile IR type became!cuda_tile.tile<1>, which doesn't parse. A literal*mut f32type argument already took theType::Ptrbranch and worked. This change instantiates a type parameter bound to a pointer type as a pointer, the same way.Fixes #1596.
Changes
cutile-compilergenerics.rs:TypeInstanceStructuredType::instantiategets a new arm before the element-type arm. A type parameter bound to a pointer type goes throughTypeInstancePtrType::instantiate, as a literal pointer type argument does. If the binding is not a pointer, or does not instantiate as one, the existing element-type arm handles it as before. The change is a pure addition; no existing line changes.compile_ptr_tile_method_chainincutile/tests/basics_and_inlining.rs. It covers the issue'sreshape().broadcast().offset_tile()chain with aload_ptr_tkothrough the result, anoffset().reshape()chain, andreshape_ptr(ptr_tile.offset(1), ..). It checks the pointer tile types in the IR. Onmainit fails with the reported error.An alternative fix in
inline_method_callgave the method body the caller's typeck type, as aletinitializer does. It fixed the same cases with identical IR, but it changes the expected type of every method call that has none, so I kept the fix at the type instantiation.Testing
Run on an RTX 3090 (sm_86), CUDA 13.3, WSL2 Ubuntu 24.04, Rust 1.98.0 (the cutile-rs pin).
I compiled 10 kernels on
mainand with the fix. Onmainthese failed: the issue's chain,reshape().broadcast(),broadcast().offset_tile(),offset().reshape(),reshape().offset()andreshape_ptr(r0.offset(1), ..). With the fix all of them compile. The 4 kernels that already compiled onmain(the step-by-step form, an unannotatedlet, aTilechain and a helper generic overP: Pointer) give byte-identical IR before and after.The issue's repro kernel now gives the same IR as its step-by-step form, apart from the kernel name:
cutile-rs/scripts/run_cpu_tests.shpassesrun_gpu_tests.sh,run_examples.shandtest_benchmarks.sh(the rest ofrun_all.sh): all pass exceptdtype_float_ops' two fp8 tests, which need sm_90 ("F8E4M3FN requires sm_90 or newer ... target sm_86") and fail the same way onmain. 24 examples pass (4 skipped by the runner), and all 8 benchmark smoke tests pass.cargo fmt -- --checkandcargo clippy --workspace --exclude cuda-tile-rs --all-targetsare clean (clippy's one warning is an existing one in acutile-benchmarksbench)mainand passes with the fixChecklist
git commit -s)AI-usage disclosure: Claude (Anthropic) was used as assistant.