From 930663cc2860a394826edb9b189a16b7e552c1a8 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 14 Feb 2025 22:44:06 -0400 Subject: [PATCH] Use GPUToolbox --- Project.toml | 2 ++ src/Metal.jl | 1 + src/device/intrinsics/version.jl | 47 -------------------------------- 3 files changed, 3 insertions(+), 47 deletions(-) diff --git a/Project.toml b/Project.toml index 219090349..0e42742df 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/src/Metal.jl b/src/Metal.jl index 5e6f53754..490ed888d 100644 --- a/src/Metal.jl +++ b/src/Metal.jl @@ -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 diff --git a/src/device/intrinsics/version.jl b/src/device/intrinsics/version.jl index 86f66971c..f876649c9 100644 --- a/src/device/intrinsics/version.jl +++ b/src/device/intrinsics/version.jl @@ -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