================
@@ -3303,6 +3303,17 @@ The field indicates how much data is fetched on a cache 
miss. It is only support
 on GFX13. GFX13 only honors it for load and atomic operations. GFX13 does not
 support a 32-byte fetch size so it treats CFS_32B the same as CFS_64B.
 
+(amdgpu_noclobber)=
+
+### '`amdgpu.noclobber`' Metadata
+
+If a `load` instruction marked as `!amdgpu.noclobber` may see any write
+other than the initialization of that location at kernel launch according to 
the
----------------
ritter-x2a wrote:

> > I'd say that the writes the load may see must all happen-before (not sure 
> > about availability, I think that might not be necessary for this aspect) 
> > the dispatching operation in the host
>
> I think we should always talk about availability. location-order is now the 
> "observable happens-before" for most purposes. It's just that we will always 
> include availability in big operations like dispatching a kernel, which is 
> governed in Vulkan by system-synchronize-with.

I didn't mean "we don't need to go to the model with avail/vis", I meant that, 
in the model with avail/vis, I think it would be enough to require 
(amdgpu-)happens-before without availability and visibility.
Requiring location-order with the operation that does the kernel dispatch would 
be somewhat weird, because location-order only connects accesses to the 
same/overlapping locations, so we'd need to say that the dispatch operation 
accesses everything that the kernel accesses (or add some special cases to the 
location-order definition).
It's probably also not necessary that the prior store is made available to the 
dispatch operation on the host if it comes from a different kernel dispatch on 
the same device; an agent-scoped make-available from the writing kernel should 
be fine. (see the example below)

> There, we decided to simply say "the location must not be written to during 
> the lifetime of the dispatch".

That doesn't work here; the goal of noclobber is to mark loads from locations 
that were not (safely) modified before the load during the lifetime of the 
dispatch.
We could write something like "If a location accessed by a load L that is 
marked as `!amdgpu.noclobber` has been written to during the liftime of the 
dispatch before L is executed, L returns undef (for this location?)."
But the vague notion of time in that wording triggers alarm bells in my mind. 
That would at least require a note saying that it needs to be updated once we 
have sketched out how exactly kernel dispatches fit into the model.


> Yeah, but like you said, for that our relations should not stop at dispatch 
> boundaries.

That's what I had in mind with this wording. Consider the following example 
(with some newly imagined kernel dispatch syntax):

```
#agent host
#thread h1
  $A_h1: load.acquire.avnone.ss=system flag  // reads from $R_d1, synchronizes
  $D: kernel_dispatch d2

#agent dev
  #workgroup d1
    #thread d1
      $S_d1: store.av=agent p
      $R_d1: store.release.avnone.ss=system flag

  #workgroup d2
    #thread d2
      $K_d2: kernel_start  // establishes some kind of hb with dispatch $D
      $L_d2: load.noclobber.av=agent p  // should read from $S_d1, no data race 
or noclobber problem
      $S_d2: store p  // $L_d2 may not see this, so it doesn't cause a 
noclobber problem
```

I'd see an (amdgpu-)happens-before chain `$S_d1 -> $R_d1 -> $A_h1 -> $D -> 
$K_d2 -> $L_d2 -> $S_d2`.
Because `$S_d1 -> $D` is in (amdgpu-)happens-before, the `noclobber` annotation 
of `$L_d2` does not cause it to return undef.
Because `$S_d1 -> $L_d2` is in (amdgpu-)happens-before with sufficient 
availability/visibility operations, which establishes location-order, there is 
also no data race causing `$L_d2` to return undef.

We don't have to fully flesh out how dispatches are handled in the memory model 
in this bugfix PR here, though.
I'd be fine with something more vague here and a note that we'll make it more 
concrete once the corresponding machinery is in place.

https://github.com/llvm/llvm-project/pull/219991
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to