Skip to content

Commit f7483ac

Browse files
committed
Fix redefinition
1 parent a8bb216 commit f7483ac

File tree

2 files changed

+1
-59
lines changed

2 files changed

+1
-59
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AMDGPU"
22
uuid = "21141c5a-9bdb-4563-92ae-f87d6854732e"
33
authors = ["Julian P Samaroo <jpsamaroo@jpsamaroo.me>", "Valentin Churavy <v.churavy@gmail.com>", "Anton Smirnov <tonysmn97@gmail.com>"]
4-
version = "1.1.1"
4+
version = "1.1.2"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/array.jl

-58
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
1-
const MemoryRecords = LockedObject(Dict{UInt64, Any}())
2-
3-
# TODO make TLS
4-
const RECORD_MEMORY::Ref{Bool} = Ref(false)
5-
6-
function record_memory!(rec::Bool; free::Bool = true, sync::Bool = false)
7-
RECORD_MEMORY[] = rec
8-
if !rec
9-
free && free_records!(; sync)
10-
end
11-
return
12-
end
13-
14-
record_memory() = RECORD_MEMORY[]
15-
16-
function record!(x)
17-
# @info "Recording $(typeof(x)) $(size(x))"
18-
Base.lock(records -> records[_hash(x)] = x, MemoryRecords)
19-
return
20-
end
21-
22-
function free_records!(; sync::Bool = false)
23-
Base.lock(MemoryRecords) do records
24-
# @info "Freeing `$(length(records))` records"
25-
for (k, x) in records
26-
unsafe_free!(x)
27-
end
28-
empty!(records)
29-
end
30-
sync && AMDGPU.synchronize()
31-
return
32-
end
33-
34-
function remove_record!(x)
35-
record_memory() || return
36-
37-
k = _hash(x)
38-
Base.lock(MemoryRecords) do records
39-
if k in records.keys
40-
# @info "Removing record"
41-
pop!(records, k)
42-
end
43-
end
44-
return
45-
end
46-
471
mutable struct ROCArray{T, N, B} <: AbstractGPUArray{T, N}
482
buf::DataRef{Managed{B}}
493
dims::Dims{N}
@@ -69,18 +23,6 @@ mutable struct ROCArray{T, N, B} <: AbstractGPUArray{T, N}
6923
end
7024
end
7125

72-
function _hash(x::ROCArray)
73-
# @info "_hash"
74-
# @show x.buf.rc.obj.mem.ptr
75-
# @show x.offset
76-
# @show x.dims
77-
r = Base.hash(x.buf.rc.obj.mem.ptr,
78-
Base.hash(x.offset,
79-
Base.hash(x.dims)))
80-
# @show r
81-
return r
82-
end
83-
8426
GPUArrays.storage(a::ROCArray) = a.buf
8527

8628
function GPUArrays.derive(

0 commit comments

Comments
 (0)