Skip to content

Commit

Permalink
Fix redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
pxl-th committed Nov 19, 2024
1 parent a8bb216 commit f7483ac
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AMDGPU"
uuid = "21141c5a-9bdb-4563-92ae-f87d6854732e"
authors = ["Julian P Samaroo <jpsamaroo@jpsamaroo.me>", "Valentin Churavy <v.churavy@gmail.com>", "Anton Smirnov <tonysmn97@gmail.com>"]
version = "1.1.1"
version = "1.1.2"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
58 changes: 0 additions & 58 deletions src/array.jl
Original file line number Diff line number Diff line change
@@ -1,49 +1,3 @@
const MemoryRecords = LockedObject(Dict{UInt64, Any}())

# TODO make TLS
const RECORD_MEMORY::Ref{Bool} = Ref(false)

function record_memory!(rec::Bool; free::Bool = true, sync::Bool = false)
RECORD_MEMORY[] = rec
if !rec
free && free_records!(; sync)
end
return
end

record_memory() = RECORD_MEMORY[]

function record!(x)
# @info "Recording $(typeof(x)) $(size(x))"
Base.lock(records -> records[_hash(x)] = x, MemoryRecords)
return
end

function free_records!(; sync::Bool = false)
Base.lock(MemoryRecords) do records
# @info "Freeing `$(length(records))` records"
for (k, x) in records
unsafe_free!(x)
end
empty!(records)
end
sync && AMDGPU.synchronize()
return
end

function remove_record!(x)
record_memory() || return

k = _hash(x)
Base.lock(MemoryRecords) do records
if k in records.keys
# @info "Removing record"
pop!(records, k)
end
end
return
end

mutable struct ROCArray{T, N, B} <: AbstractGPUArray{T, N}
buf::DataRef{Managed{B}}
dims::Dims{N}
Expand All @@ -69,18 +23,6 @@ mutable struct ROCArray{T, N, B} <: AbstractGPUArray{T, N}
end
end

function _hash(x::ROCArray)
# @info "_hash"
# @show x.buf.rc.obj.mem.ptr
# @show x.offset
# @show x.dims
r = Base.hash(x.buf.rc.obj.mem.ptr,
Base.hash(x.offset,
Base.hash(x.dims)))
# @show r
return r
end

GPUArrays.storage(a::ROCArray) = a.buf

function GPUArrays.derive(
Expand Down

2 comments on commit f7483ac

@pxl-th
Copy link
Member Author

@pxl-th pxl-th commented on f7483ac Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119785

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.2 -m "<description of version>" f7483ac5b810911ce83d1b8efa551b1c162bf0b8
git push origin v1.1.2

Please sign in to comment.