Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added oneAPI extension and buildkite CI #43

Merged
merged 12 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 13 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
name = "Atomix"
uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
authors = ["Takafumi Arakaki <[email protected]> and contributors"]
version = "0.2.0"
version = "1.0.0"

[deps]
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
anicusan marked this conversation as resolved.
Show resolved Hide resolved

[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"
58 changes: 58 additions & 0 deletions ext/AtomixoneAPIExt.jl
Original file line number Diff line number Diff line change
@@ -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