Skip to content

Commit ab74bfc

Browse files
authored
Exclude device-side sorting code from coverage (#2704)
* Exclude device-side sorting code from coverage * Exclude more kernels from coverage
1 parent a28c545 commit ab74bfc

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

src/CUDAKernels.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ end
135135

136136
## indexing
137137

138+
## COV_EXCL_START
138139
@device_override @inline function KA.__index_Local_Linear(ctx)
139140
return threadIdx().x
140141
end
@@ -191,6 +192,8 @@ end
191192
CUDA._cuprint(args...)
192193
end
193194

195+
## COV_EXCL_STOP
196+
194197
## other
195198

196199
Adapt.adapt_storage(to::KA.ConstAdaptor, a::CuDeviceArray) = Base.Experimental.Const(a)

src/indexing.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function Base.findall(bools::AnyCuArray{Bool})
3131
ys = CuArray{I}(undef, n)
3232

3333
if n > 0
34+
## COV_EXCL_START
3435
function kernel(ys::CuDeviceArray, bools, indices)
3536
i = threadIdx().x + (blockIdx().x - 1i32) * blockDim().x
3637

@@ -42,6 +43,7 @@ function Base.findall(bools::AnyCuArray{Bool})
4243

4344
return
4445
end
46+
## COV_EXCL_STOP
4547

4648
kernel = @cuda name="findall" launch=false kernel(ys, bools, indices)
4749
config = launch_configuration(kernel.fun)

src/random.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Random.seed!(rng::RNG) = Random.seed!(rng, make_seed())
4444
function Random.rand!(rng::RNG, A::AnyCuArray)
4545
isempty(A) && return A
4646

47+
## COV_EXCL_START
4748
function kernel(A::AbstractArray{T}, seed::UInt32, counter::UInt32) where {T}
4849
device_rng = Random.default_rng()
4950

@@ -65,6 +66,7 @@ function Random.rand!(rng::RNG, A::AnyCuArray)
6566

6667
return
6768
end
69+
## COV_EXCL_STOP
6870

6971
# XXX: because of how random numbers are generated, the launch configuration
7072
# affects the results. as such, use a constant number of threads, set
@@ -88,6 +90,7 @@ end
8890
function Random.randn!(rng::RNG, A::AnyCuArray{<:Union{AbstractFloat,Complex{<:AbstractFloat}}})
8991
isempty(A) && return A
9092

93+
## COV_EXCL_START
9194
function kernel(A::AbstractArray{T}, seed::UInt32, counter::UInt32) where {T<:Real}
9295
device_rng = Random.default_rng()
9396

@@ -149,6 +152,7 @@ function Random.randn!(rng::RNG, A::AnyCuArray{<:Union{AbstractFloat,Complex{<:A
149152
end
150153
return
151154
end
155+
## COV_EXCL_STOP
152156

153157
# see note in `rand!` about the launch configuration
154158
threads = 32

src/reverse.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function _reverse(input::AnyCuArray{T, N}, output::AnyCuArray{T, N};
1515
# converts a linear index in a reduced array to an ND-index, but using the reduced size
1616
nd_idx = CartesianIndices(input)
1717

18+
## COV_EXCL_START
1819
function kernel(input::AbstractArray{T, N}, output::AbstractArray{T, N}) where {T, N}
1920
offset_in = blockDim().x * (blockIdx().x - 1i32)
2021
index_in = offset_in + threadIdx().x
@@ -28,6 +29,7 @@ function _reverse(input::AnyCuArray{T, N}, output::AnyCuArray{T, N};
2829

2930
return
3031
end
32+
## COV_EXCL_STOP
3133

3234
nthreads = 256
3335
nblocks = cld(length(input), nthreads)
@@ -51,6 +53,7 @@ function _reverse!(data::AnyCuArray{T, N}; dims=1:ndims(data)) where {T, N}
5153
# converts a linear index in a reduced array to an ND-index, but using the reduced size
5254
nd_idx = CartesianIndices(reduced_size)
5355

56+
## COV_EXCL_START
5457
function kernel(data::AbstractArray{T, N}) where {T, N}
5558
offset_in = blockDim().x * (blockIdx().x - 1i32)
5659

@@ -71,6 +74,7 @@ function _reverse!(data::AnyCuArray{T, N}; dims=1:ndims(data)) where {T, N}
7174

7275
return
7376
end
77+
## COV_EXCL_STOP
7478

7579
# NOTE: we launch slightly more than half the number of elements in the array as threads.
7680
# The last non-singleton dimension along which to reverse is used to define how the array is split.

src/sorting.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ using ..CUDA: i32
3838
end
3939

4040

41+
## COV_EXCL_START
4142
# Batch partitioning
4243
"""
4344
Performs in-place cumsum using shared memory. Intended for use with indexes
@@ -118,6 +119,8 @@ function partition_batches_kernel(values::AbstractArray{T}, pivot, lo, hi, parit
118119
return
119120
end
120121

122+
## COV_EXCL_STOP
123+
121124

122125
# Batch consolidation
123126

@@ -140,6 +143,7 @@ function find_partition(array, pivot, lo, hi, parity, lt::F1, by::F2) where {F1,
140143
return low - 1
141144
end
142145

146+
## COV_EXCL_START
143147
"""
144148
This assumes the region of `vals` of length `L` starting after `lo`
145149
has been batch partitioned with respect to `pivot`. Further, it assumes that
@@ -454,6 +458,7 @@ function qsort_kernel(vals::AbstractArray{T,N}, lo, hi, parity, sync::Val{S}, sy
454458

455459
return
456460
end
461+
## COV_EXCL_STOP
457462

458463
function sort_args(args, partial_k::Nothing)
459464
return args
@@ -524,6 +529,7 @@ using ..CUDA
524529
using ..CUDA: i32
525530

526531

532+
## COV_EXCL_START
527533
# General functions
528534

529535
@inline two(::Type{Int}) = 2
@@ -882,7 +888,7 @@ function comparator_small_kernel(vals, length_vals::I, k::I, j_0::I, j_f::I,
882888
finalize_shmem!(slice, swap, index, in_range)
883889
return
884890
end
885-
891+
## COV_EXCL_STOP
886892

887893
# Host side code
888894
function bitonic_shmem(c::AbstractArray{T}, threads) where {T}

0 commit comments

Comments
 (0)