Skip to content

Commit 9cbfae7

Browse files
committed
Use KernelIntrinsics
1 parent 236c812 commit 9cbfae7

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Adapt = "4.0"
2727
GPUArraysCore = "= 0.2.0"
2828
GPUToolbox = "0.2, 0.3, 1"
2929
JLD2 = "0.4, 0.5, 0.6"
30-
KernelAbstractions = "0.9.28, 0.10"
30+
KernelAbstractions = "0.10"
3131
LLVM = "3.9, 4, 5, 6, 7, 8, 9"
3232
LinearAlgebra = "1"
3333
Printf = "1"

src/GPUArrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module GPUArrays
22

33
using GPUToolbox
44
using KernelAbstractions
5+
import KernelAbstractions.KernelIntrinsics as KI
56
using Serialization
67
using Random
78
using LinearAlgebra

src/host/reverse.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function _reverse(input::AnyGPUArray{T, N}, output::AnyGPUArray{T, N};
1717

1818
## COV_EXCL_START
1919
@kernel unsafe_indices=true function kernel(input, output)
20-
offset_in = Int32(@groupsize()[1]) * (@index(Group, Linear) - 1i32)
21-
index_in = offset_in + @index(Local, Linear)
20+
offset_in = Int32(KI.get_local_size().x) * (KI.get_group_id().x - 1i32)
21+
index_in = offset_in + KI.get_local_id().x
2222

2323
@inbounds if index_in <= length(input)
2424
idx = Tuple(nd_idx[index_in])
@@ -31,7 +31,7 @@ function _reverse(input::AnyGPUArray{T, N}, output::AnyGPUArray{T, N};
3131

3232
nthreads = 256
3333

34-
kernel(get_backend(input), nthreads)(input, output; ndrange=length(input))
34+
kernel(get_backend(input))(input, output; ndrange=length(input), nthreads)
3535
end
3636

3737
# in-place version, swapping elements on half the number of threads
@@ -52,8 +52,8 @@ function _reverse!(data::AnyGPUArray{T, N}; dims=1:ndims(data)) where {T, N}
5252

5353
## COV_EXCL_START
5454
@kernel unsafe_indices=true function kernel(data)
55-
offset_in = Int32(@groupsize()[1]) * (@index(Group, Linear) - 1i32)
56-
index_in = offset_in + @index(Local, Linear)
55+
offset_in = Int32(KI.get_local_size().x) * (KI.get_group_id().x - 1i32)
56+
index_in = offset_in + KI.get_local_id().x
5757

5858
@inbounds if index_in <= reduced_length
5959
idx = Tuple(nd_idx[index_in])
@@ -77,7 +77,7 @@ function _reverse!(data::AnyGPUArray{T, N}; dims=1:ndims(data)) where {T, N}
7777

7878
nthreads = 256
7979

80-
kernel(get_backend(data), nthreads)(data; ndrange=length(data))
80+
kernel(get_backend(data))(data; ndrange=length(data), nthreads)
8181
end
8282

8383

0 commit comments

Comments
 (0)