Repository navigation
Fix ISPC code generation for subscripted private temporaries - #1057
Merged
inducer merged 1 commit intoOct 28, 2026
Merged
Conversation
Contributor
Author
|
The basedpyright failure is in loopy/symbolic.py, which this PR doesn't touch; it fails the same way on main (067ffc8). |
ExprToISPCExprMapper.map_subscript calls get_grid_size_upper_bounds_as_exprs() without the callables table, which has been a required argument since the 2021 kernel callables work. Any kernel that subscripts a private temporary therefore fails ISPC code generation with "TypeError: LoopKernel.get_grid_size_upper_bounds_as_exprs() missing 1 required positional argument: 'callables_table'". That includes ordinary uses of an "ilp" iname, which privatizes temporaries into arrays. The other three calls in loopy/target/ispc.py were updated over time (map_variable in fbdda4d for inducergh-763, the temporary declarator in 34c7344); this one was missed. Pass self.codegen_state.callables_table, as map_variable does. test_ispc_private_array is the subscripted counterpart of test_ispc_private_var. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inducer
force-pushed
the
fix/ispc-private-array-subscript
branch
from
October 28, 2026 20:31
0ebc43f to
20ecfc0
Compare
Owner
|
Thanks! |
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.
ExprToISPCExprMapper.map_subscriptcallsself.kernel.get_grid_size_upper_bounds_as_exprs()with no arguments (loopy/target/ispc.py:172).callables_tablehas been a required parameter of that method since the kernel callables work in 2021 (loopy/kernel/__init__.py:1108), so ISPC code generation fails for any kernel that subscripts a private temporary:A kernel does not need an explicitly private array to hit this. An
ilpiname privatizes the temporaries in its loop into arrays, so this fails the same way on 067ffc8:The other three calls to this method in
loopy/target/ispc.pyalready pass the table:map_variablesince fbdda4d (#764, the scalar case from #763), the private temporary declarator since 34c7344, andpre_codegen_entrypoint_check. This call was missed. The change passesself.codegen_state.callables_table, asmap_variabledoes twenty lines above. basedpyright flags the call asreportCallIssue("Argument types: ()"), but that entry sits in.basedpyright/baseline.json.With the fix, the accesses match the declaration that
get_temporary_var_declaratoremits, with one copy of the temporary per program instance (lsize + shape). For the kernel in the new test (tmp[j]private,isplit by 8 intol.0andg.0):The
ilpexample above now generatesfloat tmp[8 * 4];, with the unrolled accessestmp[programIndex + 8 * (0 + 0)]throughtmp[programIndex + 8 * (0 + 3)].test_ispc_private_arrayintest/test_target.pyis the subscripted counterpart oftest_ispc_private_var. It checks the declaration and that both the store and the load are offset byprogramIndex. Like the other ISPC tests it only generates code, so it needs no ISPC compiler and no OpenCL device. I did not compile the generated ISPC, because no ISPC compiler was available here.Verified on macOS 26.7.1 (arm64), Python 3.12.15, numpy 2.5.4, islpy 2026.2.2, namedisl 2026.1.1, pymbolic 2025.1, pyopencl 2026.1.4. This machine has no usable OpenCL device, so a local pytest plugin made pyopencl's fixture report zero devices, and the tests that need a context are skipped:
The per-test outcomes are the same on both trees except for the new test. The one failure,
test_dgemm_with_rectangular_tile_prefetch, callscl.create_some_context()itself and getsclGetDeviceIDs failed: INVALID_VALUEon both trees.🤖 Generated with Claude Code