From 27a02e6c92e357373c271fcace32d5a637a92b92 Mon Sep 17 00:00:00 2001 From: anicusan Date: Mon, 11 Nov 2024 14:10:46 +0000 Subject: [PATCH 01/11] refactored CUDA, Metal and oneAPI backends into extensions. Refactored tests into simpler files. Added oneAPI backend. Added tests for extension finding. --- Project.toml | 15 +- docs/Project.toml | 3 +- docs/make.jl | 18 ++- docs/make_local.jl | 5 + .../src/AtomixCUDA.jl => ext/AtomixCUDAExt.jl | 4 +- .../AtomixMetal.jl => ext/AtomixMetalExt.jl | 4 +- ext/AtomixoneAPIExt.jl | 58 +++++++ lib/AtomixCUDA/.gitignore | 2 - lib/AtomixCUDA/LICENSE | 21 --- lib/AtomixCUDA/Project.toml | 13 -- lib/AtomixCUDA/README.md | 1 - .../test/AtomixCUDATests/Project.toml | 13 -- .../AtomixCUDATests/src/AtomixCUDATests.jl | 7 - .../test/AtomixCUDATests/src/test_sugar.jl | 36 ----- .../test/AtomixCUDATests/src/utils.jl | 13 -- lib/AtomixCUDA/test/Project.toml | 6 - lib/AtomixCUDA/test/runtests.jl | 2 - lib/AtomixMetal/LICENSE | 21 --- lib/AtomixMetal/Project.toml | 13 -- lib/AtomixMetal/README.md | 1 - .../test/AtomixMetalTests/Project.toml | 13 -- .../AtomixMetalTests/src/AtomixMetalTests.jl | 7 - .../test/AtomixMetalTests/src/test_sugar.jl | 36 ----- .../test/AtomixMetalTests/src/utils.jl | 13 -- lib/AtomixMetal/test/Project.toml | 6 - lib/AtomixMetal/test/runtests.jl | 2 - test/AtomixTests/Project.toml | 13 -- test/AtomixTests/src/AtomixTests.jl | 11 -- test/AtomixTests/src/test_core.jl | 35 ----- test/AtomixTests/src/test_doctest.jl | 11 -- test/AtomixTests/src/test_fallback.jl | 34 ---- test/AtomixTests/src/test_sugar.jl | 63 -------- test/Project.toml | 7 +- test/runtests.jl | 148 +++++++++++++++++- .../test_core.jl => test/test_atomix_cuda.jl | 38 +++-- .../test_core.jl => test/test_atomix_metal.jl | 38 +++-- test/test_atomix_oneapi.jl | 81 ++++++++++ 37 files changed, 378 insertions(+), 434 deletions(-) create mode 100644 docs/make_local.jl rename lib/AtomixCUDA/src/AtomixCUDA.jl => ext/AtomixCUDAExt.jl (96%) rename lib/AtomixMetal/src/AtomixMetal.jl => ext/AtomixMetalExt.jl (96%) create mode 100644 ext/AtomixoneAPIExt.jl delete mode 100644 lib/AtomixCUDA/.gitignore delete mode 100644 lib/AtomixCUDA/LICENSE delete mode 100644 lib/AtomixCUDA/Project.toml delete mode 100644 lib/AtomixCUDA/README.md delete mode 100644 lib/AtomixCUDA/test/AtomixCUDATests/Project.toml delete mode 100644 lib/AtomixCUDA/test/AtomixCUDATests/src/AtomixCUDATests.jl delete mode 100644 lib/AtomixCUDA/test/AtomixCUDATests/src/test_sugar.jl delete mode 100644 lib/AtomixCUDA/test/AtomixCUDATests/src/utils.jl delete mode 100644 lib/AtomixCUDA/test/Project.toml delete mode 100644 lib/AtomixCUDA/test/runtests.jl delete mode 100644 lib/AtomixMetal/LICENSE delete mode 100644 lib/AtomixMetal/Project.toml delete mode 100644 lib/AtomixMetal/README.md delete mode 100644 lib/AtomixMetal/test/AtomixMetalTests/Project.toml delete mode 100644 lib/AtomixMetal/test/AtomixMetalTests/src/AtomixMetalTests.jl delete mode 100644 lib/AtomixMetal/test/AtomixMetalTests/src/test_sugar.jl delete mode 100644 lib/AtomixMetal/test/AtomixMetalTests/src/utils.jl delete mode 100644 lib/AtomixMetal/test/Project.toml delete mode 100644 lib/AtomixMetal/test/runtests.jl delete mode 100644 test/AtomixTests/Project.toml delete mode 100644 test/AtomixTests/src/AtomixTests.jl delete mode 100644 test/AtomixTests/src/test_core.jl delete mode 100644 test/AtomixTests/src/test_doctest.jl delete mode 100644 test/AtomixTests/src/test_fallback.jl delete mode 100644 test/AtomixTests/src/test_sugar.jl rename lib/AtomixCUDA/test/AtomixCUDATests/src/test_core.jl => test/test_atomix_cuda.jl (69%) rename lib/AtomixMetal/test/AtomixMetalTests/src/test_core.jl => test/test_atomix_metal.jl (69%) create mode 100644 test/test_atomix_oneapi.jl diff --git a/Project.toml b/Project.toml index 38aa10e..8caa5e6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,11 +1,24 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "1.0" +version = "0.1.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" +[weakdeps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +Metal = "dde4c033-4e86-420c-a63e-0dd931031962" +oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" + +[extensions] +AtomixCUDAExt = "CUDA" +AtomixMetalExt = "Metal" +AtomixoneAPIExt = "oneAPI" + [compat] UnsafeAtomics = "0.1, 0.2" +CUDA = "5" +Metal = "1" +oneAPI = "1" julia = "1.6" diff --git a/docs/Project.toml b/docs/Project.toml index bbd3304..c19204d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] +Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" [compat] -Documenter = "1.7" +Documenter = "1" diff --git a/docs/make.jl b/docs/make.jl index 7627915..42427db 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,14 +1,18 @@ using Documenter using Atomix -makedocs( - sitename = "Atomix", - modules = [Atomix], - warnonly = :missing_docs +makedocs(; + sitename="Atomix", + modules=[Atomix], + format=Documenter.HTML(; + # Only create web pretty-URLs on the CI + prettyurls=get(ENV, "CI", nothing) == "true", + ), + warnonly=:missing_docs, ) deploydocs( - repo = "github.com/JuliaConcurrent/Atomix.jl", - devbranch = "main", - push_preview = true, + repo="github.com/JuliaConcurrent/Atomix.jl", + devbranch="main", + push_preview=true, ) diff --git a/docs/make_local.jl b/docs/make_local.jl new file mode 100644 index 0000000..2068806 --- /dev/null +++ b/docs/make_local.jl @@ -0,0 +1,5 @@ +# Activate docs environment and use ("develop") local library +using Pkg +Pkg.activate(@__DIR__) +Pkg.develop(path=joinpath(@__DIR__, "..")) +include("make.jl") diff --git a/lib/AtomixCUDA/src/AtomixCUDA.jl b/ext/AtomixCUDAExt.jl similarity index 96% rename from lib/AtomixCUDA/src/AtomixCUDA.jl rename to ext/AtomixCUDAExt.jl index 4b433c1..5a79d62 100644 --- a/lib/AtomixCUDA/src/AtomixCUDA.jl +++ b/ext/AtomixCUDAExt.jl @@ -1,5 +1,5 @@ # TODO: respect ordering -module AtomixCUDA +module AtomixCUDAExt using Atomix: Atomix, IndexableRef using CUDA: CUDA, CuDeviceArray @@ -55,4 +55,4 @@ end return old => op(old, x) end -end # module AtomixCUDA +end # module AtomixCUDAExt diff --git a/lib/AtomixMetal/src/AtomixMetal.jl b/ext/AtomixMetalExt.jl similarity index 96% rename from lib/AtomixMetal/src/AtomixMetal.jl rename to ext/AtomixMetalExt.jl index 8a76279..7df0bb6 100644 --- a/lib/AtomixMetal/src/AtomixMetal.jl +++ b/ext/AtomixMetalExt.jl @@ -1,5 +1,5 @@ # TODO: respect ordering -module AtomixMetal +module AtomixMetalExt using Atomix: Atomix, IndexableRef using Metal: Metal, MtlDeviceArray @@ -55,4 +55,4 @@ end return old => op(old, x) end -end # module AtomixMetal +end # module AtomixMetalExt diff --git a/ext/AtomixoneAPIExt.jl b/ext/AtomixoneAPIExt.jl new file mode 100644 index 0000000..1866a69 --- /dev/null +++ b/ext/AtomixoneAPIExt.jl @@ -0,0 +1,58 @@ +# TODO: respect ordering +module AtomixoneAPIExt + +using Atomix: Atomix, IndexableRef +using oneAPI: oneAPI, oneDeviceArray + +const oneIndexableRef{Indexable<:oneDeviceArray} = IndexableRef{Indexable} + +function Atomix.get(ref::oneIndexableRef, order) + error("not implemented") +end + +function Atomix.set!(ref::oneIndexableRef, v, order) + error("not implemented") +end + +@inline function Atomix.replace!( + ref::oneIndexableRef, + expected, + desired, + success_ordering, + failure_ordering, +) + ptr = Atomix.pointer(ref) + expected = convert(eltype(ref), expected) + desired = convert(eltype(ref), desired) + begin + old = oneAPI.atomic_cmpxchg!(ptr, expected, desired) + end + return (; old = old, success = old === expected) +end + +@inline function Atomix.modify!(ref::oneIndexableRef, op::OP, x, order) where {OP} + x = convert(eltype(ref), x) + ptr = Atomix.pointer(ref) + begin + old = if op === (+) + oneAPI.atomic_add!(ptr, x) + elseif op === (-) + oneAPI.atomic_sub!(ptr, x) + elseif op === (&) + oneAPI.atomic_and!(ptr, x) + elseif op === (|) + oneAPI.atomic_or!(ptr, x) + elseif op === xor + oneAPI.atomic_xor!(ptr, x) + elseif op === min + oneAPI.atomic_min!(ptr, x) + elseif op === max + oneAPI.atomic_max!(ptr, x) + else + error("not implemented") + end + end + return old => op(old, x) +end + +end # module AtomixoneAPIExt diff --git a/lib/AtomixCUDA/.gitignore b/lib/AtomixCUDA/.gitignore deleted file mode 100644 index 4fc6527..0000000 --- a/lib/AtomixCUDA/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Manifest.toml - diff --git a/lib/AtomixCUDA/LICENSE b/lib/AtomixCUDA/LICENSE deleted file mode 100644 index 02e1d79..0000000 --- a/lib/AtomixCUDA/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Takafumi Arakaki and contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/lib/AtomixCUDA/Project.toml b/lib/AtomixCUDA/Project.toml deleted file mode 100644 index 2f93523..0000000 --- a/lib/AtomixCUDA/Project.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "AtomixCUDA" -uuid = "6171a885-8764-404f-b64d-f8edb1679b6f" -authors = ["Takafumi Arakaki and contributors"] -version = "1.0" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" - -[compat] -julia = "1.6" -Atomix = "1" -CUDA = "5" diff --git a/lib/AtomixCUDA/README.md b/lib/AtomixCUDA/README.md deleted file mode 100644 index 4789416..0000000 --- a/lib/AtomixCUDA/README.md +++ /dev/null @@ -1 +0,0 @@ -# AtomixCUDA diff --git a/lib/AtomixCUDA/test/AtomixCUDATests/Project.toml b/lib/AtomixCUDA/test/AtomixCUDATests/Project.toml deleted file mode 100644 index dcb7605..0000000 --- a/lib/AtomixCUDA/test/AtomixCUDATests/Project.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "AtomixCUDATests" -uuid = "210b840b-8615-4854-b591-ce0d4815b014" -authors = ["Takafumi Arakaki and contributors"] -version = "0.1.0-DEV" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -AtomixCUDA = "6171a885-8764-404f-b64d-f8edb1679b6f" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -julia = "1.6" diff --git a/lib/AtomixCUDA/test/AtomixCUDATests/src/AtomixCUDATests.jl b/lib/AtomixCUDA/test/AtomixCUDATests/src/AtomixCUDATests.jl deleted file mode 100644 index b472702..0000000 --- a/lib/AtomixCUDA/test/AtomixCUDATests/src/AtomixCUDATests.jl +++ /dev/null @@ -1,7 +0,0 @@ -module AtomixCUDATests - -include("utils.jl") -include("test_core.jl") -include("test_sugar.jl") - -end # module AtomixCUDATests diff --git a/lib/AtomixCUDA/test/AtomixCUDATests/src/test_sugar.jl b/lib/AtomixCUDA/test/AtomixCUDATests/src/test_sugar.jl deleted file mode 100644 index ad19aba..0000000 --- a/lib/AtomixCUDA/test/AtomixCUDATests/src/test_sugar.jl +++ /dev/null @@ -1,36 +0,0 @@ -module TestSugar - -import AtomixCUDA - -using Atomix: @atomic -using CUDA -using CUDA: @allowscalar -using Test - -using ..Utils: cuda - -# Not implemented: -#= -function test_get_set() - A = CUDA.ones(Int, 3) - cuda() do - GC.@preserve A begin - x = @atomic A[begin] - @atomic A[end-2] = -x - end - end - @test collect(A) == [-1, 1, 1] -end -=# - -function test_inc() - A = CUDA.ones(Int, 3) - cuda() do - GC.@preserve A begin - @atomic A[begin] += 1 - end - end - @test collect(A) == [2, 1, 1] -end - -end # module diff --git a/lib/AtomixCUDA/test/AtomixCUDATests/src/utils.jl b/lib/AtomixCUDA/test/AtomixCUDATests/src/utils.jl deleted file mode 100644 index e9faf60..0000000 --- a/lib/AtomixCUDA/test/AtomixCUDATests/src/utils.jl +++ /dev/null @@ -1,13 +0,0 @@ -module Utils - -using CUDA - -function cuda(f) - function g() - f() - nothing - end - CUDA.@cuda g() -end - -end # module diff --git a/lib/AtomixCUDA/test/Project.toml b/lib/AtomixCUDA/test/Project.toml deleted file mode 100644 index 77d6950..0000000 --- a/lib/AtomixCUDA/test/Project.toml +++ /dev/null @@ -1,6 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d" - -[compat] -TestFunctionRunner = "0.1" diff --git a/lib/AtomixCUDA/test/runtests.jl b/lib/AtomixCUDA/test/runtests.jl deleted file mode 100644 index d358b79..0000000 --- a/lib/AtomixCUDA/test/runtests.jl +++ /dev/null @@ -1,2 +0,0 @@ -using TestFunctionRunner -TestFunctionRunner.@run diff --git a/lib/AtomixMetal/LICENSE b/lib/AtomixMetal/LICENSE deleted file mode 100644 index 02e1d79..0000000 --- a/lib/AtomixMetal/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Takafumi Arakaki and contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/lib/AtomixMetal/Project.toml b/lib/AtomixMetal/Project.toml deleted file mode 100644 index 408b31e..0000000 --- a/lib/AtomixMetal/Project.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "AtomixMetal" -uuid = "fc0d88fc-5db5-40d7-bf35-da84fd759def" -authors = ["Andrei-Leonard Nicusan and contributors"] -version = "1.0" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -Metal = "dde4c033-4e86-420c-a63e-0dd931031962" - -[compat] -julia = "1.6" -Atomix = "1" -Metal = "1" diff --git a/lib/AtomixMetal/README.md b/lib/AtomixMetal/README.md deleted file mode 100644 index 761f883..0000000 --- a/lib/AtomixMetal/README.md +++ /dev/null @@ -1 +0,0 @@ -# AtomixMetal \ No newline at end of file diff --git a/lib/AtomixMetal/test/AtomixMetalTests/Project.toml b/lib/AtomixMetal/test/AtomixMetalTests/Project.toml deleted file mode 100644 index 243a1a7..0000000 --- a/lib/AtomixMetal/test/AtomixMetalTests/Project.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "AtomixMetalTests" -uuid = "03c00b03-d8de-4838-97ce-ef69879af46e" -authors = ["Andrei-Leonard Nicusan and contributors"] -version = "0.1.0-DEV" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -AtomixMetal = "fc0d88fc-5db5-40d7-bf35-da84fd759def" -Metal = "dde4c033-4e86-420c-a63e-0dd931031962" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -julia = "1.6" diff --git a/lib/AtomixMetal/test/AtomixMetalTests/src/AtomixMetalTests.jl b/lib/AtomixMetal/test/AtomixMetalTests/src/AtomixMetalTests.jl deleted file mode 100644 index 8ee7760..0000000 --- a/lib/AtomixMetal/test/AtomixMetalTests/src/AtomixMetalTests.jl +++ /dev/null @@ -1,7 +0,0 @@ -module AtomixMetalTests - -include("utils.jl") -include("test_core.jl") -include("test_sugar.jl") - -end # module AtomixMetalTests diff --git a/lib/AtomixMetal/test/AtomixMetalTests/src/test_sugar.jl b/lib/AtomixMetal/test/AtomixMetalTests/src/test_sugar.jl deleted file mode 100644 index 97363b8..0000000 --- a/lib/AtomixMetal/test/AtomixMetalTests/src/test_sugar.jl +++ /dev/null @@ -1,36 +0,0 @@ -module TestSugar - -import AtomixMetal - -using Atomix: @atomic -using Metal -using Metal: @allowscalar -using Test - -using ..Utils: metal - -# Not implemented: -#= -function test_get_set() - A = CUDA.ones(Int, 3) - cuda() do - GC.@preserve A begin - x = @atomic A[begin] - @atomic A[end-2] = -x - end - end - @test collect(A) == [-1, 1, 1] -end -=# - -function test_inc() - A = Metal.ones(Int32, 3) - metal() do - GC.@preserve A begin - @atomic A[begin] += 1 - end - end - @test collect(A) == [2, 1, 1] -end - -end # module diff --git a/lib/AtomixMetal/test/AtomixMetalTests/src/utils.jl b/lib/AtomixMetal/test/AtomixMetalTests/src/utils.jl deleted file mode 100644 index 9abe2f0..0000000 --- a/lib/AtomixMetal/test/AtomixMetalTests/src/utils.jl +++ /dev/null @@ -1,13 +0,0 @@ -module Utils - -using Metal - -function metal(f) - function g() - f() - nothing - end - Metal.@metal g() -end - -end # module diff --git a/lib/AtomixMetal/test/Project.toml b/lib/AtomixMetal/test/Project.toml deleted file mode 100644 index 77d6950..0000000 --- a/lib/AtomixMetal/test/Project.toml +++ /dev/null @@ -1,6 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d" - -[compat] -TestFunctionRunner = "0.1" diff --git a/lib/AtomixMetal/test/runtests.jl b/lib/AtomixMetal/test/runtests.jl deleted file mode 100644 index d358b79..0000000 --- a/lib/AtomixMetal/test/runtests.jl +++ /dev/null @@ -1,2 +0,0 @@ -using TestFunctionRunner -TestFunctionRunner.@run diff --git a/test/AtomixTests/Project.toml b/test/AtomixTests/Project.toml deleted file mode 100644 index be211b1..0000000 --- a/test/AtomixTests/Project.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "AtomixTests" -uuid = "6f95a7dd-85ce-4dbe-a121-27757241c193" -authors = ["Takafumi Arakaki and contributors"] -version = "0.1.0-DEV" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" - -[compat] -julia = "1" diff --git a/test/AtomixTests/src/AtomixTests.jl b/test/AtomixTests/src/AtomixTests.jl deleted file mode 100644 index 81ffda2..0000000 --- a/test/AtomixTests/src/AtomixTests.jl +++ /dev/null @@ -1,11 +0,0 @@ -module AtomixTests - -include("test_core.jl") -include("test_sugar.jl") -include("test_doctest.jl") - -if VERSION >= v"1.7" - include("test_fallback.jl") -end - -end # module AtomixTests diff --git a/test/AtomixTests/src/test_core.jl b/test/AtomixTests/src/test_core.jl deleted file mode 100644 index 65354c8..0000000 --- a/test/AtomixTests/src/test_core.jl +++ /dev/null @@ -1,35 +0,0 @@ -module TestCore - -using Atomix -using Atomix.Internal: referenceable -using Test - -function test_indexableref() - A = ones(Int, 3) - ref = Atomix.IndexableRef(A, (1,)) - @test eltype(ref) === Int - @test Atomix.get(ref) === 1 - Atomix.set!(ref, 123) - @test Atomix.get(ref) === 123 - @test Atomix.modify!(ref, +, 1) === (123 => 124) - @test Atomix.get(ref) === 124 - @test Atomix.swap!(ref, 345) == 124 - @test Atomix.get(ref) === 345 - @test Atomix.replace!(ref, 345, 567) === (old = 345, success = true) - @test Atomix.replace!(ref, 345, 567) === (old = 567, success = false) -end - -function test_referenceablearray() - @testset for a in Any[ - ones(Int, 3), - view(ones(Int, 3), 1:2), - view(ones(Int, 2, 3), 1:1, 1:2), - ones(Int, 3)', - ] - ra = referenceable(a) - @test size(ra) == size(a) - @test IndexStyle(ra) == IndexStyle(a) - end -end - -end # module diff --git a/test/AtomixTests/src/test_doctest.jl b/test/AtomixTests/src/test_doctest.jl deleted file mode 100644 index fed6d6b..0000000 --- a/test/AtomixTests/src/test_doctest.jl +++ /dev/null @@ -1,11 +0,0 @@ -module TestDoctest - -import Atomix -using Documenter: doctest -using Test - -function test_doctest() - doctest(Atomix; manual = false) -end - -end # module diff --git a/test/AtomixTests/src/test_fallback.jl b/test/AtomixTests/src/test_fallback.jl deleted file mode 100644 index c3041aa..0000000 --- a/test/AtomixTests/src/test_fallback.jl +++ /dev/null @@ -1,34 +0,0 @@ -module TestFallback - -using Atomix: @atomic, @atomicreplace, @atomicswap -using Test - -mutable struct Atomic{T} - @atomic x::T -end - -function test() - a = Atomic(123) - @test (@atomic a.x) == 123 - @test (@atomic :monotonic a.x) == 123 - @atomic a.x = 456 - @test (@atomic a.x) == 456 - @atomic :monotonic a.x = 123 - @test (@atomic a.x) == 123 - @test (@atomic a.x += 111) == 234 - @test (@atomic :monotonic a.x += 111) == 345 - @test (@atomic a.x + 111) == (345 => 456) - @test (@atomic :monotonic a.x + 111) == (456 => 567) - @test (@atomicswap a.x = 123) == 567 - @test (@atomicswap :monotonic a.x = 234) == 123 - @test (@atomicreplace a.x 234 => 123) == (old = 234, success = true) - @test (@atomicreplace a.x 234 => 123) == (old = 123, success = false) - @test (@atomicreplace :monotonic a.x 123 => 234) == (old = 123, success = true) - @test (@atomicreplace :monotonic a.x 123 => 234) == (old = 234, success = false) - @test (@atomicreplace :monotonic :monotonic a.x 234 => 123) == - (old = 234, success = true) - @test (@atomicreplace :monotonic :monotonic a.x 234 => 123) == - (old = 123, success = false) -end - -end # module diff --git a/test/AtomixTests/src/test_sugar.jl b/test/AtomixTests/src/test_sugar.jl deleted file mode 100644 index 4777f9c..0000000 --- a/test/AtomixTests/src/test_sugar.jl +++ /dev/null @@ -1,63 +0,0 @@ -module TestSugar - -using Atomix: @atomic, @atomicreplace, @atomicswap -using Test - -function test_get() - A = [42] - @test (@atomic A[1]) === 42 - @test (@atomic A[end]) === 42 - @test (@atomic :monotonic A[begin]) === 42 - order = :monotonic - @test (@atomic order A[begin]) === 42 -end - -function test_get_2d() - A = view([11 12; 21 22], 1:2, 1:2) - @test IndexStyle(A) isa IndexCartesian - @test (@atomic A[1]) === 11 - @test (@atomic A[2]) === 21 - @test (@atomic A[end]) === 22 - @test (@atomic A[2, 1]) === 21 - @test (@atomic A[end, 1]) === 21 - @test (@atomic A[1, end]) === 12 -end - -function test_set() - A = [42, 43] - @atomic A[1] = 123 - @atomic A[end] = 124 - @test A[1] === 123 - @test A[end] === 124 -end - -function test_inc() - A = [1, 1] - @test (@atomic A[1] += 123) === 124 - @test A[1] === 124 - @test (@atomic A[end] += 123) === 124 - @test A[end] === 124 -end - -function test_swap() - A = [1, 1] - @test (@atomicswap A[1] = 123) === 1 - @test A[1] === 123 - @test (@atomicswap A[end] = 456) === 1 - @test A[end] === 456 -end - -function test_cas() - A = [1, 1] - @test (@atomicreplace A[1] 1 => 123) == (old = 1, success = true) - @test A[1] === 123 - @test (@atomicreplace A[1] 1 => 456) == (old = 123, success = false) - @test A[1] === 123 - @test (@atomicreplace A[end] 1 => 789) == (old = 1, success = true) - @test A[end] === 789 - update = 789 => 123 - @test (@atomicreplace A[end] update) == (old = 789, success = true) - @test A[end] === 123 -end - -end # module diff --git a/test/Project.toml b/test/Project.toml index c60b383..319b670 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,8 +1,3 @@ [deps] -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d" -UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" - -[compat] -UnsafeAtomics = "0.2" diff --git a/test/runtests.jl b/test/runtests.jl index d358b79..76178b1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,2 +1,146 @@ -using TestFunctionRunner -TestFunctionRunner.@run +using Atomix +using Atomix.Internal: referenceable +using Atomix: @atomic, @atomicreplace, @atomicswap +using Test + + +@testset "test_indexableref" begin + A = ones(Int, 3) + ref = Atomix.IndexableRef(A, (1,)) + @test eltype(ref) === Int + @test Atomix.get(ref) === 1 + Atomix.set!(ref, 123) + @test Atomix.get(ref) === 123 + @test Atomix.modify!(ref, +, 1) === (123 => 124) + @test Atomix.get(ref) === 124 + @test Atomix.swap!(ref, 345) == 124 + @test Atomix.get(ref) === 345 + @test Atomix.replace!(ref, 345, 567) === (old = 345, success = true) + @test Atomix.replace!(ref, 345, 567) === (old = 567, success = false) +end + + +@testset "test_referenceablearray" begin + for a in Any[ + ones(Int, 3), + view(ones(Int, 3), 1:2), + view(ones(Int, 2, 3), 1:1, 1:2), + ones(Int, 3)', + ] + ra = referenceable(a) + @test size(ra) == size(a) + @test IndexStyle(ra) == IndexStyle(a) + end +end + + +@testset "test_fallback" begin + + mutable struct Atomic{T} + @atomic x::T + end + + a = Atomic(123) + @test (@atomic a.x) == 123 + @test (@atomic :monotonic a.x) == 123 + @atomic a.x = 456 + @test (@atomic a.x) == 456 + @atomic :monotonic a.x = 123 + @test (@atomic a.x) == 123 + @test (@atomic a.x += 111) == 234 + @test (@atomic :monotonic a.x += 111) == 345 + @test (@atomic a.x + 111) == (345 => 456) + @test (@atomic :monotonic a.x + 111) == (456 => 567) + @test (@atomicswap a.x = 123) == 567 + @test (@atomicswap :monotonic a.x = 234) == 123 + @test (@atomicreplace a.x 234 => 123) == (old = 234, success = true) + @test (@atomicreplace a.x 234 => 123) == (old = 123, success = false) + @test (@atomicreplace :monotonic a.x 123 => 234) == (old = 123, success = true) + @test (@atomicreplace :monotonic a.x 123 => 234) == (old = 234, success = false) + @test (@atomicreplace :monotonic :monotonic a.x 234 => 123) == + (old = 234, success = true) + @test (@atomicreplace :monotonic :monotonic a.x 234 => 123) == + (old = 123, success = false) +end + + +@testset "test_get" begin + A = [42] + @test (@atomic A[1]) === 42 + @test (@atomic A[end]) === 42 + @test (@atomic :monotonic A[begin]) === 42 + order = :monotonic + @test (@atomic order A[begin]) === 42 +end + + +@testset "test_get_2d" begin + A = view([11 12; 21 22], 1:2, 1:2) + @test IndexStyle(A) isa IndexCartesian + @test (@atomic A[1]) === 11 + @test (@atomic A[2]) === 21 + @test (@atomic A[end]) === 22 + @test (@atomic A[2, 1]) === 21 + @test (@atomic A[end, 1]) === 21 + @test (@atomic A[1, end]) === 12 +end + + +@testset "test_set" begin + A = [42, 43] + @atomic A[1] = 123 + @atomic A[end] = 124 + @test A[1] === 123 + @test A[end] === 124 +end + + +@testset "test_inc" begin + A = [1, 1] + @test (@atomic A[1] += 123) === 124 + @test A[1] === 124 + @test (@atomic A[end] += 123) === 124 + @test A[end] === 124 +end + + +@testset "test_swap" begin + A = [1, 1] + @test (@atomicswap A[1] = 123) === 1 + @test A[1] === 123 + @test (@atomicswap A[end] = 456) === 1 + @test A[end] === 456 +end + + +@testset "test_cas" begin + A = [1, 1] + @test (@atomicreplace A[1] 1 => 123) == (old = 1, success = true) + @test A[1] === 123 + @test (@atomicreplace A[1] 1 => 456) == (old = 123, success = false) + @test A[1] === 123 + @test (@atomicreplace A[end] 1 => 789) == (old = 1, success = true) + @test A[end] === 789 + update = 789 => 123 + @test (@atomicreplace A[end] update) == (old = 789, success = true) + @test A[end] === 123 +end + + +# KernelAbstractions backend tests +# Pass command-line argument to test suite to install the right backend, e.g. +# julia> import Pkg +# julia> Pkg.test("Atomix", test_args=["--Metal"]) +if "--Metal" in ARGS + import Pkg + Pkg.add("Metal") + include("test_atomix_metal.jl") +elseif "--CUDA" in ARGS + import Pkg + Pkg.add("CUDA") + include("test_atomix_cuda.jl") +elseif "--oneAPI" in ARGS + import Pkg + Pkg.add("oneAPI") + include("test_atomix_oneapi.jl") +end diff --git a/lib/AtomixCUDA/test/AtomixCUDATests/src/test_core.jl b/test/test_atomix_cuda.jl similarity index 69% rename from lib/AtomixCUDA/test/AtomixCUDATests/src/test_core.jl rename to test/test_atomix_cuda.jl index 077d22a..487eae2 100644 --- a/lib/AtomixCUDA/test/AtomixCUDATests/src/test_core.jl +++ b/test/test_atomix_cuda.jl @@ -1,13 +1,20 @@ -module TestCore - -import AtomixCUDA - -using Atomix using CUDA using CUDA: @allowscalar -using Test -using ..Utils: cuda + +@testset "AtomixCUDAExt:extension_found" begin + @test !isnothing(Base.get_extension(Atomix, :AtomixCUDAExt)) +end + + +function cuda(f) + function g() + f() + nothing + end + CUDA.@cuda g() +end + # Not implemented: #= @@ -24,7 +31,8 @@ function test_get_set() end =# -function test_cas() + +@testset "AtomixCUDAExt:test_cas" begin idx = ( data = 1, cas1_ok = 2, @@ -47,7 +55,8 @@ function test_cas() @test collect(A) == [42, 1, 1] end -function test_inc() + +@testset "AtomixCUDAExt:test_inc" begin A = CUDA.CuVector(1:3) cuda() do GC.@preserve A begin @@ -60,4 +69,13 @@ function test_inc() @test collect(A) == [2, 1, 2] end -end # module + +@testset "AtomixCUDAExt:test_inc_sugar" begin + A = CUDA.ones(Int, 3) + cuda() do + GC.@preserve A begin + @atomic A[begin] += 1 + end + end + @test collect(A) == [2, 1, 1] +end diff --git a/lib/AtomixMetal/test/AtomixMetalTests/src/test_core.jl b/test/test_atomix_metal.jl similarity index 69% rename from lib/AtomixMetal/test/AtomixMetalTests/src/test_core.jl rename to test/test_atomix_metal.jl index f982a2a..7d9a2d3 100644 --- a/lib/AtomixMetal/test/AtomixMetalTests/src/test_core.jl +++ b/test/test_atomix_metal.jl @@ -1,13 +1,20 @@ -module TestCore - -import AtomixMetal - -using Atomix using Metal using Metal: @allowscalar -using Test -using ..Utils: metal + +@testset "AtomixMetalExt:extension_found" begin + @test !isnothing(Base.get_extension(Atomix, :AtomixMetalExt)) +end + + +function metal(f) + function g() + f() + nothing + end + Metal.@metal g() +end + # Not implemented: #= @@ -24,7 +31,8 @@ function test_get_set() end =# -function test_cas() + +@testset "AtomixMetalExt:test_cas" begin idx = ( data = 1, cas1_ok = 2, @@ -47,7 +55,8 @@ function test_cas() @test collect(A) == [42, 1, 1] end -function test_inc() + +@testset "AtomixMetalExt:test_inc" begin A = Metal.MtlVector(Int32(1):Int32(3)) metal() do GC.@preserve A begin @@ -60,4 +69,13 @@ function test_inc() @test collect(A) == [2, 1, 2] end -end # module + +@testset "AtomixMetalExt:test_inc_sugar" begin + A = Metal.ones(Int32, 3) + metal() do + GC.@preserve A begin + @atomic A[begin] += 1 + end + end + @test collect(A) == [2, 1, 1] +end diff --git a/test/test_atomix_oneapi.jl b/test/test_atomix_oneapi.jl new file mode 100644 index 0000000..ca6dfba --- /dev/null +++ b/test/test_atomix_oneapi.jl @@ -0,0 +1,81 @@ +using oneAPI +using oneAPI: @allowscalar + + +@testset "AtomixoneAPIExt:extension_found" begin + @test !isnothing(Base.get_extension(Atomix, :AtomixoneAPIExt)) +end + + +function oneapi(f) + function g() + f() + nothing + end + oneAPI.@oneapi g() +end + + +# Not implemented: +#= +function test_get_set() + A = CUDA.ones(Int, 3) + cuda() do + GC.@preserve A begin + ref = Atomix.IndexableRef(A, (1,)) + x = Atomix.get(ref) + Atomix.set!(ref, -x) + end + end + @test collect(A) == [-1, 1, 1] +end +=# + + +@testset "AtomixoneAPIExt:test_cas" begin + idx = ( + data = 1, + cas1_ok = 2, + cas2_ok = 3, + # ... + ) + @assert minimum(idx) >= 1 + @assert maximum(idx) == length(idx) + + A = oneAPI.zeros(Int32, length(idx)) + oneapi() do + GC.@preserve A begin + ref = Atomix.IndexableRef(A, (1,)) + (old, success) = Atomix.replace!(ref, 0, 42) + A[idx.cas1_ok] = old == 0 && success + (old, success) = Atomix.replace!(ref, 0, 43) + A[idx.cas2_ok] = old == 42 && !success + end + end + @test collect(A) == [42, 1, 1] +end + + +@testset "AtomixoneAPIExt:test_inc" begin + A = oneAPI.oneVector(Int32(1):Int32(3)) + oneapi() do + GC.@preserve A begin + ref = Atomix.IndexableRef(A, (1,)) + pre, post = Atomix.modify!(ref, +, 1) + A[2] = pre + A[3] = post + end + end + @test collect(A) == [2, 1, 2] +end + + +@testset "AtomixoneAPIExt:test_inc_sugar" begin + A = oneAPI.ones(Int32, 3) + oneapi() do + GC.@preserve A begin + @atomic A[begin] += 1 + end + end + @test collect(A) == [2, 1, 1] +end From 3a4ae972169f901ca27858d92a09a196f0cd8a64 Mon Sep 17 00:00:00 2001 From: anicusan Date: Mon, 11 Nov 2024 14:25:17 +0000 Subject: [PATCH 02/11] updated Atomix back to version 1.0.0, updated GPU tests, updated CI Julia versions --- .buildkite/pipeline.yml | 4 ++-- .github/workflows/ci.yml | 6 ++++-- Project.toml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0e57c6d..e692c7b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,7 +7,7 @@ steps: julia -e 'using Pkg println("--- :julia: Instantiating environment") - Pkg.activate("lib/AtomixCUDA") + Pkg.add("CUDA") Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") @@ -26,7 +26,7 @@ steps: julia -e 'using Pkg println("--- :julia: Instantiating environment") - Pkg.activate("lib/AtomixMetal") + Pkg.add("Metal") Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 845e409..057fe71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,8 @@ jobs: matrix: julia-version: - '1' - - '1.6' + - 'lts' + - 'pre' fail-fast: false name: Test Julia ${{ matrix.julia-version }} steps: @@ -39,7 +40,8 @@ jobs: matrix: julia-version: - '1' - - '1.6' + - 'lts' + - 'pre' fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/Project.toml b/Project.toml index 8caa5e6..fcd652e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "0.1.0" +version = "1.0.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" From a896cea0915b2f854ab5139f5669131eb13abcf7 Mon Sep 17 00:00:00 2001 From: anicusan Date: Mon, 11 Nov 2024 14:40:31 +0000 Subject: [PATCH 03/11] temporarily downgrading back to 0.1.0 so that KernelAbstractions can be installed on the GPU backends. Added oneAPI CI runner. TODO: put version back to 1.0.0 once they run, then update rest of ecosystem compat --- .buildkite/pipeline.yml | 23 +++++++++++++++++++++-- .github/workflows/ci.yml | 9 +-------- Project.toml | 23 ++++++++++++----------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e692c7b..eed1eb8 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -11,7 +11,7 @@ steps: Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") - Pkg.test()' + Pkg.test(test_args=["--CUDA"])' agents: queue: "juliagpu" cuda: "*" @@ -30,10 +30,29 @@ steps: Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") - Pkg.test()' + Pkg.test(test_args=["--Metal"])' agents: queue: "juliaecosystem" os: "macos" arch: "aarch64" if: build.message !~ /\[skip tests\]/ timeout_in_minutes: 15 + + - label: "oneAPI.jl" + plugins: + - JuliaCI/julia#v1: + version: "1.10" + command: | + julia -e 'using Pkg + + println("--- :julia: Instantiating environment") + Pkg.add("oneAPI") + Pkg.develop(PackageSpec(name="Atomix", path=".")) + + println("+++ :julia: Running tests") + Pkg.test(test_args=["--oneAPI"])' + agents: + queue: "juliagpu" + intel: "*" + if: build.message !~ /\[skip tests\]/ + timeout_in_minutes: 15 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 057fe71..386c6e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,17 +80,10 @@ jobs: if: steps.build-and-deploy.outcome == 'skipped' run: julia -e 'using Run; Run.docs()' - # https://github.com/tkf/julia-code-style-suggesters - code-style: - if: always() && github.event.pull_request - runs-on: ubuntu-latest - steps: - - uses: tkf/julia-code-style-suggesters@v1 - # A job that succeeds if and only if all jobs succeed. all-success: if: always() && github.event.pull_request - needs: [test, aqua, documenter, code-style] + needs: [test, aqua, documenter] runs-on: ubuntu-latest steps: # https://github.com/tkf/merge-conclusions-action diff --git a/Project.toml b/Project.toml index fcd652e..c61af46 100644 --- a/Project.toml +++ b/Project.toml @@ -1,24 +1,25 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "1.0.0" +version = "0.1.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" -[weakdeps] -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -Metal = "dde4c033-4e86-420c-a63e-0dd931031962" -oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" +[compat] +CUDA = "5" +Metal = "1" +UnsafeAtomics = "0.1, 0.2" +julia = "1.6" +oneAPI = "1" [extensions] AtomixCUDAExt = "CUDA" AtomixMetalExt = "Metal" AtomixoneAPIExt = "oneAPI" -[compat] -UnsafeAtomics = "0.1, 0.2" -CUDA = "5" -Metal = "1" -oneAPI = "1" -julia = "1.6" +[weakdeps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +Metal = "dde4c033-4e86-420c-a63e-0dd931031962" +oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" + From 4311cbbd919f79dcf450bd0512930cd1f42a0948 Mon Sep 17 00:00:00 2001 From: anicusan Date: Mon, 11 Nov 2024 14:47:19 +0000 Subject: [PATCH 04/11] specified package name in GPU CI. Removed old Aqua test from CI, and added Aqua to test/runtests.jl --- .buildkite/pipeline.yml | 6 +++--- .github/workflows/ci.yml | 21 +-------------------- Project.toml | 1 - test/Project.toml | 1 + test/runtests.jl | 6 ++++++ 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index eed1eb8..11e45a5 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -11,7 +11,7 @@ steps: Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") - Pkg.test(test_args=["--CUDA"])' + Pkg.test("Atomix", test_args=["--CUDA"])' agents: queue: "juliagpu" cuda: "*" @@ -30,7 +30,7 @@ steps: Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") - Pkg.test(test_args=["--Metal"])' + Pkg.test("Atomix", test_args=["--Metal"])' agents: queue: "juliaecosystem" os: "macos" @@ -50,7 +50,7 @@ steps: Pkg.develop(PackageSpec(name="Atomix", path=".")) println("+++ :julia: Running tests") - Pkg.test(test_args=["--oneAPI"])' + Pkg.test("Atomix", test_args=["--oneAPI"])' agents: queue: "juliagpu" intel: "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 386c6e9..0806cff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,25 +34,6 @@ jobs: flags: Pkg.test name: codecov-umbrella - aqua: - runs-on: ubuntu-latest - strategy: - matrix: - julia-version: - - '1' - - 'lts' - - 'pre' - fail-fast: false - steps: - - uses: actions/checkout@v4 - - - uses: julia-actions/setup-julia@v2 - with: - version: ${{ matrix.julia-version }} - - uses: julia-actions/cache@v2 - - - uses: tkf/julia-aqua@v1 - documenter: runs-on: ubuntu-latest steps: @@ -83,7 +64,7 @@ jobs: # A job that succeeds if and only if all jobs succeed. all-success: if: always() && github.event.pull_request - needs: [test, aqua, documenter] + needs: [test, documenter] runs-on: ubuntu-latest steps: # https://github.com/tkf/merge-conclusions-action diff --git a/Project.toml b/Project.toml index c61af46..568516d 100644 --- a/Project.toml +++ b/Project.toml @@ -22,4 +22,3 @@ AtomixoneAPIExt = "oneAPI" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" Metal = "dde4c033-4e86-420c-a63e-0dd931031962" oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" - diff --git a/test/Project.toml b/test/Project.toml index 319b670..f27b1a7 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,3 +1,4 @@ [deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 76178b1..3892706 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,12 @@ using Atomix: @atomic, @atomicreplace, @atomicswap using Test +@testset "Aqua.jl" begin + using Aqua + Aqua.test_all(Atomix) +end + + @testset "test_indexableref" begin A = ones(Int, 3) ref = Atomix.IndexableRef(A, (1,)) From d86b3966345b17c21c356274da4c68b5a859d19d Mon Sep 17 00:00:00 2001 From: "A. Leonard Nicusan" Date: Thu, 14 Nov 2024 10:37:28 +0000 Subject: [PATCH 05/11] Update Project.toml version Co-authored-by: Valentin Churavy --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 568516d..cc2b83e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "0.1.0" +version = "0.2.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" From c1b88d2c448e06601da75826b97ee1ea4bfb7359 Mon Sep 17 00:00:00 2001 From: anicusan Date: Thu, 14 Nov 2024 10:38:40 +0000 Subject: [PATCH 06/11] removed oneAPI addition, leaving only extension refactoring --- .buildkite/pipeline.yml | 18 ------------- Project.toml | 3 --- ext/AtomixoneAPIExt.jl | 58 ----------------------------------------- 3 files changed, 79 deletions(-) delete mode 100644 ext/AtomixoneAPIExt.jl diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 11e45a5..b5a2427 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -38,21 +38,3 @@ steps: if: build.message !~ /\[skip tests\]/ timeout_in_minutes: 15 - - label: "oneAPI.jl" - plugins: - - JuliaCI/julia#v1: - version: "1.10" - command: | - julia -e 'using Pkg - - println("--- :julia: Instantiating environment") - Pkg.add("oneAPI") - Pkg.develop(PackageSpec(name="Atomix", path=".")) - - println("+++ :julia: Running tests") - Pkg.test("Atomix", test_args=["--oneAPI"])' - agents: - queue: "juliagpu" - intel: "*" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 15 diff --git a/Project.toml b/Project.toml index cc2b83e..4e1e99d 100644 --- a/Project.toml +++ b/Project.toml @@ -11,14 +11,11 @@ CUDA = "5" Metal = "1" UnsafeAtomics = "0.1, 0.2" julia = "1.6" -oneAPI = "1" [extensions] AtomixCUDAExt = "CUDA" AtomixMetalExt = "Metal" -AtomixoneAPIExt = "oneAPI" [weakdeps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" Metal = "dde4c033-4e86-420c-a63e-0dd931031962" -oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" diff --git a/ext/AtomixoneAPIExt.jl b/ext/AtomixoneAPIExt.jl deleted file mode 100644 index 1866a69..0000000 --- a/ext/AtomixoneAPIExt.jl +++ /dev/null @@ -1,58 +0,0 @@ -# TODO: respect ordering -module AtomixoneAPIExt - -using Atomix: Atomix, IndexableRef -using oneAPI: oneAPI, oneDeviceArray - -const oneIndexableRef{Indexable<:oneDeviceArray} = IndexableRef{Indexable} - -function Atomix.get(ref::oneIndexableRef, order) - error("not implemented") -end - -function Atomix.set!(ref::oneIndexableRef, v, order) - error("not implemented") -end - -@inline function Atomix.replace!( - ref::oneIndexableRef, - expected, - desired, - success_ordering, - failure_ordering, -) - ptr = Atomix.pointer(ref) - expected = convert(eltype(ref), expected) - desired = convert(eltype(ref), desired) - begin - old = oneAPI.atomic_cmpxchg!(ptr, expected, desired) - end - return (; old = old, success = old === expected) -end - -@inline function Atomix.modify!(ref::oneIndexableRef, op::OP, x, order) where {OP} - x = convert(eltype(ref), x) - ptr = Atomix.pointer(ref) - begin - old = if op === (+) - oneAPI.atomic_add!(ptr, x) - elseif op === (-) - oneAPI.atomic_sub!(ptr, x) - elseif op === (&) - oneAPI.atomic_and!(ptr, x) - elseif op === (|) - oneAPI.atomic_or!(ptr, x) - elseif op === xor - oneAPI.atomic_xor!(ptr, x) - elseif op === min - oneAPI.atomic_min!(ptr, x) - elseif op === max - oneAPI.atomic_max!(ptr, x) - else - error("not implemented") - end - end - return old => op(old, x) -end - -end # module AtomixoneAPIExt From e58e8aaf5c25f0c68f0357728c3b19717dbd426f Mon Sep 17 00:00:00 2001 From: "A. Leonard Nicusan" Date: Thu, 14 Nov 2024 10:40:29 +0000 Subject: [PATCH 07/11] Update Project.toml Julia version Co-authored-by: Valentin Churavy --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4e1e99d..c2564f1 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,7 @@ UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" CUDA = "5" Metal = "1" UnsafeAtomics = "0.1, 0.2" -julia = "1.6" +julia = "1.10" [extensions] AtomixCUDAExt = "CUDA" From e8f948cc7acdc6ed1addd703b5996daca541dfa6 Mon Sep 17 00:00:00 2001 From: anicusan Date: Sat, 23 Nov 2024 17:10:55 +0000 Subject: [PATCH 08/11] added oneAPI backend --- .buildkite/pipeline.yml | 18 +++++++++++++ ext/AtomixoneAPIExt.jl | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 ext/AtomixoneAPIExt.jl diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b5a2427..11e45a5 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -38,3 +38,21 @@ steps: if: build.message !~ /\[skip tests\]/ timeout_in_minutes: 15 + - label: "oneAPI.jl" + plugins: + - JuliaCI/julia#v1: + version: "1.10" + command: | + julia -e 'using Pkg + + println("--- :julia: Instantiating environment") + Pkg.add("oneAPI") + Pkg.develop(PackageSpec(name="Atomix", path=".")) + + println("+++ :julia: Running tests") + Pkg.test("Atomix", test_args=["--oneAPI"])' + agents: + queue: "juliagpu" + intel: "*" + if: build.message !~ /\[skip tests\]/ + timeout_in_minutes: 15 diff --git a/ext/AtomixoneAPIExt.jl b/ext/AtomixoneAPIExt.jl new file mode 100644 index 0000000..1866a69 --- /dev/null +++ b/ext/AtomixoneAPIExt.jl @@ -0,0 +1,58 @@ +# TODO: respect ordering +module AtomixoneAPIExt + +using Atomix: Atomix, IndexableRef +using oneAPI: oneAPI, oneDeviceArray + +const oneIndexableRef{Indexable<:oneDeviceArray} = IndexableRef{Indexable} + +function Atomix.get(ref::oneIndexableRef, order) + error("not implemented") +end + +function Atomix.set!(ref::oneIndexableRef, v, order) + error("not implemented") +end + +@inline function Atomix.replace!( + ref::oneIndexableRef, + expected, + desired, + success_ordering, + failure_ordering, +) + ptr = Atomix.pointer(ref) + expected = convert(eltype(ref), expected) + desired = convert(eltype(ref), desired) + begin + old = oneAPI.atomic_cmpxchg!(ptr, expected, desired) + end + return (; old = old, success = old === expected) +end + +@inline function Atomix.modify!(ref::oneIndexableRef, op::OP, x, order) where {OP} + x = convert(eltype(ref), x) + ptr = Atomix.pointer(ref) + begin + old = if op === (+) + oneAPI.atomic_add!(ptr, x) + elseif op === (-) + oneAPI.atomic_sub!(ptr, x) + elseif op === (&) + oneAPI.atomic_and!(ptr, x) + elseif op === (|) + oneAPI.atomic_or!(ptr, x) + elseif op === xor + oneAPI.atomic_xor!(ptr, x) + elseif op === min + oneAPI.atomic_min!(ptr, x) + elseif op === max + oneAPI.atomic_max!(ptr, x) + else + error("not implemented") + end + end + return old => op(old, x) +end + +end # module AtomixoneAPIExt From 873e7b61d388eec9d8d0b719d79c92e44043f030 Mon Sep 17 00:00:00 2001 From: anicusan Date: Sat, 23 Nov 2024 17:22:28 +0000 Subject: [PATCH 09/11] again, temporarily downgrading to v0.1.0 to check tests on buildkite --- Project.toml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index c2564f1..569cae6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,21 +1,25 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "0.2.0" +version = "0.1.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" +oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" -[compat] -CUDA = "5" -Metal = "1" -UnsafeAtomics = "0.1, 0.2" -julia = "1.10" +[weakdeps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +Metal = "dde4c033-4e86-420c-a63e-0dd931031962" +oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" [extensions] AtomixCUDAExt = "CUDA" AtomixMetalExt = "Metal" +AtomixoneAPIExt = "oneAPI" -[weakdeps] -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -Metal = "dde4c033-4e86-420c-a63e-0dd931031962" +[compat] +CUDA = "5" +Metal = "1" +oneAPI = "1" +UnsafeAtomics = "0.1, 0.2" +julia = "1.10" From 833965589ef4dc4276154ed6332c8e274d0466d8 Mon Sep 17 00:00:00 2001 From: anicusan Date: Sat, 23 Nov 2024 17:30:09 +0000 Subject: [PATCH 10/11] okay, all backend extensions work; updating version up to 1.0.0 which will then need to be updated around the ecosystem --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 569cae6..a4bad49 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "0.1.0" +version = "1.0.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" From 1c3ead0347a579fc133f8c154dc3b50c904108a3 Mon Sep 17 00:00:00 2001 From: "A. Leonard Nicusan" Date: Mon, 25 Nov 2024 02:19:30 +0000 Subject: [PATCH 11/11] Update Project.toml Remove oneAPI from deps, as it was in weakdeps already Co-authored-by: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index a4bad49..e1c25bd 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "1.0.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" -oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" [weakdeps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"