Skip to content

[Do not merge] Test KernelIntrinsics#2944

Open
christiangnrd wants to merge 7 commits into
JuliaGPU:mainfrom
christiangnrd:intrinsics
Open

[Do not merge] Test KernelIntrinsics#2944
christiangnrd wants to merge 7 commits into
JuliaGPU:mainfrom
christiangnrd:intrinsics

Conversation

@christiangnrd

Copy link
Copy Markdown
Member

[only tests]
[only benchmarks]

@github-actions

github-actions Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/CUDAKernels.jl b/src/CUDAKernels.jl
index 5e39ab68e..7f8ec7ad4 100644
--- a/src/CUDAKernels.jl
+++ b/src/CUDAKernels.jl
@@ -162,29 +162,29 @@ end
 
 KI.argconvert(::CUDABackend, arg) = cudaconvert(arg)
 
-function KI.kernel_function(::CUDABackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
+function KI.kernel_function(::CUDABackend, f::F, tt::TT = Tuple{}; name = nothing, kwargs...) where {F, TT}
     kern = cufunction(f, tt; name, kwargs...)
-    KI.Kernel{CUDABackend, typeof(kern)}(CUDABackend(), kern)
+    return KI.Kernel{CUDABackend, typeof(kern)}(CUDABackend(), kern)
 end
 
 function (obj::KI.Kernel{CUDABackend})(args...; numworkgroups = 1, workgroupsize = 1)
     KI.check_launch_args(numworkgroups, workgroupsize)
 
-    obj.kern(args...; threads=workgroupsize, blocks=numworkgroups)
+    obj.kern(args...; threads = workgroupsize, blocks = numworkgroups)
     return nothing
 end
 
 
-function KI.kernel_max_work_group_size(kernel::KI.Kernel{<:CUDABackend}; max_work_items::Int=typemax(Int))::Int
+function KI.kernel_max_work_group_size(kernel::KI.Kernel{<:CUDABackend}; max_work_items::Int = typemax(Int))::Int
     kernel_config = launch_configuration(kernel.kern.fun)
 
-    Int(min(kernel_config.threads, max_work_items))
+    return Int(min(kernel_config.threads, max_work_items))
 end
 function KI.max_work_group_size(::CUDABackend)::Int
-    Int(attribute(device(), CUDA.DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK))
+    return Int(attribute(device(), CUDA.DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK))
 end
 function KI.multiprocessor_count(::CUDABackend)::Int
-    Int(attribute(device(), CUDA.DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT))
+    return Int(attribute(device(), CUDA.DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT))
 end
 
 ## indexing
@@ -199,7 +199,7 @@ end
 end
 
 @device_override @inline function KI.get_global_id()
-    return (; x = Int((blockIdx().x-1)*blockDim().x + threadIdx().x), y = Int((blockIdx().y-1)*blockDim().y + threadIdx().y), z = Int((blockIdx().z-1)*blockDim().z + threadIdx().z))
+    return (; x = Int((blockIdx().x - 1) * blockDim().x + threadIdx().x), y = Int((blockIdx().y - 1) * blockDim().y + threadIdx().y), z = Int((blockIdx().z - 1) * blockDim().z + threadIdx().z))
 end
 
 @device_override @inline function KI.get_local_size()
diff --git a/src/accumulate.jl b/src/accumulate.jl
index 54fab2119..e0631d387 100644
--- a/src/accumulate.jl
+++ b/src/accumulate.jl
@@ -22,9 +22,9 @@ function partial_scan(op::Function, output::AbstractArray{T}, input::AbstractArr
     temp = CuDynamicSharedArray(T, (2*threads,))
 
     # iterate the main dimension using threads and the first block dimension
-    i = (KI.get_group_id().x-1i32) * KI.get_local_size().x + KI.get_local_id().x
+    i = (KI.get_group_id().x - 1i32) * KI.get_local_size().x + KI.get_local_id().x
     # iterate the other dimensions using the remaining block dimensions
-    j = (KI.get_group_id().z-1i32) * KI.get_num_groups().y + KI.get_group_id().y
+    j = (KI.get_group_id().z - 1i32) * KI.get_num_groups().y + KI.get_group_id().y
 
     if j > length(Rother)
         return
@@ -105,9 +105,9 @@ function aggregate_partial_scan(op::Function, output::AbstractArray,
     block = KI.get_group_id().x
 
     # iterate the main dimension using threads and the first block dimension
-    i = (KI.get_group_id().x-1i32) * KI.get_local_size().x + KI.get_local_id().x
+    i = (KI.get_group_id().x - 1i32) * KI.get_local_size().x + KI.get_local_id().x
     # iterate the other dimensions using the remaining block dimensions
-    j = (KI.get_group_id().z-1i32) * KI.get_num_groups().y + KI.get_group_id().y
+    j = (KI.get_group_id().z - 1i32) * KI.get_num_groups().y + KI.get_group_id().y
 
     @inbounds if i <= length(Rdim) && j <= length(Rother)
         I = Rother[j]
diff --git a/src/device/random.jl b/src/device/random.jl
index 7d72d90a1..063c736ed 100644
--- a/src/device/random.jl
+++ b/src/device/random.jl
@@ -73,8 +73,8 @@ end
         @inbounds global_random_counters()[warpId]
     elseif field === :ctr2
         globalId = KI.get_global_id().x +
-                   (KI.get_global_id().y - 1i32) * KI.get_global_size().x +
-                   (KI.get_global_id().z - 1i32) * KI.get_global_size().x * KI.get_global_size().y
+            (KI.get_global_id().y - 1i32) * KI.get_global_size().x +
+            (KI.get_global_id().z - 1i32) * KI.get_global_size().x * KI.get_global_size().y
         globalId%UInt32
     end::UInt32
 end
diff --git a/src/mapreduce.jl b/src/mapreduce.jl
index 97a4176b4..6fccff91e 100644
--- a/src/mapreduce.jl
+++ b/src/mapreduce.jl
@@ -294,8 +294,9 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::AnyCuArray{T},
         end
 
         partial_kernel(f, op, init, Rreduce, Rother, Val(shuffle), partial, A;
-                    threads=partial_threads, blocks=partial_blocks, shmem=partial_shmem)
-                    # workgroupsize=partial_threads, numworkgroups=partial_blocks, shmem=partial_shmem)
+            threads = partial_threads, blocks = partial_blocks, shmem = partial_shmem
+        )
+        # workgroupsize=partial_threads, numworkgroups=partial_blocks, shmem=partial_shmem)
 
         GPUArrays.mapreducedim!(identity, op, R, partial; init)
     end
diff --git a/test/base/kernelabstractions.jl b/test/base/kernelabstractions.jl
index 2f2c4300b..1e674d3be 100644
--- a/test/base/kernelabstractions.jl
+++ b/test/base/kernelabstractions.jl
@@ -4,9 +4,14 @@ using SparseArrays
 
 include(joinpath(dirname(pathof(KernelAbstractions)), "..", "test", "testsuite.jl"))
 
-Testsuite.testsuite(()->CUDABackend(false, false), "CUDA", CUDA, CuArray, CuDeviceArray; skip_tests=Set([
-    "CPU synchronization",
-    "fallback test: callable types",]))
+Testsuite.testsuite(
+    () -> CUDABackend(false, false), "CUDA", CUDA, CuArray, CuDeviceArray; skip_tests = Set(
+        [
+            "CPU synchronization",
+            "fallback test: callable types",
+        ]
+    )
+)
 for (PreferBlocks, AlwaysInline) in Iterators.product((true, false), (true, false))
     Testsuite.unittest_testsuite(()->CUDABackend(PreferBlocks, AlwaysInline), "CUDA", CUDA, CuDeviceArray)
 end
diff --git a/test/runtests.jl b/test/runtests.jl
index 802c832e5..11584ca92 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,6 +1,6 @@
 @static if VERSION < v"1.11" && get(ENV, "BUILDKITE_PIPELINE_NAME", "CUDA.jl") == "CUDA.jl"
     using Pkg
-    Pkg.add(url="https://github.com/JuliaGPU/KernelAbstractions.jl", rev="main")
+    Pkg.add(url = "https://github.com/JuliaGPU/KernelAbstractions.jl", rev = "main")
 end
 
 using Distributed

Comment thread src/mapreduce.jl Outdated
Comment thread src/mapreduce.jl Outdated
Comment thread src/CUDAKernels.jl Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CUDA.jl Benchmarks

Details
Benchmark suite Current: 2e7c994 Previous: fbb9098 Ratio
array/accumulate/Float32/1d 100136 ns 98020 ns 1.02
array/accumulate/Float32/dims=1 74958 ns 73968 ns 1.01
array/accumulate/Float32/dims=1L 1631537 ns 1598577 ns 1.02
array/accumulate/Float32/dims=2 139754 ns 139829 ns 1.00
array/accumulate/Float32/dims=2L 664739 ns 660479 ns 1.01
array/accumulate/Int64/1d 118892 ns 118236 ns 1.01
array/accumulate/Int64/dims=1 79762 ns 78818 ns 1.01
array/accumulate/Int64/dims=1L 1745959 ns 1717142 ns 1.02
array/accumulate/Int64/dims=2 155075 ns 151913 ns 1.02
array/accumulate/Int64/dims=2L 987375 ns 987639 ns 1.00
array/broadcast 19008 ns 18185 ns 1.05
array/construct 897.9 ns 900.1904761904761 ns 1.00
array/copy 16063 ns 16081 ns 1.00
array/copyto!/cpu_to_gpu 208640 ns 210623 ns 0.99
array/copyto!/gpu_to_cpu 241080 ns 242406 ns 0.99
array/copyto!/gpu_to_gpu 9847 ns 8883.666666666666 ns 1.11
array/iteration/findall/bool 132942 ns 132352 ns 1.00
array/iteration/findall/int 146162 ns 146447 ns 1.00
array/iteration/findfirst/bool 68025 ns 67784 ns 1.00
array/iteration/findfirst/int 69669 ns 69220 ns 1.01
array/iteration/findmin/1d 63892 ns 62612 ns 1.02
array/iteration/findmin/2d 100230 ns 99990 ns 1.00
array/iteration/logical 189337 ns 186900 ns 1.01
array/iteration/scalar 63169 ns 62246 ns 1.01
array/permutedims/2d 49271 ns 49143 ns 1.00
array/permutedims/3d 51982 ns 49912 ns 1.04
array/permutedims/4d 54559 ns 50252 ns 1.09
array/random/rand/Float32 11779 ns 10722 ns 1.10
array/random/rand/Int64 22985 ns 20792 ns 1.11
array/random/rand!/Float32 7710.25 ns 7728 ns 1.00
array/random/rand!/Int64 18105 ns 20553 ns 0.88
array/random/randn/Float32 32991 ns 33301 ns 0.99
array/random/randn!/Float32 23238 ns 24939 ns 0.93
array/reductions/mapreduce/Float32/1d 32051 ns 31290 ns 1.02
array/reductions/mapreduce/Float32/dims=1 40230 ns 37312 ns 1.08
array/reductions/mapreduce/Float32/dims=1L 50153 ns 50036 ns 1.00
array/reductions/mapreduce/Float32/dims=2 59204 ns 54292 ns 1.09
array/reductions/mapreduce/Float32/dims=2L 68355 ns 65880 ns 1.04
array/reductions/mapreduce/Int64/1d 39690 ns 39323 ns 1.01
array/reductions/mapreduce/Int64/dims=1 44307 ns 40145 ns 1.10
array/reductions/mapreduce/Int64/dims=1L 88124 ns 87779 ns 1.00
array/reductions/mapreduce/Int64/dims=2 64626 ns 57093 ns 1.13
array/reductions/mapreduce/Int64/dims=2L 85416 ns 82500 ns 1.04
array/reductions/reduce/Float32/1d 32037 ns 31207 ns 1.03
array/reductions/reduce/Float32/dims=1 40461 ns 37284 ns 1.09
array/reductions/reduce/Float32/dims=1L 49846 ns 50034 ns 1.00
array/reductions/reduce/Float32/dims=2 58804 ns 54677 ns 1.08
array/reductions/reduce/Float32/dims=2L 69093 ns 67287 ns 1.03
array/reductions/reduce/Int64/1d 39093 ns 38695 ns 1.01
array/reductions/reduce/Int64/dims=1 44297 ns 39938 ns 1.11
array/reductions/reduce/Int64/dims=1L 88231 ns 87933 ns 1.00
array/reductions/reduce/Int64/dims=2 64577 ns 56801 ns 1.14
array/reductions/reduce/Int64/dims=2L 84719 ns 82417 ns 1.03
array/reverse/1d 16309 ns 16212 ns 1.01
array/reverse/1dL 69042 ns 69012 ns 1.00
array/reverse/1dL_inplace 66983 ns 66891 ns 1.00
array/reverse/1d_inplace 9577.333333333334 ns 9703.666666666666 ns 0.99
array/reverse/2d 19619 ns 19393 ns 1.01
array/reverse/2dL 72912 ns 72842 ns 1.00
array/reverse/2dL_inplace 66835 ns 66766 ns 1.00
array/reverse/2d_inplace 10363 ns 10134 ns 1.02
array/sorting/1d 2658417 ns 2658542 ns 1.00
array/sorting/2d 1039100 ns 1039211 ns 1.00
array/sorting/by 3194272 ns 3193897 ns 1.00
cuda/synchronization/context/auto 1075.3 ns 1040 ns 1.03
cuda/synchronization/context/blocking 813.2222222222222 ns 795.5444444444445 ns 1.02
cuda/synchronization/context/nonblocking 5741 ns 5738.666666666667 ns 1.00
cuda/synchronization/stream/auto 927.483870967742 ns 889.2083333333334 ns 1.04
cuda/synchronization/stream/blocking 695.6095890410959 ns 676.8387096774194 ns 1.03
cuda/synchronization/stream/nonblocking 5409 ns 5562.285714285715 ns 0.97
integration/byval/reference 147391 ns 147385 ns 1.00
integration/byval/slices=1 149295 ns 149634 ns 1.00
integration/byval/slices=2 292146 ns 292176 ns 1.00
integration/byval/slices=3 434924 ns 435096 ns 1.00
integration/cudadevrt 104399 ns 104391 ns 1.00
integration/volumerhs 9311191 ns 9304645 ns 1.00
kernel/indexing 12529 ns 12267 ns 1.02
kernel/indexing_checked 13393 ns 13063 ns 1.03
kernel/launch 2014.888888888889 ns 1980.4 ns 1.02
kernel/occupancy 650.9285714285714 ns 638.797619047619 ns 1.02
kernel/rand 13685 ns 14927 ns 0.92
latency/import 3976654766 ns 3890391684 ns 1.02
latency/precompile 4745040524 ns 4668709973 ns 1.02
latency/ttfp 4939834474 ns 4883527794 ns 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.80%. Comparing base (f36a98c) to head (f9ec011).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2944      +/-   ##
==========================================
+ Coverage   16.88%   17.80%   +0.92%     
==========================================
  Files         124      124              
  Lines        9886     9886              
==========================================
+ Hits         1669     1760      +91     
+ Misses       8217     8126      -91     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant