Skip to content

AMDGPU.jlProgramming AMD GPUs with Julia

AMDGPU.jl

Install

Simply add the AMDGPU.jl package to your Julia environment:

julia
using Pkg
Pkg.add("AMDGPU")

Requirements

  • Julia 1.10+:

  • MI300X requires Julia 1.12+.

  • 64-bit Linux or Windows.

  • ROCm 6.0+.

Required software

LinuxWindows
ROCmROCm
-AMD Software: Adrenalin Edition

Note

On Windows AMD Software: Adrenalin Edition contains HIP library itself, while ROCm provides support for other functionality.

Test

To ensure that everything works, you can run the test suite:

julia
using AMDGPU
using Pkg
Pkg.test("AMDGPU")

Example

Element-wise addition via high-level interface & low-level kernel:

julia
using AMDGPU

function vadd!(c, a, b)
   i = workitemIdx().x + (workgroupIdx().x - 1) * workgroupDim().x
   if i  length(a)
       c[i] = a[i] + b[i]
   end
   return
end

a = AMDGPU.ones(Int, 1024)
b = AMDGPU.ones(Int, 1024)
c = AMDGPU.zeros(Int, 1024)

groupsize = 256
gridsize = cld(length(c), groupsize)
@roc groupsize=groupsize gridsize=gridsize vadd!(c, a, b)

@assert (a .+ b)  c