Skip to content

[SYCL] create PI (Plugin Interface) layer and redirect there platform/device stuff. #222

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

Merged
merged 3 commits into from
Jul 1, 2019

Conversation

smaslov-intel
Copy link
Contributor

@smaslov-intel smaslov-intel commented Jun 16, 2019

This might look like a lot of changes but the vast majority of it is just renaming and moving (due to file renaming). The key points are:

  1. PI level is being created (pi* files), with true but yet naive plugin mechanism. It replaces CNRI (cnri* files).
  2. New naming conventions are introduced for PI
  3. Directly calling OpenCL is still the default path until everything switches to PI
  4. The platform class implementation is refactored - host and device implementations are merged into single file.

Signed-off-by: Sergey V Maslov [email protected]

@romanovvlad romanovvlad mentioned this pull request Jun 16, 2019
@romanovvlad
Copy link
Contributor

Copying here major design comments from Ronan from previous pull request. @smaslov-intel , please, address them.

+++++++++++++++++++
The concept is super useful.
We need this to have SYCL more general!
But SYCL is about modern C++ and reimplementing a C-like ICD in SYCL seems not like the right abstraction in 2019. OpenCL is written in C with its limitations...
You are reimplementing dynamic polymorphism in C while it is already available in C++.
An alternative approach can be to have the SYCL implementation classes inheriting from some more or less abstract classes and the SYCL runtime can just use transparently a launch kernel virtual member function of the device class to redirect to the actual kernel launch.
The ICD C-like method does not solve well the adaptation problem because it forces at the first place to encapsulate any runtime (even when written in C++!) to the same low-level C method...
I planned to come with an example of this in triSYCL about using dynamic polymorphism for these extensions triSYCL/triSYCL#237 but we are late... I made some presentation in the SYCL committee with some ideas and in triSYCL there is already the use of dynamic polymorphism but without the ability to inject different runtime on the fly yet...
Your plug-in mechanism can be a class inheriting from the runtime interface and implementing various operations or customization points.
A multilayered abstraction seems better suited than going directly down to the metal, because probably some SYCL implementation parts will be common to some classes of devices or API (for example some devices require eager buffer allocation, other lazy late allocation, and this does not fit well is a low-level only approach).
++++++++++++++++++++
I am unsure that reinventing a low-level runtime C API in a high-level modern C++ API is the good direction.
++++++++++++++++++++
The OpenCL ICD exists just because it is implemented in C according to 1970's techniques...
SYCL is about modern C++...
Your method can work actually, just by reusing the OpenCL ICD or the OpenCL intercepting layer from Intel.
But then do it there, not inside the SYCL implementation.
++++++++++++++++++++

@smaslov-intel
Copy link
Contributor Author

smaslov-intel commented Jun 16, 2019

@keryell: We do want to keep the core pi.h interfaces to be C-only for greater interoperability with non-C++ environments, which is envisioned to be needed. The integration of pi.h into SYCL is done with C++ and all the good modern stuff.

Copy link
Contributor

@keryell keryell left a comment

Choose a reason for hiding this comment

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

A few typos.
I am understanding better what you are doing, even if I do not understand the internal reason you might have to rename "cl" to "pi_".
It might be clearer in the middle/long-term future to split the ...impl.cpp into several files, to have for example the host backend in some directories or files, the OpenCL in some others, the PI in some others, etc.

@smaslov-intel
Copy link
Contributor Author

smaslov-intel commented Jun 18, 2019

A few typos.

Thanks for pointing those out! I really feel like I need to get a better source editor, not sure that one exist though ;)

reason you might have to rename "cl" to "pi_".

For the most part it is to decouple from OpenCL.

The core of PI is still OpenCL as you can see, but it only includes a subset of OpenCL, and it also extends it with what OpenCL does not have. This, we thought, deserves a new name and also the whole SYCL is moving to untie from OpenCL, making the later just one of the possible back-ends.

@keryell
Copy link
Contributor

keryell commented Jun 19, 2019

A few typos.

Thanks for pointing those out! I really feel like I need to get a
better source editor, not sure that one exist though ;)

I do not know what you are using.
I am using an operating system named "Emacs" which has a good editor
mode. ;-) The problem is that the default mode is not that great and
needs some tweaking to shine... :-(
The Git mode is amazingly powerful https://magit.vc/

The core of PI is still OpenCL as you can see, but it only includes a subset of OpenCL, and it also extends it with what OpenCL does not have. This, we thought, deserves a new name and also the whole SYCL is moving to untie from OpenCL, making the later just one of the possible back-ends.

That makes sense.
We can always massage this later anyway.

@romanovvlad romanovvlad self-requested a review June 20, 2019 11:06
@bader bader assigned romanovvlad and unassigned bader Jun 20, 2019
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

I think description missing that:

  • CNRI was removed (or replaced by PI)
  • platform class implementation is refactored - host and opencl or pi implementations are merged into single file.

@@ -8,8 +8,9 @@

#pragma once
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/platform_info.hpp>
#include <CL/sycl/detail/force_device.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you move force_device.hpp to the interface headers?
This is supposed to be an implementation details of SYCL runtime library only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved them into "detail" headers, which seemed to be consistent with the overall structure. If you inisist, I can copy back to the sources, but prefer doing so in a separate subsequent change-set. Please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the right place for this header is source directory because it doesn't declare public interface, so SYCL library users are not supposed to include this header fie.
It must be included into sycl/source/* files only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing in the "sycl/detail" is supposed to be included directly by SYCL users, and this one is not an exception to this. If this was really the goal (not to let people see the detail) we could have gone too much further in separation, but is is the goal?

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason why we have "sycl/detail" sub-directory in public interface is because they contain implementation of template classes/methods, which can't be moved to the source directory, but it's not the case with force_device.hpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, we can "hide" this one and many more from sycl/detail if we wanted to.

@Ruyk
Copy link
Contributor

Ruyk commented Jun 24, 2019

There should be some macro defining the version of the PI interface used. I am assuming incremental changes to the API will happen and that people need to ensure the right version of the PI API is being used, or that some new API entries could be added in future versions.

Simply adding #define PI_VERSION 1 would do, unless there is some other scheme already in place!

@keryell
Copy link
Contributor

keryell commented Jun 24, 2019

There should be some macro defining the version of the PI interface used. I am assuming incremental changes to the API will happen and that people need to ensure the right version of the PI API is being used, or that some new API entries could be added in future versions.

Simply adding #define PI_VERSION 1 would do, unless there is some other scheme already in place!

What about using a versioning like TeX?
#define PI_VERSION 3
#define PI_VERSION 3.1
#define PI_VERSION 3.14
#define PI_VERSION 3.141
#define PI_VERSION 3.1415
:-)
More seriously, this macro should be renamed with a name quite longer and related to the project...

@bader
Copy link
Contributor

bader commented Jun 25, 2019

@smaslov-intel, please, rebase the patch to the tip of the branch.

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

LGTM.
Just a few typos.

Signed-off-by: Sergey V Maslov <[email protected]>
@bader bader merged commit e0e7177 into intel:sycl Jul 1, 2019
bader pushed a commit that referenced this pull request Jul 10, 2019
This incremental change on top of PI infrastructure being added in #222. It turns all of SYCL RT OpenCL calls into PI. For the time being PI implementation is still directly the OpenCL one (in pi_opencl.*), and the next step will be to run OpenCL through the PI.

Signed-off-by: Sergey V Maslov <[email protected]>
vmaksimo pushed a commit to vmaksimo/llvm that referenced this pull request Jul 5, 2021
Bring spirv.hpp in sync with ddf3230 ("Merge pull request intel#222 from
kpet/github-actions", 2021-06-30) from
github.com/KhronosGroup/SPIRV-Headers .

This brings the SPV_KHR_bit_instructions and SPV_INTEL_debug_module
extension enum values.  Drop the internal enum value of the latter.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@da11807
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.

6 participants