[code-reflection] RFR: [hat] ComputeRange and ThreadMesh API for defining 1D, 2D and 3D Ranges [v2]
Juan Fumero
duke at openjdk.org
Thu Aug 7 15:32:58 UTC 2025
> 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
More information about the babylon-dev
mailing list