[Metal] deferred codegen does not lower thread id intrinsics #624
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.
We currently handle our fake intrinsics for thread id etc. (
add_input_arguments!
) onfinish_module
if we are dealing with a kernel (job.config.kernel = true
). This all happens before deferred codegen and linking those deferred modules.Now if our kernel contains deferred codegen jobs which are not kernels (
job.config.kernel = false
) (using Enzyme for example) we end up withjulia.air.thread_position_in_grid.i32
in our main kernel after linking. Which will not be removed sincefinish_module
already ran before. The deferred code is not a kernel and thus never ranadd_input_arguments!
during itsfinish_module
.This PR solves this issue by calling
add_input_arguments!
infinish_ir
which is called after linking.cc @wsmoses
Other Solutions / Discussion
add_input_arguments
during IR post-processing