Skip to content

Problem using @atomic in a kernel #619

Open
@emmabeniston

Description

@emmabeniston

Hello!

I'm trying to run some code on Apple M2 and am encountering errors which we think are due to @atomic. I'm not experienced enough to produce a MWE but the issue seems to be due to the @atomic lines in the following kernel:

@kernel inbounds = true function MassCGKernel!(M,MMass,@Const(JJ),@Const(w),@Const(Glob))
  I,J,Iz,IF = @index(Global, NTuple)

  N = @uniform @groupsize()[1]
  Nz = @uniform @ndrange()[3]
  NF = @uniform @ndrange()[4]

  if Iz <= Nz && IF <= NF
    ID = I + (J - 1) * N  
    ind = Glob[ID,IF]  
    @atomic :monotonic M[Iz,ind,1] += JJ[ID,1,Iz,IF]
    @atomic :monotonic M[Iz,ind,2] += JJ[ID,2,Iz,IF]
    @atomic :monotonic MMass[Iz,ind] += eltype(M)(0.5) * (JJ[ID,1,Iz,IF] + JJ[ID,2,Iz,IF]) * w[I] * w[J]
  end  
end

I get the following error message (not including the Stacktrace):

ERROR: LoadError: Compilation to native code failed; see below for details.
If you think this is a bug, please file an issue and attach /var/folders/hb/kf4qgnbd3mjb5gbb7nm8klmw0000gn/T/jl_gjS3EJcBoZ.metallib
caused by: NSError: Failed to materializeAll. (AGXMetalG14G, code 3)

Are there any suggestions for how to get this to run? Are there known to be any problems with using @atomic with Metal?

Code is courtesy of @OsKnoth who should be able to provide more details if needed. Related to this issue on oneAPI: JuliaGPU/oneAPI.jl#508

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions