-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from anicusan/main
Add support for Metal atomics.
- Loading branch information
Showing
21 changed files
with
372 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
steps: | ||
- label: "CUDA.jl" | ||
plugins: | ||
- JuliaCI/julia#v1: | ||
version: "1.10" | ||
command: | | ||
julia -e 'using Pkg | ||
println("--- :julia: Instantiating environment") | ||
Pkg.activate("lib/AtomixCUDA") | ||
Pkg.develop(PackageSpec(name="Atomix", path=".")) | ||
println("+++ :julia: Running tests") | ||
Pkg.test()' | ||
agents: | ||
queue: "juliagpu" | ||
cuda: "*" | ||
if: build.message !~ /\[skip tests\]/ | ||
timeout_in_minutes: 15 | ||
|
||
- label: "Metal.jl" | ||
plugins: | ||
- JuliaCI/julia#v1: | ||
version: "1.10" | ||
command: | | ||
julia -e 'using Pkg | ||
println("--- :julia: Instantiating environment") | ||
Pkg.activate("lib/AtomixMetal") | ||
Pkg.develop(PackageSpec(name="Atomix", path=".")) | ||
println("+++ :julia: Running tests") | ||
Pkg.test()' | ||
agents: | ||
queue: "juliaecosystem" | ||
os: "macos" | ||
arch: "aarch64" | ||
if: build.message !~ /\[skip tests\]/ | ||
timeout_in_minutes: 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "monthly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: CompatHelper | ||
|
||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if Julia is already available in the PATH | ||
id: julia_in_path | ||
run: which julia | ||
continue-on-error: true | ||
- name: Install Julia, but only if it is not already available in the PATH | ||
uses: julia-actions/setup-julia@v2 | ||
with: | ||
version: '1' | ||
arch: ${{ runner.arch }} | ||
if: steps.julia_in_path.outcome != 'success' | ||
- name: "Add the General registry via Git" | ||
run: | | ||
import Pkg | ||
ENV["JULIA_PKG_SERVER"] = "" | ||
Pkg.Registry.add("General") | ||
shell: julia --color=yes {0} | ||
- name: "Install CompatHelper" | ||
run: | | ||
import Pkg | ||
name = "CompatHelper" | ||
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" | ||
version = "3" | ||
Pkg.add(; name, uuid, version) | ||
shell: julia --color=yes {0} | ||
- name: "Run CompatHelper" | ||
run: | | ||
import CompatHelper | ||
CompatHelper.main() | ||
shell: julia --color=yes {0} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
name: TagBot | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
push: | ||
branches: | ||
- actions/trigger/TagBot | ||
workflow_dispatch: | ||
inputs: | ||
lookback: | ||
default: 3 | ||
|
||
permissions: | ||
actions: read | ||
checks: read | ||
contents: write | ||
deployments: read | ||
issues: read | ||
discussions: read | ||
packages: read | ||
pages: read | ||
pull-requests: read | ||
repository-projects: read | ||
security-events: read | ||
statuses: read | ||
|
||
jobs: | ||
TagBot: | ||
if: >- | ||
github.event_name == 'workflow_dispatch' || | ||
github.event_name == 'push' || | ||
github.actor == 'JuliaTagBot' | ||
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: JuliaRegistries/TagBot@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ssh: ${{ secrets.SSH_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Manifest.toml | ||
*.cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Atomix" | ||
uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" | ||
authors = ["Takafumi Arakaki <[email protected]> and contributors"] | ||
version = "0.1.1-DEV" | ||
version = "1.0" | ||
|
||
[deps] | ||
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
|
||
[compat] | ||
Documenter = "1.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
name = "AtomixCUDA" | ||
uuid = "6171a885-8764-404f-b64d-f8edb1679b6f" | ||
authors = ["Takafumi Arakaki <[email protected]> and contributors"] | ||
version = "0.1.0-DEV" | ||
version = "1.0" | ||
|
||
[deps] | ||
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
|
||
[compat] | ||
julia = "1.6" | ||
Atomix = "1" | ||
CUDA = "5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Takafumi Arakaki <[email protected]> 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = "AtomixMetal" | ||
uuid = "fc0d88fc-5db5-40d7-bf35-da84fd759def" | ||
authors = ["Andrei-Leonard Nicusan <[email protected]> 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# AtomixMetal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# TODO: respect ordering | ||
module AtomixMetal | ||
|
||
using Atomix: Atomix, IndexableRef | ||
using Metal: Metal, MtlDeviceArray | ||
|
||
const MtlIndexableRef{Indexable<:MtlDeviceArray} = IndexableRef{Indexable} | ||
|
||
function Atomix.get(ref::MtlIndexableRef, order) | ||
error("not implemented") | ||
end | ||
|
||
function Atomix.set!(ref::MtlIndexableRef, v, order) | ||
error("not implemented") | ||
end | ||
|
||
@inline function Atomix.replace!( | ||
ref::MtlIndexableRef, | ||
expected, | ||
desired, | ||
success_ordering, | ||
failure_ordering, | ||
) | ||
ptr = Atomix.pointer(ref) | ||
expected = convert(eltype(ref), expected) | ||
desired = convert(eltype(ref), desired) | ||
begin | ||
old = Metal.atomic_compare_exchange_weak_explicit(ptr, expected, desired) | ||
end | ||
return (; old = old, success = old === expected) | ||
end | ||
|
||
@inline function Atomix.modify!(ref::MtlIndexableRef, op::OP, x, order) where {OP} | ||
x = convert(eltype(ref), x) | ||
ptr = Atomix.pointer(ref) | ||
begin | ||
old = if op === (+) | ||
Metal.atomic_fetch_add_explicit(ptr, x) | ||
elseif op === (-) | ||
Metal.atomic_fetch_sub_explicit(ptr, x) | ||
elseif op === (&) | ||
Metal.atomic_fetch_and_explicit(ptr, x) | ||
elseif op === (|) | ||
Metal.atomic_fetch_or_explicit(ptr, x) | ||
elseif op === xor | ||
Metal.atomic_fetch_xor_explicit(ptr, x) | ||
elseif op === min | ||
Metal.atomic_fetch_min_explicit(ptr, x) | ||
elseif op === max | ||
Metal.atomic_fetch_max_explicit(ptr, x) | ||
else | ||
error("not implemented") | ||
end | ||
end | ||
return old => op(old, x) | ||
end | ||
|
||
end # module AtomixMetal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = "AtomixMetalTests" | ||
uuid = "03c00b03-d8de-4838-97ce-ef69879af46e" | ||
authors = ["Andrei-Leonard Nicusan <[email protected]> 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" |
7 changes: 7 additions & 0 deletions
7
lib/AtomixMetal/test/AtomixMetalTests/src/AtomixMetalTests.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module AtomixMetalTests | ||
|
||
include("utils.jl") | ||
include("test_core.jl") | ||
include("test_sugar.jl") | ||
|
||
end # module AtomixMetalTests |
Oops, something went wrong.