|
1 | | -@kernel function groupreduce_1!(y, x, op, neutral, algo) |
| 1 | +@kernel cpu=false function groupreduce_1!(y, x, op, neutral) |
2 | 2 | i = @index(Global) |
3 | 3 | val = i > length(x) ? neutral : x[i] |
4 | | - res = @groupreduce(op, val, neutral, algo) |
| 4 | + res = @groupreduce(op, val, neutral) |
5 | 5 | i == 1 && (y[1] = res) |
6 | 6 | end |
7 | 7 |
|
8 | | -@kernel function groupreduce_2!(y, x, op, neutral, algo, ::Val{groupsize}) where {groupsize} |
| 8 | +@kernel cpu=false function groupreduce_2!(y, x, op, neutral, ::Val{groupsize}) where {groupsize} |
9 | 9 | i = @index(Global) |
10 | 10 | val = i > length(x) ? neutral : x[i] |
11 | | - res = @groupreduce(op, val, neutral, algo, groupsize) |
| 11 | + res = @groupreduce(op, val, neutral, groupsize) |
12 | 12 | i == 1 && (y[1] = res) |
13 | 13 | end |
14 | 14 |
|
15 | 15 | function groupreduce_testsuite(backend, AT) |
16 | | - # TODO should be better way of querying max groupsize |
| 16 | + # TODO should be a better way of querying max groupsize |
17 | 17 | groupsizes = "$backend" == "oneAPIBackend" ? |
18 | 18 | (256,) : |
19 | 19 | (256, 512, 1024) |
20 | 20 | @testset "@groupreduce" begin |
21 | | - @testset "thread reduction T=$T, n=$n" for T in (Float16, Float32, Int32, Int64), n in groupsizes |
| 21 | + @testset "T=$T, n=$n" for T in (Float16, Float32, Float64, Int16, Int32, Int64), n in groupsizes |
22 | 22 | x = AT(ones(T, n)) |
23 | 23 | y = AT(zeros(T, 1)) |
24 | 24 |
|
25 | | - groupreduce_1!(backend(), n)(y, x, +, zero(T), Reduction.thread; ndrange = n) |
| 25 | + groupreduce_1!(backend(), n)(y, x, +, zero(T); ndrange = n) |
26 | 26 | @test Array(y)[1] == n |
27 | 27 |
|
28 | | - groupreduce_2!(backend())(y, x, +, zero(T), Reduction.thread, Val(128); ndrange = n) |
| 28 | + groupreduce_2!(backend())(y, x, +, zero(T), Val(128); ndrange = n) |
29 | 29 | @test Array(y)[1] == 128 |
30 | 30 |
|
31 | | - groupreduce_2!(backend())(y, x, +, zero(T), Reduction.thread, Val(64); ndrange = n) |
| 31 | + groupreduce_2!(backend())(y, x, +, zero(T), Val(64); ndrange = n) |
32 | 32 | @test Array(y)[1] == 64 |
33 | 33 | end |
34 | | - |
35 | | - warp_reduction = KernelAbstractions.supports_warp_reduction(backend()) |
36 | | - if warp_reduction |
37 | | - @testset "warp reduction T=$T, n=$n" for T in (Float16, Float32, Int32, Int64), n in groupsizes |
38 | | - x = AT(ones(T, n)) |
39 | | - y = AT(zeros(T, 1)) |
40 | | - groupreduce_1!(backend(), n)(y, x, +, zero(T), Reduction.warp; ndrange = n) |
41 | | - @test Array(y)[1] == n |
42 | | - |
43 | | - groupreduce_2!(backend())(y, x, +, zero(T), Reduction.warp, Val(128); ndrange = n) |
44 | | - @test Array(y)[1] == 128 |
45 | | - |
46 | | - groupreduce_2!(backend())(y, x, +, zero(T), Reduction.warp, Val(64); ndrange = n) |
47 | | - @test Array(y)[1] == 64 |
48 | | - end |
49 | | - end |
50 | 34 | end |
51 | 35 | end |
0 commit comments