-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document GenericMemory and AtomicMemory #54642
Changes from all commits
501e7de
25d3595
2189584
54e5809
ee46aad
d0fac47
9f7959f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,9 +3,21 @@ | |||||||||
## genericmemory.jl: Managed Memory | ||||||||||
|
||||||||||
""" | ||||||||||
GenericMemory{kind::Symbol, T, addrspace=Core.CPU} <: AbstractVector{T} | ||||||||||
GenericMemory{kind::Symbol, T, addrspace=Core.CPU} <: DenseVector{T} | ||||||||||
|
||||||||||
One-dimensional dense array with elements of type `T`. | ||||||||||
Fixed-size [`DenseVector{T}`](@ref DenseVector). | ||||||||||
|
||||||||||
`kind` can currently be either `:not_atomic` or `:atomic`. For details on what `:atomic` implies, see [`AtomicMemory`](@ref) | ||||||||||
|
||||||||||
`addrspace` can currently only be set to Core.CPU. It is designed to to permit extension by other systems | ||||||||||
such as GPUs, which might define values such as: | ||||||||||
``` | ||||||||||
module CUDA | ||||||||||
const Generic = bitcast(Core.AddrSpace{CUDA}, 0) | ||||||||||
const Global = bitcast(Core.AddrSpace{CUDA}, 1) | ||||||||||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This code doesn't work since a) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was unresolved with the force push. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops. Will re-resolve once #54681 merges. |
||||||||||
end | ||||||||||
``` | ||||||||||
The exact semantics of these other addrspaces is defined by the specific backend, but will error if the user is attempting to access these on the CPU. | ||||||||||
|
||||||||||
!!! compat "Julia 1.11" | ||||||||||
This type requires Julia 1.11 or later. | ||||||||||
|
@@ -15,7 +27,7 @@ GenericMemory | |||||||||
""" | ||||||||||
Memory{T} == GenericMemory{:not_atomic, T, Core.CPU} | ||||||||||
|
||||||||||
One-dimensional dense array with elements of type `T`. | ||||||||||
Fixed-size [`DenseVector{T}`](@ref DenseVector). | ||||||||||
|
||||||||||
!!! compat "Julia 1.11" | ||||||||||
This type requires Julia 1.11 or later. | ||||||||||
|
@@ -25,8 +37,18 @@ Memory | |||||||||
""" | ||||||||||
AtomicMemory{T} == GenericMemory{:atomic, T, Core.CPU} | ||||||||||
|
||||||||||
One-dimensional dense array with elements of type `T`, where each element is | ||||||||||
independently atomic when accessed, and cannot be set non-atomically. | ||||||||||
Fixed-size [`DenseVector{T}`](@ref DenseVector). | ||||||||||
Access to its any of its elements is performed atomically (with `:monotonic` ordering). | ||||||||||
Setting any of the elements must be accomplished using the `@atomic` macro and explicitly specifying ordering. | ||||||||||
|
||||||||||
!!! warning | ||||||||||
Each element is independently atomic when accessed, and cannot be set non-atomically. | ||||||||||
Currently the `@atomic` macro and higher level interface have not been completed, | ||||||||||
but the building blocks for a future implementation are the internal intrinsics | ||||||||||
`Core.memoryrefget`, `Core.memoryrefset!`, `Core.memoryref_isassigned`, `Core.memoryrefswap!`, | ||||||||||
`Core.memoryrefmodify!`, and `Core.memoryrefreplace!`. | ||||||||||
|
||||||||||
For details, see [Atomic Operations](@ref man-atomic-operations) | ||||||||||
oscardssmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
!!! compat "Julia 1.11" | ||||||||||
This type requires Julia 1.11 or later. | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it'd be better to be more precise regarding "fixed-size"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see this is clearer. Is there an ambiguity with the original version? Would "constant length" be clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the current version is OK. My motivation is to avoid confusion with the StaticArrays.jl-sense of "constant length", where the length is in the type domain.