DCompute Metal Backend
Asadbek
aosindarov at gmail.com
Thu Jul 9 08:26:09 UTC 2026
Hello everyone,
I am creating this thread to share my progress on building a
Metal GPU target for DCompute. Apologies for the delay in sharing
this as promised earlier!
I started working on this back in late April. I have set up basic
compiler support to lower to correct, Apple-compliant LLVM IR
(AIR). Since Apple uses a custom fork of LLVM, getting this to
work involved a fair amount of reverse engineering, but the
baseline is now functional.
Here is the draft PR on LDC:
https://github.com/ldc-developers/ldc/pull/5118
For context, GPU programming splits code into two categories:
device code and host code. Device code is sent to the GPU runtime
and mostly contains shaders. Because DCompute is a compute
library (where compute shaders are called kernels), the device
code that DCompute sends to the GPU contains only kernels.
Host code facilitates execution between the GPU and the CPU. It
handles copying memory buffers to the GPU address space, sending
the device code binary to the GPU, and waiting for the results to
process them (though it does not necessarily need to wait and
block the running thread while waiting). I have also set up a
basic host code implementation.
Here is the PR on DCompute for the host code:
https://github.com/libmir/dcompute/pull/99
Currently, basic kernels can successfully execute on Apple Metal
GPUs. I will continue development and share future updates in
this thread.
Special thanks to Nicholas and Gaofei for their help and
suggestions throughout the development process!
More information about the Digitalmars-d
mailing list