Skip to content

Getting Started

Bogdan edited this page Jun 21, 2026 · 2 revisions

Dependency Setup

dependencies {
    implementation project(':processor')
    annotationProcessor project(':processor')
}

Minimal Kernel

import net.sixik.ga_utils.javatogpu.api.GPU;
import net.sixik.ga_utils.javatogpu.api.anotations.GPUGlobal;

public final class Demo {
    @net.sixik.ga_utils.javatogpu.api.anotations.GPU
    public static void saxpy(@GPUGlobal float[] input, @GPUGlobal float[] output) {
        int id = GPU.get_global_id(0);
        output[id] = GPU.sin(input[id]) + 2.0f;
    }
}

Runtime Backend

import net.sixik.ga_utils.javatogpu.runtime.GpuRuntime;
import net.sixik.ga_utils.javatogpu.runtime.opencl.OpenClGpuRuntimeBackend;

try (OpenClGpuRuntimeBackend backend = new OpenClGpuRuntimeBackend()) {
    GpuRuntime.setBackend(backend);
    Demo.saxpy(input, output);
} finally {
    GpuRuntime.setBackend(GpuRuntime.defaultBackend());
}

What Gets Generated

At build time JavaToGpu generates:

  • OpenCL kernel source
  • a Java launcher with kernel metadata
  • rewritten direct @GPU method bodies

At runtime the generated launcher dispatches through GpuRuntime into the selected backend.

Typical Build Commands

Windows:

./gradlew.bat clean test --console=plain
./gradlew.bat :test-app:run --console=plain

Unix-like systems:

./gradlew clean test --console=plain
./gradlew :test-app:run --console=plain

Next

Clone this wiki locally