Allowing dma_start between same "memory space"

Hi, folks. I’m continuing to play with using dma_start/dma_wait to represent asynchronous memory transfers and i’ve run into a limitation in the MLIR implementation.

As implemented, the validation of dma_start operations enforces that the source and destination memory types must be different:

LogicalResult AffineDmaStartOp::verify() {
  // DMAs from different memory spaces supported.
  if (getSrcMemorySpace() == getDstMemorySpace()) {
    return emitOpError("DMA should be between different memory spaces");

The particular memory transfers are between the same “memory space” in the scenario i’m trying to model in MLIR.

What do folks think about relaxing this limitation?

At the time this was added, it wasn’t clear if this was going to be needed. We can definitely relax it if there is a use case for operations within the same memory space. I don’t think there is anything on the op’s semantics or the implementation right now that are affected by the memory spaces being the same, but you’ll have to perhaps specify the behavior when such a DMA has an overlapping address range. Undefined behavior?

Undefined behavior works for me; is it sufficient to document that and remove the assert/check?

Yes, that sounds fine to me.