Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that input memref to upmem.scatter is legal, that is, all scattered elements must be contiguous in memory #6

Open
Tracked by #2
oowekyala opened this issue Jun 18, 2024 · 1 comment

Comments

@oowekyala
Copy link
Collaborator

oowekyala commented Jun 18, 2024

This is in part enforced by the CNM scatter map shape. The scatter map mandates that the last dimensions of the input have the same shape as the buffer. However since then, CNM scatter has been made bufferizable. If the memref has a custom layout or strides, the elements may not be contiguous anyway.

For instance

%3 = scf.for %arg6 = %c0 to %c1024 step %c32 iter_args(%arg7 = %alloc_0) -> (memref<1x128xi32>) {
          %subview_2 = memref.subview %arg0[%arg2, %arg6] [1, 32] [1, 1] : memref<1x1024xi32> to memref<1x32xi32, strided<[1024, 1], offset: ?>>
          %4 = upmem.alloc_dpus : !upmem.hierarchy<1x128x1>
          upmem.scatter %subview_2[132, 32, #map] onto %4 : memref<1x32xi32, strided<[1024, 1], offset: ?>> onto !upmem.hierarchy<1x128x1>

is this legal?
-> yes, because the stride in the second dimension is 1.

@oowekyala oowekyala mentioned this issue Jun 18, 2024
18 tasks
@oowekyala oowekyala changed the title Make sure that input memref to upmem.scatter is legal, that is, all scattered elements must be continuous in memory Make sure that input memref to upmem.scatter is legal, that is, all scattered elements must be contiguous in memory Jun 19, 2024
@oowekyala
Copy link
Collaborator Author

This can currently only be verified at the CNM level. The thing is not the entire input memref is required to be contiguous, only the dimensions that we are transferring (which is the shape of the cnm.buffer). However at the upmem level, the cnm.buffer has disappeared, and the scatter/gather ops are operating on the whole memref with a linear index. We have lost information about which dimensions need to be contiguous, and which don't. We could add an attribute to upmem.gather/scatter to be able to verify that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant