Skip to content

Commit b3b9790

Browse files
authored
Replace PerDevice cache with GPUToolbox memoization (#268)
1 parent a0e2353 commit b3b9790

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CUDA_Tile_jll = "2068806d-a867-5dbd-af0e-42c2eb5d895d"
1515
CompilerCaching = "9db33cc3-5358-4881-8759-fa4194144afd"
1616
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
1717
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
18+
GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
1819
IRStructurizer = "93e32bba-5bb8-402b-805d-ffb066edee93"
1920
LMDB = "11f193de-5e89-5f17-923a-7d207d56daf9"
2021
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
@@ -42,6 +43,7 @@ CompilerCaching = "0.2.4"
4243
DLFP8Types = "0.1.0"
4344
EnumX = "1.0"
4445
GPUArrays = "11"
46+
GPUToolbox = "3"
4547
IRStructurizer = "0.6.2"
4648
LMDB = "3"
4749
Microfloats = "0.2"

src/launch.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# `(MethodInstance, sm_arch, opt_level, num_ctas, occupancy, num_worker_warps, bytecode_version)`.
77

88
using CUDACore: CUDACore, CuArray, CuModule, CuFunction, cudacall, device, capability,
9-
AbstractBackend, AbstractKernel, kernel_convert, kernel_compile, PerDevice
9+
deviceid, AbstractBackend, AbstractKernel, kernel_convert, kernel_compile
1010
using CUDA_Compiler_jll
11+
using GPUToolbox: @memoize
1112
using Preferences: @load_preference
1213

1314
using Adapt: Adapt, adapt
@@ -176,8 +177,6 @@ function run_and_collect(cmd)
176177
return proc, log
177178
end
178179

179-
const tile_ir_support = PerDevice{Union{Nothing, VersionNumber}}()
180-
181180
const toolkit_version_cache =
182181
Base.Lockable(Base.RefValue{Union{Nothing, Some{Union{Nothing, String}}}}(nothing))
183182

@@ -339,7 +338,7 @@ function check_tile_ir_support()
339338
end
340339

341340
dev = device()
342-
ver = get!(tile_ir_support, dev) do
341+
ver = @memoize index=deviceid(dev)+1 begin
343342
ver = bytecode_version()
344343

345344
cap = capability(dev)
@@ -356,7 +355,7 @@ function check_tile_ir_support()
356355
end
357356

358357
return ver
359-
end
358+
end::Union{Nothing, VersionNumber}
360359

361360
if ver === nothing
362361
error("CUDA Tile is not supported on the current device")

0 commit comments

Comments
 (0)