diff --git a/test/runtests.jl b/test/runtests.jl index 261b07f2..df280a3e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -166,9 +166,13 @@ end cunumeric_res = reduction(cunumeric_arr) julia_res = reduction(julia_arr) + n = length(julia_arr) allowscalar() do # assumes 0D result - @test isapprox(julia_res, cunumeric_res[]; atol=atol(T), rtol=rtol(T)) + @test isapprox( + julia_res, cunumeric_res[]; + atol=reduction_atol(T, n), rtol=reduction_rtol(T, n), + ) end end end @@ -283,7 +287,7 @@ end @testset "Copy-To" begin a = cuNumeric.zeros(2, 2) b = cuNumeric.ones(2, 2) - copyto!(a, b); + copyto!(a, b) @test is_same(a, b) end diff --git a/test/tests/unary_tests.jl b/test/tests/unary_tests.jl index 8c1e4f52..6bc87a58 100644 --- a/test/tests/unary_tests.jl +++ b/test/tests/unary_tests.jl @@ -96,8 +96,11 @@ function test_unary_reduction_dims( for d in 1:N julia_res = func(julia_arr; dims=d) cunumeric_res = func(cunumeric_arr; dims=d) + n = size(julia_arr, d) allowscalar() do - @test cuNumeric.compare(julia_res, cunumeric_res, atol(T), rtol(T)) + @test cuNumeric.compare( + julia_res, cunumeric_res, reduction_atol(T, n), reduction_rtol(T, n) + ) end end diff --git a/test/tests/util.jl b/test/tests/util.jl index 17b52e2e..fcf21cc0 100644 --- a/test/tests/util.jl +++ b/test/tests/util.jl @@ -38,6 +38,10 @@ atol(::Type{I}) where {I<:Integer} = atol(float(I)) rtol(::Type{Complex{T}}) where {T} = rtol(T) atol(::Type{Complex{T}}) where {T} = atol(T) +# Reduction rounding error grows with the number of elements reduced (n). +reduction_rtol(::Type{T}, n) where {T} = rtol(T) * n +reduction_atol(::Type{T}, n) where {T} = atol(T) * n + is_same(arr1::NDArray, arr2::NDArray) = @allowscalar (arr1 == arr2)[1] is_same(arr1::NDArray, arr2::Array) = @allowscalar (arr1 == arr2)[1] is_same(arr1::Array, arr2::NDArray) = @allowscalar (arr1 == arr2)[1]