Fix LMUL overflow mismatch on GPU - #205
Closed
Horace-Maxwell wants to merge 1 commit into
Closed
Horace-Maxwell wants to merge 1 commit into
Horace-Maxwell wants to merge 1 commit into
Conversation
Work around miscompiled 64-bit multiply by lowering LMUL to 32-bit operations and add regression test for issue #38.
3 tasks
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.
Fixes #38
Some OpenCL drivers/devices appear to miscompile 64-bit integer multiplication, producing results where the high 32 bits of a 64-bit product are incorrect/zero. This shows up as CPU/GPU mismatches for expressions like
(long) tc * 100when the mathematical result does not fit in 32 bits.This change lowers
LMULto a helper (aparapi_lmul) implemented in terms of 32-bit multiplies (andmul_hi) so kernels do not rely on native 64-bit multiply support. The helper is only emitted when the entrypoint (or any called method) containsLMUL.Tests run:
mvn -q -Dtest=com.aparapi.codegen.test.LongMultiplyCastOverflowTest testmvn -q -Dtest='com.aparapi.codegen.test.*Test' -DfailIfNoTests=false testBuild tweaks (for newer JDKs):
-XX:MaxPermSizefrom SurefireargLine