Skip to content

[WIP][SYCL] Host pipe runtime implementation #5894

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

Closed
wants to merge 10 commits into from

Conversation

sherry-yuan
Copy link
Contributor

@sherry-yuan sherry-yuan commented Mar 25, 2022

Spec: #5838
Broken down version of: #5851

The first three commits come from the following 3 changes:
Resolves #5766
Resolves #5854
Resolves #5885

Closes #5851

Although it's 1000+ lines change but first three commit does not need to be looked at.

@sherry-yuan sherry-yuan changed the title Host pipe runtime2 [WIP][SYCL] Host pipe runtime implementation Mar 25, 2022
@sherry-yuan sherry-yuan force-pushed the host_pipe_runtime2 branch 4 times, most recently from 7477220 to 0c0d218 Compare March 31, 2022 20:33
@sherry-yuan sherry-yuan force-pushed the host_pipe_runtime2 branch 2 times, most recently from ac564e9 to 2db1ba4 Compare April 20, 2022 21:40
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

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.
Setup lower runtime extension functions for host pipes.

See also
intel#5766
intel#5851

Host pipe sycl spec: intel#5838
Defines new properties for data flow pipes

Properties defined to align with spec in [1]

Existing data flow pipe defined in [2]

data flow pipe will be accepting new property list, spec in [3]

[1] intel#5839
[2] https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_intel_dataflow_pipes.asciidoc
[3] intel#5838
Defines the flow of enqueue new host pipe operations (read/write),
User provide the queue to enqueue this event, and the runtime queries
the pipe address from registration using the given address and unique ID.
The runtime pass the pipe name, and host address into queue submit of new command group.
The enqueued command calls new opencl function, and provide the current program, queue,
event wait list, pipe name, host pointer of the data destination.

Spec: intel#5838
The pipe name is generated in integration footer and will be available to the runtime during device image registration.

The runtime then store host pipe information in host piep map entry, which is kept track of in program manager.

The host pipe information can be queried from the program manager through getHostPipeEntry using the host pipe pointer that is determined by its class member __pipe.
To build program before first kernel launch, the program manager requires knowing the device image, device and context associated with a host pipe.
It then will take from cache or build the program from device image.
This work around the difficulty of program being built on first kernel launch, and allows the host pipe read/write to happen at any point.
This test mocks the following:
1. host pipe registration
2. device image registration
3. opencl function calls

This aims to test: assuming the host pipe registration is correct the host pipe read and write should behave correctly, in this case, read and write the right data into the global variables.
@zibaiwan
Copy link
Contributor

Please make sure don't delete this. I am porting this to a new PR.

@github-actions github-actions bot removed the Stale label Nov 18, 2022
steffenlarsen pushed a commit that referenced this pull request Mar 30, 2023
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>
@github-actions
Copy link
Contributor

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@github-actions github-actions bot added the Stale label May 18, 2023
@bader bader closed this Sep 14, 2023
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.

3 participants