This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Lower aborts (incl. panics) to "return from entry-point", instead of infinite loops.#1070
Merged
eddyb merged 1 commit intoEmbarkStudios:mainfrom Jul 7, 2023
LykenSol:custom-abort
Merged
Lower aborts (incl. panics) to "return from entry-point", instead of infinite loops.#1070eddyb merged 1 commit intoEmbarkStudios:mainfrom LykenSol:custom-abort
eddyb merged 1 commit intoEmbarkStudios:mainfrom
LykenSol:custom-abort
Conversation
Member
|
No noticable perf difference in ark. near identical timings. |
VZout
approved these changes
Jun 8, 2023
Contributor
Author
|
Thanks for the confirmation! I will leave this open until I have anything else to land (as I'd rather not stack too many PRs), to give more time to anyone who may have perf-sensitive shaders (e.g. @charles-r-earp @pema99 @Shfty) to test it, but we're likely fine as-is based on what I'm seeing. |
Contributor
Author
|
Decided to merge this despite wanting to dig further into @pema99's usecase, where this PR does seem to have a perf impact - ideally we will move towards more flexibility, which will make comparisons easier. |
This was referenced Jul 14, 2023
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 map the
abortintrinsic (used almost exclusively for panic) to infinite loops, and they either:spirv-optor drivers (i.e. treated as UB)spirv-optand drivers, and cause a timeout when usedDebugPrintfprevents panics' infinite loops from being (unsoundly) optimized away. #1048With infinite loops being so terrible, I propose we move towards a "well-defined invocation exit" approach, where we keep the "abort" as a custom instruction (using our "extended instruction set", added in #1064), and then effectively emulate the semantics of
OpTerminateInvocationfor it by:Abort(either directly, or transitively through some functions it calls) - in the end, we should end up withAborts only used directly from entry-pointsAborts to a plainOpReturn(from the entry-point, i.e. exiting the invocation)debugPrintfcall at this point, with the same inlining-aware "backtrace" we use elsewhere, so that the user gets some feedback if they have the validation layers enabled (and/or try to extract a panic message when we generate the abort in the first place, too)This PR implements that proposal (but without any
debugPrintfconveniences), and so far it seems to work great, but I haven't tested the performance impact (i.e. where before the infinite loops were optimized away, now we're seeing an actual cost to various e.g. bounds checks, that need to do something at all).There are also other ways of implementing this, and we could do the
Abort->OpReturnrewriting very late (if we think it would be better than letting the SPIR-T structurizer see it), so there's some room to explore mitigations to perf issues, if they arise.(I will leave this PR as draft until we're sure about the perf aspects)