Skip to content

Commit d8714a6

Browse files
committed
Run Runic after explicit return rule addition
1 parent 419481c commit d8714a6

28 files changed

+80
-45
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function main()
4444
push_preview = true,
4545
)
4646
end
47+
return
4748
end
4849

4950
isinteractive() || main()

examples/histogram.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ function histogram!(histogram_output, input)
6363
# Need static block size
6464
kernel! = histogram_kernel!(backend, (256,))
6565
kernel!(histogram_output, input, ndrange = size(input))
66+
return
6667
end
6768

6869
function move(backend, input)
6970
# TODO replace with adapt(backend, input)
7071
out = KernelAbstractions.allocate(backend, eltype(input), size(input))
7172
KernelAbstractions.copyto!(backend, out, input)
73+
return
7274
end
7375

7476
@testset "histogram tests" begin

examples/matmul.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function matmul!(output, a, b)
2323
backend = KernelAbstractions.get_backend(a)
2424
kernel! = matmul_kernel!(backend)
2525
kernel!(output, a, b, ndrange = size(output))
26+
return
2627
end
2728

2829
a = rand!(allocate(backend, Float32, 256, 123))

examples/memcopy.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function mycopy!(A, B)
1313

1414
kernel = copy_kernel!(backend)
1515
kernel(A, B, ndrange = length(A))
16+
return
1617
end
1718

1819
A = KernelAbstractions.zeros(backend, Float64, 128, 128)

examples/memcopy_static.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function mycopy_static!(A, B)
1313

1414
kernel = copy_kernel!(backend, 32, size(A)) # if size(A) varies this will cause recompilation
1515
kernel(A, B, ndrange = size(A))
16+
return
1617
end
1718

1819
A = KernelAbstractions.zeros(backend, Float64, 128, 128)

examples/mpi.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function cooperative_test!(req)
99
done, _ = MPI.Test(req, MPI.Status)
1010
yield()
1111
end
12+
return
1213
end
1314

1415
function cooperative_wait(task::Task)
@@ -17,6 +18,7 @@ function cooperative_wait(task::Task)
1718
yield()
1819
end
1920
wait(task)
21+
return
2022
end
2123

2224
function exchange!(h_send_buf, d_recv_buf, h_recv_buf, src_rank, dst_rank, comm)
@@ -68,6 +70,7 @@ function main(backend)
6870
cooperative_wait(send_task)
6971

7072
@test all(d_recv_buf .== src_rank)
73+
return
7174
end
7275

7376
main(backend)

examples/naive_transpose.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function naive_transpose!(a, b)
1818
groupsize = KernelAbstractions.isgpu(backend) ? 256 : 1024
1919
kernel! = naive_transpose_kernel!(backend, groupsize)
2020
kernel!(a, b, ndrange = size(a))
21+
return
2122
end
2223

2324
# resolution of grid will be res*res

ext/EnzymeCore07Ext.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function EnzymeRules.forward(
2222
f = kernel.f
2323
fwd_kernel = similar(kernel, cpu_fwd)
2424

25-
fwd_kernel(f, args...; ndrange, workgroupsize)
25+
return fwd_kernel(f, args...; ndrange, workgroupsize)
2626
end
2727

2828
function EnzymeRules.forward(
@@ -36,7 +36,7 @@ function EnzymeRules.forward(
3636
f = kernel.f
3737
fwd_kernel = similar(kernel, gpu_fwd)
3838

39-
fwd_kernel(f, args...; ndrange, workgroupsize)
39+
return fwd_kernel(f, args...; ndrange, workgroupsize)
4040
end
4141

4242
_enzyme_mkcontext(kernel::Kernel{CPU}, ndrange, iterspace, dynamic) =

ext/EnzymeCore08Ext.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function EnzymeRules.forward(
2323
f = kernel.f
2424
fwd_kernel = similar(kernel, cpu_fwd)
2525

26-
fwd_kernel(config, f, args...; ndrange, workgroupsize)
26+
return fwd_kernel(config, f, args...; ndrange, workgroupsize)
2727
end
2828

2929
function EnzymeRules.forward(
@@ -38,7 +38,7 @@ function EnzymeRules.forward(
3838
f = kernel.f
3939
fwd_kernel = similar(kernel, gpu_fwd)
4040

41-
fwd_kernel(config, f, args...; ndrange, workgroupsize)
41+
return fwd_kernel(config, f, args...; ndrange, workgroupsize)
4242
end
4343

4444
_enzyme_mkcontext(kernel::Kernel{CPU}, ndrange, iterspace, dynamic) =

src/KernelAbstractions.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ synchronize(backend)
5151
```
5252
"""
5353
macro kernel(expr)
54-
__kernel(expr, #=generate_cpu=# true, #=force_inbounds=# false)
54+
return __kernel(expr, #=generate_cpu=# true, #=force_inbounds=# false)
5555
end
5656

5757
"""
@@ -69,7 +69,7 @@ This allows for two different configurations:
6969
"""
7070
macro kernel(ex...)
7171
if length(ex) == 1
72-
__kernel(ex[1], true, false)
72+
return __kernel(ex[1], true, false)
7373
else
7474
generate_cpu = true
7575
force_inbounds = false
@@ -89,7 +89,7 @@ macro kernel(ex...)
8989
)
9090
end
9191
end
92-
__kernel(ex[end], generate_cpu, force_inbounds)
92+
return __kernel(ex[end], generate_cpu, force_inbounds)
9393
end
9494
end
9595

@@ -167,7 +167,7 @@ a tuple corresponding to kernel configuration. In order to get
167167
the total size you can use `prod(@groupsize())`.
168168
"""
169169
macro groupsize()
170-
quote
170+
return quote
171171
$groupsize($(esc(:__ctx__)))
172172
end
173173
end
@@ -179,7 +179,7 @@ Query the ndrange on the backend. This function returns
179179
a tuple corresponding to kernel configuration.
180180
"""
181181
macro ndrange()
182-
quote
182+
return quote
183183
$size($ndrange($(esc(:__ctx__))))
184184
end
185185
end
@@ -193,7 +193,7 @@ macro localmem(T, dims)
193193
# Stay in sync with CUDAnative
194194
id = gensym("static_shmem")
195195

196-
quote
196+
return quote
197197
$SharedMemory($(esc(T)), Val($(esc(dims))), Val($(QuoteNode(id))))
198198
end
199199
end
@@ -214,7 +214,7 @@ macro private(T, dims)
214214
if dims isa Integer
215215
dims = (dims,)
216216
end
217-
quote
217+
return quote
218218
$Scratchpad($(esc(:__ctx__)), $(esc(T)), Val($(esc(dims))))
219219
end
220220
end
@@ -226,7 +226,7 @@ Creates a private local of `mem` per item in the workgroup. This can be safely u
226226
across [`@synchronize`](@ref) statements.
227227
"""
228228
macro private(expr)
229-
esc(expr)
229+
return esc(expr)
230230
end
231231

232232
"""
@@ -236,7 +236,7 @@ end
236236
that span workitems, or are reused across `@synchronize` statements.
237237
"""
238238
macro uniform(value)
239-
esc(value)
239+
return esc(value)
240240
end
241241

242242
"""
@@ -247,7 +247,7 @@ from each thread in the workgroup are visible in from all other threads in the
247247
workgroup.
248248
"""
249249
macro synchronize()
250-
quote
250+
return quote
251251
$__synchronize()
252252
end
253253
end
@@ -264,7 +264,7 @@ workgroup. `cond` is not allowed to have any visible sideffects.
264264
- `CPU`: This synchronization will always occur.
265265
"""
266266
macro synchronize(cond)
267-
quote
267+
return quote
268268
$(esc(cond)) && $__synchronize()
269269
end
270270
end
@@ -289,7 +289,7 @@ end
289289
```
290290
"""
291291
macro context()
292-
esc(:(__ctx__))
292+
return esc(:(__ctx__))
293293
end
294294

295295
"""
@@ -329,7 +329,7 @@ macro print(items...)
329329
end
330330
end
331331

332-
quote
332+
return quote
333333
$__print($(map(esc, args)...))
334334
end
335335
end
@@ -385,7 +385,7 @@ macro index(locale, args...)
385385
end
386386

387387
index_function = Symbol(:__index_, locale, :_, indexkind)
388-
Expr(:call, GlobalRef(KernelAbstractions, index_function), esc(:__ctx__), map(esc, args)...)
388+
return Expr(:call, GlobalRef(KernelAbstractions, index_function), esc(:__ctx__), map(esc, args)...)
389389
end
390390

391391
###
@@ -591,7 +591,7 @@ struct Kernel{Backend, WorkgroupSize <: _Size, NDRange <: _Size, Fun}
591591
end
592592

593593
function Base.similar(kernel::Kernel{D, WS, ND}, f::F) where {D, WS, ND, F}
594-
Kernel{D, WS, ND, F}(kernel.backend, f)
594+
return Kernel{D, WS, ND, F}(kernel.backend, f)
595595
end
596596

597597
workgroupsize(::Kernel{D, WorkgroupSize}) where {D, WorkgroupSize} = WorkgroupSize
@@ -701,7 +701,7 @@ end
701701
push!(args, item)
702702
end
703703

704-
quote
704+
return quote
705705
print($(args...))
706706
end
707707
end

0 commit comments

Comments
 (0)