Libmir Archive

dcompute — GPU Computing for D

dcompute lets you write GPU compute kernels in D that compile to OpenCL and CUDA targets. Archive page — the library is no longer actively maintained.

Archived / dormant

dcompute is no longer actively maintained. Last meaningful activity was 2019–2020. This page is preserved for historical reference. The repository remains public at github.com/libmir/dcompute.

dcompute was an experimental project to enable GPU computing from D, allowing D code to be compiled to OpenCL and CUDA kernels. The goal was to write unified CPU/GPU code in a single D source file.

Concept

// A D kernel that runs on GPU via dcompute
@compute(CompileFor.deviceOnly)
module mykernel;

import dcompute.std;

@kernel void vectorAdd(
    GlobalPointer!(const float) a,
    GlobalPointer!(const float) b,
    GlobalPointer!float c,
    int n,
) {
    auto i = GlobalIndex.x;
    if (i < n) c[i] = a[i] + b[i];
}

The kernel code is compiled with LDC's LLVM backend targeting SPIR (for OpenCL) or PTX (for CUDA), while the host code remains normal D.

Current status

AspectStatus
RepositoryPublic, not archived
Last commit~2020
OpenCL supportPartial
CUDA supportExperimental
LDC integrationRequired, version-locked

Alternatives

For GPU computing in D today, consider:

  • CLOP — older OpenCL DSL for D
  • Direct OpenCL C bindings via cl4d or raw CL/cl.h imports in D
  • CUDA C interop — call CUDA from D using extern(C) bindings
  • mir-algorithm on CPU — for many numerical workloads, vectorized D+Mir is fast enough without GPU

Historical context

dcompute was presented at DConf and showed genuine promise for bringing D's zero-overhead abstractions to GPU programming. The project stalled due to the complexity of maintaining LDC LLVM target support across versions. If you are interested in reviving GPU computing for D, the repository is a reasonable starting point.

GitHub: libmir/dcompute

On this page