From 5f5c1e922770b3ce234ff1f61a2d61ce817489e9 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:08:14 -0300 Subject: [PATCH 1/9] Test appropriate backend in examples --- examples/memcopy.jl | 4 ++-- examples/memcopy_static.jl | 4 ++-- examples/performant_matmul.jl | 2 +- examples/utils.jl | 4 ++++ test/examples.jl | 3 ++- test/testsuite.jl | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/memcopy.jl b/examples/memcopy.jl index 3159f3670..0fe141041 100644 --- a/examples/memcopy.jl +++ b/examples/memcopy.jl @@ -16,8 +16,8 @@ function mycopy!(A, B) return end -A = KernelAbstractions.zeros(backend, Float64, 128, 128) -B = KernelAbstractions.ones(backend, Float64, 128, 128) +A = KernelAbstractions.zeros(backend, f_type, 128, 128) +B = KernelAbstractions.ones(backend, f_type, 128, 128) mycopy!(A, B) KernelAbstractions.synchronize(backend) @test A == B diff --git a/examples/memcopy_static.jl b/examples/memcopy_static.jl index 9f088294e..7c965c557 100644 --- a/examples/memcopy_static.jl +++ b/examples/memcopy_static.jl @@ -16,8 +16,8 @@ function mycopy_static!(A, B) return end -A = KernelAbstractions.zeros(backend, Float64, 128, 128) -B = KernelAbstractions.ones(backend, Float64, 128, 128) +A = KernelAbstractions.zeros(backend, f_type, 128, 128) +B = KernelAbstractions.ones(backend, f_type, 128, 128) mycopy_static!(A, B) KernelAbstractions.synchronize(backend) @test A == B diff --git a/examples/performant_matmul.jl b/examples/performant_matmul.jl index dbd5ad75a..3b274de5d 100644 --- a/examples/performant_matmul.jl +++ b/examples/performant_matmul.jl @@ -4,7 +4,7 @@ using Test using Random include(joinpath(dirname(pathof(KernelAbstractions)), "../examples/utils.jl")) # Load backend -const TILE_DIM = 32 +const TILE_DIM = 16 @kernel function coalesced_matmul_kernel!( output, @Const(input1), @Const(input2), N, R, M, diff --git a/examples/utils.jl b/examples/utils.jl index 5e93299b1..44d0a7ebb 100644 --- a/examples/utils.jl +++ b/examples/utils.jl @@ -1,4 +1,5 @@ # EXCLUDE FROM TESTING +if !(@isdefined backend) if Base.find_package("CUDA") !== nothing using CUDA using CUDA.CUDAKernels @@ -7,3 +8,6 @@ if Base.find_package("CUDA") !== nothing else const backend = CPU() end +end + +const f_type = KernelAbstractions.supports_float64(backend) ? Float64 : Float32 diff --git a/test/examples.jl b/test/examples.jl index 02374db89..d10f48d65 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -9,7 +9,7 @@ function find_sources(path::String, sources = String[]) return sources end -function examples_testsuite(backend_str) +function examples_testsuite(backend, backend_str) @testset "examples" begin examples_dir = joinpath(@__DIR__, "..", "examples") examples = find_sources(examples_dir) @@ -21,6 +21,7 @@ function examples_testsuite(backend_str) @testset "$(basename(example))" for example in examples @eval module $(gensym()) backend_str = $backend_str + const backend = ($backend)() include($example) end @test true diff --git a/test/testsuite.jl b/test/testsuite.jl index 29f780272..dd1f4629e 100644 --- a/test/testsuite.jl +++ b/test/testsuite.jl @@ -89,7 +89,7 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{ end @conditional_testset "Examples" skip_tests begin - examples_testsuite(backend_str) + examples_testsuite(backend, backend_str) end return From 2fc895c720fdb1925ba1606beabbc8f7102fe84d Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:08:46 -0300 Subject: [PATCH 2/9] Disable other tests for now --- test/runtests.jl | 12 ++++---- test/testsuite.jl | 72 +++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index f992afad2..5c7f41625 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -73,9 +73,9 @@ struct NewBackend <: KernelAbstractions.GPU end end -include("extensions/enzyme.jl") -@static if VERSION >= v"1.7.0" - @testset "Enzyme" begin - enzyme_testsuite(CPU, Array) - end -end +# include("extensions/enzyme.jl") +# @static if VERSION >= v"1.7.0" +# @testset "Enzyme" begin +# enzyme_testsuite(CPU, Array) +# end +# end diff --git a/test/testsuite.jl b/test/testsuite.jl index dd1f4629e..8efbd5624 100644 --- a/test/testsuite.jl +++ b/test/testsuite.jl @@ -40,53 +40,53 @@ include("convert.jl") include("specialfunctions.jl") function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{String}()) - @conditional_testset "Unittests" skip_tests begin - unittest_testsuite(backend, backend_str, backend_mod, DAT; skip_tests) - end + # @conditional_testset "Unittests" skip_tests begin + # unittest_testsuite(backend, backend_str, backend_mod, DAT; skip_tests) + # end - @conditional_testset "SpecialFunctions" skip_tests begin - specialfunctions_testsuite(backend) - end + # @conditional_testset "SpecialFunctions" skip_tests begin + # specialfunctions_testsuite(backend) + # end - @conditional_testset "Localmem" skip_tests begin - localmem_testsuite(backend, AT) - end + # @conditional_testset "Localmem" skip_tests begin + # localmem_testsuite(backend, AT) + # end - @conditional_testset "Private" skip_tests begin - private_testsuite(backend, AT) - end + # @conditional_testset "Private" skip_tests begin + # private_testsuite(backend, AT) + # end - @conditional_testset "Unroll" skip_tests begin - unroll_testsuite(backend, AT) - end + # @conditional_testset "Unroll" skip_tests begin + # unroll_testsuite(backend, AT) + # end - @testset "NDIteration" begin - nditeration_testsuite() - end + # @testset "NDIteration" begin + # nditeration_testsuite() + # end - @conditional_testset "copyto!" skip_tests begin - copyto_testsuite(backend, AT) - end + # @conditional_testset "copyto!" skip_tests begin + # copyto_testsuite(backend, AT) + # end - @conditional_testset "Devices" skip_tests begin - devices_testsuite(backend) - end + # @conditional_testset "Devices" skip_tests begin + # devices_testsuite(backend) + # end - @conditional_testset "Printing" skip_tests begin - printing_testsuite(backend) - end + # @conditional_testset "Printing" skip_tests begin + # printing_testsuite(backend) + # end - @conditional_testset "Compiler" skip_tests begin - compiler_testsuite(backend, AT) - end + # @conditional_testset "Compiler" skip_tests begin + # compiler_testsuite(backend, AT) + # end - @conditional_testset "Reflection" skip_tests begin - reflection_testsuite(backend, backend_str, AT) - end + # @conditional_testset "Reflection" skip_tests begin + # reflection_testsuite(backend, backend_str, AT) + # end - @conditional_testset "Convert" skip_tests begin - convert_testsuite(backend, AT) - end + # @conditional_testset "Convert" skip_tests begin + # convert_testsuite(backend, AT) + # end @conditional_testset "Examples" skip_tests begin examples_testsuite(backend, backend_str) From 5fea286c9d9673417262ce426a71b1f483a5e136 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:21:13 -0300 Subject: [PATCH 3/9] Show backend used --- examples/utils.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/utils.jl b/examples/utils.jl index 44d0a7ebb..970cc4433 100644 --- a/examples/utils.jl +++ b/examples/utils.jl @@ -10,4 +10,6 @@ else end end +@show backend, backend_str + const f_type = KernelAbstractions.supports_float64(backend) ? Float64 : Float32 From 945569f6485a684656205d3028370015ac448596 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:25:36 -0300 Subject: [PATCH 4/9] Undo some changes --- examples/utils.jl | 2 -- test/examples.jl | 3 +-- test/testsuite.jl | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/utils.jl b/examples/utils.jl index 970cc4433..3d2fa6ecf 100644 --- a/examples/utils.jl +++ b/examples/utils.jl @@ -1,5 +1,4 @@ # EXCLUDE FROM TESTING -if !(@isdefined backend) if Base.find_package("CUDA") !== nothing using CUDA using CUDA.CUDAKernels @@ -8,7 +7,6 @@ if Base.find_package("CUDA") !== nothing else const backend = CPU() end -end @show backend, backend_str diff --git a/test/examples.jl b/test/examples.jl index d10f48d65..02374db89 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -9,7 +9,7 @@ function find_sources(path::String, sources = String[]) return sources end -function examples_testsuite(backend, backend_str) +function examples_testsuite(backend_str) @testset "examples" begin examples_dir = joinpath(@__DIR__, "..", "examples") examples = find_sources(examples_dir) @@ -21,7 +21,6 @@ function examples_testsuite(backend, backend_str) @testset "$(basename(example))" for example in examples @eval module $(gensym()) backend_str = $backend_str - const backend = ($backend)() include($example) end @test true diff --git a/test/testsuite.jl b/test/testsuite.jl index 8efbd5624..858a33f1c 100644 --- a/test/testsuite.jl +++ b/test/testsuite.jl @@ -89,7 +89,7 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{ # end @conditional_testset "Examples" skip_tests begin - examples_testsuite(backend, backend_str) + examples_testsuite(backend_str) end return From 497ffc1429ee325f6d6ef256449e21eb3c28a343 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:36:18 -0300 Subject: [PATCH 5/9] Apply workaround --- .buildkite/pipeline.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 43999a1df..79a64866d 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -11,6 +11,7 @@ steps: - JuliaCI/julia-coverage#v1: codecov: true command: | + echo -e "[CUDA_Runtime_jll]\nlocal = \"true\"" >LocalPreferences.toml julia -e 'println("--- :julia: Instantiating project") using Pkg Pkg.develop(; path=pwd()) @@ -38,6 +39,7 @@ steps: - JuliaCI/julia-coverage#v1: codecov: true command: | + echo -e "[CUDA_Runtime_jll]\nlocal = \"true\"" >LocalPreferences.toml julia -e 'println("--- :julia: Instantiating project") using Pkg try @@ -70,6 +72,7 @@ steps: - JuliaCI/julia-coverage#v1: codecov: true command: | + echo -e "[CUDA_Runtime_jll]\nlocal = \"true\"" >LocalPreferences.toml julia -e 'println("--- :julia: Instantiating project") using Pkg Pkg.develop(; path=pwd()) From a482d60b214741e992ce6ea01874bb621639e2fc Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 15:50:58 -0300 Subject: [PATCH 6/9] Revert "Undo some changes" This reverts commit 945569f6485a684656205d3028370015ac448596. --- examples/utils.jl | 2 ++ test/examples.jl | 3 ++- test/testsuite.jl | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/utils.jl b/examples/utils.jl index 3d2fa6ecf..970cc4433 100644 --- a/examples/utils.jl +++ b/examples/utils.jl @@ -1,4 +1,5 @@ # EXCLUDE FROM TESTING +if !(@isdefined backend) if Base.find_package("CUDA") !== nothing using CUDA using CUDA.CUDAKernels @@ -7,6 +8,7 @@ if Base.find_package("CUDA") !== nothing else const backend = CPU() end +end @show backend, backend_str diff --git a/test/examples.jl b/test/examples.jl index 02374db89..d10f48d65 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -9,7 +9,7 @@ function find_sources(path::String, sources = String[]) return sources end -function examples_testsuite(backend_str) +function examples_testsuite(backend, backend_str) @testset "examples" begin examples_dir = joinpath(@__DIR__, "..", "examples") examples = find_sources(examples_dir) @@ -21,6 +21,7 @@ function examples_testsuite(backend_str) @testset "$(basename(example))" for example in examples @eval module $(gensym()) backend_str = $backend_str + const backend = ($backend)() include($example) end @test true diff --git a/test/testsuite.jl b/test/testsuite.jl index 858a33f1c..8efbd5624 100644 --- a/test/testsuite.jl +++ b/test/testsuite.jl @@ -89,7 +89,7 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{ # end @conditional_testset "Examples" skip_tests begin - examples_testsuite(backend_str) + examples_testsuite(backend, backend_str) end return From 4e5a6c3072270c9db48bed1b63c6e24bb9c1f92b Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 16:10:12 -0300 Subject: [PATCH 7/9] Use Int32 for histogram example --- examples/histogram.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/histogram.jl b/examples/histogram.jl index 958fa0e1d..8970cbea7 100644 --- a/examples/histogram.jl +++ b/examples/histogram.jl @@ -5,7 +5,7 @@ include(joinpath(dirname(pathof(KernelAbstractions)), "../examples/utils.jl")) # # Function to use as a baseline for CPU metrics function create_histogram(input) - histogram_output = zeros(Int, maximum(input)) + histogram_output = zeros(eltype(input), maximum(input)) for i in input histogram_output[i] += 1 end @@ -22,7 +22,7 @@ end @uniform gs = @groupsize()[1] @uniform N = length(histogram_output) - shared_histogram = @localmem Int (gs) + shared_histogram = @localmem eltype(input) (gs) # This will go through all input elements and assign them to a location in # shmem. Note that if there is not enough shem, we create different shmem @@ -77,9 +77,10 @@ end if Base.VERSION < v"1.7.0" && !KernelAbstractions.isgpu(backend) @test_skip false else - rand_input = [rand(1:128) for i in 1:1000] - linear_input = [i for i in 1:1024] - all_two = [2 for i in 1:512] + # Use Int32 as some backends don't support 64-bit atomics + rand_input = Int32[rand(1:128) for i in 1:1000] + linear_input = Int32[i for i in 1:1024] + all_two = Int32[2 for i in 1:512] histogram_rand_baseline = create_histogram(rand_input) histogram_linear_baseline = create_histogram(linear_input) @@ -89,9 +90,9 @@ end linear_input = move(backend, linear_input) all_two = move(backend, all_two) - rand_histogram = KernelAbstractions.zeros(backend, Int, 128) - linear_histogram = KernelAbstractions.zeros(backend, Int, 1024) - two_histogram = KernelAbstractions.zeros(backend, Int, 2) + rand_histogram = KernelAbstractions.zeros(backend, Int32, 128) + linear_histogram = KernelAbstractions.zeros(backend, Int32, 1024) + two_histogram = KernelAbstractions.zeros(backend, Int32, 2) histogram!(rand_histogram, rand_input) histogram!(linear_histogram, linear_input) From 2338e189a2e2e0704a6ae94a2c24dbc04ed370d9 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 2 May 2025 16:11:08 -0300 Subject: [PATCH 8/9] Oops --- .buildkite/pipeline.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 79a64866d..44a369866 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -72,7 +72,6 @@ steps: - JuliaCI/julia-coverage#v1: codecov: true command: | - echo -e "[CUDA_Runtime_jll]\nlocal = \"true\"" >LocalPreferences.toml julia -e 'println("--- :julia: Instantiating project") using Pkg Pkg.develop(; path=pwd()) From e2c6378a3960c50d73137e8b2f04189a58832b6b Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Wed, 14 May 2025 14:40:03 -0300 Subject: [PATCH 9/9] sdgse --- examples/utils.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/utils.jl b/examples/utils.jl index 970cc4433..44d0a7ebb 100644 --- a/examples/utils.jl +++ b/examples/utils.jl @@ -10,6 +10,4 @@ else end end -@show backend, backend_str - const f_type = KernelAbstractions.supports_float64(backend) ? Float64 : Float32