Skip to content

Commit 4da9269

Browse files
Correct Platform::initialize function
Initialize values only once. Change-Id: I5261f3b8e6a088878fb7f240418bafb93612da1c Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
1 parent 6ee7c6d commit 4da9269

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

opencl/source/platform/platform.cpp

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,39 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
127127

128128
state = StateIniting;
129129

130-
DEBUG_BREAK_IF(this->platformInfo);
131-
this->platformInfo.reset(new PlatformInfo);
132-
133130
for (auto &inputDevice : devices) {
134131
ClDevice *pClDevice = nullptr;
135132
auto pDevice = inputDevice.release();
136133
UNRECOVERABLE_IF(!pDevice);
137134
pClDevice = new ClDevice{*pDevice, this};
138135
this->clDevices.push_back(pClDevice);
139136

140-
this->platformInfo->extensions = pClDevice->getDeviceInfo().deviceExtensions;
141-
this->platformInfo->extensionsWithVersion = pClDevice->getDeviceInfo().extensionsWithVersion;
142-
143-
switch (pClDevice->getEnabledClVersion()) {
144-
case 30:
145-
this->platformInfo->version = "OpenCL 3.0 ";
146-
this->platformInfo->numericVersion = CL_MAKE_VERSION(3, 0, 0);
147-
break;
148-
case 21:
149-
this->platformInfo->version = "OpenCL 2.1 ";
150-
this->platformInfo->numericVersion = CL_MAKE_VERSION(2, 1, 0);
151-
break;
152-
default:
153-
this->platformInfo->version = "OpenCL 1.2 ";
154-
this->platformInfo->numericVersion = CL_MAKE_VERSION(1, 2, 0);
155-
break;
137+
auto hwInfo = pClDevice->getHardwareInfo();
138+
if (pClDevice->getPreemptionMode() == PreemptionMode::MidThread || pClDevice->isDebuggerActive()) {
139+
auto sipType = SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, pClDevice->isDebuggerActive());
140+
initSipKernel(sipType, *pDevice);
156141
}
157142
}
158143

159-
for (auto &clDevice : clDevices) {
160-
auto hwInfo = clDevice->getHardwareInfo();
161-
if (clDevice->getPreemptionMode() == PreemptionMode::MidThread || clDevice->isDebuggerActive()) {
162-
auto sipType = SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, clDevice->isDebuggerActive());
163-
initSipKernel(sipType, clDevice->getDevice());
164-
}
144+
DEBUG_BREAK_IF(this->platformInfo);
145+
this->platformInfo.reset(new PlatformInfo);
146+
147+
this->platformInfo->extensions = this->clDevices[0]->getDeviceInfo().deviceExtensions;
148+
this->platformInfo->extensionsWithVersion = this->clDevices[0]->getDeviceInfo().extensionsWithVersion;
149+
150+
switch (this->clDevices[0]->getEnabledClVersion()) {
151+
case 30:
152+
this->platformInfo->version = "OpenCL 3.0 ";
153+
this->platformInfo->numericVersion = CL_MAKE_VERSION(3, 0, 0);
154+
break;
155+
case 21:
156+
this->platformInfo->version = "OpenCL 2.1 ";
157+
this->platformInfo->numericVersion = CL_MAKE_VERSION(2, 1, 0);
158+
break;
159+
default:
160+
this->platformInfo->version = "OpenCL 1.2 ";
161+
this->platformInfo->numericVersion = CL_MAKE_VERSION(1, 2, 0);
162+
break;
165163
}
166164

167165
this->fillGlobalDispatchTable();

0 commit comments

Comments
 (0)