Repository navigation
Call-site rewrite: review fixes - #85
Merged
Merged
Conversation
… the changes Review fixes for the call-site rewrite: - Calls in different cases of a switch no longer share a plan: the try block would take the case label between them. - No TaskGraph is built where the call may not run: a plan is shared only from a call the code always reaches, and is not moved out of an if, switch, try or lambda into an enclosing loop. Before a loop, which may run no iteration, only arguments that cannot throw (unqualified variables, literals, operators other than / and %) are evaluated. - An array changed between executions through another variable, in a lambda or anonymous class, or, for a field, by any method called there, is transferred at every execution. - A field argument that is not final, of any type, may be reassigned by a called method, so the calls around such a call do not share a plan. - A local class declared between the calls stays out of the try block. - TaskGraph names given by constants are seen, so they are not reused. - Only line breaks are added between the new imports; the user's import list is not reformatted.
Merged
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
Fixes from a review of the call-site rewrite merged in #83. Each could make the rewritten code fail to compile, run code the original never ran, or replay a plan on stale data.
casegroups of one switch: they shared one plan, so the try block took thecaselabel between them and the file no longer compiled. Each case now gets its own TaskGraph.if).if,switch,tryor lambda into an enclosing loop./and%. An argument such asa.length / kkeeps its TaskGraph inside the loop.float[] alias = a; alias[0] = 1;), in a lambda or anonymous class, or, for a field, by any method called between the executions, now getsEVERY_EXECUTION.new TaskGraph(NAME)) are now seen, so a new graph doesn't reuse them.The review also flagged that an array the kernel only writes is not sent to the device, so elements the kernel skips might come back as device garbage. With TornadoVM 8.2.0 on Metal, they keep their host values: a kernel writing only some elements of
c, withconly intransferToHost, gives the same result as the original Java. So that pattern (transferToDevice(FIRST_EXECUTION, a, b),transferToHost(EVERY_EXECUTION, c)) is kept, with a comment.Testing
./gradlew test: all 329 tests pass. Seven new tests inCallSiteRewriterTest, one per fix: the switch, conditional calls, arguments that can throw, aliases/lambdas/called methods, a local class, a constant graph name, and the user's imports.