[code-reflection] RFR: Example use of code reflection in translating Java to SPIR-V [v2]
Steve Dohrmann
duke at openjdk.org
Wed Mar 13 17:10:33 UTC 2024
On Tue, 12 Mar 2024 23:01:55 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 one additional commit since the last revision:
>
> Update full name
Hi Juan,
Thanks, I’ll make the change. Very happy to have the Beehive SPIR-V Toolkit available!
-Steve
From: Juan Fumero ***@***.***>
Sent: 2024.03.13 0:12
To: openjdk/babylon ***@***.***>
Cc: Dohrmann, Steve ***@***.***>; Mention ***@***.***>
Subject: Re: [openjdk/babylon] Example use of code reflection in translating Java to SPIR-V (PR #38)
@jjfumero commented on this pull request.
________________________________
In cr-examples/spirv/src/main/java/intel/code/spirv/SpirvModuleGenerator.java<https://github.com/openjdk/babylon/pull/38#discussion_r1522643909>:
> + Disassembler dis = new Disassembler(input, ps, options);
+ dis.run();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return new String(out.toByteArray());
+ }
+
+ private record SpirvResult(SPIRVId type, SPIRVId address, SPIRVId value) {}
+
+ private final SPIRVModule module;
+ private final Symbols symbols;
+
+ private SpirvModuleGenerator() {
+ this.module = new SPIRVModule(new SPIRVHeader(1, 2, 29, 0, 0));
Suggestion: Since the SPIR-V is generated from the Beehive SPIR-V Toolkit, you can use the ID generator from that tool. The number is 32, so it will be:
this.module = new SPIRVModule(new SPIRVHeader(1, 2, 32, 0, 0));
Link: https://github.com/KhronosGroup/SPIRV-Headers/blob/main/include/spirv/spir-v.xml#L85
—
Reply to this email directly, view it on GitHub<https://github.com/openjdk/babylon/pull/38#pullrequestreview-1933308626>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA5ODQXUHEV65BDH2P3AOUDYX734TAVCNFSM6AAAAABETCZQSCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMZTGMYDQNRSGY>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
-------------
PR Comment: https://git.openjdk.org/babylon/pull/38#issuecomment-1995025558
More information about the babylon-dev
mailing list