Skip to content

Commit 541e161

Browse files
Change error code from CL_INVALID_VALUE to CL_SUCCESSS
when image are not suppoorted Change-Id: I8350558ada1ab048b02b68cb372a22fdadf8c2f5 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
1 parent b28e3fc commit 541e161

File tree

5 files changed

+88
-39
lines changed

5 files changed

+88
-39
lines changed

runtime/api/api.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,10 @@ cl_int CL_API_CALL clGetSupportedImageFormats(cl_context context,
10161016
retVal = pContext->getSupportedImageFormats(&pClDevice->getDevice(), flags, imageType, numEntries,
10171017
imageFormats, numImageFormats);
10181018
} else {
1019-
retVal = CL_INVALID_VALUE;
1019+
if (numImageFormats) {
1020+
*numImageFormats = 0u;
1021+
}
1022+
retVal = CL_SUCCESS;
10201023
}
10211024
} else {
10221025
retVal = CL_INVALID_CONTEXT;

runtime/device/device_info.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
190190
break;
191191
}
192192
default:
193-
if (device.getDeviceInfo().imageSupport && getDeviceInfoForImage(paramName, src, srcSize, retSize)) {
193+
if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !device.getDeviceInfo().imageSupport) {
194+
param = 0u;
195+
src = &param;
196+
srcSize = retSize = sizeof(param);
194197
break;
195198
}
196199
ClDeviceHelper::getExtraDeviceInfo(*this, paramName, param, src, srcSize, retSize);
@@ -209,6 +212,7 @@ bool ClDevice::getDeviceInfoForImage(cl_device_info paramName,
209212
const void *&src,
210213
size_t &srcSize,
211214
size_t &retSize) {
215+
bool retVal = true;
212216
switch (paramName) {
213217
case CL_DEVICE_MAX_READ_IMAGE_ARGS:
214218
getCap<CL_DEVICE_MAX_READ_IMAGE_ARGS>(src, srcSize, retSize);
@@ -247,17 +251,23 @@ bool ClDevice::getDeviceInfoForImage(cl_device_info paramName,
247251
getCap<CL_DEVICE_IMAGE_PITCH_ALIGNMENT>(src, srcSize, retSize);
248252
break;
249253
case CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL:
250-
if (getDeviceInfo().nv12Extension)
254+
if (getDeviceInfo().nv12Extension) {
251255
getCap<CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL>(src, srcSize, retSize);
256+
break;
257+
}
258+
retVal = false;
252259
break;
253260
case CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL:
254-
if (getDeviceInfo().nv12Extension)
261+
if (getDeviceInfo().nv12Extension) {
255262
getCap<CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL>(src, srcSize, retSize);
263+
break;
264+
}
265+
retVal = false;
256266
break;
257267
default:
258-
return false;
268+
retVal = false;
259269
}
260-
return true;
270+
return retVal;
261271
}
262272

263273
} // namespace NEO

unit_tests/api/cl_get_supported_image_formats_tests.inl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_F(clGetSupportedImageFormatsTests, givenInvalidContextWhenGettingSupportIma
4949
EXPECT_EQ(CL_INVALID_CONTEXT, retVal);
5050
}
5151

52-
TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSupportImageFormatsThenClInvalidValueIsReturned) {
52+
TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSupportImageFormatsThenCLSuccessReturned) {
5353
HardwareInfo hwInfo = *platformDevices[0];
5454
hwInfo.capabilityTable.supportsImages = false;
5555
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
@@ -67,7 +67,28 @@ TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSu
6767
nullptr,
6868
&numImageFormats);
6969

70-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
70+
EXPECT_EQ(CL_SUCCESS, retVal);
71+
EXPECT_EQ(0u, numImageFormats);
72+
}
73+
74+
TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageAndNullPointerToNumFormatsWhenGettingSupportImageFormatsThenCLSuccessReturned) {
75+
HardwareInfo hwInfo = *platformDevices[0];
76+
hwInfo.capabilityTable.supportsImages = false;
77+
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
78+
cl_device_id clDevice = device.get();
79+
cl_int retVal;
80+
auto context = ReleaseableObjectPtr<Context>(Context::create<Context>(nullptr, ClDeviceVector(&clDevice, 1), nullptr, nullptr, retVal));
81+
EXPECT_EQ(CL_SUCCESS, retVal);
82+
83+
retVal = clGetSupportedImageFormats(
84+
context.get(),
85+
CL_MEM_READ_WRITE,
86+
CL_MEM_OBJECT_IMAGE2D,
87+
0,
88+
nullptr,
89+
nullptr);
90+
91+
EXPECT_EQ(CL_SUCCESS, retVal);
7192
}
7293

7394
TEST(clGetSupportedImageFormatsTest, givenPlatformWithoutDevicesWhenClGetSupportedImageFormatIsCalledThenDeviceIsTakenFromContext) {

unit_tests/device/get_device_info_size_tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ TEST_P(GetDeviceInfoForImage, imageInfoSizeIsValid) {
146146
EXPECT_EQ(param.second, sizeReturned);
147147
}
148148

149-
TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturned) {
149+
TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClSuccessAndSizeofCluintIsReturned) {
150150
auto device = std::make_unique<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr), platform());
151151
if (device->getDeviceInfo().imageSupport) {
152152
GTEST_SKIP();
@@ -157,7 +157,8 @@ TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturn
157157
0,
158158
nullptr,
159159
&sizeReturned);
160-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
160+
EXPECT_EQ(CL_SUCCESS, retVal);
161+
EXPECT_EQ(sizeof(cl_uint), sizeReturned);
161162
}
162163

163164
TEST_P(GetDeviceInfoForImage, givenInfoImageParamsWhenCallGetDeviceInfoForImageThenSizeIsValidAndTrueReturned) {

unit_tests/device/get_device_info_tests.cpp

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -113,50 +113,54 @@ TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtens
113113
EXPECT_EQ(CL_INVALID_VALUE, retVal);
114114
}
115115

116-
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) {
116+
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsSuccessWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) {
117117
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
118118
device->deviceInfo.imageSupport = false;
119119
device->deviceInfo.nv12Extension = true;
120120
size_t value = 0;
121121

122122
auto retVal = device->getDeviceInfo(
123123
CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL,
124-
4,
124+
sizeof(size_t),
125125
&value,
126126
nullptr);
127127

128-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
128+
EXPECT_EQ(CL_SUCCESS, retVal);
129+
EXPECT_EQ(0u, value);
129130

130131
retVal = device->getDeviceInfo(
131132
CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL,
132-
4,
133+
sizeof(size_t),
133134
&value,
134135
nullptr);
135136

136-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
137+
EXPECT_EQ(CL_SUCCESS, retVal);
138+
EXPECT_EQ(0u, value);
137139
}
138140

139-
TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsErrorWhenImageSupportDisabled) {
141+
TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsSuccessWhenImageSupportDisabled) {
140142
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
141143

142144
device->deviceInfo.imageSupport = false;
143-
uint32_t value;
145+
size_t value = 0;
144146

145147
auto retVal = device->getDeviceInfo(
146148
CL_DEVICE_IMAGE2D_MAX_WIDTH,
147149
sizeof(size_t),
148150
&value,
149151
nullptr);
150152

151-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
153+
EXPECT_EQ(CL_SUCCESS, retVal);
154+
EXPECT_EQ(0u, value);
152155

153156
retVal = device->getDeviceInfo(
154157
CL_DEVICE_IMAGE2D_MAX_HEIGHT,
155158
sizeof(size_t),
156159
&value,
157160
nullptr);
158161

159-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
162+
EXPECT_EQ(CL_SUCCESS, retVal);
163+
EXPECT_EQ(0u, value);
160164
}
161165

162166
TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -182,35 +186,38 @@ TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsCorrectValuesWhenImageSu
182186
EXPECT_EQ(CL_SUCCESS, retVal);
183187
}
184188

185-
TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsErrorWhenImageSupportDisabled) {
189+
TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsSuccessWhenImageSupportDisabled) {
186190
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
191+
size_t value = 0;
187192

188193
device->deviceInfo.imageSupport = false;
189-
uint32_t value;
190194

191195
auto retVal = device->getDeviceInfo(
192196
CL_DEVICE_IMAGE3D_MAX_WIDTH,
193197
sizeof(size_t),
194198
&value,
195199
nullptr);
196200

197-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
201+
EXPECT_EQ(CL_SUCCESS, retVal);
202+
EXPECT_EQ(0u, value);
198203

199204
retVal = device->getDeviceInfo(
200205
CL_DEVICE_IMAGE3D_MAX_HEIGHT,
201206
sizeof(size_t),
202207
&value,
203208
nullptr);
204209

205-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
210+
EXPECT_EQ(CL_SUCCESS, retVal);
211+
EXPECT_EQ(0u, value);
206212

207213
retVal = device->getDeviceInfo(
208214
CL_DEVICE_IMAGE3D_MAX_DEPTH,
209215
sizeof(size_t),
210216
&value,
211217
nullptr);
212218

213-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
219+
EXPECT_EQ(CL_SUCCESS, retVal);
220+
EXPECT_EQ(0u, value);
214221
}
215222

216223
TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -244,7 +251,7 @@ TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsCorrectValuesWhenIm
244251
EXPECT_EQ(CL_SUCCESS, retVal);
245252
}
246253

247-
TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) {
254+
TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsSuccessWhenImageSupportDisabled) {
248255
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
249256

250257
device->deviceInfo.imageSupport = false;
@@ -256,23 +263,26 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) {
256263
&value,
257264
nullptr);
258265

259-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
266+
EXPECT_EQ(CL_SUCCESS, retVal);
267+
EXPECT_EQ(0u, value);
260268

261269
retVal = device->getDeviceInfo(
262270
CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
263271
sizeof(size_t),
264272
&value,
265273
nullptr);
266274

267-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
275+
EXPECT_EQ(CL_SUCCESS, retVal);
276+
EXPECT_EQ(0u, value);
268277

269278
retVal = device->getDeviceInfo(
270279
CL_DEVICE_MAX_WRITE_IMAGE_ARGS,
271280
sizeof(size_t),
272281
&value,
273282
nullptr);
274283

275-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
284+
EXPECT_EQ(CL_SUCCESS, retVal);
285+
EXPECT_EQ(0u, value);
276286
}
277287

278288
TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -306,19 +316,20 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsCorrectValuesWhenImageSupportEnab
306316
EXPECT_EQ(CL_SUCCESS, retVal);
307317
}
308318

309-
TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsErrorWhenImageSupportDisabled) {
319+
TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsSuccessWhenImageSupportDisabled) {
310320
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
321+
size_t value = 0;
311322

312323
device->deviceInfo.imageSupport = false;
313-
uint32_t value;
314324

315325
auto retVal = device->getDeviceInfo(
316326
CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
317327
sizeof(cl_uint),
318328
&value,
319329
nullptr);
320330

321-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
331+
EXPECT_EQ(CL_SUCCESS, retVal);
332+
EXPECT_EQ(0u, value);
322333
}
323334

324335
TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -338,17 +349,18 @@ TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsCorrectValuesWhenIma
338349

339350
TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsErrorWhenImageSupportDisabled) {
340351
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
352+
size_t value = 0;
341353

342354
device->deviceInfo.imageSupport = false;
343-
uint32_t value;
344355

345356
auto retVal = device->getDeviceInfo(
346357
CL_DEVICE_IMAGE_MAX_ARRAY_SIZE,
347358
sizeof(size_t),
348359
&value,
349360
nullptr);
350361

351-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
362+
EXPECT_EQ(CL_SUCCESS, retVal);
363+
EXPECT_EQ(0u, value);
352364
}
353365

354366
TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -366,19 +378,20 @@ TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsCorrectValuesWhenImageSuppor
366378
EXPECT_EQ(CL_SUCCESS, retVal);
367379
}
368380

369-
TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsErrorWhenImageSupportDisabled) {
381+
TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsSuccessWhenImageSupportDisabled) {
370382
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
383+
size_t value = 0;
371384

372385
device->deviceInfo.imageSupport = false;
373-
uint32_t value;
374386

375387
auto retVal = device->getDeviceInfo(
376388
CL_DEVICE_IMAGE_MAX_BUFFER_SIZE,
377389
sizeof(size_t),
378390
&value,
379391
nullptr);
380392

381-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
393+
EXPECT_EQ(CL_SUCCESS, retVal);
394+
EXPECT_EQ(0u, value);
382395
}
383396

384397
TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsCorrectValuesWhenImageSupportEnabled) {
@@ -396,19 +409,20 @@ TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsCorrectValuesWhenImageSuppo
396409
EXPECT_EQ(CL_SUCCESS, retVal);
397410
}
398411

399-
TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsErrorWhenImageSupportDisabled) {
412+
TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsSuccessWhenImageSupportDisabled) {
400413
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
414+
size_t value = 0;
401415

402416
device->deviceInfo.imageSupport = false;
403-
uint32_t value;
404417

405418
auto retVal = device->getDeviceInfo(
406419
CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
407420
sizeof(cl_uint),
408421
&value,
409422
nullptr);
410423

411-
EXPECT_EQ(CL_INVALID_VALUE, retVal);
424+
EXPECT_EQ(CL_SUCCESS, retVal);
425+
EXPECT_EQ(0u, value);
412426
}
413427

414428
TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsCorrectValuesWhenImageSupportEnabled) {

0 commit comments

Comments
 (0)