Skip to content

Commit 27135eb

Browse files
Merge pull request #1896 from omarahmed1111/change-opencl-sampler-info-size
Map ur_bool_t to cl_bool in sampler getinfo for opencl adapter
2 parents a69e1b5 + bfc7536 commit 27135eb

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

source/adapters/opencl/sampler.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,38 @@ urSamplerGetInfo(ur_sampler_handle_t hSampler, ur_sampler_info_t propName,
158158
static_assert(sizeof(cl_addressing_mode) ==
159159
sizeof(ur_sampler_addressing_mode_t));
160160

161-
size_t CheckPropSize = 0;
162-
ur_result_t Err = mapCLErrorToUR(
163-
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
164-
propSize, pPropValue, &CheckPropSize));
165-
if (pPropValue && CheckPropSize != propSize) {
166-
return UR_RESULT_ERROR_INVALID_SIZE;
167-
}
168-
UR_RETURN_ON_FAILURE(Err);
169-
if (pPropSizeRet) {
170-
*pPropSizeRet = CheckPropSize;
161+
ur_result_t Err = UR_RESULT_SUCCESS;
162+
// ur_bool_t have a size of uint8_t, but cl_bool size have the size of
163+
// uint32_t so this adjust UR_SAMPLER_INFO_NORMALIZED_COORDS info to map
164+
// between them.
165+
if (propName == UR_SAMPLER_INFO_NORMALIZED_COORDS) {
166+
cl_bool normalized_coords = false;
167+
Err = mapCLErrorToUR(
168+
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
169+
sizeof(cl_bool), &normalized_coords, nullptr));
170+
if (pPropValue && propSize != sizeof(ur_bool_t)) {
171+
return UR_RESULT_ERROR_INVALID_SIZE;
172+
}
173+
UR_RETURN_ON_FAILURE(Err);
174+
if (pPropValue) {
175+
*static_cast<ur_bool_t *>(pPropValue) =
176+
static_cast<ur_bool_t>(normalized_coords);
177+
}
178+
if (pPropSizeRet) {
179+
*pPropSizeRet = sizeof(ur_bool_t);
180+
}
181+
} else {
182+
size_t CheckPropSize = 0;
183+
Err = mapCLErrorToUR(
184+
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
185+
propSize, pPropValue, &CheckPropSize));
186+
if (pPropValue && CheckPropSize != propSize) {
187+
return UR_RESULT_ERROR_INVALID_SIZE;
188+
}
189+
UR_RETURN_ON_FAILURE(Err);
190+
if (pPropSizeRet) {
191+
*pPropSizeRet = CheckPropSize;
192+
}
171193
}
172194

173195
// Convert OpenCL returns to UR

0 commit comments

Comments
 (0)