JuliaGPU / JuliaGPU/AMDGPU.jl

Integer overflow for large ROCArray A in AMDGPU.rand!(A)

Open
#245 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug rng
Dominant language
Julia
Stars
344
Forks
79
Avg merge
2d 23h
Merged PRs (30d)
27

Description

The following error appears for a large ROCArray, 50Kx50K (or larger) Float32 on AMDGPU.rand!
It points at this line in random.jl and might be related to using Int32.

To reproduce:
Hardware: Crusher MI250X using rocm 5.1.0 and AMDGPU v0.3.7
Code:

import AMDGPU
A = AMDGPU.ROCArray{Float32,2}(undef, 50000, 50000)
AMDGPU.rand!(A)

Error message:

ERROR: LoadError: InexactError: trunc(Int32, 3600000000)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, #unused#::Type{Int32}, val::Int64)
    @ Core ./boot.jl:614
  [2] checked_trunc_sint
    @ ./boot.jl:636 [inlined]
  [3] toInt32
    @ ./boot.jl:673 [inlined]
  [4] Int32
    @ ./boot.jl:763 [inlined]
  [5] convert
    @ ./number.jl:7 [inlined]
  [6] cconvert
    @ ./essentials.jl:412 [inlined]
  [7] macro expansion
    @ ~/.julia/packages/AMDGPU/f6OQx/src/rand/error.jl:44 [inlined]
  [8] rocrand_generate_uniform
    @ ~/.julia/packages/AMDGPU/f6OQx/src/rand/librocrand.jl:42 [inlined]
  [9] rand!
    @ ~/.julia/packages/AMDGPU/f6OQx/src/rand/random.jl:50 [inlined]
 [10] rand!
    @ ~/.julia/packages/AMDGPU/f6OQx/src/random.jl:43 [inlined]
 [11] macro expansion
    @ ./timing.jl:242 [inlined]

I'll be happy to help testing on this system.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/rand/random.jl:50 and trace the call through src/rand/librocrand.jl:42 and src/rand/error.jl:44, where the reported Int32 conversion occurs. Reproduce with the 50,000x50,000 Float32 ROCArray on the stated AMDGPU/ROCm setup. Done means AMDGPU.rand!(A) completes for this large array without the reported InexactError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.