Skip to content

Kernel Programming Model

Bogdan edited this page Jun 21, 2026 · 2 revisions

This page describes the supported Java subset for @GPU entry methods.

Supported

  • arithmetic, comparisons, logical operators
  • casts
  • if / else
  • for, while, do-while
  • switch / case
  • compound assignments
  • ++ / --
  • primitive arrays and scalars
  • helper methods via @CCode
  • pointer wrappers
  • vector wrappers
  • @GPUStruct
  • atomics
  • local memory helpers
  • images and samplers
  • OpenCL attributes
  • OpenCL address spaces

Typical Kernel Shape

@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;
}

Supported Control Flow

  • if
  • if / else
  • for
  • while
  • do-while
  • switch / case
  • break
  • continue
  • compound assignments and ++ / --

Kernel Entry Rules

  • @GPU entry methods should be static
  • current entry-point support is void only
  • array and scalar parameters are the normal calling convention
  • supported wrappers such as pointers, vectors, structs, images, and samplers can also participate where explicitly supported

Design Philosophy

JavaToGpu is intentionally strict.

The goal is not "run arbitrary Java on GPU", but "accept a well-defined GPU-safe Java subset and fail fast on everything else".

Intentionally Limited

  • non-void @GPU entry methods
  • arbitrary object allocation
  • arbitrary Java method calls
  • arbitrary JVM bytecode in ASM frontend

See Also

Clone this wiki locally