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

Access memory allocated in segment in the herd #666

Closed
hunhoffe opened this issue Jul 12, 2024 · 5 comments
Closed

Access memory allocated in segment in the herd #666

hunhoffe opened this issue Jul 12, 2024 · 5 comments

Comments

@hunhoffe
Copy link
Collaborator

I'm trying to make an example where I allocate it in the segment (in L2 memory) and then use it as a target for the dma_memcpy_nd in the herd within the segment. I have written an example for that in a branch called alloc-check-example.

In the current form of the code, where I try to send the allocated memory to the herd through an operand/argument, I get the following error:

  File "mlir-air/install-xrt/python/air/dialects/_air_ops_ext.py", line 105, in <listcomp>
    operand_types = [s.type for s in sizes] * 2 + [o.type for o in operands]
AttributeError: 'AllocOp' object has no attribute 'type'
make: *** [Makefile:9: run] Error 1

If I don't try to send it from the segment to the herd as a herd operand, I get this error instead:

air._mlir_libs._site_initialize.<locals>.MLIRError: Unable to parse module assembly:
error: "-":21:11: 'air.dma_memcpy_nd' op using value defined outside the region
 note: "-":21:11: see current operation: "air.dma_memcpy_nd"(<<UNKNOWN SSA VALUE>>, %arg4, %2, %3, %4, %5, %6, %7) <{operandSegmentSizes = array<i32: 0, 1, 0, 0, 0, 1, 2, 2, 2>}> : (memref<16x8xi32, 1 : i32>, memref<32x16xi32>, index, index, index, index, index, index) -> ()
 note: "-":11:9: required by region isolation constraints
make: *** [Makefile:9: run] Error 1

I believe one of these two things should work, but I'm not sure which one (or both).

@erwei-xilinx
Copy link
Collaborator

In the first case, it looks to me that it was the memref.alloc op that got passed as argument to the herd op. I think if we pass the ssa memref value being returned from the alloc op, then it might work? Would be really useful if you could share the example.

In the second case, yeah this is expected because air herd/segment/launch ops have trait isolatedFromAbove.

@hunhoffe
Copy link
Collaborator Author

The example is here: https://github.com/Xilinx/mlir-air/blob/alloc-check-example/programming_examples/segment_alloc/segment_alloc.py

I'm not sure how to get a handle to/represent the ssa memref value in Python, but I can try to look into it. Let me know if you have any ideas!

@erwei-xilinx
Copy link
Collaborator

I'm not expert in mlir python binding, but just wondering if we could do something here to check for operand's returned value's type if operand is an Operation instead of Value?

operand_types = [s.type for s in sizes] * 2 + [o.type for o in operands]

@hunhoffe
Copy link
Collaborator Author

I'll give it a try!

@hunhoffe
Copy link
Collaborator Author

It worked! Solution merged here: #668

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

2 participants