[RFC] Simplifying Dynamic Shared Memory Access in GPU

This will depend on how you define the semantics of having SSA-values vs using attributes for the operands. If you define them as static attributes being semantically equivalent to having constant SSA values, then no, as (I assume) you might then turn the constant SSA values to attributes and run into the same problem as before.

You can define attributes as additionally verifying that property, but this has the implications that:

%100 = arith.constant 100
gpu.launch dynamic_shared_memory_size %100 {
  %2 = gpu.dynamic.shared.memory [1, 0, 0] : memref<32x64xf32,3>

cannot be constant folded to gpu.launch dynamic_shared_memory_size 100 as this creates an ill-formed structure out of something that was previously not.
Whether the conceptual overhead of being able to use both Attributes and SSA-Values as operands is worth it I have no clue as I am too unfamiliar with memref, bufferization etc. where I believe this is more commonly used (and I don’t know why).

For a previous discussion see also [RFC] More OpFoldResult and "mixed indices" in ops that deal with Shaped Values

1 Like