From duke at openjdk.org Fri Aug 1 13:21:05 2025 From: duke at openjdk.org (Juan Fumero) Date: Fri, 1 Aug 2025 13:21:05 GMT Subject: [code-reflection] RFR: [hat][opencl] Check errors macro added Message-ID: This PR adds a new macro for controlling OpenCL errors. Notes: At the moment, the macro exits the VM if an error is encountered. In long run, what we should do is to return a state to the Java side. Thus the Java/HAT runtime can control what to do with the exception. The state can be common for all backends, at least at a high-level. Then each backend can have its own list of error status. ------------- Commit messages: - [hat][opencl] Check errors macro added Changes: https://git.openjdk.org/babylon/pull/510/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=510&range=00 Stats: 282 lines in 8 files changed: 36 ins; 58 del; 188 mod Patch: https://git.openjdk.org/babylon/pull/510.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/510/head:pull/510 PR: https://git.openjdk.org/babylon/pull/510 From duke at openjdk.org Fri Aug 1 13:27:16 2025 From: duke at openjdk.org (duke) Date: Fri, 1 Aug 2025 13:27:16 GMT Subject: [code-reflection] RFR: [hat][opencl] Check errors macro added In-Reply-To: References: Message-ID: On Fri, 1 Aug 2025 13:16:26 GMT, Juan Fumero wrote: > This PR adds a new macro for controlling OpenCL errors. > > Notes: At the moment, the macro exits the VM if an error is encountered. In long run, what we should do is to return a state to the Java side. Thus the Java/HAT runtime can control what to do with the exception. > > The state can be common for all backends, at least at a high-level. Then each backend can have its own list of error status. @jjfumero Your change (at version 5b67c75bc2df3f29242126a1b38de26e841ac362) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/510#issuecomment-3144587457 From gfrost at openjdk.org Fri Aug 1 15:24:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Fri, 1 Aug 2025 15:24:45 GMT Subject: git: openjdk/babylon: code-reflection: [hat][opencl] Check errors macro added Message-ID: <6083269c-6221-48c3-a042-2c66d27249c2@openjdk.org> Changeset: 9e465bb6 Branch: code-reflection Author: Juan Fumero Committer: Gary Frost Date: 2025-08-01 15:23:05 +0000 URL: https://git.openjdk.org/babylon/commit/9e465bb60c51e379fa211b1e92dc1d904239a7b2 [hat][opencl] Check errors macro added ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_buffer.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_info.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_kernel.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_program.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_queue.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/squares.cpp ! hat/backends/ffi/opencl/src/main/native/include/opencl_backend.h From duke at openjdk.org Fri Aug 1 15:26:14 2025 From: duke at openjdk.org (Juan Fumero) Date: Fri, 1 Aug 2025 15:26:14 GMT Subject: [code-reflection] Integrated: [hat][opencl] Check errors macro added In-Reply-To: References: Message-ID: On Fri, 1 Aug 2025 13:16:26 GMT, Juan Fumero wrote: > This PR adds a new macro for controlling OpenCL errors. > > Notes: At the moment, the macro exits the VM if an error is encountered. In long run, what we should do is to return a state to the Java side. Thus the Java/HAT runtime can control what to do with the exception. > > The state can be common for all backends, at least at a high-level. Then each backend can have its own list of error status. This pull request has now been integrated. Changeset: 9e465bb6 Author: Juan Fumero Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/9e465bb60c51e379fa211b1e92dc1d904239a7b2 Stats: 282 lines in 8 files changed: 36 ins; 58 del; 188 mod [hat][opencl] Check errors macro added ------------- PR: https://git.openjdk.org/babylon/pull/510 From mabbay at openjdk.org Fri Aug 1 20:47:23 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 1 Aug 2025 20:47:23 GMT Subject: [code-reflection] RFR: Disallow insertion of a root op in a block [v6] In-Reply-To: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> References: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> Message-ID: > A root operation shouldn't be inserted in a block. This changes enforce this rule. Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 11 commits: - Test that freezing an already bound op, throws - Test that structural quoted lambda are frozen - Update method Op.parentBlock to take into account frozen operations - Force copying of a frozen operation - Freeze code models we produce, in the OpBuilder - Merge branch 'code-reflection' into root-op-insertion - Not leak out the special Result value - Remove trace of previous attempt - Implement freezing of an op - Merge branch 'code-reflection' into root-op-insertion # Conflicts: # src/jdk.incubator.code/share/classes/jdk/incubator/code/op/CoreOp.java - ... and 1 more: https://git.openjdk.org/babylon/compare/32de7710...6e873fd4 ------------- Changes: https://git.openjdk.org/babylon/pull/425/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=425&range=05 Stats: 116 lines in 5 files changed: 112 ins; 0 del; 4 mod Patch: https://git.openjdk.org/babylon/pull/425.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/425/head:pull/425 PR: https://git.openjdk.org/babylon/pull/425 From mabbay at openjdk.org Fri Aug 1 22:07:47 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 1 Aug 2025 22:07:47 GMT Subject: [code-reflection] RFR: Disallow insertion of a root op in a block [v7] In-Reply-To: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> References: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> Message-ID: <2je5GvIRMgwR-6dppVH2ZNuJzN7SPn8t6LNKZHaOjO8=.3ba8dd5c-6c5c-4bfb-8658-9845c33a98dd@github.com> > A root operation shouldn't be inserted in a block. This changes enforce this rule. Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits: - Merge branch 'code-reflection' into root-op-insertion # Conflicts: # src/jdk.incubator.code/share/classes/jdk/incubator/code/Op.java # src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java - Test that freezing an already bound op, throws - Test that structural quoted lambda are frozen - Update method Op.parentBlock to take into account frozen operations - Force copying of a frozen operation - Freeze code models we produce, in the OpBuilder - Merge branch 'code-reflection' into root-op-insertion - Not leak out the special Result value - Remove trace of previous attempt - Implement freezing of an op - ... and 2 more: https://git.openjdk.org/babylon/compare/9e465bb6...e2979129 ------------- Changes: https://git.openjdk.org/babylon/pull/425/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=425&range=06 Stats: 116 lines in 5 files changed: 112 ins; 0 del; 4 mod Patch: https://git.openjdk.org/babylon/pull/425.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/425/head:pull/425 PR: https://git.openjdk.org/babylon/pull/425 From mabbay at openjdk.org Fri Aug 1 22:15:17 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 1 Aug 2025 22:15:17 GMT Subject: [code-reflection] RFR: Disallow insertion of a root op in a block [v8] In-Reply-To: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> References: <8sB7qlbnONF4wEI39cUCoik0sXf2Oj8NV7TsJ-ZbDWA=.a4cd10a1-ef17-4170-8697-4fd15557b568@github.com> Message-ID: > A root operation shouldn't be inserted in a block. This changes enforce this rule. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Update TestFreezeOp as result of API change ------------- Changes: - all: https://git.openjdk.org/babylon/pull/425/files - new: https://git.openjdk.org/babylon/pull/425/files/e2979129..46147724 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=425&range=07 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=425&range=06-07 Stats: 8 lines in 1 file changed: 0 ins; 2 del; 6 mod Patch: https://git.openjdk.org/babylon/pull/425.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/425/head:pull/425 PR: https://git.openjdk.org/babylon/pull/425 From psandoz at openjdk.org Fri Aug 1 22:44:10 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 1 Aug 2025 22:44:10 GMT Subject: git: openjdk/babylon: code-reflection: Transformation API changes Message-ID: Changeset: 20b98973 Branch: code-reflection Author: Paul Sandoz Date: 2025-08-01 22:42:43 +0000 URL: https://git.openjdk.org/babylon/commit/20b98973c2d3e453942ff34794c62b3f7027cf95 Transformation API changes ! cr-examples/onnx/src/main/java/oracle/code/onnx/compiler/OnnxTransformer.java ! cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java ! hat/core/src/main/java/hat/OpsAndTypes.java ! hat/examples/experiments/src/main/java/experiments/LayoutExample.java ! hat/examples/experiments/src/main/java/experiments/RawLayout.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/Block.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/Body.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/OpTransformer.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/Inliner.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/NormalizeBlocksTransformer.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/SSABraun.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/StringConcatTransformer.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/UnresolvedTypesTransformer.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java ! test/jdk/java/lang/reflect/code/CoreBinaryOpsTest.java ! test/jdk/java/lang/reflect/code/TestVarOp.java From psandoz at openjdk.org Fri Aug 1 22:45:15 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 1 Aug 2025 22:45:15 GMT Subject: [code-reflection] RFR: Transformation API changes In-Reply-To: References: Message-ID: <6Sf-gFs0_qHaR2m22bPCblbxIpQ2WEVj-SQOfH3BUdk=.aeb6721e-92ad-45e9-857d-f7b469b8324f@github.com> On Mon, 14 Jul 2025 20:47:59 GMT, Paul Sandoz wrote: > Move transformation of a `Body` starting at a `Block.Builder` to `OpTransformer`, which now has three methods, default method `acceptBody` calls default method `acceptBlock`, which in turn calls abstract method `acceptOp`. > > Simplify the body accepting methods on `Block.Builder` which now defer to `OpTransformer.acceptBody`. Those methods are responsible for rebinding the `Block.Builder` and passing the rebound result to `acceptBody`. ------------- PR Review: https://git.openjdk.org/babylon/pull/494#pullrequestreview-3080705847 From psandoz at openjdk.org Fri Aug 1 22:45:16 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 1 Aug 2025 22:45:16 GMT Subject: [code-reflection] Integrated: Transformation API changes In-Reply-To: References: Message-ID: On Mon, 14 Jul 2025 20:47:59 GMT, Paul Sandoz wrote: > Move transformation of a `Body` starting at a `Block.Builder` to `OpTransformer`, which now has three methods, default method `acceptBody` calls default method `acceptBlock`, which in turn calls abstract method `acceptOp`. > > Simplify the body accepting methods on `Block.Builder` which now defer to `OpTransformer.acceptBody`. Those methods are responsible for rebinding the `Block.Builder` and passing the rebound result to `acceptBody`. This pull request has now been integrated. Changeset: 20b98973 Author: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/20b98973c2d3e453942ff34794c62b3f7027cf95 Stats: 222 lines in 16 files changed: 64 ins; 42 del; 116 mod Transformation API changes ------------- PR: https://git.openjdk.org/babylon/pull/494 From mabbay at openjdk.org Fri Aug 1 22:49:58 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 1 Aug 2025 22:49:58 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v2] In-Reply-To: References: Message-ID: > We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Apply suggestions ------------- Changes: - all: https://git.openjdk.org/babylon/pull/509/files - new: https://git.openjdk.org/babylon/pull/509/files/f140304e..641cba3b Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=00-01 Stats: 130 lines in 3 files changed: 69 ins; 56 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/509.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/509/head:pull/509 PR: https://git.openjdk.org/babylon/pull/509 From mabbay at openjdk.org Fri Aug 1 23:21:03 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 1 Aug 2025 23:21:03 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v3] In-Reply-To: References: Message-ID: > We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Apply suggestions ------------- Changes: - all: https://git.openjdk.org/babylon/pull/509/files - new: https://git.openjdk.org/babylon/pull/509/files/641cba3b..b3d56672 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=01-02 Stats: 7 lines in 1 file changed: 1 ins; 0 del; 6 mod Patch: https://git.openjdk.org/babylon/pull/509.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/509/head:pull/509 PR: https://git.openjdk.org/babylon/pull/509 From gfrost at openjdk.org Sat Aug 2 12:50:40 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 2 Aug 2025 12:50:40 GMT Subject: git: openjdk/babylon: code-reflection: Add SSA id dependency viewer tool + DotViewer infra Message-ID: <84dfcd4a-1a8e-446c-b090-15ba416bed5b@openjdk.org> Changeset: 32671792 Branch: code-reflection Author: Gary Frost Date: 2025-08-02 12:49:43 +0000 URL: https://git.openjdk.org/babylon/commit/326717927244f691793cb11ffb2027c0175910a0 Add SSA id dependency viewer tool + DotViewer infra + hat/tools/src/main/java/hat/tools/jdot/DotBuilder.java + hat/tools/src/main/java/hat/tools/jdot/ui/JDot.java + hat/tools/src/main/java/hat/tools/json/Json.java + hat/tools/src/main/java/hat/tools/json/JsonArray.java + hat/tools/src/main/java/hat/tools/json/JsonBoolean.java + hat/tools/src/main/java/hat/tools/json/JsonNull.java + hat/tools/src/main/java/hat/tools/json/JsonNumber.java + hat/tools/src/main/java/hat/tools/json/JsonObject.java + hat/tools/src/main/java/hat/tools/json/JsonParseException.java + hat/tools/src/main/java/hat/tools/json/JsonString.java + hat/tools/src/main/java/hat/tools/json/JsonValue.java + hat/tools/src/main/java/hat/tools/json/impl/JsonArrayImpl.java + hat/tools/src/main/java/hat/tools/json/impl/JsonBooleanImpl.java + hat/tools/src/main/java/hat/tools/json/impl/JsonNullImpl.java + hat/tools/src/main/java/hat/tools/json/impl/JsonNumberImpl.java + hat/tools/src/main/java/hat/tools/json/impl/JsonObjectImpl.java + hat/tools/src/main/java/hat/tools/json/impl/JsonParser.java + hat/tools/src/main/java/hat/tools/json/impl/JsonStringImpl.java + hat/tools/src/main/java/hat/tools/json/impl/Utils.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/AbstractTextModelViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/FuncOpTextModelViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/JavaTextModelViewer.java + hat/tools/src/main/java/hat/tools/textmodel/ui/SSAIDViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/TextGutter.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/TextViewer.java From gfrost at openjdk.org Sat Aug 2 12:55:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 2 Aug 2025 12:55:03 GMT Subject: [code-reflection] Integrated: Add SSA id dependency viewer tool + DotViewer infra Message-ID: Another HAT tool that I needed to find a home for. This one shows a dependency graph between the SSA id (refs to defs) for a given Babylon funcOp graph. This is essentially a DOT graph view of the dependencies shown in the existing line based FuncOpViewer tool ------------- Commit messages: - Add SSA id dependency viewer tool + DotViewer infra Changes: https://git.openjdk.org/babylon/pull/511/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=511&range=00 Stats: 3346 lines in 25 files changed: 3259 ins; 42 del; 45 mod Patch: https://git.openjdk.org/babylon/pull/511.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/511/head:pull/511 PR: https://git.openjdk.org/babylon/pull/511 From gfrost at openjdk.org Sat Aug 2 12:55:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 2 Aug 2025 12:55:03 GMT Subject: [code-reflection] Integrated: Add SSA id dependency viewer tool + DotViewer infra In-Reply-To: References: Message-ID: <-KfBU4Nbbs3G6riP2KxQ5vmPQpjqbB3sF-F0jV2H1N0=.02280e19-f953-497d-a122-766ff4a84a40@github.com> On Sat, 2 Aug 2025 12:47:21 GMT, Gary Frost wrote: > Another HAT tool that I needed to find a home for. > > This one shows a dependency graph between the SSA id (refs to defs) for a given Babylon funcOp graph. > > This is essentially a DOT graph view of the dependencies shown in the existing line based FuncOpViewer tool This pull request has now been integrated. Changeset: 32671792 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/326717927244f691793cb11ffb2027c0175910a0 Stats: 3346 lines in 25 files changed: 3259 ins; 42 del; 45 mod Add SSA id dependency viewer tool + DotViewer infra ------------- PR: https://git.openjdk.org/babylon/pull/511 From psandoz at openjdk.org Sat Aug 2 14:47:09 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Sat, 2 Aug 2025 14:47:09 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v3] In-Reply-To: References: Message-ID: On Fri, 1 Aug 2025 23:21:03 GMT, Mourad Abbay wrote: >> We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Apply suggestions src/jdk.incubator.code/share/classes/jdk/incubator/code/interpreter/Interpreter.java line 117: > 115: Class c = typeToResolve.toNominalDescriptor().resolveConstantDesc(l); > 116: if (!c.isInstance(rv)) { > 117: Class svc = ((JavaType) sv.type()).toNominalDescriptor().resolveConstantDesc(l); You don't have to resolve here, we can just directly use `sv.type()` as an argument for the exception message. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/509#discussion_r2249269498 From mabbay at openjdk.org Mon Aug 4 16:19:34 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Mon, 4 Aug 2025 16:19:34 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v4] In-Reply-To: References: Message-ID: > We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Apply suggestion ------------- Changes: - all: https://git.openjdk.org/babylon/pull/509/files - new: https://git.openjdk.org/babylon/pull/509/files/b3d56672..3db706b0 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=03 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=02-03 Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/509.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/509/head:pull/509 PR: https://git.openjdk.org/babylon/pull/509 From psandoz at openjdk.org Tue Aug 5 14:21:27 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 5 Aug 2025 14:21:27 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v4] In-Reply-To: References: Message-ID: <4_rH276gGDxL3XKrYB0lQowPIBtO-IZBLIlvOpSEjR4=.a974825f-f4a5-4716-8008-6b030b12f2d5@github.com> On Mon, 4 Aug 2025 16:19:34 GMT, Mourad Abbay wrote: >> We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Apply suggestion Marked as reviewed by psandoz (Lead). src/jdk.incubator.code/share/classes/jdk/incubator/code/interpreter/Interpreter.java line 113: > 111: case PrimitiveType pt -> pt.box().orElseThrow(); > 112: case JavaType jt -> jt; > 113: default -> throw new IllegalStateException("Unexpected value: " + sv.type()); Suggestion: default -> throw new IllegalStateException("Unexpected type: " + sv.type()); ------------- PR Review: https://git.openjdk.org/babylon/pull/509#pullrequestreview-3088520734 PR Review Comment: https://git.openjdk.org/babylon/pull/509#discussion_r2254509313 From mabbay at openjdk.org Tue Aug 5 21:23:02 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Tue, 5 Aug 2025 21:23:02 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods Message-ID: Specify the behaviour of quoteOp and quotedOp methods. ------------- Commit messages: - Document QuotedOp.quoteOp method Changes: https://git.openjdk.org/babylon/pull/512/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=00 Stats: 26 lines in 1 file changed: 25 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From mabbay at openjdk.org Tue Aug 5 21:24:16 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Tue, 5 Aug 2025 21:24:16 GMT Subject: git: openjdk/babylon: code-reflection: Validate arguments types when interpreting an operation Message-ID: <93340d10-5a9e-4a05-9608-3e9480669ed1@openjdk.org> Changeset: 4e218910 Branch: code-reflection Author: Mourad Abbay Date: 2025-08-05 21:22:36 +0000 URL: https://git.openjdk.org/babylon/commit/4e218910f140ef6d86c2ce35278061b063846431 Validate arguments types when interpreting an operation Reviewed-by: mcimadamore, psandoz ! src/jdk.incubator.code/share/classes/jdk/incubator/code/interpreter/Interpreter.java + test/jdk/java/lang/reflect/code/interpreter/TestArgsTypesValidationWhenInterpreting.java From mabbay at openjdk.org Tue Aug 5 21:25:44 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Tue, 5 Aug 2025 21:25:44 GMT Subject: [code-reflection] Integrated: Validate arguments types when interpreting an operation In-Reply-To: References: Message-ID: On Thu, 31 Jul 2025 20:22:46 GMT, Mourad Abbay wrote: > We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. This pull request has now been integrated. Changeset: 4e218910 Author: Mourad Abbay URL: https://git.openjdk.org/babylon/commit/4e218910f140ef6d86c2ce35278061b063846431 Stats: 87 lines in 2 files changed: 86 ins; 0 del; 1 mod Validate arguments types when interpreting an operation Reviewed-by: mcimadamore, psandoz ------------- PR: https://git.openjdk.org/babylon/pull/509 From mabbay at openjdk.org Tue Aug 5 21:25:43 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Tue, 5 Aug 2025 21:25:43 GMT Subject: [code-reflection] RFR: Validate arguments types when interpreting an operation [v5] In-Reply-To: References: Message-ID: <1e3m1V0T0jPSLaZJnKv1VbT7EkXMrbn7Fu12Kse8EkA=.6108a8fe-3db4-482e-bc85-ba9ddc2963f1@github.com> > We don't validate arguments types in the interpreter. This PR add the validation allowing us to catch invalid arguments early. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Apply suggestion Co-authored-by: Paul Sandoz ------------- Changes: - all: https://git.openjdk.org/babylon/pull/509/files - new: https://git.openjdk.org/babylon/pull/509/files/3db706b0..7f2b97bf Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=509&range=03-04 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/509.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/509/head:pull/509 PR: https://git.openjdk.org/babylon/pull/509 From mabbay at openjdk.org Wed Aug 6 00:02:56 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 6 Aug 2025 00:02:56 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v2] In-Reply-To: References: Message-ID: > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: When we quote an op, don't include a captured value that's an operand ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/0481b203..5785fab5 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=00-01 Stats: 31 lines in 2 files changed: 30 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From mabbay at openjdk.org Wed Aug 6 00:12:12 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 6 Aug 2025 00:12:12 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v3] In-Reply-To: References: Message-ID: <7PdnH-Eqku4oYLXlwuqyYv23fFdm8IEXEV1lGnzi5gA=.ec513f7f-2aa0-45eb-a00f-23aaf154086a@github.com> > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Update quoteOp doc ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/5785fab5..659f018f Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=01-02 Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From gfrost at openjdk.org Thu Aug 7 14:33:53 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 7 Aug 2025 14:33:53 GMT Subject: git: openjdk/babylon: code-reflection: HAT simplify tool text styling Message-ID: Changeset: 32995e46 Branch: code-reflection Author: Gary Frost Date: 2025-08-07 14:31:36 +0000 URL: https://git.openjdk.org/babylon/commit/32995e46dfed2b2d689c493232f1f9b70e75cf5f HAT simplify tool text styling ! hat/tools/src/main/java/hat/tools/textmodel/TextModel.java - hat/tools/src/main/java/hat/tools/textmodel/ui/AbstractTextModelViewer.java + hat/tools/src/main/java/hat/tools/textmodel/ui/BabylonStyleMapper.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/ElementSpan.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/FuncOpTextModelViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/FuncOpViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/JavaTextModelViewer.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/SSAIDViewer.java + hat/tools/src/main/java/hat/tools/textmodel/ui/StyleMapper.java ! hat/tools/src/main/java/hat/tools/textmodel/ui/TextGutter.java + hat/tools/src/main/java/hat/tools/textmodel/ui/TextModelViewer.java - hat/tools/src/main/java/hat/tools/textmodel/ui/TextViewer.java From gfrost at openjdk.org Thu Aug 7 14:35:02 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 7 Aug 2025 14:35:02 GMT Subject: [code-reflection] Integrated: HAT simplify tool text styling Message-ID: Recent PR's have included components for styling Java and CodeReflection text. In preparation for allowing edits of text (for new upcomming tooling) I refactored the styling, so it can be reused. ------------- Commit messages: - Externalized TextModelViewer styling - Switching to external StyleMapper Changes: https://git.openjdk.org/babylon/pull/514/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=514&range=00 Stats: 902 lines in 12 files changed: 480 ins; 385 del; 37 mod Patch: https://git.openjdk.org/babylon/pull/514.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/514/head:pull/514 PR: https://git.openjdk.org/babylon/pull/514 From gfrost at openjdk.org Thu Aug 7 14:35:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 7 Aug 2025 14:35:03 GMT Subject: [code-reflection] Integrated: HAT simplify tool text styling In-Reply-To: References: Message-ID: On Thu, 7 Aug 2025 14:28:08 GMT, Gary Frost wrote: > Recent PR's have included components for styling Java and CodeReflection text. > > In preparation for allowing edits of text (for new upcomming tooling) I refactored the styling, so it can be reused. This pull request has now been integrated. Changeset: 32995e46 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/32995e46dfed2b2d689c493232f1f9b70e75cf5f Stats: 902 lines in 12 files changed: 480 ins; 385 del; 37 mod HAT simplify tool text styling ------------- PR: https://git.openjdk.org/babylon/pull/514 From duke at openjdk.org Thu Aug 7 15:27:53 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 7 Aug 2025 15:27:53 GMT Subject: [code-reflection] RFR: [hat] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges Message-ID: This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. How to dispatch 1D kernels? ComputeRange range1D = new ComputeRange(new ThreadMesh(size)); cc.dispatchKernel(computeRange, kc -> myKernel(...)); How to dispatch 2D kernels? ComputeRange range2D = new ComputeRange(new ThreadMesh(size, size)); cc.dispatchKernel(computeRange, kc -> my2DKernel(...)); How to enable local mesh? We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. ComputeRange computeRange = new ComputeRange( new ThreadMesh(globalSize, globalSize), new ThreadMesh(16, 16)); cc.dispatchKernel(computeRange, kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) ); In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. #### How to check? java @hat/run ffi-opencl matmul 1D java @hat/run ffi-opencl matmul 2D java @hat/run ffi-cuda matmul 1D java @hat/run ffi-cuda matmul 2D ------------- Commit messages: - Merge branch 'code-reflection' into hat/api/lw - [hat] ComputeRange enable for the CUDA Runtime - [hat][example] Fix arguments for compute context - [hat] ComputeRange/ThreadMesh proposal for OpenCL Changes: https://git.openjdk.org/babylon/pull/515/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=515&range=00 Stats: 639 lines in 37 files changed: 396 ins; 161 del; 82 mod Patch: https://git.openjdk.org/babylon/pull/515.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/515/head:pull/515 PR: https://git.openjdk.org/babylon/pull/515 From duke at openjdk.org Thu Aug 7 15:32:58 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 7 Aug 2025 15:32:58 GMT Subject: [code-reflection] RFR: [hat] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v2] In-Reply-To: References: Message-ID: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new ThreadMesh(size)); > cc.dispatchKernel(computeRange, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new ThreadMesh(size, size)); > cc.dispatchKernel(computeRange, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new ThreadMesh(globalSize, globalSize), > new ThreadMesh(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: minor change ------------- Changes: - all: https://git.openjdk.org/babylon/pull/515/files - new: https://git.openjdk.org/babylon/pull/515/files/257ff1de..51efd2c2 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=515&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=515&range=00-01 Stats: 2 lines in 1 file changed: 0 ins; 2 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/515.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/515/head:pull/515 PR: https://git.openjdk.org/babylon/pull/515 From duke at openjdk.org Fri Aug 8 07:58:37 2025 From: duke at openjdk.org (duke) Date: Fri, 8 Aug 2025 07:58:37 GMT Subject: [code-reflection] RFR: [hat] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v2] In-Reply-To: References: Message-ID: On Thu, 7 Aug 2025 15:32:58 GMT, Juan Fumero wrote: >> This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. >> A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. >> >> Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. >> >> How to dispatch 1D kernels? >> >> >> ComputeRange range1D = new ComputeRange(new ThreadMesh(size)); >> cc.dispatchKernel(computeRange, >> kc -> myKernel(...)); >> >> >> How to dispatch 2D kernels? >> >> >> ComputeRange range2D = new ComputeRange(new ThreadMesh(size, size)); >> cc.dispatchKernel(computeRange, >> kc -> my2DKernel(...)); >> >> >> How to enable local mesh? >> >> We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. >> >> >> ComputeRange computeRange = new ComputeRange( >> new ThreadMesh(globalSize, globalSize), >> new ThreadMesh(16, 16)); >> cc.dispatchKernel(computeRange, >> kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) >> ); >> >> >> In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. >> >> >> #### How to check? >> >> >> java @hat/run ffi-opencl matmul 1D >> java @hat/run ffi-opencl matmul 2D >> >> java @hat/run ffi-cuda matmul 1D >> java @hat/run ffi-cuda matmul 2D > > Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: > > minor change @jjfumero Your change (at version 51efd2c2085b0ee9a17423258615c5872d75c6fc) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/515#issuecomment-3166913943 From duke at openjdk.org Fri Aug 8 09:20:41 2025 From: duke at openjdk.org (Juan Fumero) Date: Fri, 8 Aug 2025 09:20:41 GMT Subject: [code-reflection] RFR: New example suite for code reflection Message-ID: New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. ### How to build? This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: #### 1. Build Babylon JDK We need to use the JDK build that enables the code reflection API (Babylon). git clone https://github.com/openjdk/babylon cd babylon bash configure --with-boot-jdk=${JAVA_HOME} Then, we use the built JDK as `JAVA_HOME` export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ export PATH=$JAVA_HOME/bin:$PATH #### 2. Build the example suite mvn clean package #### 3. Run the examples ##### Run HelloCodeReflection java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection ##### Run MathOptimizer java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer More example to appear in this module. ------------- Commit messages: - minor cleanup - Merge branch 'code-reflection' into cr/examples/suite - trim spaces - [samples] Analysis of parameters simplified - Remove scripts for build and run - New example suite for code reflection Changes: https://git.openjdk.org/babylon/pull/513/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=513&range=00 Stats: 534 lines in 4 files changed: 534 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/513.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/513/head:pull/513 PR: https://git.openjdk.org/babylon/pull/513 From duke at openjdk.org Fri Aug 8 09:42:41 2025 From: duke at openjdk.org (duke) Date: Fri, 8 Aug 2025 09:42:41 GMT Subject: [code-reflection] RFR: New example suite for code reflection In-Reply-To: References: Message-ID: On Wed, 6 Aug 2025 10:39:43 GMT, Juan Fumero wrote: > New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. > > ### How to build? > > This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: > > #### 1. Build Babylon JDK > > We need to use the JDK build that enables the code reflection API (Babylon). > > > git clone https://github.com/openjdk/babylon > cd babylon > bash configure --with-boot-jdk=${JAVA_HOME} > > > Then, we use the built JDK as `JAVA_HOME` > > > export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ > export PATH=$JAVA_HOME/bin:$PATH > > > #### 2. Build the example suite > > > mvn clean package > > > #### 3. Run the examples > > ##### Run HelloCodeReflection > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection > > > ##### Run MathOptimizer > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer > > > More example to appear in this module. @jjfumero Your change (at version 49f5ef90f4c2da613332fe84a620a4ea64ec6764) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/513#issuecomment-3167229200 From duke at openjdk.org Fri Aug 8 14:04:40 2025 From: duke at openjdk.org (Juan Fumero) Date: Fri, 8 Aug 2025 14:04:40 GMT Subject: [code-reflection] Withdrawn: [hat] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: References: Message-ID: On Thu, 7 Aug 2025 15:20:29 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new ThreadMesh(size)); > cc.dispatchKernel(computeRange, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new ThreadMesh(size, size)); > cc.dispatchKernel(computeRange, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new ThreadMesh(globalSize, globalSize), > new ThreadMesh(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/babylon/pull/515 From psandoz at openjdk.org Fri Aug 8 14:52:31 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 8 Aug 2025 14:52:31 GMT Subject: [code-reflection] RFR: New example suite for code reflection In-Reply-To: References: Message-ID: On Wed, 6 Aug 2025 10:39:43 GMT, Juan Fumero wrote: > New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. > > ### How to build? > > This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: > > #### 1. Build Babylon JDK > > We need to use the JDK build that enables the code reflection API (Babylon). > > > git clone https://github.com/openjdk/babylon > cd babylon > bash configure --with-boot-jdk=${JAVA_HOME} > > > Then, we use the built JDK as `JAVA_HOME` > > > export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ > export PATH=$JAVA_HOME/bin:$PATH > > > #### 2. Build the example suite > > > mvn clean package > > > #### 3. Run the examples > > ##### Run HelloCodeReflection > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection > > > ##### Run MathOptimizer > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer > > > More example to appear in this module. Looks good just one minor comment inline you could address now or later up to you. In subsequent PRs we could add more examples e.g., taken from say [`TestLocalTransformationsAdaption` ](https://github.com/openjdk/babylon/blob/code-reflection/test/jdk/java/lang/reflect/code/TestLocalTransformationsAdaption.java ) cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java line 87: > 85: > 86: // if pow(x, 2) then substitute for this function > 87: private static double functionMult(double x) { A more complex example to consider later after this PR would be to make these methods reflectable, and then you can inline these methods into the transformed model so `Math.pow` is substituted with direct expressions. cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java line 129: > 127: case JavaOp.InvokeOp invokeOp when whenIsMathPowFunction(invokeOp) -> { > 128: // The idea here is to create a new JavaOp.invoke with the optimization and replace it. > 129: List operands = blockBuilder.context().getValues(op.operands()); Strictly speaking `operands` are the _output_ operands of values in output model we are building. We get them from the _input_ operands, values in the input model. This works because the transformation has already mapped those input values to output values, since it already encountered them (when copying of the func op and its parameters). cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java line 176: > 174: // invoke function. > 175: List newOperandList2 = new ArrayList<>(); > 176: newOperandList2.add(operands.get(0)); You don't need to create list (or a sub list). The `Java.invoke` method is overloaded to accept a var args or a list. In this case we can use the former and just pass `operands.get(0)` directly, or more clearly `operands.getFirst()`. cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java line 260: > 258: > 259: // Inspect a value for a parameter > 260: static boolean inspectParameterRecursive(JavaOp.ConvOp convOp, int valToMatch) { At some point we will get better at pattern matching, we need the language enhancements for pattern matching. In the interim see the experiment in `jdk.incubator.code.analysis.Patterns` and its use [here](https://github.com/openjdk/babylon/blob/code-reflection/test/jdk/java/lang/reflect/code/ad/ExpressionElimination.java#L58). Not suggesting you use it here, just for information which you might find interesting. ------------- Marked as reviewed by psandoz (Lead). PR Review: https://git.openjdk.org/babylon/pull/513#pullrequestreview-3101083514 PR Review Comment: https://git.openjdk.org/babylon/pull/513#discussion_r2263169163 PR Review Comment: https://git.openjdk.org/babylon/pull/513#discussion_r2263177769 PR Review Comment: https://git.openjdk.org/babylon/pull/513#discussion_r2263159978 PR Review Comment: https://git.openjdk.org/babylon/pull/513#discussion_r2263189072 From duke at openjdk.org Fri Aug 8 15:04:36 2025 From: duke at openjdk.org (Juan Fumero) Date: Fri, 8 Aug 2025 15:04:36 GMT Subject: [code-reflection] RFR: New example suite for code reflection In-Reply-To: References: Message-ID: <9a7sPcNuuf9k-hO3BOGpTIYXXfZCps-5n2zO_wSmw4o=.42fd7d08-7e35-4ada-ba95-6be60aa31d64@github.com> On Fri, 8 Aug 2025 14:38:13 GMT, Paul Sandoz wrote: >> New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. >> >> ### How to build? >> >> This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: >> >> #### 1. Build Babylon JDK >> >> We need to use the JDK build that enables the code reflection API (Babylon). >> >> >> git clone https://github.com/openjdk/babylon >> cd babylon >> bash configure --with-boot-jdk=${JAVA_HOME} >> >> >> Then, we use the built JDK as `JAVA_HOME` >> >> >> export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ >> export PATH=$JAVA_HOME/bin:$PATH >> >> >> #### 2. Build the example suite >> >> >> mvn clean package >> >> >> #### 3. Run the examples >> >> ##### Run HelloCodeReflection >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection >> >> >> ##### Run MathOptimizer >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer >> >> >> More example to appear in this module. > > cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java line 87: > >> 85: >> 86: // if pow(x, 2) then substitute for this function >> 87: private static double functionMult(double x) { > > A more complex example to consider later after this PR would be to make these methods reflectable, and then you can inline these methods into the transformed model so `Math.pow` is substituted with direct expressions. This looks a nice follow up example. I will take a look after this PR. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/513#discussion_r2263222271 From mabbay at openjdk.org Fri Aug 8 18:40:43 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 8 Aug 2025 18:40:43 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v4] In-Reply-To: References: Message-ID: > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with three additional commits since the last revision: - Update comment - Comment on the validation of block params and ConstantOp results - Document Quoted.quotedOp ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/659f018f..e75f36f9 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=03 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=02-03 Stats: 29 lines in 1 file changed: 21 ins; 0 del; 8 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From mabbay at openjdk.org Fri Aug 8 19:01:12 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 8 Aug 2025 19:01:12 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v5] In-Reply-To: References: Message-ID: > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Add negative test cases ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/e75f36f9..1781cdb0 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=03-04 Stats: 31 lines in 1 file changed: 31 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From mabbay at openjdk.org Fri Aug 8 19:07:07 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 8 Aug 2025 19:07:07 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v6] In-Reply-To: References: Message-ID: > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Rectify the validation logic ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/1781cdb0..1fcefbcf Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=05 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=04-05 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512 From duke at openjdk.org Mon Aug 11 09:04:47 2025 From: duke at openjdk.org (Juan Fumero) Date: Mon, 11 Aug 2025 09:04:47 GMT Subject: [code-reflection] RFR: New example suite for code reflection [v2] In-Reply-To: References: Message-ID: > New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. > > ### How to build? > > This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: > > #### 1. Build Babylon JDK > > We need to use the JDK build that enables the code reflection API (Babylon). > > > git clone https://github.com/openjdk/babylon > cd babylon > bash configure --with-boot-jdk=${JAVA_HOME} > > > Then, we use the built JDK as `JAVA_HOME` > > > export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ > export PATH=$JAVA_HOME/bin:$PATH > > > #### 2. Build the example suite > > > mvn clean package > > > #### 3. Run the examples > > ##### Run HelloCodeReflection > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection > > > ##### Run MathOptimizer > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer > > > More example to appear in this module. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [samples] Example suite fixed with commets from PR#513 ------------- Changes: - all: https://git.openjdk.org/babylon/pull/513/files - new: https://git.openjdk.org/babylon/pull/513/files/49f5ef90..7ca5d4f8 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=513&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=513&range=00-01 Stats: 7 lines in 1 file changed: 0 ins; 5 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/513.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/513/head:pull/513 PR: https://git.openjdk.org/babylon/pull/513 From duke at openjdk.org Mon Aug 11 09:56:24 2025 From: duke at openjdk.org (Juan Fumero) Date: Mon, 11 Aug 2025 09:56:24 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges Message-ID: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. How to dispatch 1D kernels? ComputeRange range1D = new ComputeRange(new ThreadMesh1D(size)); cc.dispatchKernel(range1D, kc -> myKernel(...)); How to dispatch 2D kernels? ComputeRange range2D = new ComputeRange(new ThreadMesh2D(size, size)); cc.dispatchKernel(range2D, kc -> my2DKernel(...)); How to enable local mesh? We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. ComputeRange computeRange = new ComputeRange( new ThreadMesh2D(globalSize, globalSize), new ThreadMesh2D(16, 16)); cc.dispatchKernel(computeRange, kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) ); In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. #### How to check? java @hat/run ffi-opencl matmul 1D java @hat/run ffi-opencl matmul 2D java @hat/run ffi-cuda matmul 1D java @hat/run ffi-cuda matmul 2D ------------- Commit messages: - [hat] Javadoc for the rest of the ComputeRange Class - [hat] Add threadmesh subtyping to keep consistency accross dimensions between global and local - [hat] ThreadBlock dispatcher enabled for the CUDA backend - [hat][api] Proposal for ComputeRange and ThreadMesh Changes: https://git.openjdk.org/babylon/pull/516/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=516&range=00 Stats: 639 lines in 18 files changed: 507 ins; 97 del; 35 mod Patch: https://git.openjdk.org/babylon/pull/516.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/516/head:pull/516 PR: https://git.openjdk.org/babylon/pull/516 From duke at openjdk.org Mon Aug 11 09:56:24 2025 From: duke at openjdk.org (Juan Fumero) Date: Mon, 11 Aug 2025 09:56:24 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: On Fri, 8 Aug 2025 14:00:23 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new ThreadMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new ThreadMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new ThreadMesh2D(globalSize, globalSize), > new ThreadMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D This PR is ready for review ------------- PR Comment: https://git.openjdk.org/babylon/pull/516#issuecomment-3173999163 From duke at openjdk.org Mon Aug 11 09:56:25 2025 From: duke at openjdk.org (duke) Date: Mon, 11 Aug 2025 09:56:25 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: On Fri, 8 Aug 2025 14:00:23 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new ThreadMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new ThreadMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new ThreadMesh2D(globalSize, globalSize), > new ThreadMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D @jjfumero Your change (at version 6cdb52fffb1fd56fbcd65e86fd8a88ddfe180671) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/516#issuecomment-3174007745 From psandoz at openjdk.org Mon Aug 11 16:02:33 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 11 Aug 2025 16:02:33 GMT Subject: [code-reflection] RFR: New example suite for code reflection [v2] In-Reply-To: References: Message-ID: On Mon, 11 Aug 2025 09:04:47 GMT, Juan Fumero wrote: >> New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. >> >> ### How to build? >> >> This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: >> >> #### 1. Build Babylon JDK >> >> We need to use the JDK build that enables the code reflection API (Babylon). >> >> >> git clone https://github.com/openjdk/babylon >> cd babylon >> bash configure --with-boot-jdk=${JAVA_HOME} >> >> >> Then, we use the built JDK as `JAVA_HOME` >> >> >> export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ >> export PATH=$JAVA_HOME/bin:$PATH >> >> >> #### 2. Build the example suite >> >> >> mvn clean package >> >> >> #### 3. Run the examples >> >> ##### Run HelloCodeReflection >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection >> >> >> ##### Run MathOptimizer >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer >> >> >> More example to appear in this module. > > Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: > > [samples] Example suite fixed with commets from PR#513 Marked as reviewed by psandoz (Lead). ------------- PR Review: https://git.openjdk.org/babylon/pull/513#pullrequestreview-3106572567 From duke at openjdk.org Tue Aug 12 06:49:34 2025 From: duke at openjdk.org (duke) Date: Tue, 12 Aug 2025 06:49:34 GMT Subject: [code-reflection] RFR: New example suite for code reflection [v2] In-Reply-To: References: Message-ID: On Mon, 11 Aug 2025 09:04:47 GMT, Juan Fumero wrote: >> New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. >> >> ### How to build? >> >> This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: >> >> #### 1. Build Babylon JDK >> >> We need to use the JDK build that enables the code reflection API (Babylon). >> >> >> git clone https://github.com/openjdk/babylon >> cd babylon >> bash configure --with-boot-jdk=${JAVA_HOME} >> >> >> Then, we use the built JDK as `JAVA_HOME` >> >> >> export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ >> export PATH=$JAVA_HOME/bin:$PATH >> >> >> #### 2. Build the example suite >> >> >> mvn clean package >> >> >> #### 3. Run the examples >> >> ##### Run HelloCodeReflection >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection >> >> >> ##### Run MathOptimizer >> >> >> java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer >> >> >> More example to appear in this module. > > Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: > > [samples] Example suite fixed with commets from PR#513 @jjfumero Your change (at version 7ca5d4f8dd6c20cbd95e9317ce9f09bfec016c88) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/513#issuecomment-3177927193 From duke at openjdk.org Tue Aug 12 07:25:46 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 07:25:46 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v2] In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D Juan Fumero has updated the pull request incrementally with five additional commits since the last revision: - [hat] BuildCallGraph refactored - [hat] Improve logging for thread-mesh in OpenCL - [hat][cuda] 1D to 3D mesh refactored for the CUDA Backend - [hat] ThreadMesh Buffer composed with iFace to set global and local thread-mesh - [hat][api] ThreadMesh moved to records implementation ------------- Changes: - all: https://git.openjdk.org/babylon/pull/516/files - new: https://git.openjdk.org/babylon/pull/516/files/6cdb52ff..438537da Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=516&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=516&range=00-01 Stats: 654 lines in 22 files changed: 344 ins; 201 del; 109 mod Patch: https://git.openjdk.org/babylon/pull/516.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/516/head:pull/516 PR: https://git.openjdk.org/babylon/pull/516 From duke at openjdk.org Tue Aug 12 07:25:46 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 07:25:46 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: <1CjWbNt7ea_4W8S_BvYb3jLO-U59ArFBxtDmGkho4a4=.366061d5-b077-4a67-a2d2-ab467494b72c@github.com> On Fri, 8 Aug 2025 14:00:23 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D After some meetings, I moved this PR to a draft. Refining the internal interfaces for representing NDRanges. ------------- PR Comment: https://git.openjdk.org/babylon/pull/516#issuecomment-3174586571 From duke at openjdk.org Tue Aug 12 07:25:46 2025 From: duke at openjdk.org (duke) Date: Tue, 12 Aug 2025 07:25:46 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: On Fri, 8 Aug 2025 14:00:23 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D @jjfumero Your change (at version 438537dae41b36504089964c73e8686f4d81bf40) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/516#issuecomment-3178029933 From duke at openjdk.org Tue Aug 12 10:03:41 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 10:03:41 GMT Subject: [code-reflection] RFR: [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions Message-ID: This PR fixes the code generator when passing the `kernelContext` object to new invoke functions within the main compute kernel. Code like this: ```java @CodeReflection public static float compute(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, int size, int j) { float acc = 0; for (int k = 0; k < size; k++) { acc += (matrixA.array(kc.x * size + k) * matrixB.array(k * size + j)); } return acc; } @CodeReflection public static void matrixMultiplyKernel1D(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, @RW F32Array matrixC, int size) { if (kc.x < kc.maxX) { for (int j = 0; j < size; j++) { float acc = compute(kc, matrixA, matrixB, size, j); matrixC.array(kc.x * size + j, acc); } } } Generated the following error when compiling the kernel: UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed buildStatus =failed logLen = 1993 log = program_source:33:5: error: unknown type name 'hat' hat.KernelContext kc, __global F32Array_t* matrixA, __global F32Array_t* matrixB, int size, int j ^ This is due to the wrong naming from the `kernelContext` when it gets compiled to OpenCL or CUDA. This PR patches this by checking the argument type and replacing with the appropriate CUDA/OpenCL struct. ### How to check? HAT=INFO,SHOW_CODE java @hat/run ffi-opencl matmul 1DFC This patch has been tested for both the OpenCL and the CUDA HAT Backends. ------------- Commit messages: - Add todo for checking param types in HAT - [fix][hat] Codegen fixed when passing the kernel context to multple inner function calls Changes: https://git.openjdk.org/babylon/pull/519/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=519&range=00 Stats: 50 lines in 2 files changed: 46 ins; 0 del; 4 mod Patch: https://git.openjdk.org/babylon/pull/519.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/519/head:pull/519 PR: https://git.openjdk.org/babylon/pull/519 From duke at openjdk.org Tue Aug 12 10:03:41 2025 From: duke at openjdk.org (duke) Date: Tue, 12 Aug 2025 10:03:41 GMT Subject: [code-reflection] RFR: [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions In-Reply-To: References: Message-ID: On Tue, 12 Aug 2025 09:56:00 GMT, Juan Fumero wrote: > This PR fixes the code generator when passing the `kernelContext` object to new invoke functions within the main compute kernel. > > Code like this: > ```java > @CodeReflection > public static float compute(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, int size, int j) { > float acc = 0; > for (int k = 0; k < size; k++) { > acc += (matrixA.array(kc.x * size + k) * matrixB.array(k * size + j)); > } > return acc; > } > > @CodeReflection > public static void matrixMultiplyKernel1D(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, @RW F32Array matrixC, int size) { > if (kc.x < kc.maxX) { > for (int j = 0; j < size; j++) { > float acc = compute(kc, matrixA, matrixB, size, j); > matrixC.array(kc.x * size + j, acc); > } > } > } > > > Generated the following error when compiling the kernel: > > > UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed > buildStatus =failed > logLen = 1993 log = program_source:33:5: error: unknown type name 'hat' > hat.KernelContext kc, __global F32Array_t* matrixA, __global F32Array_t* matrixB, int size, int j > ^ > > > This is due to the wrong naming from the `kernelContext` when it gets compiled to OpenCL or CUDA. > This PR patches this by checking the argument type and replacing with the appropriate CUDA/OpenCL struct. > > ### How to check? > > > HAT=INFO,SHOW_CODE java @hat/run ffi-opencl matmul 1DFC > > > This patch has been tested for both the OpenCL and the CUDA HAT Backends. @jjfumero Your change (at version ea9a7bf815001a618fa742a7dfe10c876b83885c) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/519#issuecomment-3178657528 From gfrost at openjdk.org Tue Aug 12 10:31:36 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 12 Aug 2025 10:31:36 GMT Subject: [code-reflection] Integrated: HAT remove trailing eol ws from pom.xml files Message-ID: Extended sanity check to include pom.xml files which detected trailing eol ws in pom files ------------- Commit messages: - Removed trailing eol ws from pom.xml files - ModuleOp support for HAT CallGraph Changes: https://git.openjdk.org/babylon/pull/520/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=520&range=00 Stats: 274 lines in 15 files changed: 151 ins; 30 del; 93 mod Patch: https://git.openjdk.org/babylon/pull/520.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/520/head:pull/520 PR: https://git.openjdk.org/babylon/pull/520 From gfrost at openjdk.org Tue Aug 12 10:31:36 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 12 Aug 2025 10:31:36 GMT Subject: [code-reflection] Integrated: HAT remove trailing eol ws from pom.xml files In-Reply-To: References: Message-ID: On Tue, 12 Aug 2025 10:25:47 GMT, Gary Frost wrote: > Extended sanity check to include pom.xml files which detected trailing eol ws in pom files This pull request has now been integrated. Changeset: 33437b1f Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/33437b1f36c7fbaf7d58dc2f0691dde2b4deec04 Stats: 274 lines in 15 files changed: 151 ins; 30 del; 93 mod HAT remove trailing eol ws from pom.xml files ------------- PR: https://git.openjdk.org/babylon/pull/520 From gfrost at openjdk.org Tue Aug 12 10:31:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 12 Aug 2025 10:31:45 GMT Subject: git: openjdk/babylon: code-reflection: HAT remove trailing eol ws from pom.xml files Message-ID: <5f060f91-b3b7-4d38-839f-71e9c23135d9@openjdk.org> Changeset: 33437b1f Branch: code-reflection Author: Gary Frost Date: 2025-08-12 10:28:57 +0000 URL: https://git.openjdk.org/babylon/commit/33437b1f36c7fbaf7d58dc2f0691dde2b4deec04 HAT remove trailing eol ws from pom.xml files ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaBackend.java ! hat/backends/ffi/mock/src/main/java/hat/backend/ffi/MockBackend.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/callgraph/CallGraph.java ! hat/core/src/main/java/hat/callgraph/ComputeCallGraph.java ! hat/core/src/main/java/hat/callgraph/KernelCallGraph.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/optools/ModuleOpWrapper.java ! hat/hat/Script.java ! hat/hat/run.java ! hat/wraps/cuda/pom.xml ! hat/wraps/opencl/pom.xml ! hat/wraps/opengl/pom.xml ! hat/wraps/pom.xml ! hat/wraps/shared/pom.xml From gfrost at openjdk.org Tue Aug 12 10:49:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 12 Aug 2025 10:49:45 GMT Subject: git: openjdk/babylon: code-reflection: [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions Message-ID: Changeset: b9b8906c Branch: code-reflection Author: Juan Fumero Committer: Gary Frost Date: 2025-08-12 10:47:25 +0000 URL: https://git.openjdk.org/babylon/commit/b9b8906cdd8f4d53ac8e34331a983d31070c6300 [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/examples/matmul/src/main/java/matmul/Main.java From duke at openjdk.org Tue Aug 12 10:50:26 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 10:50:26 GMT Subject: [code-reflection] Integrated: [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions In-Reply-To: References: Message-ID: On Tue, 12 Aug 2025 09:56:00 GMT, Juan Fumero wrote: > This PR fixes the code generator when passing the `kernelContext` object to new invoke functions within the main compute kernel. > > Code like this: > ```java > @CodeReflection > public static float compute(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, int size, int j) { > float acc = 0; > for (int k = 0; k < size; k++) { > acc += (matrixA.array(kc.x * size + k) * matrixB.array(k * size + j)); > } > return acc; > } > > @CodeReflection > public static void matrixMultiplyKernel1D(@RO KernelContext kc, @RO F32Array matrixA, @RO F32Array matrixB, @RW F32Array matrixC, int size) { > if (kc.x < kc.maxX) { > for (int j = 0; j < size; j++) { > float acc = compute(kc, matrixA, matrixB, size, j); > matrixC.array(kc.x * size + j, acc); > } > } > } > > > Generated the following error when compiling the kernel: > > > UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed > buildStatus =failed > logLen = 1993 log = program_source:33:5: error: unknown type name 'hat' > hat.KernelContext kc, __global F32Array_t* matrixA, __global F32Array_t* matrixB, int size, int j > ^ > > > This is due to the wrong naming from the `kernelContext` when it gets compiled to OpenCL or CUDA. > This PR patches this by checking the argument type and replacing with the appropriate CUDA/OpenCL struct. > > ### How to check? > > > HAT=INFO,SHOW_CODE java @hat/run ffi-opencl matmul 1DFC > > > This patch has been tested for both the OpenCL and the CUDA HAT Backends. This pull request has now been integrated. Changeset: b9b8906c Author: Juan Fumero Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/b9b8906cdd8f4d53ac8e34331a983d31070c6300 Stats: 50 lines in 2 files changed: 46 ins; 0 del; 4 mod [fix][hat] Codegen fixed when passing the kernel context to multiple invoke functions ------------- PR: https://git.openjdk.org/babylon/pull/519 From duke at openjdk.org Tue Aug 12 15:00:13 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 15:00:13 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v3] In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits: - Merge branch 'code-reflection' into hat/api/computerange - [hat] BuildCallGraph refactored - [hat] Improve logging for thread-mesh in OpenCL - [hat][cuda] 1D to 3D mesh refactored for the CUDA Backend - [hat] ThreadMesh Buffer composed with iFace to set global and local thread-mesh - [hat][api] ThreadMesh moved to records implementation - [hat] Javadoc for the rest of the ComputeRange Class - [hat] Add threadmesh subtyping to keep consistency accross dimensions between global and local - [hat] ThreadBlock dispatcher enabled for the CUDA backend - [hat][api] Proposal for ComputeRange and ThreadMesh ------------- Changes: https://git.openjdk.org/babylon/pull/516/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=516&range=02 Stats: 851 lines in 23 files changed: 709 ins; 91 del; 51 mod Patch: https://git.openjdk.org/babylon/pull/516.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/516/head:pull/516 PR: https://git.openjdk.org/babylon/pull/516 From psandoz at openjdk.org Tue Aug 12 15:29:03 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 12 Aug 2025 15:29:03 GMT Subject: git: openjdk/babylon: code-reflection: New example suite for code reflection Message-ID: <5ee7d4db-28fc-4f49-89e6-2fb381131372@openjdk.org> Changeset: 72e696eb Branch: code-reflection Author: Juan Fumero Committer: Paul Sandoz Date: 2025-08-12 15:26:14 +0000 URL: https://git.openjdk.org/babylon/commit/72e696ebc33c15044df961c088188f745aeb76b4 New example suite for code reflection Reviewed-by: psandoz + cr-examples/samples/README.md + cr-examples/samples/pom.xml + cr-examples/samples/src/main/java/oracle/code/samples/HelloCodeReflection.java + cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java From duke at openjdk.org Tue Aug 12 15:30:45 2025 From: duke at openjdk.org (Juan Fumero) Date: Tue, 12 Aug 2025 15:30:45 GMT Subject: [code-reflection] Integrated: New example suite for code reflection In-Reply-To: References: Message-ID: On Wed, 6 Aug 2025 10:39:43 GMT, Juan Fumero wrote: > New example suite for code reflection. It includes two programs that illustrate different functionality of the code reflection API. > > ### How to build? > > This module is built using the code-reflection fork of OpenJDK. Then, update the `JAVA_HOME` to point to the code-reflection port, and compile with maven. In detail: > > #### 1. Build Babylon JDK > > We need to use the JDK build that enables the code reflection API (Babylon). > > > git clone https://github.com/openjdk/babylon > cd babylon > bash configure --with-boot-jdk=${JAVA_HOME} > > > Then, we use the built JDK as `JAVA_HOME` > > > export JAVA_HOME=/$HOME/repos/babylon/build/macosx-aarch64-server-release/jdk/ > export PATH=$JAVA_HOME/bin:$PATH > > > #### 2. Build the example suite > > > mvn clean package > > > #### 3. Run the examples > > ##### Run HelloCodeReflection > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.HelloCodeReflection > > > ##### Run MathOptimizer > > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizer > > > More example to appear in this module. This pull request has now been integrated. Changeset: 72e696eb Author: Juan Fumero Committer: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/72e696ebc33c15044df961c088188f745aeb76b4 Stats: 529 lines in 4 files changed: 529 ins; 0 del; 0 mod New example suite for code reflection Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/513 From duke at openjdk.org Tue Aug 12 17:06:11 2025 From: duke at openjdk.org (Ruby Chen) Date: Tue, 12 Aug 2025 17:06:11 GMT Subject: [code-reflection] RFR: Minor logging changes for HAT ModuleOp support Message-ID: Add more descriptive logs for ModuleOp backend in HAT. To use the ModuleOp backend, pass `moduleOp` as an arg to the `hat/run.java` script when running a HAT example. For example, running the `mandel` example with the `ffi-opencl` backend and `moduleOp` enabled can be done with java @hat/run moduleOp ffi-opencl squares Adding `moduleOp` sets `-DmoduleOp=true` and passes it to the backend, which uses the flag to choose between the original `CallGraph` implementation and the new `moduleOp` implementation. `ModuleOpWrapper` now contains `createTransitiveInvokeModule()`, which creates a `ModuleOp` representing a call graph when given an entrypoint. This method is called in `KernelCallGraph` and `ComputeCallGraph` to generate their respective call graphs. The kernel and compute call graph classes also maintain a map of buffer accesses, along with structures storing other useful methods. The `C99FFIBackend`, `CudaBackend`, `MockBackend`, and `C99HATKernelBuilder` access call graphs structures differently depending on the `moduleOp` flag. ------------- Commit messages: - Fix naming for ModuleOp stdout logs - Add error messages and output mode to stdout Changes: https://git.openjdk.org/babylon/pull/521/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=521&range=00 Stats: 13 lines in 5 files changed: 10 ins; 0 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/521.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/521/head:pull/521 PR: https://git.openjdk.org/babylon/pull/521 From duke at openjdk.org Tue Aug 12 17:06:11 2025 From: duke at openjdk.org (duke) Date: Tue, 12 Aug 2025 17:06:11 GMT Subject: [code-reflection] RFR: Minor logging changes for HAT ModuleOp support In-Reply-To: References: Message-ID: On Tue, 12 Aug 2025 16:57:25 GMT, Ruby Chen wrote: > Add more descriptive logs for ModuleOp backend in HAT. > > To use the ModuleOp backend, pass `moduleOp` as an arg to the `hat/run.java` script when running a HAT example. For example, running the `mandel` example with the `ffi-opencl` backend and `moduleOp` enabled can be done with > > java @hat/run moduleOp ffi-opencl squares > > Adding `moduleOp` sets `-DmoduleOp=true` and passes it to the backend, which uses the flag to choose between the original `CallGraph` implementation and the new `moduleOp` implementation. > > `ModuleOpWrapper` now contains `createTransitiveInvokeModule()`, which creates a `ModuleOp` representing a call graph when given an entrypoint. This method is called in `KernelCallGraph` and `ComputeCallGraph` to generate their respective call graphs. The kernel and compute call graph classes also maintain a map of buffer accesses, along with structures storing other useful methods. > > The `C99FFIBackend`, `CudaBackend`, `MockBackend`, and `C99HATKernelBuilder` access call graphs structures differently depending on the `moduleOp` flag. @rbrchen Your change (at version 07b1939532d4077c17d5a87fa3ea01e1bf3cb6fb) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/521#issuecomment-3180233871 From gfrost at openjdk.org Wed Aug 13 07:55:34 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 07:55:34 GMT Subject: git: openjdk/babylon: code-reflection: Minor logging changes for HAT ModuleOp support Message-ID: <3270b08f-01f9-4ed9-993f-f3ef9b46bb34@openjdk.org> Changeset: ae9adb6f Branch: code-reflection Author: Ruby Chen Committer: Gary Frost Date: 2025-08-13 07:54:23 +0000 URL: https://git.openjdk.org/babylon/commit/ae9adb6f1c2be8d54a2d7a4dc3ee6d5e3352dac1 Minor logging changes for HAT ModuleOp support ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaBackend.java ! hat/backends/ffi/mock/src/main/java/hat/backend/ffi/MockBackend.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/optools/ModuleOpWrapper.java ! hat/hat/run.java From duke at openjdk.org Wed Aug 13 07:57:27 2025 From: duke at openjdk.org (Ruby Chen) Date: Wed, 13 Aug 2025 07:57:27 GMT Subject: [code-reflection] Integrated: Minor logging changes for HAT ModuleOp support In-Reply-To: References: Message-ID: On Tue, 12 Aug 2025 16:57:25 GMT, Ruby Chen wrote: > Add more descriptive logs for ModuleOp backend in HAT. > > To use the ModuleOp backend, pass `moduleOp` as an arg to the `hat/run.java` script when running a HAT example. For example, running the `mandel` example with the `ffi-opencl` backend and `moduleOp` enabled can be done with > > java @hat/run moduleOp ffi-opencl squares > > Adding `moduleOp` sets `-DmoduleOp=true` and passes it to the backend, which uses the flag to choose between the original `CallGraph` implementation and the new `moduleOp` implementation. > > `ModuleOpWrapper` now contains `createTransitiveInvokeModule()`, which creates a `ModuleOp` representing a call graph when given an entrypoint. This method is called in `KernelCallGraph` and `ComputeCallGraph` to generate their respective call graphs. The kernel and compute call graph classes also maintain a map of buffer accesses, along with structures storing other useful methods. > > The `C99FFIBackend`, `CudaBackend`, `MockBackend`, and `C99HATKernelBuilder` access call graphs structures differently depending on the `moduleOp` flag. This pull request has now been integrated. Changeset: ae9adb6f Author: Ruby Chen Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/ae9adb6f1c2be8d54a2d7a4dc3ee6d5e3352dac1 Stats: 13 lines in 5 files changed: 10 ins; 0 del; 3 mod Minor logging changes for HAT ModuleOp support ------------- PR: https://git.openjdk.org/babylon/pull/521 From gfrost at openjdk.org Wed Aug 13 15:31:05 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 15:31:05 GMT Subject: git: openjdk/babylon: code-reflection: Added an experiment to investigate Quoted Constant Args Message-ID: <3db92ce4-2235-4ca8-9ff8-8cf18c6bf412@openjdk.org> Changeset: 6c598848 Branch: code-reflection Author: Gary Frost Date: 2025-08-13 15:28:43 +0000 URL: https://git.openjdk.org/babylon/commit/6c598848fb15490c0a01368fed6f66845d93c888 Added an experiment to investigate Quoted Constant Args + hat/examples/experiments/src/main/java/experiments/QuotedConstantArgs.java From gfrost at openjdk.org Wed Aug 13 15:32:21 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 15:32:21 GMT Subject: [code-reflection] Integrated: Added an experiment to investigate Quoted Constant Args Message-ID: An experiment to investigate issue observed passing constants as Quoted args After building you should be able to run (using opencl backend) with java --enable-preview --enable-native-access=ALL-UNNAMED --add-exports=jdk.incubator.code/jdk.incubator.code.dialect.java.impl=ALL-UNNAMED --class-path /Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-core-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-backend-ffi-shared-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-backend-ffi-opencl-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-example-experiments-1.0.jar -Djava.library.path=/Users/grfrost/github/babylon-grfrost-fork/hat/build -DmoduleOp=true experiments.QuotedConstantArgs ------------- Commit messages: - Added an experiment to investigate Quoted Constant Args Changes: https://git.openjdk.org/babylon/pull/522/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=522&range=00 Stats: 63 lines in 1 file changed: 63 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/522.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/522/head:pull/522 PR: https://git.openjdk.org/babylon/pull/522 From gfrost at openjdk.org Wed Aug 13 15:32:22 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 15:32:22 GMT Subject: [code-reflection] Integrated: Added an experiment to investigate Quoted Constant Args In-Reply-To: References: Message-ID: On Wed, 13 Aug 2025 15:25:40 GMT, Gary Frost wrote: > An experiment to investigate issue observed passing constants as Quoted args > > After building you should be able to run (using opencl backend) with > > > java --enable-preview --enable-native-access=ALL-UNNAMED --add-exports=jdk.incubator.code/jdk.incubator.code.dialect.java.impl=ALL-UNNAMED --class-path /Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-core-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-backend-ffi-shared-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-backend-ffi-opencl-1.0.jar:/Users/grfrost/github/babylon-grfrost-fork/hat/build/hat-example-experiments-1.0.jar -Djava.library.path=/Users/grfrost/github/babylon-grfrost-fork/hat/build -DmoduleOp=true experiments.QuotedConstantArgs This pull request has now been integrated. Changeset: 6c598848 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/6c598848fb15490c0a01368fed6f66845d93c888 Stats: 63 lines in 1 file changed: 63 ins; 0 del; 0 mod Added an experiment to investigate Quoted Constant Args ------------- PR: https://git.openjdk.org/babylon/pull/522 From gfrost at openjdk.org Wed Aug 13 17:01:33 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 17:01:33 GMT Subject: git: openjdk/babylon: code-reflection: Added more quoted experiments Message-ID: <2ef2ed8f-2ba5-4b4f-9e3d-ca70e8d7a165@openjdk.org> Changeset: 700e5ee3 Branch: code-reflection Author: Gary Frost Date: 2025-08-13 16:58:48 +0000 URL: https://git.openjdk.org/babylon/commit/700e5ee3957a251e926ae29675944fbfe671fda0 Added more quoted experiments + hat/examples/experiments/src/main/java/experiments/QuotedArrayArg.java ! hat/examples/experiments/src/main/java/experiments/QuotedConstantArgs.java From gfrost at openjdk.org Wed Aug 13 17:02:47 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 17:02:47 GMT Subject: [code-reflection] Integrated: Added more quoted experiments Message-ID: Added a couple more quoted experiments This time added QuotedArrayArg ------------- Commit messages: - Added more quoted experiments Changes: https://git.openjdk.org/babylon/pull/523/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=523&range=00 Stats: 76 lines in 2 files changed: 74 ins; 0 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/523.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/523/head:pull/523 PR: https://git.openjdk.org/babylon/pull/523 From gfrost at openjdk.org Wed Aug 13 17:02:47 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 13 Aug 2025 17:02:47 GMT Subject: [code-reflection] Integrated: Added more quoted experiments In-Reply-To: References: Message-ID: On Wed, 13 Aug 2025 16:54:58 GMT, Gary Frost wrote: > Added a couple more quoted experiments > > This time added QuotedArrayArg This pull request has now been integrated. Changeset: 700e5ee3 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/700e5ee3957a251e926ae29675944fbfe671fda0 Stats: 76 lines in 2 files changed: 74 ins; 0 del; 2 mod Added more quoted experiments ------------- PR: https://git.openjdk.org/babylon/pull/523 From psandoz at openjdk.org Wed Aug 13 22:37:35 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 13 Aug 2025 22:37:35 GMT Subject: [code-reflection] RFR: Fix interpreter arg checking Message-ID: A prior update to the interpreter to check its arguments caused some test failures. This is a quick fix to ensure test pass while still ensuring most checks are still in place 1. ensure run time representation of variables (Var) are supported. 2. allow for primitive conversions, which for now i punt on and just let them through, as the check needs more thought. 3. accept null for any argument, refine later for primitive values. ------------- Commit messages: - Fix interpreter arg checking. Changes: https://git.openjdk.org/babylon/pull/524/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=524&range=00 Stats: 9 lines in 2 files changed: 4 ins; 3 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/524.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/524/head:pull/524 PR: https://git.openjdk.org/babylon/pull/524 From psandoz at openjdk.org Wed Aug 13 22:48:30 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 13 Aug 2025 22:48:30 GMT Subject: [code-reflection] Integrated: Fix interpreter arg checking In-Reply-To: References: Message-ID: On Wed, 13 Aug 2025 22:30:44 GMT, Paul Sandoz wrote: > A prior update to the interpreter to check its arguments caused some test failures. This is a quick fix to ensure test pass while still ensuring most checks are still in place > 1. ensure run time representation of variables (Var) are supported. > 2. allow for primitive conversions, which for now i punt on and just let them through, as the check needs more thought. > 3. accept null for any argument, refine later for primitive values. This pull request has now been integrated. Changeset: c5102d7e Author: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/c5102d7e1e7e688cb6aa34f5e474d8c0d989c141 Stats: 9 lines in 2 files changed: 4 ins; 3 del; 2 mod Fix interpreter arg checking ------------- PR: https://git.openjdk.org/babylon/pull/524 From psandoz at openjdk.org Wed Aug 13 22:48:54 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 13 Aug 2025 22:48:54 GMT Subject: git: openjdk/babylon: code-reflection: Fix interpreter arg checking Message-ID: <632dc8af-15c3-45cc-a8bd-f8e62944de6c@openjdk.org> Changeset: c5102d7e Branch: code-reflection Author: Paul Sandoz Date: 2025-08-13 22:45:12 +0000 URL: https://git.openjdk.org/babylon/commit/c5102d7e1e7e688cb6aa34f5e474d8c0d989c141 Fix interpreter arg checking ! src/jdk.incubator.code/share/classes/jdk/incubator/code/interpreter/Interpreter.java ! test/jdk/java/lang/reflect/code/interpreter/TestArgsTypesValidationWhenInterpreting.java From duke at openjdk.org Thu Aug 14 07:18:17 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 14 Aug 2025 07:18:17 GMT Subject: [code-reflection] RFR: Expand the example suite with Inlining and Bytecode generation Message-ID: This PR extends the sample suite for learning code reflection. It adds a couple of examples to learn how to apply inlining. 1. Inline values 2. Inline new code-reflected methods after code transformations. In addition, it expands the examples to generate Java bytecode from code models. All examples have been documented. #### How to compile and run export JAVA_HOME= mvn clean package java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.InlineExample java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizerWithInlining ------------- Commit messages: - [samples] documentation added - [samples] Documentation added - Javadoc for new examples - Add missing examples - [samples] Two new examples to show how to inline Changes: https://git.openjdk.org/babylon/pull/525/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=525&range=00 Stats: 486 lines in 5 files changed: 475 ins; 0 del; 11 mod Patch: https://git.openjdk.org/babylon/pull/525.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/525/head:pull/525 PR: https://git.openjdk.org/babylon/pull/525 From duke at openjdk.org Thu Aug 14 08:36:24 2025 From: duke at openjdk.org (duke) Date: Thu, 14 Aug 2025 08:36:24 GMT Subject: [code-reflection] RFR: Expand the example suite with Inlining and Bytecode generation In-Reply-To: References: Message-ID: On Thu, 14 Aug 2025 07:11:14 GMT, Juan Fumero wrote: > This PR extends the sample suite for learning code reflection. It adds a couple of examples to learn how to apply inlining. > 1. Inline values > 2. Inline new code-reflected methods after code transformations. > > In addition, it expands the examples to generate Java bytecode from code models. > > All examples have been documented. > > #### How to compile and run > > > export JAVA_HOME= > mvn clean package > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.InlineExample > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizerWithInlining @jjfumero Your change (at version fcfca2a269e73b87a7e8492bd103d490dbbfbc1f) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/525#issuecomment-3187486440 From duke at openjdk.org Thu Aug 14 08:38:41 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 14 Aug 2025 08:38:41 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v4] In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 11 commits: - Merge branch 'code-reflection' into hat/api/computerange - Merge branch 'code-reflection' into hat/api/computerange - [hat] BuildCallGraph refactored - [hat] Improve logging for thread-mesh in OpenCL - [hat][cuda] 1D to 3D mesh refactored for the CUDA Backend - [hat] ThreadMesh Buffer composed with iFace to set global and local thread-mesh - [hat][api] ThreadMesh moved to records implementation - [hat] Javadoc for the rest of the ComputeRange Class - [hat] Add threadmesh subtyping to keep consistency accross dimensions between global and local - [hat] ThreadBlock dispatcher enabled for the CUDA backend - ... and 1 more: https://git.openjdk.org/babylon/compare/c5102d7e...31bee39b ------------- Changes: https://git.openjdk.org/babylon/pull/516/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=516&range=03 Stats: 851 lines in 23 files changed: 709 ins; 91 del; 51 mod Patch: https://git.openjdk.org/babylon/pull/516.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/516/head:pull/516 PR: https://git.openjdk.org/babylon/pull/516 From duke at openjdk.org Thu Aug 14 08:49:30 2025 From: duke at openjdk.org (duke) Date: Thu, 14 Aug 2025 08:49:30 GMT Subject: [code-reflection] RFR: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v4] In-Reply-To: References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: On Thu, 14 Aug 2025 08:38:41 GMT, Juan Fumero wrote: >> This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. >> A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. >> >> Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. >> >> How to dispatch 1D kernels? >> >> >> ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); >> cc.dispatchKernel(range1D, >> kc -> myKernel(...)); >> >> >> How to dispatch 2D kernels? >> >> >> ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); >> cc.dispatchKernel(range2D, >> kc -> my2DKernel(...)); >> >> >> How to enable local mesh? >> >> We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. >> >> >> ComputeRange computeRange = new ComputeRange( >> new GlobalMesh2D(globalSize, globalSize), >> new LocalMesh2D(16, 16)); >> cc.dispatchKernel(computeRange, >> kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) >> ); >> >> >> In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. >> >> >> #### How to check? >> >> >> java @hat/run ffi-opencl matmul 1D >> java @hat/run ffi-opencl matmul 2D >> >> java @hat/run ffi-cuda matmul 1D >> java @hat/run ffi-cuda matmul 2D > > Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 11 commits: > > - Merge branch 'code-reflection' into hat/api/computerange > - Merge branch 'code-reflection' into hat/api/computerange > - [hat] BuildCallGraph refactored > - [hat] Improve logging for thread-mesh in OpenCL > - [hat][cuda] 1D to 3D mesh refactored for the CUDA Backend > - [hat] ThreadMesh Buffer composed with iFace to set global and local thread-mesh > - [hat][api] ThreadMesh moved to records implementation > - [hat] Javadoc for the rest of the ComputeRange Class > - [hat] Add threadmesh subtyping to keep consistency accross dimensions between global and local > - [hat] ThreadBlock dispatcher enabled for the CUDA backend > - ... and 1 more: https://git.openjdk.org/babylon/compare/c5102d7e...31bee39b @jjfumero Your change (at version 31bee39b5c4a355cfec341d479ec007871af69ea) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/516#issuecomment-3187524303 From gfrost at openjdk.org Thu Aug 14 11:05:37 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 14 Aug 2025 11:05:37 GMT Subject: git: openjdk/babylon: code-reflection: Expand the example suite with Inlining and Bytecode generation Message-ID: Changeset: 19daae13 Branch: code-reflection Author: Juan Fumero Committer: Gary Frost Date: 2025-08-14 11:04:42 +0000 URL: https://git.openjdk.org/babylon/commit/19daae133c6fc99c31a02a276cc11fdf2a8a099a Expand the example suite with Inlining and Bytecode generation ! cr-examples/samples/README.md ! cr-examples/samples/src/main/java/oracle/code/samples/HelloCodeReflection.java + cr-examples/samples/src/main/java/oracle/code/samples/InlineExample.java ! cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java + cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizerWithInlining.java From duke at openjdk.org Thu Aug 14 11:08:38 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 14 Aug 2025 11:08:38 GMT Subject: [code-reflection] Integrated: Expand the example suite with Inlining and Bytecode generation In-Reply-To: References: Message-ID: On Thu, 14 Aug 2025 07:11:14 GMT, Juan Fumero wrote: > This PR extends the sample suite for learning code reflection. It adds a couple of examples to learn how to apply inlining. > 1. Inline values > 2. Inline new code-reflected methods after code transformations. > > In addition, it expands the examples to generate Java bytecode from code models. > > All examples have been documented. > > #### How to compile and run > > > export JAVA_HOME= > mvn clean package > > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.InlineExample > java --enable-preview -cp target/crsamples-1.0-SNAPSHOT.jar oracle.code.samples.MathOptimizerWithInlining This pull request has now been integrated. Changeset: 19daae13 Author: Juan Fumero Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/19daae133c6fc99c31a02a276cc11fdf2a8a099a Stats: 486 lines in 5 files changed: 475 ins; 0 del; 11 mod Expand the example suite with Inlining and Bytecode generation ------------- PR: https://git.openjdk.org/babylon/pull/525 From gfrost at openjdk.org Thu Aug 14 11:09:56 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 14 Aug 2025 11:09:56 GMT Subject: git: openjdk/babylon: code-reflection: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges Message-ID: <59ef7dac-dc68-476f-b87f-33abeefc72f2@openjdk.org> Changeset: 92df1be6 Branch: code-reflection Author: Juan Fumero Committer: Gary Frost Date: 2025-08-14 11:07:48 +0000 URL: https://git.openjdk.org/babylon/commit/92df1be61c8ef32f3ea2ac64c33b340b19737ec6 [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges ! hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend_queue.cpp ! hat/backends/ffi/mock/src/main/native/cpp/mock_backend.cpp ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLBackend.java ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_queue.cpp ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/backends/ffi/shared/src/main/native/cpp/shared.cpp ! hat/backends/ffi/shared/src/main/native/include/shared.h ! hat/backends/jextracted/shared/src/main/java/hat/backend/jextracted/C99JExtractedBackend.java ! hat/core/src/main/java/hat/Accelerator.java ! hat/core/src/main/java/hat/ComputeContext.java + hat/core/src/main/java/hat/ComputeRange.java + hat/core/src/main/java/hat/GlobalMesh1D.java + hat/core/src/main/java/hat/GlobalMesh2D.java + hat/core/src/main/java/hat/GlobalMesh3D.java ! hat/core/src/main/java/hat/KernelContext.java + hat/core/src/main/java/hat/LocalMesh1D.java + hat/core/src/main/java/hat/LocalMesh2D.java + hat/core/src/main/java/hat/LocalMesh3D.java + hat/core/src/main/java/hat/ThreadMesh.java + hat/core/src/main/java/hat/buffer/KernelBufferContext.java - hat/core/src/main/java/hat/buffer/KernelContext.java ! hat/core/src/main/java/hat/optools/InvokeOpWrapper.java ! hat/examples/matmul/src/main/java/matmul/Main.java From duke at openjdk.org Thu Aug 14 11:11:32 2025 From: duke at openjdk.org (Juan Fumero) Date: Thu, 14 Aug 2025 11:11:32 GMT Subject: [code-reflection] Integrated: [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges In-Reply-To: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> References: <-lCItgPVgLRL31tktliCjAtnmxwxPiVxeFgd4_w1jXk=.4ed5ebab-e449-4334-b90f-3ee721874c1e@github.com> Message-ID: <_BXIbNZ7IPd0OIvP6eiyE8_2AnQwNh-9gSyxYWftaGs=.5327ffdb-034d-4dd9-a3f6-ba59914f0eaa@github.com> On Fri, 8 Aug 2025 14:00:23 GMT, Juan Fumero wrote: > This PR proposes an extension of the HAT API to leverage 1D, 2D and 3D ranges for the compute context dispatch. > A `ComputeRange` is an entity that holds global and local thread mesh. In the future, we can add offsets to it. > > Each `ThreadMesh` is a triplet representing the number of threads for x,y, and z dimensions. > > How to dispatch 1D kernels? > > > ComputeRange range1D = new ComputeRange(new GlobalMesh1D(size)); > cc.dispatchKernel(range1D, > kc -> myKernel(...)); > > > How to dispatch 2D kernels? > > > ComputeRange range2D = new ComputeRange(new GlobalMesh2D(size, size)); > cc.dispatchKernel(range2D, > kc -> my2DKernel(...)); > > > How to enable local mesh? > > We pass a second parameter to the ComputeRange constructor to define local mesh. If it is not passed, then it is `null` and the HAT runtime can select a default set of values. > > > ComputeRange computeRange = new ComputeRange( > new GlobalMesh2D(globalSize, globalSize), > new LocalMesh2D(16, 16)); > cc.dispatchKernel(computeRange, > kc -> matrixMultiplyKernel2D(kc, matrixA, matrixB, matrixC, globalSize) > ); > > > In addition, this PR renames the `KernelContext` internal API to map the context ndrange object to native memory to `KernelBufferContext`. > > > #### How to check? > > > java @hat/run ffi-opencl matmul 1D > java @hat/run ffi-opencl matmul 2D > > java @hat/run ffi-cuda matmul 1D > java @hat/run ffi-cuda matmul 2D This pull request has now been integrated. Changeset: 92df1be6 Author: Juan Fumero Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/92df1be61c8ef32f3ea2ac64c33b340b19737ec6 Stats: 851 lines in 23 files changed: 709 ins; 91 del; 51 mod [hat][proposal] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges ------------- PR: https://git.openjdk.org/babylon/pull/516 From gfrost at openjdk.org Sun Aug 17 12:41:32 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 17 Aug 2025 12:41:32 GMT Subject: git: openjdk/babylon: code-reflection: Use existing code for creating KernelContext_s from its iface buffer schema Message-ID: Changeset: bb4f7ff8 Branch: code-reflection Author: Gary Frost Date: 2025-08-17 12:38:47 +0000 URL: https://git.openjdk.org/babylon/commit/bb4f7ff8f94590f4e019a9c28c354e461ad91821 Use existing code for creating KernelContext_s from its iface buffer schema ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilderWithContext.java From gfrost at openjdk.org Sun Aug 17 12:42:12 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 17 Aug 2025 12:42:12 GMT Subject: [code-reflection] Integrated: Use existing code for creating KernelContext_s from its iface buffer schema Message-ID: Previously we had custom code for creating KernelContext_s C99 code. We already had code which could create typedefed structs from iface schemas. Now KernelContext is an iface mapped buffer we can use this same code. This stops us from having tto manually ensure that the class and generated C99 code were in sync. ------------- Commit messages: - Use existing code for creating KernelContext_s from its iface buffer schema Changes: https://git.openjdk.org/babylon/pull/526/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=526&range=00 Stats: 50 lines in 2 files changed: 10 ins; 21 del; 19 mod Patch: https://git.openjdk.org/babylon/pull/526.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/526/head:pull/526 PR: https://git.openjdk.org/babylon/pull/526 From gfrost at openjdk.org Sun Aug 17 12:42:12 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 17 Aug 2025 12:42:12 GMT Subject: [code-reflection] Integrated: Use existing code for creating KernelContext_s from its iface buffer schema In-Reply-To: References: Message-ID: On Sun, 17 Aug 2025 12:35:29 GMT, Gary Frost wrote: > Previously we had custom code for creating KernelContext_s C99 code. > > We already had code which could create typedefed structs from iface schemas. > > Now KernelContext is an iface mapped buffer we can use this same code. This stops us from having tto manually ensure that the class and generated C99 code were in sync. This pull request has now been integrated. Changeset: bb4f7ff8 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/bb4f7ff8f94590f4e019a9c28c354e461ad91821 Stats: 50 lines in 2 files changed: 10 ins; 21 del; 19 mod Use existing code for creating KernelContext_s from its iface buffer schema ------------- PR: https://git.openjdk.org/babylon/pull/526 From mabbay at openjdk.org Sun Aug 17 17:07:12 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Sun, 17 Aug 2025 17:07:12 GMT Subject: [code-reflection] RFR: Document quoteOp and quotedOp methods [v7] In-Reply-To: References: Message-ID: > Specify the behaviour of quoteOp and quotedOp methods. Mourad Abbay has updated the pull request incrementally with three additional commits since the last revision: - Update Quoted.quoteOp documentation - Correct validation in Quoted constructor - Don't include duplicate operands / captured values when quoting an operation ------------- Changes: - all: https://git.openjdk.org/babylon/pull/512/files - new: https://git.openjdk.org/babylon/pull/512/files/1fcefbcf..34cc6a8f Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=06 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=512&range=05-06 Stats: 176 lines in 2 files changed: 132 ins; 20 del; 24 mod Patch: https://git.openjdk.org/babylon/pull/512.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/512/head:pull/512 PR: https://git.openjdk.org/babylon/pull/512