From aaefe62aa92b778fcb97e1ec628400299580cdfe Mon Sep 17 00:00:00 2001 From: "A. Leonard Nicusan" Date: Mon, 25 Nov 2024 19:12:44 +0000 Subject: [PATCH] Added oneAPI extension and Buildkite CI (#43) Co-authored-by: Valentin Churavy Co-authored-by: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> --- .buildkite/pipeline.yml | 18 +++++++++++++ Project.toml | 21 ++++++++------- ext/AtomixoneAPIExt.jl | 58 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 9 deletions(-) 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/Project.toml b/Project.toml index c2564f1..e1c25bd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,21 +1,24 @@ name = "Atomix" uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" authors = ["Takafumi Arakaki and contributors"] -version = "0.2.0" +version = "1.0.0" [deps] UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" -[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" 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