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

Extracted more helper functions into test_utils and separated test.cpp and test.py versions #1208

Merged
merged 29 commits into from
Apr 11, 2024

Conversation

jackl-xilinx
Copy link
Collaborator

No description provided.

@jackl-xilinx
Copy link
Collaborator Author

So I reviewed the helper/ convenience functions in xrtUtils and the additional ones that would also be helpful and consolidated them into test_utils.h/.cpp instead of xrtUtils.h/.cpp because theses functions are not strictly xrt related. I've updated vision kernels to match this (there's more changes needed to support it).

Another choice I made was that in test_utils, I've also put it in its own namespace to avoid possible future conflicts.

Finally, section-3 test.cpp/test.py have been simplified with run loop/timer and trace stuff moved to section-4.

There may be some debate about how "simple" the new test.cpp/.py is. In particular, some feel that we should have more details about the xrt calls in the top level host code. But that seems like a lot of code that we can wrap up and prevent type-o's from creeping in. We can still refer to the xrt calls in test_utils and explain it but no need to have it in every test.cpp. I've also moved camelCase function names to underscore to make it more consistent with other helper functions.

@makslevental
Copy link
Contributor

makslevental commented Apr 10, 2024

Is everyone aware that we have extremely simple in-tree Python bindings to XRT https://github.com/Xilinx/mlir-aie/blob/main/python/XRTModule.cpp#L146-L174 since ~December?

from aie.xrt import XCLBin
xclbin = XCLBin(xclbin_path, "MLIR_AIE")

xclbin.load_ipu_instructions(ipu_insts)
[c] = xclbin.mmap_buffers([(K,)], np.int32)
wrap_C = np.asarray(c)
C = np.zeros((K,), dtype=np.int32)
np.copyto(wrap_C, C, casting="no")

xclbin.sync_buffers_to_device()
xclbin.run()
print("Running kernel")
xclbin.wait(30)
xclbin.sync_buffers_from_device()

@jackl-xilinx jackl-xilinx merged commit 7278621 into Xilinx:asplos Apr 11, 2024
@jackl-xilinx
Copy link
Collaborator Author

Is everyone aware that we have extremely simple in-tree Python bindings to XRT https://github.com/Xilinx/mlir-aie/blob/main/python/XRTModule.cpp#L146-L174 since ~December?

from aie.xrt import XCLBin
xclbin = XCLBin(xclbin_path, "MLIR_AIE")

xclbin.load_ipu_instructions(ipu_insts)
[c] = xclbin.mmap_buffers([(K,)], np.int32)
wrap_C = np.asarray(c)
C = np.zeros((K,), dtype=np.int32)
np.copyto(wrap_C, C, casting="no")

xclbin.sync_buffers_to_device()
xclbin.run()
print("Running kernel")
xclbin.wait(30)
xclbin.sync_buffers_from_device()

Sorry, Max. I was not aware. This looks really good for the python host code. I'll bring it up as something we can use. Thanks for pointing it out.

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

Successfully merging this pull request may close these issues.

2 participants