Skip to content

Commit ab5449a

Browse files
Disable cl_khr_3d_image_writes when image are not supported
Change-Id: I1a9fc02135dac60156de3d7cc2abe61d685149df Signed-off-by: Katarzyna Cencelewska <[email protected]>
1 parent d489989 commit ab5449a

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

runtime/device/device_caps.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ void Device::initializeCaps() {
178178
deviceExtensions += "cl_khr_image2d_from_buffer ";
179179
deviceExtensions += "cl_khr_depth_images ";
180180
deviceExtensions += "cl_intel_media_block_io ";
181+
deviceExtensions += "cl_khr_3d_image_writes ";
181182
}
182183

183184
auto sharingAllowed = (HwHelper::getSubDevicesCount(&hwInfo) == 1u);

runtime/platform/extensions.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
namespace NEO {
1515

16-
const char *deviceExtensionsList = "cl_khr_3d_image_writes "
17-
"cl_khr_byte_addressable_store "
16+
const char *deviceExtensionsList = "cl_khr_byte_addressable_store "
1817
"cl_khr_fp16 "
1918
"cl_khr_global_int32_base_atomics "
2019
"cl_khr_global_int32_extended_atomics "
@@ -61,6 +60,10 @@ std::string getExtensionsList(const HardwareInfo &hwInfo) {
6160
allExtensionsList += "cl_khr_int64_extended_atomics ";
6261
}
6362

63+
if (hwInfo.capabilityTable.supportsImages) {
64+
allExtensionsList += "cl_khr_3d_image_writes ";
65+
}
66+
6467
if (hwInfo.capabilityTable.supportsVme) {
6568
allExtensionsList += "cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation ";
6669
}
@@ -85,7 +88,8 @@ std::string convertEnabledExtensionsToCompilerInternalOptions(const char *enable
8588
while ((pos = extensionsList.find(" ", pos)) != std::string::npos) {
8689
extensionsList.replace(pos, 1, ",+");
8790
}
88-
extensionsList = " -cl-ext=-all,+" + extensionsList + " ";
91+
extensionsList = " -cl-ext=-all,+" + extensionsList + ",+cl_khr_3d_image_writes ";
92+
8993
return extensionsList;
9094
}
9195

unit_tests/api/cl_get_device_info_tests.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ TEST_F(clGetDeviceInfoTests, GivenClDeviceExtensionsParamWhenGettingDeviceInfoTh
163163

164164
std::string extensionString(paramValue.get());
165165
std::string supportedExtensions[] = {
166-
"cl_khr_3d_image_writes ",
167166
"cl_khr_byte_addressable_store ",
168167
"cl_khr_fp16 ",
169168
"cl_khr_global_int32_base_atomics ",

unit_tests/api/gl/cl_get_gl_device_info_tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ TEST_P(GetDeviceGlInfoStr, StringType) {
4949
std::string extensionString(paramValue);
5050
size_t currentOffset = 0u;
5151
std::string supportedExtensions[] = {
52-
"cl_khr_3d_image_writes ",
5352
"cl_khr_byte_addressable_store ",
5453
"cl_khr_fp16 ",
5554
"cl_khr_global_int32_base_atomics ",

unit_tests/device/device_caps_tests.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,10 @@ TEST_F(DeviceGetCapsTest, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReport
427427
}
428428
if (hwInfo->capabilityTable.supportsImages) {
429429
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_intel_spirv_media_block_io")));
430+
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
430431
} else {
431432
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_intel_spirv_media_block_io"))));
433+
EXPECT_THAT(caps.deviceExtensions, testing::Not(std::string("cl_khr_3d_image_writes")));
432434
}
433435
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_intel_spirv_subgroups")));
434436
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration")));
@@ -454,6 +456,23 @@ TEST_F(DeviceGetCapsTest, givenNotSupportImagesWhenCapsAreCreatedThenDeviceNotRe
454456
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_intel_spirv_media_block_io"))));
455457
}
456458

459+
TEST_F(DeviceGetCapsTest, givenSupportImagesWhenCapsAreCreatedThenDeviceReportsClKhr3dImageWritesExtensions) {
460+
HardwareInfo hwInfo = *platformDevices[0];
461+
hwInfo.capabilityTable.supportsImages = true;
462+
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
463+
const auto &caps = device->getDeviceInfo();
464+
465+
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
466+
}
467+
468+
TEST_F(DeviceGetCapsTest, givenNotSupportImagesWhenCapsAreCreatedThenDeviceNotReportsClKhr3dImageWritesExtensions) {
469+
HardwareInfo hwInfo = *platformDevices[0];
470+
hwInfo.capabilityTable.supportsImages = false;
471+
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
472+
const auto &caps = device->getDeviceInfo();
473+
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_3d_image_writes"))));
474+
}
475+
457476
TEST_F(DeviceGetCapsTest, givenOpenCLVersion12WhenCapsAreCreatedThenDeviceDoesntReportClIntelSpirvExtensions) {
458477
DebugManagerStateRestore dbgRestorer;
459478
DebugManager.flags.ForceOCLVersion.set(12);

unit_tests/platform/platform_tests.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ TEST_F(PlatformTest, givenSupportingCl21WhenPlatformSupportsFp64ThenFillMatching
246246
const HardwareInfo *hwInfo;
247247
hwInfo = platformDevices[0];
248248
std::string extensionsList = getExtensionsList(*hwInfo);
249-
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
250249

251250
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
252251
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string(" -cl-ext=-all,+cl")));
@@ -273,6 +272,9 @@ TEST_F(PlatformTest, givenSupportingCl21WhenPlatformSupportsFp64ThenFillMatching
273272
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("cl_khr_fp64")));
274273
}
275274

275+
if (hwInfo->capabilityTable.supportsImages) {
276+
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
277+
}
276278
EXPECT_THAT(compilerExtensions, ::testing::EndsWith(std::string(" ")));
277279
}
278280

@@ -282,7 +284,9 @@ TEST_F(PlatformTest, givenNotSupportingCl21WhenPlatformNotSupportFp64ThenNotFill
282284
TesthwInfo.capabilityTable.clVersionSupport = 10;
283285

284286
std::string extensionsList = getExtensionsList(TesthwInfo);
285-
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
287+
if (TesthwInfo.capabilityTable.supportsImages) {
288+
EXPECT_THAT(extensionsList, ::testing::HasSubstr(std::string("cl_khr_3d_image_writes")));
289+
}
286290

287291
std::string compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str());
288292
EXPECT_THAT(compilerExtensions, ::testing::HasSubstr(std::string("-cl-ext=-all,+cl")));

0 commit comments

Comments
 (0)