Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions test/core/rocarray_broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,27 @@ end
end

# https://github.com/JuliaGPU/AMDGPU.jl/issues/1002
if Base.datatype_alignment(Int128) == 16
# note: miscompile only occurs with `julia --check-bounds=yes`
@testset "Int128 miscompilation" begin
function test_kernel(a::T, b) where T
c = a
for i=1:5
c += T(b)
c = a * T(2)
end
return c
# note: miscompile only occurs with `julia --check-bounds=yes`
@testset "Int128 miscompilation" begin
function test_kernel(a::T, b) where T
c = a
for i=1:5
c += T(b)
c = a * T(2)
end
M = rand(Int128, 10, 10)
@test Array(test_kernel.(ROCArray(M), Int128(10))) == test_kernel.(M, Int128(10))
AMDGPU.synchronize()
return c
end
M = rand(Int128, 10, 10)
@test Array(test_kernel.(ROCArray(M), Int128(10))) == test_kernel.(M, Int128(10))
AMDGPU.synchronize()
end

@testset "Int128 axpby! miscompilation" begin
a, b = rand(Int128), rand(Int128)
x, y = rand(Int128, 5), rand(Int128, 5)
gx, gy = ROCArray(x), ROCArray(y)
gy .= gx .* a .+ gy .* b
@test Array(gy) == x .* a .+ y .* b
AMDGPU.synchronize()
end
# https://github.com/JuliaGPU/AMDGPU.jl/issues/1002
@testset "Int128 axpby! miscompilation" begin
a, b = rand(Int128), rand(Int128)
x, y = rand(Int128, 5), rand(Int128, 5)
gx, gy = ROCArray(x), ROCArray(y)
gy .= gx .* a .+ gy .* b
@test Array(gy) == x .* a .+ y .* b
AMDGPU.synchronize()
end
19 changes: 19 additions & 0 deletions test/device/launch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ end
AMDGPU.synchronize()
end

# https://github.com/JuliaGPU/AMDGPU.jl/issues/1002
@testset "Int128 layout matches the host" begin
# a kernel argument with fields after an Int128
function kernel(out, s)
out[1] = s[1]
out[2] = s[2]
out[3] = s[3]
return
end
s = (Int32(-7), typemax(Int128) - 3, Int64(42))
out = ROCArray{Int128}(undef, 3)
@roc kernel(out, s)
@test Array(out) == [-7, typemax(Int128) - 3, 42]

# device memory holding such values, as laid out by the host
xs = [(Int32(i), Int128(i) << 70, Int64(-i)) for i in 1:4]
@test Array(map(x -> x[1] + x[2] + x[3], ROCArray(xs))) == map(x -> x[1] + x[2] + x[3], xs)
end

@testset "Function/Argument Conversion" begin
@testset "Closure as Argument" begin
function kernel(closure)
Expand Down
4 changes: 1 addition & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ init_code = quote
include($gpuarrays_testsuite)
testf(f, xs...; kwargs...) = TestSuite.compare(f, AMDGPU.ROCArray, xs...; kwargs...)

# Int128 kernel arguments need the host to align Int128 to 16 bytes like the device (Julia 1.12+), see #1002
const eltypes = [Int16, Int32, Int64,
(Base.datatype_alignment(Int128) == 16 ? (Int128,) : ())...,
const eltypes = [Int16, Int32, Int64, Int128,
Float16, Float32, Float64,
ComplexF16, ComplexF32, ComplexF64,
Complex{Int16}, Complex{Int32}, Complex{Int64}]
Expand Down
Loading