mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
Add method for getting number of available devices
Related-To: NEO-3691 Change-Id: Ida2454adbfc9b177acbbb320f3f9577849a6fd74 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
05c8f40677
commit
ea64a3fbc3
@@ -97,6 +97,7 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
bool areSharedSystemAllocationsAllowed() const {
|
||||
return this->deviceInfo.sharedSystemMemCapabilities != 0u;
|
||||
}
|
||||
virtual uint32_t getNumAvailableDevices() const = 0;
|
||||
|
||||
protected:
|
||||
Device() = delete;
|
||||
|
||||
@@ -18,6 +18,13 @@ uint32_t RootDevice::getNumSubDevices() const {
|
||||
return static_cast<uint32_t>(subdevices.size());
|
||||
}
|
||||
|
||||
uint32_t RootDevice::getNumAvailableDevices() const {
|
||||
if (subdevices.empty()) {
|
||||
return 1u;
|
||||
}
|
||||
return getNumSubDevices();
|
||||
}
|
||||
|
||||
RootDevice::RootDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : Device(executionEnvironment, deviceIndex) {}
|
||||
bool RootDevice::createDeviceImpl() {
|
||||
auto status = Device::createDeviceImpl();
|
||||
|
||||
@@ -17,6 +17,7 @@ class RootDevice : public Device {
|
||||
RootDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
~RootDevice() override;
|
||||
bool createDeviceImpl() override;
|
||||
uint32_t getNumAvailableDevices() const override;
|
||||
uint32_t getNumSubDevices() const;
|
||||
|
||||
/* We hide the retain and release function of BaseObject. */
|
||||
|
||||
@@ -32,5 +32,8 @@ DeviceBitfield SubDevice::getDeviceBitfieldForOsContext() const {
|
||||
deviceBitfield.set(subDeviceIndex);
|
||||
return deviceBitfield;
|
||||
}
|
||||
uint32_t SubDevice::getNumAvailableDevices() const {
|
||||
return 1u;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -17,6 +17,7 @@ class SubDevice : public Device {
|
||||
unique_ptr_if_unused<Device> release() override;
|
||||
void retainInternal();
|
||||
void releaseInternal();
|
||||
uint32_t getNumAvailableDevices() const override;
|
||||
|
||||
protected:
|
||||
DeviceBitfield getDeviceBitfieldForOsContext() const override;
|
||||
|
||||
Reference in New Issue
Block a user