-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Implement initial host_pipe registration #5766
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
Conversation
5a7360f
to
8b8574d
Compare
struct HostPipeMapEntry { | ||
// Pointer to the host_pipe on host. | ||
void *MHostPipePtr; | ||
// Size of the underlying type in the host_pipe. | ||
std::uint32_t MHostPipeTSize; | ||
// True if the host_pipe has been decorated with device_image_scope | ||
bool MIsDeviceImageScopeDecorated; | ||
|
||
// Constructor only initializes with the pointer to the host_pipe as the | ||
// additional information is loaded after. | ||
HostPipeMapEntry(void *HostPipePtr) | ||
: MHostPipePtr(HostPipePtr), MHostPipeTSize(0), | ||
MIsDeviceImageScopeDecorated(false) {} | ||
|
||
void initialize(std::uint32_t HostPipeTSize, | ||
bool IsDeviceImageScopeDecorated) { | ||
assert(HostPipeTSize != 0 && "Host pipe initialized with 0 size."); | ||
assert(MHostPipeTSize == 0 && "Host pipe has already been initialized."); | ||
MHostPipeTSize = HostPipeTSize; | ||
MIsDeviceImageScopeDecorated = IsDeviceImageScopeDecorated; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main place of interest: Is there other information that needed to be encoded in each pipe_id to pipe_pointer mapping. Currently it only keeps track of the underlying data type's size and whether is device image scope decorated (which I doubt if it is needed), possibly need to see the final spec to determine what is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite interesting features.
@@ -383,6 +383,13 @@ class DeviceBinaryImage { | |||
DeviceGlobals.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS); | |||
return DeviceGlobals; | |||
} | |||
const PropertyRange getHostPipes() const { | |||
// We can't have this variable as a class member, since it would break | |||
// the ABI backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This do-not-break-my-ABI story starts being a technical debt generator... :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not against your comment, but more generally targeted at the project itself. @bader
@sherry-yuan So I want your great comment back! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding TODO here (like
llvm/sycl/include/CL/sycl/stream.hpp
Line 802 in 769851c
// TODO: This field is not used anymore. |
@s-kanaev, list you generated recently could be updated with this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I will add //TODO
in a separate PR that annotated all places in this files that will require changes after ABI policy change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODOs are annotated in #5929
Let me know if there is any additional information that needs to be encoded/added in the class (for integration with frontend, and integration with runtime). The main place of interest is commented up there: |
This comment was marked as resolved.
This comment was marked as resolved.
6f63eaa
to
aa8906e
Compare
Hi all, the suggestions are applied accordingly, the review could resume now. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PropertySetIO
changes LGTM.
It looks like the patch don't have a unit-test for the runtime changes. I honestly have no idea how to write those, but @intel/llvm-reviewers-runtime should be able to help here
Thanks for the review!
The test will only be meaningful if the frontend changes are also implemented. This change set up the required structure for storing the information of the host pipe (which compilation should cover what it is supposed to do). Once the frontend change & integration footer is done, then a unit test could be written to check if the whole flow works as expected. (do let me know if there is a way to test this specific part tho) |
9e689d5
9e689d5
to
5fb2f3a
Compare
What is this for: pipes expose the concept of a first in first out buffer, this FIFO construct provide link between elements of a design that are accessed through read/write/push/pop APIs. A host pipe is a pipe that links a device kernel with host program. This extension is framed from FPGA perspective. This change add required interface for the integration footer to register the `host_pipe` of a program as well as reading extended info supplied through "SYCL/host pipes" property. Info is stored in a map managed by program manager. The integration header and footer provides a mapping from the host address of each pipe variable to the unique string for that variable. This is required so that sycl runtime can query the pipe address from the given pipe name, and pass both into opencl runtime function calls. Opencl defines pipes, which are FIFO constructs that are consistent with Khronos specification. Spec link: intel#5838 List of suported properties: intel#5839 Note: it is the first change to runtime relating to host_pipe, thus the feature is not complete / fully testable. It is intended to add an interface for integration footer as well as consumer for the information sycl-post-link will be generating when future work is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PI API changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@intel/llvm-gatekeepers This change is ready to merge. The test failures are known issues that are not related to this change, as it was also discovered in another PR. Edit, the test re-run fails because of the known issue commented here: #5924 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good.
Though, are there any tests to be added for this functionality?
Unit-tests or E2E ones (in intel/llvm-test-suite)?
Thanks @s-kanaev for the comments. This change is intended to unblock future development on integration footer (by exposing the |
Got it. Thank you. |
Setup lower runtime extension functions for host pipes. See also intel#5766 intel#5851 Host pipe sycl spec: intel#5838
Please make sure don't delete this. I am porting this to a new PR. |
Setup lower runtime extension functions for host pipes. See also intel#5766 intel#5851 Host pipe sycl spec: intel#5838 (cherry picked from commit e4d513c) Zibai fixed the conflict.
Setup lower runtime extension functions for host pipes. See also intel#5766 intel#5851 Host pipe sycl spec: intel#5838 (cherry picked from commit e4d513c) Zibai fixed the conflict.
Disclaimer: This work is a continuation of a previous approved Sherry's PR: #5766 and her draft work #5894. We are implementing Hostpipes based on the Spec [here](https://github.com/rho180/llvm/blob/rho180-pipe-design/sycl/doc/design/HostPipes.md). OpenCL spec is [here](https://github.com/intel-sandbox/ip-authoring-specs/blob/MJ_ChangeDocs4/Pipe/Spec/cl_intel_host_pipe_symbol.asciidoc). The following is the outline of the design. 1. The host pipe properties need to be added to the device image (probably similar to the previous change here a9ad3af) 2.The frontend calls the [registration of device image, maybe similar to this code](https://github.com/intel/llvm/blob/af858c74e4be95b2163ce6ba545ce588ff0aca4c/sycl/source/detail/program_manager/program_manager.cpp#L2014): which is where the host pipe information is available. This is where the mapping from host pipe name to host pipe pointer is extracted. 3. The frontend also calls `host_pipe_map::add` to register/initialize the host pipes. This is the new function. We are not sure about the ordering of registration of device image / registration of host pipe. for which ever one that comes later, it need to initialize the remaining attribute of host pipe (such as its properties). 4. The opencl runtime will need to get a cl_program object, which is typically not available until the first kernel launch. To get a program object early on, the host pipe name/pointer to device image mapping is cached during registration. And when the specific host pipe is needed, build the program and get its ocl runtime representation. This is done in the first couple commits. 5. Since a host pipe read/write need to depend on other write operation finishing before it (including the inter kernel write). This means the pipe needs to know the dependency of kernel execution. For this reason, the host pipe read and write ocl function cannot be called with no dep event. therefore, it is implemented with handler , which is aware of the event that it is supposed to wait upon. This is done in the "Register new command group .." commit. 6. Unit test - mock a fake device image. - register the fake device image - register fake pipe with some name you specified - fake the opencl functionality, this can be done with unittest::PiMock::redefine --------- Co-authored-by: Sherry Yuan <sherry.yuan@intel.com> Co-authored-by: Ho, Robert <robert.ho@intel.com>
What is this for: pipes expose the concept of a first in first out buffer,
this FIFO construct provide link between elements of a design that are
accessed through read/write/push/pop APIs.
A host pipe is a pipe that links a device kernel with host program.
This extension is framed from FPGA perspective.
This change add required interface for the integration footer to register
the
host_pipe
of a program as well as reading extended info suppliedthrough "SYCL/host pipes" property.
Info is stored in a map managed by program manager.
The integration header and footer provides a mapping from the host address of
each pipe variable to the unique string for that variable.
This is required so that sycl runtime can query the pipe address from the
given pipe name, and pass both into opencl runtime function calls.
Opencl defines pipes, which are FIFO constructs that are consistent with Khronos specification.
Note: it is the first change to runtime relating to host_pipe,
thus the feature is not complete / fully testable.
It is intended to add an interface for integration footer as well as
consumer for the information sycl-post-link will be generating when
future work is added.
Spec link: #5838
CC: @pcolberg @aditikum @rho180