Skip to content

Commit

Permalink
Use GPUToolbox (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd authored Feb 15, 2025
1 parent bec8c71 commit 4324871
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 47 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
LLVMDowngrader_jll = "f52de702-fb25-5922-94ba-81dd59b07444"
Expand Down Expand Up @@ -37,6 +38,7 @@ CodecBzip2 = "0.8.5"
ExprTools = "0.1"
GPUArrays = "11.2.1"
GPUCompiler = "0.26, 0.27, 1"
GPUToolbox = "0.1"
KernelAbstractions = "0.9.1"
LLVM = "7.2, 8, 9"
LLVMDowngrader_jll = "0.6"
Expand Down
1 change: 1 addition & 0 deletions src/Metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Metal
using GPUArrays
using Adapt
using GPUCompiler
using GPUToolbox: SimpleVersion, @sv_str
using LLVM
using LLVM.Interop
import LLVMDowngrader_jll
Expand Down
47 changes: 0 additions & 47 deletions src/device/intrinsics/version.jl
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@
# device intrinsics for querying the compute SimpleVersion and PTX ISA version


## a GPU-compatible version number

# XXX: this is duplicated with CUDA.jl; move it to a common place

struct SimpleVersion
major::UInt32
minor::UInt32

SimpleVersion(major, minor=0) = new(major, minor)
end

function Base.tryparse(::Type{SimpleVersion}, v::AbstractString)
parts = split(v, ".")
1 <= length(parts) <= 2 || return nothing

int_parts = map(parts) do part
tryparse(Int, part)
end
any(isnothing, int_parts) && return nothing

SimpleVersion(int_parts...)
end

function Base.parse(::Type{SimpleVersion}, v::AbstractString)
ver = tryparse(SimpleVersion, v)
ver === nothing && throw(ArgumentError("invalid SimpleVersion string: '$v'"))
return ver
end

SimpleVersion(v::AbstractString) = parse(SimpleVersion, v)

@inline function Base.isless(a::SimpleVersion, b::SimpleVersion)
(a.major < b.major) && return true
(a.major > b.major) && return false
(a.minor < b.minor) && return true
(a.minor > b.minor) && return false
return false
end

macro sv_str(str)
SimpleVersion(str)
end


## accessors for the Metal and AIR version

export metal_version, air_version
Expand Down

0 comments on commit 4324871

Please sign in to comment.