-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL][CUDA] Minor fixes required to run BabelStream benchmarks on CUDA #1543
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 8 commits
1757da8
aa384ae
f910c93
195414f
5f611cb
09b9859
a907581
ac3b6f8
70a3e08
a659354
17480e0
66810be
ad3951c
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 |
---|---|---|
|
@@ -80,6 +80,17 @@ class plugin { | |
RT::PiPlugin MPlugin; | ||
const backend MBackend; | ||
}; // class plugin | ||
|
||
/// Two plugins are the same if their string is the same. | ||
/// There is no need to check the actual string, just the pointer, since | ||
/// there is only one instance of the PiPlugin struct per backend. | ||
/// | ||
/// \ingroup sycl_pi | ||
/// | ||
inline bool operator==(const plugin &lhs, const plugin &rhs) { | ||
return (lhs.getPiPlugin().PluginVersion == rhs.getPiPlugin().PluginVersion); | ||
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. Should this just check the MBackend (getBackend) of the plugins are the same. |
||
} | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
#include <CL/sycl/device_selector.hpp> | ||
#include <CL/sycl/exception.hpp> | ||
#include <CL/sycl/stl.hpp> | ||
#include <detail/config.hpp> | ||
#include <detail/device_impl.hpp> | ||
#include <detail/force_device.hpp> | ||
// 4.6.1 Device selection class | ||
|
@@ -28,11 +29,60 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) { | |
backend::opencl; | ||
} | ||
|
||
// @return True if the device is invalid for the current backend preferences | ||
static bool isDeviceInvalidForBe(const device &Device) { | ||
|
||
if (Device.is_host()) | ||
return false; | ||
|
||
// Taking the version information from the platform gives us more useful | ||
// information than the driver_version of the device. | ||
const platform platform = Device.get_info<info::device::platform>(); | ||
const std::string platformVersion = | ||
platform.get_info<info::platform::version>(); | ||
|
||
backend *BackendPref = detail::SYCLConfig<detail::SYCL_BE>::get(); | ||
auto BackendType = detail::getSyclObjImpl(Device)->getPlugin().getBackend(); | ||
static_assert(std::is_same<backend, decltype(BackendType)>(), | ||
"Type is not the same"); | ||
|
||
// If no preference, assume OpenCL and reject CUDA backend | ||
if (BackendType == backend::cuda && !BackendPref) { | ||
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 always disqualifies cuda devices when 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, OpenCL is the preferred path... |
||
return true; | ||
} else if (!BackendPref) | ||
return false; | ||
|
||
// If using PI_CUDA, don't accept a non-CUDA device | ||
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. couldn't we just do:
|
||
if (BackendType == backend::opencl && *BackendPref == backend::cuda) | ||
return true; | ||
|
||
// If using PI_OPENCL, don't accept a non-OpenCL device | ||
if (BackendType == backend::cuda && *BackendPref == backend::opencl) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
device device_selector::select_device() const { | ||
vector_class<device> devices = device::get_devices(); | ||
int score = -1; | ||
const device *res = nullptr; | ||
for (const auto &dev : devices) { | ||
|
||
// Reject the NVIDIA OpenCL platform | ||
if (!dev.is_host()) { | ||
string_class PlatformName = dev.get_info<info::device::platform>() | ||
.get_info<info::platform::name>(); | ||
const bool IsCUDAPlatform = | ||
PlatformName.find("CUDA") != std::string::npos; | ||
|
||
if (detail::getSyclObjImpl(dev)->getPlugin().getBackend() == | ||
backend::opencl && | ||
IsCUDAPlatform) { | ||
continue; | ||
} | ||
} | ||
|
||
int dev_score = (*this)(dev); | ||
if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL)) { | ||
string_class PlatformVersion = dev.get_info<info::device::platform>() | ||
|
@@ -81,6 +131,9 @@ int default_selector::operator()(const device &dev) const { | |
|
||
int Score = -1; | ||
|
||
if (isDeviceInvalidForBe(dev)) | ||
bader marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return -1; | ||
|
||
// Give preference to device of SYCL BE. | ||
if (isDeviceOfPreferredSyclBe(dev)) | ||
Score = 50; | ||
|
@@ -103,19 +156,28 @@ int default_selector::operator()(const device &dev) const { | |
|
||
int gpu_selector::operator()(const device &dev) const { | ||
int Score = -1; | ||
|
||
if (isDeviceInvalidForBe(dev)) | ||
return -1; | ||
|
||
if (dev.is_gpu()) { | ||
Score = 1000; | ||
// Give preference to device of SYCL BE. | ||
if (isDeviceOfPreferredSyclBe(dev)) | ||
Score += 50; | ||
Score = 50; | ||
} | ||
return Score; | ||
} | ||
|
||
int cpu_selector::operator()(const device &dev) const { | ||
int Score = -1; | ||
|
||
if (isDeviceInvalidForBe(dev)) | ||
return -1; | ||
|
||
if (dev.is_cpu()) { | ||
Score = 1000; | ||
|
||
// Give preference to device of SYCL BE. | ||
if (isDeviceOfPreferredSyclBe(dev)) | ||
Score += 50; | ||
|
@@ -125,6 +187,10 @@ int cpu_selector::operator()(const device &dev) const { | |
|
||
int accelerator_selector::operator()(const device &dev) const { | ||
int Score = -1; | ||
|
||
if (isDeviceInvalidForBe(dev)) | ||
return -1; | ||
|
||
if (dev.is_accelerator()) { | ||
Score = 1000; | ||
// Give preference to device of SYCL BE. | ||
|
@@ -139,8 +205,10 @@ int host_selector::operator()(const device &dev) const { | |
if (dev.is_host()) { | ||
Score = 1000; | ||
// Give preference to device of SYCL BE. | ||
if (isDeviceOfPreferredSyclBe(dev)) | ||
if (isDeviceOfPreferredSyclBe(dev)) { | ||
Score += 50; | ||
} else if (isDeviceInvalidForBe(dev)) | ||
return -1; | ||
} | ||
return Score; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.