Skip to content

Commit 57786e6

Browse files
committed
apply formatting
1 parent 88c24aa commit 57786e6

File tree

5 files changed

+44
-37
lines changed

5 files changed

+44
-37
lines changed

src/KernelAbstractions.jl

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

5656
"""
@@ -68,7 +68,7 @@ This allows for two different configurations:
6868
"""
6969
macro kernel(ex...)
7070
if length(ex) == 1
71-
__kernel(ex[1], true, false)
71+
return __kernel(ex[1], true, false)
7272
else
7373
generate_cpu = true
7474
force_inbounds = false
@@ -88,7 +88,7 @@ macro kernel(ex...)
8888
)
8989
end
9090
end
91-
__kernel(ex[end], generate_cpu, force_inbounds)
91+
return __kernel(ex[end], generate_cpu, force_inbounds)
9292
end
9393
end
9494

@@ -166,7 +166,7 @@ a tuple corresponding to kernel configuration. In order to get
166166
the total size you can use `prod(@groupsize())`.
167167
"""
168168
macro groupsize()
169-
quote
169+
return quote
170170
$groupsize($(esc(:__ctx__)))
171171
end
172172
end
@@ -178,7 +178,7 @@ Query the ndrange on the backend. This function returns
178178
a tuple corresponding to kernel configuration.
179179
"""
180180
macro ndrange()
181-
quote
181+
return quote
182182
$size($ndrange($(esc(:__ctx__))))
183183
end
184184
end
@@ -192,7 +192,7 @@ macro localmem(T, dims)
192192
# Stay in sync with CUDAnative
193193
id = gensym("static_shmem")
194194

195-
quote
195+
return quote
196196
$SharedMemory($(esc(T)), Val($(esc(dims))), Val($(QuoteNode(id))))
197197
end
198198
end
@@ -213,7 +213,7 @@ macro private(T, dims)
213213
if dims isa Integer
214214
dims = (dims,)
215215
end
216-
quote
216+
return quote
217217
$Scratchpad($(esc(:__ctx__)), $(esc(T)), Val($(esc(dims))))
218218
end
219219
end
@@ -225,7 +225,7 @@ Creates a private local of `mem` per item in the workgroup. This can be safely u
225225
across [`@synchronize`](@ref) statements.
226226
"""
227227
macro private(expr)
228-
esc(expr)
228+
return esc(expr)
229229
end
230230

231231
"""
@@ -235,7 +235,7 @@ end
235235
that span workitems, or are reused across `@synchronize` statements.
236236
"""
237237
macro uniform(value)
238-
esc(value)
238+
return esc(value)
239239
end
240240

241241
"""
@@ -246,7 +246,7 @@ from each thread in the workgroup are visible in from all other threads in the
246246
workgroup.
247247
"""
248248
macro synchronize()
249-
quote
249+
return quote
250250
$__synchronize()
251251
end
252252
end
@@ -263,7 +263,7 @@ workgroup. `cond` is not allowed to have any visible sideffects.
263263
- `CPU`: This synchronization will always occur.
264264
"""
265265
macro synchronize(cond)
266-
quote
266+
return quote
267267
$(esc(cond)) && $__synchronize()
268268
end
269269
end
@@ -288,7 +288,7 @@ end
288288
```
289289
"""
290290
macro context()
291-
esc(:(__ctx__))
291+
return esc(:(__ctx__))
292292
end
293293

294294
"""
@@ -328,7 +328,7 @@ macro print(items...)
328328
end
329329
end
330330

331-
quote
331+
return quote
332332
$__print($(map(esc, args)...))
333333
end
334334
end
@@ -384,7 +384,7 @@ macro index(locale, args...)
384384
end
385385

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

390390
###
@@ -590,7 +590,7 @@ struct Kernel{Backend, WorkgroupSize <: _Size, NDRange <: _Size, Fun}
590590
end
591591

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

596596
workgroupsize(::Kernel{D, WorkgroupSize}) where {D, WorkgroupSize} = WorkgroupSize
@@ -700,7 +700,7 @@ end
700700
push!(args, item)
701701
end
702702

703-
quote
703+
return quote
704704
print($(args...))
705705
end
706706
end

src/cpu.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function (obj::Kernel{CPU})(args...; ndrange = nothing, workgroupsize = nothing)
4242
end
4343

4444
__run(obj, ndrange, iterspace, args, dynamic, obj.backend.static)
45+
return nothing
4546
end
4647

4748
const CPU_GRAINSIZE = 1024 # Vectorization, 4x unrolling, minimal grain size
@@ -160,15 +161,15 @@ end
160161

161162
@inline function __index_Global_Linear(ctx, idx::CartesianIndex)
162163
I = @inbounds expand(__iterspace(ctx), __groupindex(ctx), idx)
163-
@inbounds LinearIndices(__ndrange(ctx))[I]
164+
return @inbounds LinearIndices(__ndrange(ctx))[I]
164165
end
165166

166167
@inline function __index_Local_Cartesian(_, idx::CartesianIndex)
167168
return idx
168169
end
169170

170171
@inline function __index_Group_Cartesian(ctx, ::CartesianIndex)
171-
__groupindex(ctx)
172+
return __groupindex(ctx)
172173
end
173174

174175
@inline function __index_Global_Cartesian(ctx, idx::CartesianIndex)
@@ -189,7 +190,7 @@ end
189190
# CPU implementation of shared memory
190191
###
191192
@inline function SharedMemory(::Type{T}, ::Val{Dims}, ::Val) where {T, Dims}
192-
MArray{__size(Dims), T}(undef)
193+
return MArray{__size(Dims), T}(undef)
193194
end
194195

195196
###
@@ -210,7 +211,7 @@ end
210211
# https://github.com/JuliaLang/julia/issues/39308
211212
@inline function aview(A, I::Vararg{Any, N}) where {N}
212213
J = Base.to_indices(A, I)
213-
Base.unsafe_view(Base._maybe_reshape_parent(A, Base.index_ndims(J...)), J...)
214+
return Base.unsafe_view(Base._maybe_reshape_parent(A, Base.index_ndims(J...)), J...)
214215
end
215216

216217
@inline function Base.getindex(A::ScratchArray{N}, idx) where {N}

src/macros.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function find_return(stmt)
66
result |= @capture(expr, return x_)
77
expr
88
end
9-
result
9+
return result
1010
end
1111

1212
# XXX: Proper errors
@@ -103,6 +103,7 @@ function transform_gpu!(def, constargs, force_inbounds)
103103
Expr(:block, let_constargs...),
104104
body,
105105
)
106+
return nothing
106107
end
107108

108109
# The hard case, transform the function for CPU execution
@@ -137,6 +138,7 @@ function transform_cpu!(def, constargs, force_inbounds)
137138
Expr(:block, let_constargs...),
138139
Expr(:block, new_stmts...),
139140
)
141+
return nothing
140142
end
141143

142144
struct WorkgroupLoop
@@ -150,7 +152,7 @@ end
150152
is_sync(expr) = @capture(expr, @synchronize() | @synchronize(a_))
151153

152154
function is_scope_construct(expr::Expr)
153-
expr.head === :block # ||
155+
return expr.head === :block # ||
154156
# expr.head === :let
155157
end
156158

@@ -160,7 +162,7 @@ function find_sync(stmt)
160162
result |= is_sync(expr)
161163
expr
162164
end
163-
result
165+
return result
164166
end
165167

166168
# TODO proper handling of LineInfo

src/nditeration.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract type _Size end
1313
struct DynamicSize <: _Size end
1414
struct StaticSize{S} <: _Size
1515
function StaticSize{S}() where {S}
16-
new{S::Tuple{Vararg{Int}}}()
16+
return new{S::Tuple{Vararg{Int}}}()
1717
end
1818
end
1919

@@ -51,11 +51,11 @@ struct NDRange{N, StaticBlocks, StaticWorkitems, DynamicBlock, DynamicWorkitems}
5151
workitems::DynamicWorkitems
5252

5353
function NDRange{N, B, W}() where {N, B, W}
54-
new{N, B, W, Nothing, Nothing}(nothing, nothing)
54+
return new{N, B, W, Nothing, Nothing}(nothing, nothing)
5555
end
5656

5757
function NDRange{N, B, W}(blocks, workitems) where {N, B, W}
58-
new{N, B, W, typeof(blocks), typeof(workitems)}(blocks, workitems)
58+
return new{N, B, W, typeof(blocks), typeof(workitems)}(blocks, workitems)
5959
end
6060
end
6161

@@ -78,7 +78,7 @@ Base.length(range::NDRange) = length(blocks(range))
7878
gidx = groupidx.I[I]
7979
(gidx - 1) * stride + idx.I[I]
8080
end
81-
CartesianIndex(nI)
81+
return CartesianIndex(nI)
8282
end
8383

8484

@@ -88,7 +88,9 @@ end
8888
Assume that the condition `cond` is true. This is a hint to the compiler, possibly enabling
8989
it to optimize more aggressively.
9090
"""
91-
@inline assume(cond::Bool) = Base.llvmcall(("""
91+
@inline assume(cond::Bool) = Base.llvmcall(
92+
(
93+
"""
9294
declare void @llvm.assume(i1)
9395
9496
define void @entry(i8) #0 {
@@ -97,11 +99,13 @@ it to optimize more aggressively.
9799
ret void
98100
}
99101
100-
attributes #0 = { alwaysinline }""", "entry"),
101-
Nothing, Tuple{Bool}, cond)
102+
attributes #0 = { alwaysinline }""", "entry",
103+
),
104+
Nothing, Tuple{Bool}, cond
105+
)
102106

103107
@inline function assume_nonzero(CI::CartesianIndices)
104-
ntuple(Val(ndims(CI))) do I
108+
return ntuple(Val(ndims(CI))) do I
105109
Base.@_inline_meta
106110
indices = CI.indices[I]
107111
assume(indices.stop > 0)
@@ -114,15 +118,15 @@ Base.@propagate_inbounds function expand(ndrange::NDRange, groupidx::Integer, id
114118
W = workitems(ndrange)
115119
assume_nonzero(B)
116120
assume_nonzero(W)
117-
expand(ndrange, B[groupidx], workitems(ndrange)[idx])
121+
return expand(ndrange, B[groupidx], workitems(ndrange)[idx])
118122
end
119123

120124
Base.@propagate_inbounds function expand(ndrange::NDRange{N}, groupidx::CartesianIndex{N}, idx::Integer) where {N}
121-
expand(ndrange, groupidx, workitems(ndrange)[idx])
125+
return expand(ndrange, groupidx, workitems(ndrange)[idx])
122126
end
123127

124128
Base.@propagate_inbounds function expand(ndrange::NDRange{N}, groupidx::Integer, idx::CartesianIndex{N}) where {N}
125-
expand(ndrange, blocks(ndrange)[groupidx], idx)
129+
return expand(ndrange, blocks(ndrange)[groupidx], idx)
126130
end
127131

128132
"""

src/reflection.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434

3535

3636
function ka_code_llvm(kernel, argtypes; ndrange = nothing, workgroupsize = nothing, kwargs...)
37-
ka_code_llvm(stdout, kernel, argtypes; ndrange = ndrange, workgroupsize = nothing, kwargs...)
37+
return ka_code_llvm(stdout, kernel, argtypes; ndrange = ndrange, workgroupsize = nothing, kwargs...)
3838
end
3939

4040
function ka_code_llvm(io::IO, kernel, argtypes; ndrange = nothing, workgroupsize = nothing, kwargs...)
@@ -119,7 +119,7 @@ macro ka_code_typed(ex0...)
119119

120120
thecall = InteractiveUtils.gen_call_with_extracted_types_and_kwargs(__module__, :ka_code_typed, ex)
121121

122-
quote
122+
return quote
123123
local $(esc(args)) = $(old_args)
124124
# e.g. translate CuArray to CuBackendArray
125125
$(esc(args)) = map(x -> argconvert($kern, x), $(esc(args)))
@@ -152,7 +152,7 @@ macro ka_code_llvm(ex0...)
152152

153153
thecall = InteractiveUtils.gen_call_with_extracted_types_and_kwargs(__module__, :ka_code_llvm, ex)
154154

155-
quote
155+
return quote
156156
local $(esc(args)) = $(old_args)
157157

158158
if isa($kern, Kernel{G} where {G <: GPU})

0 commit comments

Comments
 (0)