Skip to content

Commit

Permalink
Better version?
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Feb 7, 2025
1 parent 231d2a1 commit 4ea0848
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ include("device/utils.jl")
include("device/pointer.jl")
include("device/array.jl")
include("device/runtime.jl")
include("device/intrinsics/version.jl")
include("device/intrinsics/arguments.jl")
include("device/intrinsics/math.jl")
include("device/intrinsics/synchronization.jl")
include("device/intrinsics/memory.jl")
include("device/intrinsics/simd.jl")
include("device/intrinsics/version.jl")
include("device/intrinsics/atomics.jl")
include("device/quirks.jl")

Expand Down
16 changes: 13 additions & 3 deletions src/device/intrinsics/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,19 @@ end
@device_override Base.trunc(x::Float32) = ccall("extern air.trunc.f32", llvmcall, Cfloat, (Cfloat,), x)
@device_override Base.trunc(x::Float16) = ccall("extern air.trunc.f16", llvmcall, Float16, (Float16,), x)

@static if Metal.is_macos(v"14")
@device_function nextafter(x::Float32, y::Float32) = ccall("extern air.nextafter.f32", llvmcall, Cfloat, (Cfloat, Cfloat), x, y)
@device_function nextafter(x::Float16, y::Float16) = ccall("extern air.nextafter.f16", llvmcall, Float16, (Float16, Float16), x, y)
@device_function function nextafter(x::Float32, y::Float32)
if metal_version() >= sv"3.1" # macOS 14+
ccall("extern air.nextafter.f32", llvmcall, Cfloat, (Cfloat, Cfloat), x, y)
else
error()
end
end
@device_function function nextafter(x::Float16, y::Float16)
if metal_version() >= sv"3.1" # macOS 14+
ccall("extern air.nextafter.f16", llvmcall, Float16, (Float16, Float16), x, y)
else
error()
end
end

# hypot without use of double
Expand Down

0 comments on commit 4ea0848

Please sign in to comment.