mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Correct accessing cl device from Platform
don't use root device index to store cl device in Platform::initialize Related-To: NEO-3691 Change-Id: I1fc5435e0246e241c4a38060de26f5c0369a1873 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Jablonski, Mateusz

parent
d542b215ff
commit
ffed348f3b
@ -225,9 +225,9 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
|
||||
}
|
||||
|
||||
cl_uint retNum = 0;
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < numDev; rootDeviceIndex++) {
|
||||
for (auto platformDeviceIndex = 0u; platformDeviceIndex < numDev; platformDeviceIndex++) {
|
||||
|
||||
ClDevice *device = pPlatform->getClDevice(rootDeviceIndex);
|
||||
ClDevice *device = pPlatform->getClDevice(platformDeviceIndex);
|
||||
UNRECOVERABLE_IF(device == nullptr);
|
||||
|
||||
if (deviceType & device->getDeviceInfo().deviceType) {
|
||||
|
@ -65,9 +65,7 @@ Platform::Platform(ExecutionEnvironment &executionEnvironmentIn) : executionEnvi
|
||||
Platform::~Platform() {
|
||||
asyncEventsHandler->closeThread();
|
||||
for (auto clDevice : this->clDevices) {
|
||||
if (clDevice) {
|
||||
clDevice->decRefInternal();
|
||||
}
|
||||
clDevice->decRefInternal();
|
||||
}
|
||||
|
||||
gtpinNotifyPlatformShutdown();
|
||||
@ -144,13 +142,12 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
|
||||
DEBUG_BREAK_IF(this->platformInfo);
|
||||
this->platformInfo.reset(new PlatformInfo);
|
||||
|
||||
this->clDevices.resize(devices.size());
|
||||
for (auto &inputDevice : devices) {
|
||||
ClDevice *pClDevice = nullptr;
|
||||
auto pDevice = inputDevice.release();
|
||||
UNRECOVERABLE_IF(!pDevice);
|
||||
pClDevice = new ClDevice{*pDevice, this};
|
||||
this->clDevices[pDevice->getRootDeviceIndex()] = pClDevice;
|
||||
this->clDevices.push_back(pClDevice);
|
||||
|
||||
this->platformInfo->extensions = pClDevice->getDeviceInfo().deviceExtensions;
|
||||
|
||||
@ -176,7 +173,7 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
|
||||
}
|
||||
|
||||
this->fillGlobalDispatchTable();
|
||||
DEBUG_BREAK_IF(DebugManager.flags.CreateMultipleRootDevices.get() > 1 && !this->clDevices[0]->getDefaultEngine().commandStreamReceiver->peekTimestampPacketWriteEnabled());
|
||||
DEBUG_BREAK_IF(DebugManager.flags.CreateMultipleSubDevices.get() > 1 && !this->clDevices[0]->getDefaultEngine().commandStreamReceiver->peekTimestampPacketWriteEnabled());
|
||||
state = StateInited;
|
||||
return true;
|
||||
}
|
||||
|
@ -386,6 +386,17 @@ TEST(PlatformInitTest, givenInitializedPlatformWhenInitializeIsCalledOneMoreTime
|
||||
EXPECT_TRUE(platform()->initialize(std::move(devices)));
|
||||
}
|
||||
|
||||
TEST(PlatformInitTest, givenSingleDeviceWithNonZeroRootDeviceIndexInPassedDeviceVectorWhenInitializePlatformThenCreateOnlyOneClDevice) {
|
||||
std::vector<std::unique_ptr<Device>> devices;
|
||||
auto executionEnvironment = new MockExecutionEnvironment(*platformDevices, false, 3);
|
||||
devices.push_back(std::make_unique<MockDevice>(executionEnvironment, 2));
|
||||
auto status = platform()->initialize(std::move(devices));
|
||||
EXPECT_TRUE(status);
|
||||
size_t expectedNumDevices = 1u;
|
||||
EXPECT_EQ(expectedNumDevices, platform()->getNumDevices());
|
||||
EXPECT_EQ(2u, platform()->getClDevice(0)->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
TEST(PlatformInitLoopTests, givenPlatformWithDebugSettingWhenInitIsCalledThenItEntersEndlessLoop) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.LoopAtPlatformInitialize.set(true);
|
||||
|
Reference in New Issue
Block a user