Skip to content

Commit b5b6991

Browse files
lkdvosclaude
andcommitted
Drop the coverage exclusions around GPU kernels and the @index workaround
The workaround for nested `@index` in the CPU backend of KernelAbstractions is no longer needed since KernelAbstractions v0.9.45 (JuliaGPU/KernelAbstractions.jl#877). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 607fe0c commit b5b6991

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

‎ext/TensorKitGPUArraysExt.jl‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ using TensorKit: SubblockIterator
1919
import TensorKit: randisometry, rand, randn, fill_braidingsubblock!, add_transform_kernel!, trace_transform_kernel!
2020

2121
function TensorKit.fill_braidingsubblock!(data::TD, val) where {T, TD <: Union{<:AnyGPUMatrix{T}, <:StridedViews.StridedView{T, 4, <:AnyGPUArray{T}}}}
22-
# COV_EXCL_START
23-
# kernels are not reachable by coverage
2422
@kernel function fill_subblock_kernel!(subblock, val)
2523
idx = @index(Global, Cartesian)
2624
idx_val = idx[1] == idx[4] && idx[2] == idx[3] ? val : zero(val)
2725
@inbounds subblock[idx] = idx_val
2826
end
29-
# COV_EXCL_STOP
3027
kernel = fill_subblock_kernel!(get_backend(data))
3128
kernel(data, val; ndrange = size(data))
3229
return data
@@ -469,9 +466,6 @@ function device_transformer(A, transformer::TraceTransformer, p, q)
469466
end
470467
end
471468

472-
# COV_EXCL_START
473-
# kernels are not reachable by coverage
474-
475469
# largest `i` with `offsets[i] <= w`. This corresponds to the
476470
# block which this kernel thread will work on. Since this is
477471
# used inside a GPU kernel, searchsortedlast/searchsortedfirst
@@ -510,9 +504,7 @@ end
510504
@kernel function unique_batched_permute_kernel!(
511505
data_dst, data_src, op, blocks, work_offsets, α, β, nwork, ::Val{N}
512506
) where {N}
513-
# w = @index(Global, Linear) - 1 does not work due to JLArrays bug
514-
w = @index(Global, Linear)
515-
w -= 1
507+
w = @index(Global, Linear) - 1
516508
if w < nwork
517509
b = _searchblock(work_offsets, w)
518510
blk = @inbounds blocks[b]
@@ -523,8 +515,6 @@ end
523515
end
524516
end
525517

526-
# COV_EXCL_STOP
527-
528518
# One thread per destination element in `data_dst`. This makes much better use of the
529519
# GPU "massive parallelism" as compared to the one-thread-per-subtransformer approach.
530520
# It also more evenly divides the work among threads so the work profile is less
@@ -537,9 +527,7 @@ end
537527
data_dst, data_src, op, blocks, work_offsets, coeffs, structs_dst, structs_src,
538528
α, β, nwork, ::Val{N}
539529
) where {N}
540-
# w = @index(Global, Linear) - 1 does not work due to JLArrays bug
541-
w = @index(Global, Linear)
542-
w -= 1
530+
w = @index(Global, Linear) - 1
543531
if w < nwork
544532
# bookkeeping to figure out where to read from and write to
545533
b = _searchblock(work_offsets, w)
@@ -568,13 +556,10 @@ end
568556
end
569557
end
570558

571-
# COV_EXCL_START
572559
# First stage: one thread per (chunk, remaining entry) of every source subblock, writing its
573560
# partial trace to `partials[w + 1]`. Consecutive threads handle consecutive remaining entries.
574561
@kernel function partial_trace_kernel!(partials, data_src, sources, partial_offsets, npartials)
575-
# w = @index(Global, Linear) - 1 does not work due to JLArrays bug
576-
w = @index(Global, Linear)
577-
w -= 1
562+
w = @index(Global, Linear) - 1
578563
if w < npartials
579564
j = _searchblock(partial_offsets, w)
580565
src = @inbounds sources[j]
@@ -598,8 +583,7 @@ end
598583
data_dst, partials, blocks, work_offsets, coeffs, structs_dst, sources, partial_offsets,
599584
α, β, nwork
600585
)
601-
w = @index(Global, Linear)
602-
w -= 1
586+
w = @index(Global, Linear) - 1
603587
if w < nwork
604588
b = _searchblock(work_offsets, w)
605589
blk = @inbounds blocks[b]
@@ -627,7 +611,6 @@ end
627611
@inbounds data_dst[i_dst] = iszero(β) ? α * acc : α * acc + β * data_dst[i_dst]
628612
end
629613
end
630-
# COV_EXCL_STOP
631614

632615
function _launch_unique!(data_dst, data_src, op, transformer, α, β, ::Val{N}) where {N}
633616
nwork = transformer.nwork

0 commit comments

Comments
 (0)