Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gtimuri committed Jan 20, 2025
1 parent f481b01 commit ca416ac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

27 changes: 26 additions & 1 deletion test/test-basic-test.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
using InclusiveScans
using CUDA

@testset "InclusiveScans.jl" begin
@test InclusiveScans.hello_world() == "Hello, World!"
function _cpu_inclusive_cumsum(x::Vector{Float32})
s = 0.0f0
out = similar(x)
for i = 1:length(x)
s += x[i]
out[i] = s
end
return out
end
eps = 0.1
N = 25000
h_in = rand(Float32, N)
d_in = CuArray(h_in)
d_out = CUDA.zeros(Float32, N)

InclusiveScans.largeArrayScanInclusive!(d_out, d_in, N)
h_out = Array(d_out)

# CPU cumsum check
h_check = _cpu_inclusive_cumsum(h_in)

maxdiff = maximum(abs.(h_out .- h_check))
@test maxdiff < eps
end

0 comments on commit ca416ac

Please sign in to comment.