[code-reflection] RFR: Example use of code reflection in translating Java to SPIR-V [v3]

Paul Sandoz psandoz at openjdk.org
Thu Mar 14 17:08:58 UTC 2024


On Thu, 14 Mar 2024 01:16:29 GMT, Steve Dohrmann <duke at openjdk.org> wrote:

>> Example code showing use of code reflection in translation from Java to SPIR-V intermediate language.  For more information on SPIR-V see [https://www.khronos.org/spir](https://www.khronos.org/spir).
>> 
>> Translates from a Java CoreOps.FuncOp object to a SpirvOps.FuncOp object and then to an entry point in a SPIR-V binary module.  One test is included that demonstrates use and renders the Java model, SPIR-V model, and disassembled binary representations of an example Java method. 
>> 
>> A subsequent pull-request will provide additional test code, including the ability to test SPIR-V binaries on GPU hardware. 
>> 
>> Dependencies:
>> 
>> This code depends on a Java SPIR-V builder API (https://github.com/beehive-lab/beehive-spirv-toolkit).  The toolkit can be installed locally with:
>> 
>> git clone https://github.com/beehive-lab/beehive-spirv-toolkit 
>> cd beehive-spirv-toolkit
>> mvn clean install
>
> Steve Dohrmann has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - - apply FieldRef, MethodRef changes
>    - remove unused imports
>  - update README and module header id

Just a minor comment to fix the compilation, otherwise looks good. There are ways we can improve integration with the serialized form later. 

For support of the Vector API and what element/shape the vectors are I think we might be able to learn from techniques used in the Triton example e.g., when we transform the code model of the Java method the method we can pass a constant default shape as an additional argument (rather than hard code), and then do static shape checking for operations, so `Vector<T>` gets augmented with a type element `VectorType`

-------------

Marked as reviewed by psandoz (Lead).

PR Review: https://git.openjdk.org/babylon/pull/38#pullrequestreview-1937293190


More information about the babylon-dev mailing list