Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Mar 21, 2019
1 parent cd85622 commit bd5e97f
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions test/device/execution.jl
Expand Up @@ -807,4 +807,96 @@ end

############################################################################################

@testset "dynamic parallelism" begin

@testset "basic usage" begin
function hello()
@cuprintf("Hello, ")
@cuda dynamic=true world()
return
end

@eval function world()
@cuprintf("World!")
return
end

_, out = @grab_output begin
@cuda hello()
synchronize()
end
@test out == "Hello, World!"
end

@testset "argument passing" begin
function kernel(a, b, c)
@cuprintf("%ld %ld %ld", Int64(a), Int64(b), Int64(c))
return
end

for args in ((Int16(1), Int32(2), Int64(3)), # padding
(Int32(1), Int32(2), Int32(3)), # no padding, equal size
(Int64(1), Int32(2), Int16(3)), # no padding, inequal size
(Int16(1), Int64(2), Int32(3))) # mixed
_, out = @grab_output begin
@cuda kernel(args...)
synchronize()
end
@test out == "1 2 3"
end
end

@testset "self-recursion" begin
@eval function kernel(x::Bool)
if x
@cuprintf("recurse ")
@cuda dynamic=true kernel(false)
else
@cuprintf("stop")
end
return
end

_, out = @grab_output begin
@cuda kernel(true)
synchronize()
end
@test out == "recurse stop"
end

@testset "deep recursion" begin
@eval function kernel_a(x::Bool)
@cuprintf("a ")
@cuda dynamic=true kernel_b(x)
return
end

@eval function kernel_b(x::Bool)
@cuprintf("b ")
@cuda dynamic=true kernel_c(x)
return
end

@eval function kernel_c(x::Bool)
@cuprintf("c ")
if x
@cuprintf("recurse ")
@cuda dynamic=true kernel_a(false)
else
@cuprintf("stop")
end
return
end

_, out = @grab_output begin
@cuda kernel_a(true)
synchronize()
end
@test out == "a b c recurse a b c stop"
end

end

############################################################################################

end

0 comments on commit bd5e97f

Please sign in to comment.