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

[ESI][Runtime] XRT support for host memory access #8122

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

teqdruid
Copy link
Contributor

Adds support for allocating, flushing, and getting the device pointer on XRT platforms.

@teqdruid teqdruid added the ESI label Jan 23, 2025
Adds support for allocating, flushing, and getting the device pointer on
XRT platforms.
@teqdruid teqdruid force-pushed the teqdruid/esirt/xrthostmem branch from 1c07d92 to ef7e3c0 Compare January 23, 2025 20:24
@teqdruid teqdruid requested a review from mortbopet January 23, 2025 21:01
Copy link
Contributor

@mortbopet mortbopet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know much about the XRT intricacies, so someone else would be better suited to review that. A few other style comments... (and I'll never get over the use of raw pointers and new in the ESI runtime used anywhere outside of an immediate wrapping of a smart pointer, but you know that 🤷).

lib/Dialect/ESI/runtime/cpp/lib/backends/Xrt.cpp Outdated Show resolved Hide resolved
lib/Dialect/ESI/runtime/cpp/lib/backends/Xrt.cpp Outdated Show resolved Hide resolved
/// It is recommended to use 'sync' to flush the caches before executing any
/// DMA.
virtual void flush() override { bo.sync(XCL_BO_SYNC_BO_TO_DEVICE); }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any sense in adding 'dirty'-flags to HostMemRegion s.t. when a write has been performed to it, HostMem implementations can check/verify that flush has been called?

I'm just a bit sceptical about the "it's recommended" phrase (although that probably originates from xrt documentation and not you). I can accept "it's recommended" if it's purely performance related, but if not, it either is required or it isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a 'write' method on HostMemRegion. Standard use case is that the application writes directly to the host pointer. Avoids a memcpy, which as you well know is a killer on the host. So I have no way of (quickly) determining whether the buffer is dirty.

As for it's recommended... certain platforms will require it, and certain platforms won't. In the interest of applications writing platform-independent code, I wrote that it's recommended. As for Xrt, I found some documentation saying:

XRT Native API: xrt::bo::sync()) should be used. Though these API will not do any DMA operation, they are used for Cache Invalidate/Flush as the application works on the Cache memory.

so it sounds like it's required. I'll update the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm surprised that it's not required for the Catapult based platforms on x86. But I don't fully understand how this new user-pointer translation support works. It must go through the cache system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teqdruid teqdruid force-pushed the teqdruid/esirt/xrthostmem branch from 6ba4fe8 to 92174df Compare January 24, 2025 16:00
@teqdruid teqdruid merged commit 328a4bd into main Jan 24, 2025
5 checks passed
@teqdruid teqdruid deleted the teqdruid/esirt/xrthostmem branch January 24, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants