Skip to content

Commit 59493c7

Browse files
committed
update spec changes: include access
1 parent 23f419d commit 59493c7

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

proposals/030-coherent-pointers.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SP\#030: Coherent Pointers
1+
# SP\#030: Coherent Pointers & Pointer Access
22

33
## Status
44

@@ -13,6 +13,8 @@ Reviewer:
1313

1414
GPUs have a concept known as coherent operations. Coherent operations flush cache for reads/writes so that when **thread A** modifies memory, **thread B** may read that memory, seeing all changes to memory done by a different thread. When flushing cache it is important to note that not all caches will be flushed. If a user wants coherence to `WorkGroup` memory, only the levels of cache up to `WorkGroup` memory will need to be flushed.
1515

16+
Additionally, pointers will be permitted to be marked as read-only or read/write. A read-only pointer will be immutable (unable to modify the data pointed to).
17+
1618
### Prior Implementations
1719

1820
* HLSL – `globallycoherent` keyword can be added to declarations (`globallycoherent RWStructuredBuffer<T> buffer`). This keyword ensures coherence with all operations to a tagged object. Memory scope of coherence is device memory. `groupshared` objects are likely coherent, specification does not specify.
@@ -45,10 +47,12 @@ If we specify `MakePointerAvailable/MakePointerVisible` with `OpStore`/`OpLoad`
4547

4648
## Proposed Solution
4749

48-
### Frontend For Coherent Pointers
50+
### Frontend For Coherent Pointers & Pointer Access
4951

5052
We propose to implement coherence on a per-operation level for only SPIR-V targets. This will be accomplished through modifying `Ptr` to include the new generic argument `CoherentScope coherentScope`.
5153

54+
We also propose the new generic argument `Access access` to specify if a pointer is read-only or not.
55+
5256
```c#
5357
public enum CoherentScope
5458
{
@@ -63,7 +67,13 @@ public enum CoherentScope
6367
//...
6468
}
6569

66-
__generic<T, uint64_t addrSpace=AddressSpace::UserPointer, CoherentScope coherentScope=CoherentScope::NotCoherent>
70+
public enum Access
71+
{
72+
ReadWrite = 0,
73+
Read = 1
74+
}
75+
76+
__generic<T, uint64_t addrSpace=AddressSpace::UserPointer, Access access = Access::ReadWrite, CoherentScope coherentScope=CoherentScope::NotCoherent>
6777
struct Ptr
6878
{
6979
...
@@ -72,11 +82,14 @@ struct Ptr
7282

7383
If `coherentScope` is not `CoherentScope::NotCoherent`, all accesses to memory through this pointer will be considered coherent to the specified memory scope (example: `CoherentScope::Device` is coherent to the memory scope of `Device`).
7484

75-
We will also provide a type alias for user-convenience.
85+
If `access` is `Access::ReadWrite` a pointer can read/write to the data pointed to.
86+
If `access` is `Access::Read`, a pointer will only be allowed to read from the data pointed to.
87+
88+
We will also provide a a type alias for user-convenience.
7689

7790
```c#
78-
__generic<T>
79-
typealias CoherentPtr = Ptr<T, AddressSpace::UserPointer, CoherentScope::CrossDevice>;
91+
__generic<T, Access access = Access::ReadWrite>
92+
typealias CoherentPtr = Ptr<T, AddressSpace::UserPointer, access, CoherentScope::Device>;
8093
```
8194

8295
### Support For Coherent Buffers and Textures
@@ -104,19 +117,24 @@ Any access through a coherent-pointer to a `groupshared` object is coherent; Sin
104117

105118
We will allow pointers with different `CoherentScope` to be explicitly castable to each other. For example, `CoherentPtr<int, CoherentScope::Device>` will be castable to `CoherentPtr<int, MemoryScope.Workgroup>`.
106119

120+
### Casting and Pointer access
121+
122+
We will not allow casting between pointers of different `Access`.
123+
107124
### Banned keywords
108125

109126
HLSL style `globallycoherent T*` and GLSL style `coherent T*` will be disallowed.
110127

111128
### Order of Implementation
112129

113-
1. Support for workgroup memory pointers.
114-
2. Frontend for coherent pointers
115-
3. Support for coherent buffers and textures
116-
4. Support for coherent workgroup memory
117-
5. Support for coherent cooperative matrix & cooperative vector
118-
6. Support casting between pointers with different `CoherentScope`
119-
7. disallow `globallycoherent T*` and `coherent T*`
130+
* Frontend for coherent pointers & pointer access
131+
* Logic for pointer access
132+
* Support for coherent buffers and textures
133+
* Support casting between pointers with different `CoherentScope`
134+
* Support for workgroup memory pointers.
135+
* Support for coherent workgroup memory
136+
* Support for coherent cooperative matrix & cooperative vector
137+
* disallow `globallycoherent T*` and `coherent T*`
120138

121139
## Future Work
122140

0 commit comments

Comments
 (0)