Skip to content

Commit aaefe62

Browse files
anicusanvchuravychristiangnrd
authored
Added oneAPI extension and Buildkite CI (#43)
Co-authored-by: Valentin Churavy <[email protected]> Co-authored-by: Christian Guinard <[email protected]>
1 parent b027bdd commit aaefe62

File tree

3 files changed

+88
-9
lines changed

3 files changed

+88
-9
lines changed

.buildkite/pipeline.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,21 @@ steps:
3838
if: build.message !~ /\[skip tests\]/
3939
timeout_in_minutes: 15
4040

41+
- label: "oneAPI.jl"
42+
plugins:
43+
- JuliaCI/julia#v1:
44+
version: "1.10"
45+
command: |
46+
julia -e 'using Pkg
47+
48+
println("--- :julia: Instantiating environment")
49+
Pkg.add("oneAPI")
50+
Pkg.develop(PackageSpec(name="Atomix", path="."))
51+
52+
println("+++ :julia: Running tests")
53+
Pkg.test("Atomix", test_args=["--oneAPI"])'
54+
agents:
55+
queue: "juliagpu"
56+
intel: "*"
57+
if: build.message !~ /\[skip tests\]/
58+
timeout_in_minutes: 15

Project.toml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
name = "Atomix"
22
uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
33
authors = ["Takafumi Arakaki <[email protected]> and contributors"]
4-
version = "0.2.0"
4+
version = "1.0.0"
55

66
[deps]
77
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"
88

9-
[compat]
10-
CUDA = "5"
11-
Metal = "1"
12-
UnsafeAtomics = "0.1, 0.2"
13-
julia = "1.10"
9+
[weakdeps]
10+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
11+
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
12+
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
1413

1514
[extensions]
1615
AtomixCUDAExt = "CUDA"
1716
AtomixMetalExt = "Metal"
17+
AtomixoneAPIExt = "oneAPI"
1818

19-
[weakdeps]
20-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
21-
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
19+
[compat]
20+
CUDA = "5"
21+
Metal = "1"
22+
oneAPI = "1"
23+
UnsafeAtomics = "0.1, 0.2"
24+
julia = "1.10"

ext/AtomixoneAPIExt.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# TODO: respect ordering
2+
module AtomixoneAPIExt
3+
4+
using Atomix: Atomix, IndexableRef
5+
using oneAPI: oneAPI, oneDeviceArray
6+
7+
const oneIndexableRef{Indexable<:oneDeviceArray} = IndexableRef{Indexable}
8+
9+
function Atomix.get(ref::oneIndexableRef, order)
10+
error("not implemented")
11+
end
12+
13+
function Atomix.set!(ref::oneIndexableRef, v, order)
14+
error("not implemented")
15+
end
16+
17+
@inline function Atomix.replace!(
18+
ref::oneIndexableRef,
19+
expected,
20+
desired,
21+
success_ordering,
22+
failure_ordering,
23+
)
24+
ptr = Atomix.pointer(ref)
25+
expected = convert(eltype(ref), expected)
26+
desired = convert(eltype(ref), desired)
27+
begin
28+
old = oneAPI.atomic_cmpxchg!(ptr, expected, desired)
29+
end
30+
return (; old = old, success = old === expected)
31+
end
32+
33+
@inline function Atomix.modify!(ref::oneIndexableRef, op::OP, x, order) where {OP}
34+
x = convert(eltype(ref), x)
35+
ptr = Atomix.pointer(ref)
36+
begin
37+
old = if op === (+)
38+
oneAPI.atomic_add!(ptr, x)
39+
elseif op === (-)
40+
oneAPI.atomic_sub!(ptr, x)
41+
elseif op === (&)
42+
oneAPI.atomic_and!(ptr, x)
43+
elseif op === (|)
44+
oneAPI.atomic_or!(ptr, x)
45+
elseif op === xor
46+
oneAPI.atomic_xor!(ptr, x)
47+
elseif op === min
48+
oneAPI.atomic_min!(ptr, x)
49+
elseif op === max
50+
oneAPI.atomic_max!(ptr, x)
51+
else
52+
error("not implemented")
53+
end
54+
end
55+
return old => op(old, x)
56+
end
57+
58+
end # module AtomixoneAPIExt

0 commit comments

Comments
 (0)