Skip to content

OpenCL Features

Bogdan edited this page Jun 21, 2026 · 2 revisions

Work-Item Functions

  • get_work_dim()
  • get_global_size(int dim)
  • get_global_id(int dim)
  • get_local_size(int dim)
  • get_local_id(int dim)
  • get_num_groups(int dim)
  • get_group_id(int dim)

Math

Supported math helpers live on GPU.

Common examples:

  • sin
  • cos
  • tan
  • exp
  • log
  • log2
  • pow
  • sqrt
  • rsqrt
  • fmin
  • fmax
  • mad
  • clamp
  • mix
  • step
  • smoothstep

Synchronization

  • GPU.barrier(...)
  • GPU.local_mem_fence()
  • GPU.local_barrier()

Fence constants:

  • GPU.CLK_LOCAL_MEM_FENCE
  • GPU.CLK_GLOBAL_MEM_FENCE

Images and Samplers

Basic image and sampler kernel parameters and OpenCL image intrinsics are supported.

Typical operations:

  • GPU.read_imagei(...)
  • GPU.read_imagef(...)
  • GPU.write_imagei(...)
  • GPU.write_imagef(...)
  • GPU.get_image_width(...)
  • GPU.get_image_height(...)

Current limitation:

  • code generation is implemented
  • runtime marshalling for real image and sampler objects is still pending

Address Spaces

  • @GPUGlobal
  • @GPUConstant
  • @GPULocal

Mappings:

  • @GPUGlobal -> __global
  • @GPUGlobal(constant = true) -> __global const
  • @GPUConstant -> __constant
  • @GPULocal -> __local

Attributes

  • @OpenCLAttributes

Typical use:

@OpenCLAttributes({"reqd_work_group_size(16, 1, 1)"})
@net.sixik.ga_utils.javatogpu.api.anotations.GPU
static void kernel(@GPUGlobal float[] output) {
    output[0] = 1.0f;
}

See Also

Clone this wiki locally