33# # genericmemory.jl: Managed Memory
44
55"""
6- GenericMemory{kind::Symbol, T, addrspace=Core.CPU} <: AbstractVector {T}
6+ GenericMemory{kind::Symbol, T, addrspace=Core.CPU} <: DenseVector {T}
77
8- One-dimensional dense array with elements of type `T`.
8+ Fixed-size [`DenseVector{T}`](@ref DenseVector).
9+
10+ `kind` can currently be either `:not_atomic` or `:atomic`. For details on what `:atomic` implies, see [`AtomicMemory`](@ref)
11+
12+ `addrspace` can currently only be set to Core.CPU. It is designed to to permit extension by other systems
13+ such as GPUs, which might define values such as:
14+ ```
15+ module CUDA
16+ const Generic = bitcast(Core.AddrSpace{CUDA}, 0)
17+ const Global = bitcast(Core.AddrSpace{CUDA}, 1)
18+ end
19+ ```
20+ 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.
921
1022!!! compat "Julia 1.11"
1123 This type requires Julia 1.11 or later.
@@ -15,7 +27,7 @@ GenericMemory
1527"""
1628 Memory{T} == GenericMemory{:not_atomic, T, Core.CPU}
1729
18- One-dimensional dense array with elements of type `T` .
30+ Fixed-size [`DenseVector{T}`](@ref DenseVector) .
1931
2032!!! compat "Julia 1.11"
2133 This type requires Julia 1.11 or later.
@@ -25,8 +37,18 @@ Memory
2537"""
2638 AtomicMemory{T} == GenericMemory{:atomic, T, Core.CPU}
2739
28- One-dimensional dense array with elements of type `T`, where each element is
29- independently atomic when accessed, and cannot be set non-atomically.
40+ Fixed-size [`DenseVector{T}`](@ref DenseVector).
41+ Access to its any of its elements is performed atomically (with `:monotonic` ordering).
42+ Setting any of the elements must be accomplished using the `@atomic` macro and explicitly specifying ordering.
43+
44+ !!! warning
45+ Each element is independently atomic when accessed, and cannot be set non-atomically.
46+ Currently the `@atomic` macro and higher level interface have not been completed,
47+ but the building blocks for a future implementation are the internal intrinsics
48+ `Core.memoryrefget`, `Core.memoryrefset!`, `Core.memoryref_isassigned`, `Core.memoryrefswap!`,
49+ `Core.memoryrefmodify!`, and `Core.memoryrefreplace!`.
50+
51+ For details, see [Atomic Operations](@ref man-atomic-operations)
3052
3153!!! compat "Julia 1.11"
3254 This type requires Julia 1.11 or later.
0 commit comments