-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CUDA kernels take 3 #427
CUDA kernels take 3 #427
Changes from 12 commits
d530bf9
3b54150
5cdf38c
57a87da
4298112
5d22903
8365568
90a85b0
df6717f
b682b5e
fa13d83
80b4d49
e129edb
37bb247
bb47389
87d12d2
40bc031
5708ff9
e9d4443
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Reactant | ||
using Test | ||
using CUDA | ||
|
||
function square_kernel!(x, y) | ||
i = threadIdx().x | ||
x[i] *= y[i] | ||
sync_threads() | ||
return nothing | ||
end | ||
|
||
# basic squaring on GPU | ||
function square!(x, y) | ||
@cuda blocks = 1 threads = length(x) square_kernel!(x, y) | ||
return nothing | ||
end | ||
|
||
@testset "Square Kernel" begin | ||
oA = collect(1:1:64) | ||
A = Reactant.to_rarray(oA) | ||
B = Reactant.to_rarray(100 .* oA) | ||
if CUDA.functional() | ||
@jit square!(A, B) | ||
@test all(Array(A) .≈ (oA .* oA .* 100)) | ||
@test all(Array(B) .≈ (oA .* 100)) | ||
else | ||
@compile optimize = :before_kernel square!(A, B) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ const REACTANT_TEST_GROUP = lowercase(get(ENV, "REACTANT_TEST_GROUP", "all")) | |
end | ||
|
||
if REACTANT_TEST_GROUP == "all" || REACTANT_TEST_GROUP == "integration" | ||
@safetestset "CUDA" include("integration/cuda.jl") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conditionally run with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we have that in the test itself, but it’s actually important that we can compile cuda code even without a cuda gpu (since we want to take existing cuda kernels and rewrite them to whatever hardware). |
||
@safetestset "Linear Algebra" include("integration/linear_algebra.jl") | ||
@safetestset "AbstractFFTs" include("integration/fft.jl") | ||
@safetestset "Random" include("integration/random.jl") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jumerckx as a note. Something that I missed earlier, we previously had a catch all like this that we'll only do rewrite insts if the top level function is not a reactant method, but I think this was accidentally removed by your earlier PR. In any case restored here (and once CUDA lands will actually be tested it is done)