Skip to content

Commit 3640695

Browse files
[NFC][SYCL] Use raw device_impl/devices_range in misc places (#19462)
1 parent eca641e commit 3640695

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

sycl/source/detail/context_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ class context_impl : public std::enable_shared_from_this<context_impl> {
345345
};
346346

347347
template <typename T, typename Capabilities>
348-
void GetCapabilitiesIntersectionSet(const std::vector<sycl::device> &Devices,
348+
void GetCapabilitiesIntersectionSet(devices_range Devices,
349349
std::vector<T> &CapabilityList) {
350-
for (const sycl::device &Device : Devices) {
350+
for (device_impl &Device : Devices) {
351351
std::vector<T> NewCapabilityList;
352352
std::vector<T> DeviceCapabilities = Device.get_info<Capabilities>();
353353
std::set_intersection(

sycl/source/detail/kernel_impl.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::string_view kernel_impl::getName() const {
103103
return MName;
104104
}
105105

106-
bool kernel_impl::isBuiltInKernel(const device &Device) const {
106+
bool kernel_impl::isBuiltInKernel(device_impl &Device) const {
107107
auto BuiltInKernels = Device.get_info<info::device::built_in_kernel_ids>();
108108
if (BuiltInKernels.empty())
109109
return false;
@@ -116,9 +116,10 @@ bool kernel_impl::isBuiltInKernel(const device &Device) const {
116116
void kernel_impl::checkIfValidForNumArgsInfoQuery() const {
117117
if (isInteropOrSourceBased())
118118
return;
119-
auto Devices = MKernelBundleImpl->get_devices();
120-
if (std::any_of(Devices.begin(), Devices.end(),
121-
[this](device &Device) { return isBuiltInKernel(Device); }))
119+
devices_range Devices = MKernelBundleImpl->get_devices();
120+
if (std::any_of(Devices.begin(), Devices.end(), [this](device_impl &Device) {
121+
return isBuiltInKernel(Device);
122+
}))
122123
return;
123124

124125
throw sycl::exception(
@@ -149,8 +150,8 @@ kernel_impl::get_backend_info<info::platform::version>() const {
149150
"the info::platform::version info descriptor can "
150151
"only be queried with an OpenCL backend");
151152
}
152-
auto Devices = MKernelBundleImpl->get_devices();
153-
return Devices[0].get_platform().get_info<info::platform::version>();
153+
devices_range Devices = MKernelBundleImpl->get_devices();
154+
return Devices.front().get_platform().get_info<info::platform::version>();
154155
}
155156
#endif
156157

sycl/source/detail/kernel_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class kernel_impl {
255255
std::mutex *MCacheMutex = nullptr;
256256
mutable std::string MName;
257257

258-
bool isBuiltInKernel(const device &Device) const;
258+
bool isBuiltInKernel(device_impl &Device) const;
259259
void checkIfValidForNumArgsInfoQuery() const;
260260

261261
/// Check if the occupancy limits are exceeded for the given kernel launch
@@ -327,7 +327,7 @@ kernel_impl::get_info(const device &Device) const {
327327
Param, info::kernel_device_specific::global_work_size>) {
328328
bool isDeviceCustom = Device.get_info<info::device::device_type>() ==
329329
info::device_type::custom;
330-
if (!isDeviceCustom && !isBuiltInKernel(Device))
330+
if (!isDeviceCustom && !isBuiltInKernel(*getSyclObjImpl(Device)))
331331
throw exception(
332332
sycl::make_error_code(errc::invalid),
333333
"info::kernel_device_specific::global_work_size descriptor may only "

sycl/source/detail/queue_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
135135
int Idx = get_property<ext::intel::property::queue::compute_index>()
136136
.get_index();
137137
int NumIndices =
138-
createSyclObjFromImpl<device>(Device)
138+
Device
139139
.get_info<ext::intel::info::device::max_compute_queue_indices>();
140140
if (Idx < 0 || Idx >= NumIndices)
141141
throw sycl::exception(

sycl/source/detail/syclbin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// LLVMObject.
1111

1212
#include <detail/compiler.hpp>
13+
#include <detail/device_impl.hpp>
1314
#include <detail/program_manager/program_manager.hpp>
1415
#include <detail/syclbin.hpp>
1516

@@ -389,14 +390,13 @@ SYCLBINBinaries::convertAbstractModuleProperties(SYCLBIN::AbstractModule &AM) {
389390
}
390391

391392
std::vector<const RTDeviceBinaryImage *>
392-
SYCLBINBinaries::getBestCompatibleImages(const device &Dev) {
393-
detail::device_impl &DevImpl = *getSyclObjImpl(Dev);
393+
SYCLBINBinaries::getBestCompatibleImages(device_impl &Dev) {
394394
auto SelectCompatibleImages =
395395
[&](const std::vector<RTDeviceBinaryImage> &Imgs) {
396396
std::vector<const RTDeviceBinaryImage *> CompatImgs;
397397
for (const RTDeviceBinaryImage &Img : Imgs)
398-
if (doesDevSupportDeviceRequirements(DevImpl, Img) &&
399-
doesImageTargetMatchDevice(Img, DevImpl))
398+
if (doesDevSupportDeviceRequirements(Dev, Img) &&
399+
doesImageTargetMatchDevice(Img, Dev))
400400
CompatImgs.push_back(&Img);
401401
return CompatImgs;
402402
};
@@ -412,9 +412,9 @@ SYCLBINBinaries::getBestCompatibleImages(const device &Dev) {
412412
}
413413

414414
std::vector<const RTDeviceBinaryImage *>
415-
SYCLBINBinaries::getBestCompatibleImages(const std::vector<device> &Devs) {
415+
SYCLBINBinaries::getBestCompatibleImages(devices_range Devs) {
416416
std::set<const RTDeviceBinaryImage *> Images;
417-
for (const device &Dev : Devs) {
417+
for (device_impl &Dev : Devs) {
418418
std::vector<const RTDeviceBinaryImage *> BestImagesForDev =
419419
getBestCompatibleImages(Dev);
420420
Images.insert(BestImagesForDev.cbegin(), BestImagesForDev.cend());

sycl/source/detail/syclbin.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ struct SYCLBINBinaries {
120120
SYCLBINBinaries(const char *SYCLBINContent, size_t SYCLBINSize);
121121

122122
std::vector<const RTDeviceBinaryImage *>
123-
getBestCompatibleImages(const device &Dev);
123+
getBestCompatibleImages(device_impl &Dev);
124124
std::vector<const RTDeviceBinaryImage *>
125-
getBestCompatibleImages(const std::vector<device> &Dev);
125+
getBestCompatibleImages(devices_range Dev);
126126

127127
uint8_t getState() const noexcept {
128128
PropertySet &GlobalMetadata =

0 commit comments

Comments
 (0)