Getting Started

Basic Usage

The most basic usage involves moving data to the GPU using oneArray and performing operations on it.

using oneAPI# Create an array on the CPUa = rand(Float32, 1024)# Move it to the GPUd_a = oneArray(a)# Perform operations on the GPUd_b = d_a .+ 1.0f0# Move the result back to the CPUb = Array(d_b)

Matrix Multiplication

Matrix multiplication is accelerated using the oneMKL library when available.

using oneAPIA = oneArray(rand(Float32, 128, 128))B = oneArray(rand(Float32, 128, 128))# This operation runs on the GPUC = A * B

Writing Kernels

For custom operations, you can write kernels using the @oneapi macro.

using oneAPIfunction my_kernel(a, b)    i = get_global_id()    @inbounds a[i] += b[i]    returnenda = oneArray(ones(Float32, 1024))b = oneArray(ones(Float32, 1024))# Launch the kernel with 1024 items@oneapi items=1024 my_kernel(a, b)

See the Kernel Programming section for more details.