-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Plugin Interface: Single Call to Plugin to populate a Plugin Datastructure. #808
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
9f11c42
to
234ef82
Compare
rebased and removed conflicts over PR#798. |
234ef82
to
708fc25
Compare
Rebased over PR#798. and removed conflicts after merge of PR#776. |
708fc25
to
5fb5ca1
Compare
rebase. |
5fb5ca1
to
ade27b1
Compare
@smaslov-intel Please review. |
datastructure with all function pointers. Extension to this will allow us to bind multiple plugins. Signed-off-by: Garima Gupta <[email protected]>
PI_CALL( or PI_CALL_RESULT( and other required changes. Signed-off-by: Garima Gupta <[email protected]>
ade27b1
to
bc2305d
Compare
rebase,clang-format and conflict resolution. |
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE, | ||
sizeof(size_t), &BufSize, nullptr); | ||
PI_CALL(piMemGetInfo, detail::pi::cast<detail::RT::PiMem>(MemObject), | ||
CL_MEM_SIZE, sizeof(size_t), &BufSize, nullptr); |
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.
Only noticing this now - this somehow reminds me of Lisp 😄
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.
I have never used Lisp. Are you talking about use of comma after the api name?
I have the call interface changed in #843 . Do you think that works?
Maybe I can close this PR and merge the two PRs together.
Let me know what you think.
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.
Oh, sorry for the confusion and the extra work that I now caused - I meant "Lisp" as a positive thing 😿
Both approaches seem ok to me, the one in this PR seems to require less state in the trace class though.
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.
That's true. The other way makes it more like calling a constructor and a functor on it.
// checks and writes the appropriate Function Pointers in | ||
// PIFunctionTable. | ||
const char PiVersion[4] = "1.1"; | ||
char PluginVersion[4] = "1.1"; // Plugin edits this. |
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.
Will the fixed-sized array be a problem?
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.
Hmmm.. I will a todo for this problem. I think this is a different problem to be resolved at a later point.
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.
I have added a TODO like below:
// TODO: Work on version fields and their handshaking mechanism.
// Some choices are:
// - Use of integers to keep major and minor version.
// - Keeping char* Versions.
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.
in commit # 5 in PR 843
// TODO: Remove the 'OclPtr' extension used with the PI_APIs. | ||
// Forward calls to OpenCL RT. | ||
pi_result piPluginInit(pi_plugin *PluginInit) { | ||
strcpy(PluginInit->PluginVersion, SupportedVersion); |
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.
As the version array is of fixed size the use of strncpy
would be safer here.
Wondering though if it would be ok to make PluginInit->PluginVersion
a const char*
to point to the version string literal in this file?
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.
Hmmm..
I thought keeping all memory allocation and destruction in Plugin Interface will be a better idea. The library is loaded and it populates the fields.
I will take the focus off the version discussion and add a TODO for future.
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.
What I mean it, if the plugin cpp file defines the version as a string literal, then piPluginInit
could just point PluginInit->PluginVersion
to the string literal. No copying required and therefore no memory management.
There might be intricacies with the plugin unloading though which could leave a dangling pointer but my guess is that an unloaded plugin means that most SYCL calls become unsafe anyway.
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.
I will add a TODO. I can create a separate patch for the version discussion and changes. It will help segregate this discussion and keep the progress going.
pi_result piPluginInit(pi_plugin *PluginInit) { | ||
strcpy(PluginInit->PluginVersion, SupportedVersion); | ||
int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); | ||
if (CompareVersions < 0) { |
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.
If this comparison fails we already changed the PluginInit->PluginVersion
. Should we move the comparison before the version is set in the plugin?
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.
Yes. That was the intention I initially had. For the Plugin Interface to know that the plugin supported some other Version and maybe take an action for it.
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.
Changed it now.
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.
Is that commit not pushed yet as I cannot see a change in the code?
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 is their in 4ce1cc4.
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.
Thank you! 👍
|
||
decltype(::piPluginInit) *PluginInitializeFunction = (decltype( | ||
&::piPluginInit))(getOsLibraryFuncAddress(Library, "piPluginInit")); | ||
int err = PluginInitializeFunction(&PluginInformation); |
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.
I would implement the init function to not affect the argument if an error occurs. If we need/want that at least the plugin version is set - even on an error - then please document this required behavior.
Though I would prefer to not access the argument if an error is returned in the code below.
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.
Done.
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.
I have removed piPluginInit function to edit the PluginInformation structure when an error occurs.
@@ -74,18 +78,21 @@ void *loadPlugin(const std::string &PluginPath) { | |||
// needs to setup infrastructure to route PI_CALLs to the appropriate plugins. | |||
// Currently, we bind to a singe plugin. | |||
bool bindPlugin(void *Library) { |
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.
Unsure about the calling-sites of this though passing an explicit plugin argument in would be clearer instead of changing a global variable.
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.
That's true. I think we will have to do that once the plugin data structure becomes a part of a sycl object.
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.
Added the changes in commit 5 of PR#843.
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE, | ||
sizeof(size_t), &BufSize, nullptr); | ||
PI_CALL(piMemGetInfo, detail::pi::cast<detail::RT::PiMem>(MemObject), | ||
CL_MEM_SIZE, sizeof(size_t), &BufSize, nullptr); |
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.
That's true. The other way makes it more like calling a constructor and a functor on it.
// checks and writes the appropriate Function Pointers in | ||
// PIFunctionTable. | ||
const char PiVersion[4] = "1.1"; | ||
char PluginVersion[4] = "1.1"; // Plugin edits this. |
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.
Hmmm.. I will a todo for this problem. I think this is a different problem to be resolved at a later point.
// TODO: Remove the 'OclPtr' extension used with the PI_APIs. | ||
// Forward calls to OpenCL RT. | ||
pi_result piPluginInit(pi_plugin *PluginInit) { | ||
strcpy(PluginInit->PluginVersion, SupportedVersion); |
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.
I will add a TODO. I can create a separate patch for the version discussion and changes. It will help segregate this discussion and keep the progress going.
pi_result piPluginInit(pi_plugin *PluginInit) { | ||
strcpy(PluginInit->PluginVersion, SupportedVersion); | ||
int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); | ||
if (CompareVersions < 0) { |
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.
Yes. That was the intention I initially had. For the Plugin Interface to know that the plugin supported some other Version and maybe take an action for it.
pi_result piPluginInit(pi_plugin *PluginInit) { | ||
strcpy(PluginInit->PluginVersion, SupportedVersion); | ||
int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); | ||
if (CompareVersions < 0) { |
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.
Changed it now.
@@ -74,18 +78,21 @@ void *loadPlugin(const std::string &PluginPath) { | |||
// needs to setup infrastructure to route PI_CALLs to the appropriate plugins. | |||
// Currently, we bind to a singe plugin. | |||
bool bindPlugin(void *Library) { |
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.
That's true. I think we will have to do that once the plugin data structure becomes a part of a sycl object.
|
||
decltype(::piPluginInit) *PluginInitializeFunction = (decltype( | ||
&::piPluginInit))(getOsLibraryFuncAddress(Library, "piPluginInit")); | ||
int err = PluginInitializeFunction(&PluginInformation); |
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.
Done.
@bjoernknafla |
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.
Not seeing some of the TODOs in the code - probably missing pushing the commits, otherwise ok.
This PR is a part of PR #843 . |
[SYCL] Using a single call to Plugin, and populating a Plugin
datastructure with all function pointers. Extension to this will allow
us to bind multiple plugins.
[SYCL] Changing all the PI_CALL(RT:: or PI_CALL_RESULT(RT:: to
PI_CALL( or PI_CALL_RESULT( and other required changes.
Two last commits represent this change.
They are built over the previous PR#776, PR#798 .