Skip to content

Commit

Permalink
Add ctor with buffer type (#641)
Browse files Browse the repository at this point in the history
* Add ctor with buffer type

* Bump to 0.9.4
  • Loading branch information
pxl-th authored Jun 7, 2024
1 parent 5678bbb commit 4eeb92e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 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 = "0.9.3"
version = "0.9.4"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
17 changes: 7 additions & 10 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ ROCArray{T}(::UndefInitializer, dims::NTuple{N, Integer}) where {T,N} =
ROCArray{T}(::UndefInitializer, dims::Vararg{Integer, N}) where {T, N} =
ROCArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))

# from Base arrays
function ROCArray{T,N}(x::Array{T,N}, dims::Dims{N}) where {T,N}
r = ROCArray{T,N}(undef, dims)
Mem.upload!(convert(Mem.AbstractAMDBuffer, r.buf[]),
pointer(x), sizeof(x); stream=stream())
return r
end

# empty vector constructor
ROCArray{T,1}() where {T} = ROCArray{T,1}(undef, 0)

Expand All @@ -111,8 +103,13 @@ Base.sizeof(x::ROCArray) = Base.elsize(x) * length(x)

## interop with Julia arrays

ROCArray{T,N}(x::AbstractArray{S,N}) where {T,N,S} =
ROCArray{T,N}(convert(Array{T}, x), size(x))
function ROCArray{T,N,B}(x::AbstractArray{<:Any,N}) where {T,N,B}
r = ROCArray{T,N,B}(undef, size(x))
copyto!(r, convert(Array{T}, x))
return r
end

ROCArray{T,N}(x::AbstractArray{<:Any,N}) where {T,N} = ROCArray{T,N,Mem.HIPBuffer}(x)

# underspecified constructors
ROCArray(A::AbstractArray{T,N}) where {T,N} = ROCArray{T,N}(A)
Expand Down

2 comments on commit 4eeb92e

@pxl-th
Copy link
Collaborator Author

@pxl-th pxl-th commented on 4eeb92e Jun 7, 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/108503

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 v0.9.4 -m "<description of version>" 4eeb92e9e5a3ea2b418054e6fd3b915171d09d28
git push origin v0.9.4

Please sign in to comment.