fix: preserve int semantics for OpenCL work-item getters#200
Open
ItsOtherMauridian wants to merge 1 commit into
Open
fix: preserve int semantics for OpenCL work-item getters#200ItsOtherMauridian wants to merge 1 commit into
ItsOtherMauridian wants to merge 1 commit into
Conversation
5fb5084 to
026f2e8
Compare
Author
|
Small clarification after reviewing the related closed PR #205: this PR now covers both parts of the failure mode for #38.
I also re-ran the targeted regression checks in Docker: docker run --rm -v "$PWD":/workspace -w /workspace maven:3.8.8-eclipse-temurin-8 \
mvn -q -Dtest=com.aparapi.codegen.test.LongMultiplyCastOverflowTest,com.aparapi.codegen.test.LongCastMultiplyTest test |
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
intsemantics for OpenCL work-item/size getter mappings by emitting an explicit(int)cast before enclosing widening/arithmetic.getPassId()from that cast because its generated helper already returnsint.longmultiplication (LMUL) to anaparapi_lmulhelper implemented with 32-bit OpenCL operations, avoiding driver/device miscompilation of native 64-bit multiply.LMUL.(long)getGlobalId() * 100nearInteger.MAX_VALUEto preserve Java getter narrowing semantics.(long)value * 100to ensure generated OpenCL usesaparapi_lmul(...)instead of native*.get_global_idnarrowing cast.Why this addresses #38
The issue can be hit through two layers:
intwork-item getters to OpenCL functions that returnsize_t; without narrowing first, enclosing casts/arithmetic can observe the wrong width.long * longfor this case.This PR handles both: it preserves the Java getter return semantics and routes generated
LMULthrough a helper based on 32-bit operations.Test Plan
docker run --rm -v "$PWD":/workspace -w /workspace maven:3.8.8-eclipse-temurin-8 mvn -q -Dtest=com.aparapi.codegen.test.LongMultiplyCastOverflowTest,com.aparapi.codegen.test.LongCastMultiplyTest testdocker run --rm -v "$PWD":/workspace -w /workspace maven:3.8.8-eclipse-temurin-8 mvn -q -Dtest=com.aparapi.codegen.test.CallGetPassIdTest,com.aparapi.codegen.test.LongCastMultiplyTest,com.aparapi.codegen.test.CompositeArbitraryScopeTest,com.aparapi.codegen.test.ObjectArrayMemberAccessTest,com.aparapi.codegen.test.ObjectArrayMemberCallTest,com.aparapi.codegen.test.ObjectArrayMemberGetterSetterTest,com.aparapi.codegen.test.ObjectArrayMemberHierarchyTest,com.aparapi.codegen.test.ObjectRefCopyTest,com.aparapi.SimpleScalaTest testdocker run --rm -v "$PWD":/workspace -w /workspace maven:3.8.8-eclipse-temurin-8 mvn -q -Dtest=com.aparapi.codegen.test.*Test,com.aparapi.SimpleScalaTest test/claim #38