-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL][PI] get backend type from Plugin, not env #1477
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,10 @@ class plugin { | |
|
||
const RT::PiPlugin &getPiPlugin() const { return MPlugin; } | ||
|
||
bool isBackendType(Backend backend) const { | ||
return MPlugin.backend == backend; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems awkward to have a comparison method inside a plugin, why not simply return the Plugin type and let the caller do the comparison? Backend getBackendType() const noexcept {
return MPlugin.backend;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for returning the Backend. Also we need this info be available externally. Could you add a method to return the BE via, say
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes sure. Actually, as I'm at it already, maybe there is a more agnostic way than to have the plugin types hard-coded in an enum in "pi.h"? what if - for example - there was a On the other hand i found this: Sycl-Shared and they describe to even have an enum at There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. ok, thanks. Then I'll wait for that PR to be merged and base off it. regarding the platform.get_info<> it should return an std::string in the end...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should return the "backend" not a string. But note that the BE generalization proposal defines get_backend() method instead (maybe in addition?): https://github.com/KhronosGroup/SYCL-Shared/blob/master/proposals/sycl_generalization.md There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 on returning the backend, not a string. We don't have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, sure. thanks. i will stick to whats in the generalization for now.
i will wait for #1332 to be merged and start from there. |
||
|
||
/// Checks return value from PI calls. | ||
/// | ||
/// \throw Exception if pi_result is not a PI_SUCCESS. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,8 +269,10 @@ static bool isDeviceBinaryTypeSupported(const context &C, | |
return false; | ||
} | ||
|
||
ContextImplPtr ContextImpl = getSyclObjImpl(C); | ||
|
||
// OpenCL 2.1 and greater require clCreateProgramWithIL | ||
if (pi::useBackend(pi::SYCL_BE_PI_OPENCL) && | ||
if (ContextImpl->getPlugin().isBackendType(Backend::SYCL_BE_PI_OPENCL) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be instead: ContextImpl->getPlugin()->getBackend() == Backend::SYCL_BE_PI_OPENCL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, getBackendType ? if you prefer, i will do that :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say |
||
C.get_platform().get_info<info::platform::version>() >= "2.1") | ||
return true; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1661,7 +1661,7 @@ cl_int ExecCGCommand::enqueueImp() { | |
Requirement *Req = (Requirement *)(Arg.MPtr); | ||
AllocaCommandBase *AllocaCmd = getAllocaForReq(Req); | ||
RT::PiMem MemArg = (RT::PiMem)AllocaCmd->getMemAllocation(); | ||
if (RT::useBackend(pi::Backend::SYCL_BE_PI_OPENCL)) { | ||
if (Plugin.isBackendType(Backend::SYCL_BE_PI_OPENCL)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above... |
||
Plugin.call<PiApiKind::piKernelSetArg>(Kernel, Arg.MIndex, | ||
sizeof(RT::PiMem), &MemArg); | ||
} else { | ||
|
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.
Does the comment still apply? The environmental variable is not used anymore
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.
no, i will remove it. i just took the part from pi.hpp to get feedback on this