Skip to content

Commit c97254c

Browse files
committed
juliaformatter
1 parent 30db77e commit c97254c

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/bitonic_sort/gpu.jl

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
xor(x, x >> 1i32)
5151
end
5252

53-
@inline function bisect_range(index::I, lo::I, n::I) where I
53+
@inline function bisect_range(index::I, lo::I, n::I) where {I}
5454
if n <= one(I)
5555
return -one(I), -one(I)
5656
end
@@ -64,15 +64,15 @@ end
6464
return lo, n
6565
end
6666

67-
@inline function rev_lt(a :: T, b :: T, lt, rev :: Val{R}) where {T,R}
67+
@inline function rev_lt(a::T, b::T, lt, rev::Val{R}) where {T,R}
6868
if R
6969
return lt(b, a)
7070
else
7171
return lt(a, b)
7272
end
7373
end
7474

75-
@inline function rev_lt(a :: Tuple{T, J}, b :: Tuple{T, J}, lt, rev :: Val{R}) where {T, J, R}
75+
@inline function rev_lt(a::Tuple{T,J}, b::Tuple{T,J}, lt, rev::Val{R}) where {T,J,R}
7676
if R
7777
if a[1] == b[1]
7878
return a[2] < b[2]
@@ -94,7 +94,7 @@ end
9494
end
9595
end
9696

97-
@inline function compare!(vals_inds::Tuple, i1::I, i2::I, dir::Bool, by, lt, rev) where I
97+
@inline function compare!(vals_inds::Tuple, i1::I, i2::I, dir::Bool, by, lt, rev) where {I}
9898
i1′, i2′ = i1 + one(I), i2 + one(I)
9999
vals, inds = vals_inds
100100
# comparing tuples of (value, index) guarantees stability of sort
@@ -104,7 +104,7 @@ end
104104
end
105105

106106

107-
@inline function get_range_part1(n::I, index::I, k::I)::Tuple{I,I,Bool} where I
107+
@inline function get_range_part1(n::I, index::I, k::I)::Tuple{I,I,Bool} where {I}
108108
lo = zero(I)
109109
dir = true
110110
for iter = one(I):k-one(I)
@@ -123,7 +123,7 @@ end
123123
return lo, n, dir
124124
end
125125

126-
@inline function get_range_part2(lo::I, n::I, index::I, j::I)::Tuple{I,I} where I
126+
@inline function get_range_part2(lo::I, n::I, index::I, j::I)::Tuple{I,I} where {I}
127127
for iter = one(I):j-one(I)
128128
lo, n = bisect_range(index, lo, n)
129129
end
@@ -175,7 +175,7 @@ end
175175
end
176176
end
177177

178-
@inline function compare_small!(vals_inds::Tuple, i1::I, i2::I, dir::Bool, by, lt, rev) where I
178+
@inline function compare_small!(vals_inds::Tuple, i1::I, i2::I, dir::Bool, by, lt, rev) where {I}
179179
i1′, i2′ = i1 + one(I), i2 + one(I)
180180
vals, inds = vals_inds
181181
# comparing tuples of (value, index) guarantees stability of sort
@@ -192,7 +192,7 @@ all threads perform swaps accessible using shmem.
192192
193193
Various negative exit values just for debugging.
194194
"""
195-
@inline function block_range(n::I, block_index::I, k::I, j::I)::Tuple{I,I,Bool} where I
195+
@inline function block_range(n::I, block_index::I, k::I, j::I)::Tuple{I,I,Bool} where {I}
196196
lo = zero(I)
197197
dir = true
198198
tmp = block_index * two(I)
@@ -252,11 +252,7 @@ end
252252
For sortperm/sortperm!, allocate and return shared memory views of `c` and index
253253
array. Each view is indexed along block x dim: one view per pseudo-block
254254
"""
255-
@inline function initialize_shmem!(
256-
vals_inds::Tuple{AbstractArray{T},AbstractArray{J}},
257-
index,
258-
in_range,
259-
) where {T,J}
255+
@inline function initialize_shmem!(vals_inds::Tuple{AbstractArray{T},AbstractArray{J}}, index, in_range) where {T,J}
260256
# NB: I tried creating both shmem arrays with `initialize_shmem!`
261257
# but the behavior changed - maybe it's necessary to alloc both before
262258
# writing to either?
@@ -275,7 +271,7 @@ end
275271
"""
276272
For sort/sort!, copy shmem view `swap` back into global array `c`
277273
"""
278-
@inline function finalize_shmem!(vals::AbstractArray, swap::AbstractArray, index::I, in_range::Bool) where I
274+
@inline function finalize_shmem!(vals::AbstractArray, swap::AbstractArray, index::I, in_range::Bool) where {I}
279275
if in_range
280276
@inbounds vals[index+one(I)] = swap[threadIdx().x]
281277
end
@@ -348,7 +344,7 @@ of values and an index array for doing `sortperm!`. Cannot provide a stable
348344
`sort!` although `sortperm!` is properly stable. To reverse, set `rev=true`
349345
rather than `lt=!isless` (otherwise stability of sortperm breaks down).
350346
"""
351-
function bitonic_sort!(c; by = identity, lt = isless, rev=false) where {T}
347+
function bitonic_sort!(c; by = identity, lt = isless, rev = false) where {T}
352348
c_len = if typeof(c) <: Tuple
353349
length(c[1])
354350
else

0 commit comments

Comments
 (0)