Skip to content

Commit 051e01b

Browse files
author
Ivan Karachun
committed
[SYCL] Replaced cl_sampler_properties with pi_sampler_properties
Signed-off-by: Ivan Karachun <ivan.karachun@intel.com>
1 parent 97b6396 commit 051e01b

File tree

4 files changed

+60
-25
lines changed

4 files changed

+60
-25
lines changed

sycl/include/CL/sycl/detail/pi.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@ typedef enum {
155155
PI_BUFFER_CREATE_TYPE_REGION = CL_BUFFER_CREATE_TYPE_REGION
156156
} _pi_buffer_create_type;
157157

158+
typedef pi_bitfield pi_sampler_properties;
159+
const pi_bool PI_TRUE = CL_TRUE;
160+
const pi_bool PI_FALSE = CL_FALSE;
161+
162+
typedef enum {
163+
PI_SAMPLER_REFERENCE_COUNT = CL_SAMPLER_REFERENCE_COUNT,
164+
PI_SAMPLER_CONTEXT = CL_SAMPLER_CONTEXT,
165+
PI_SAMPLER_NORMALIZED_COORDS = CL_SAMPLER_NORMALIZED_COORDS,
166+
PI_SAMPLER_ADDRESSING_MODE = CL_SAMPLER_ADDRESSING_MODE,
167+
PI_SAMPLER_FILTER_MODE = CL_SAMPLER_FILTER_MODE,
168+
PI_SAMPLER_MIP_FILTER_MODE = CL_SAMPLER_MIP_FILTER_MODE,
169+
PI_SAMPLER_LOD_MIN = CL_SAMPLER_LOD_MIN,
170+
PI_SAMPLER_LOD_MAX = CL_SAMPLER_LOD_MAX
171+
} _pi_sampler_info;
172+
173+
typedef enum {
174+
PI_ADDRESS_MIRRORED_REPEAT = CL_ADDRESS_MIRRORED_REPEAT,
175+
PI_ADDRESS_REPEAT = CL_ADDRESS_REPEAT,
176+
PI_ADDRESS_CLAMP_TO_EDGE = CL_ADDRESS_CLAMP_TO_EDGE,
177+
PI_ADDRESS_CLAMP = CL_ADDRESS_CLAMP,
178+
PI_ADDRESS_NONE = CL_ADDRESS_NONE
179+
} _pi_addressing_mode;
180+
181+
typedef enum {
182+
PI_FILTER_NEAREST = CL_FILTER_NEAREST,
183+
PI_FILTER_LINEAR = CL_FILTER_LINEAR,
184+
} _pi_filter_mode;
185+
158186
// NOTE: this is made 64-bit to match the size of cl_mem_flags to
159187
// make the translation to OpenCL transparent.
160188
// TODO: populate
@@ -187,6 +215,9 @@ typedef _pi_mem_type pi_mem_type;
187215
typedef _pi_image_channel_order pi_image_channel_order;
188216
typedef _pi_image_channel_type pi_image_channel_type;
189217
typedef _pi_buffer_create_type pi_buffer_create_type;
218+
typedef _pi_addressing_mode pi_addressing_mode;
219+
typedef _pi_filter_mode pi_filter_mode;
220+
typedef _pi_sampler_info pi_sampler_info;
190221

191222
// Opaque data type for compatibility with OpenMP.
192223
typedef void * _pi_offload_entry;
@@ -631,12 +662,12 @@ pi_result piEventRelease(pi_event event);
631662
//
632663
pi_result piSamplerCreate(
633664
pi_context context,
634-
const cl_sampler_properties * sampler_properties, // TODO: untie from OpenCL
665+
const pi_sampler_properties * sampler_properties,
635666
pi_sampler * result_sampler);
636667

637668
pi_result piSamplerGetInfo(
638669
pi_sampler sampler,
639-
cl_sampler_info param_name, // TODO: untie from OpenCL
670+
pi_sampler_info param_name,
640671
size_t param_value_size,
641672
void * param_value,
642673
size_t * param_value_size_ret);

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ namespace pi {
4444
using PiMemFlags = ::pi_mem_flags;
4545
using PiEvent = ::pi_event;
4646
using PiSampler = ::pi_sampler;
47+
using PiSamplerInfo = ::pi_sampler_info;
48+
using PiSamplerProperties = ::pi_sampler_properties;
49+
using PiAddressingMode = ::pi_addressing_mode;
50+
using PiFilterMode = ::pi_filter_mode;
4751
using PiMemImageFormat = ::pi_image_format;
4852
using PiMemImageDesc = ::pi_image_desc;
4953
using PiMemImageInfo = ::pi_image_info;

sycl/source/detail/pi_opencl.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,23 +212,23 @@ pi_result OCL(piProgramCreate)(pi_context context, const void *il,
212212
}
213213

214214
pi_result OCL(piSamplerCreate)(pi_context context,
215-
const cl_sampler_properties *sampler_properties,
215+
const pi_sampler_properties *sampler_properties,
216216
pi_sampler *result_sampler) {
217217
// Initialize properties according to OpenCL 2.1 spec.
218218
pi_result error_code;
219-
cl_bool normalizedCoords = CL_TRUE;
220-
cl_addressing_mode addressingMode = CL_ADDRESS_CLAMP;
221-
cl_filter_mode filterMode = CL_FILTER_NEAREST;
219+
pi_bool normalizedCoords = PI_TRUE;
220+
pi_addressing_mode addressingMode = PI_ADDRESS_CLAMP;
221+
pi_filter_mode filterMode = PI_FILTER_NEAREST;
222222

223223
// Unpack sampler properties
224224
for (std::size_t i = 0; sampler_properties && sampler_properties[i] != 0;
225225
++i) {
226-
if (sampler_properties[i] == CL_SAMPLER_NORMALIZED_COORDS) {
227-
normalizedCoords = sampler_properties[++i];
228-
} else if (sampler_properties[i] == CL_SAMPLER_ADDRESSING_MODE) {
229-
addressingMode = sampler_properties[++i];
230-
} else if (sampler_properties[i] == CL_SAMPLER_FILTER_MODE) {
231-
filterMode = sampler_properties[++i];
226+
if (sampler_properties[i] == PI_SAMPLER_NORMALIZED_COORDS) {
227+
normalizedCoords = (pi_bool)sampler_properties[++i];
228+
} else if (sampler_properties[i] == PI_SAMPLER_ADDRESSING_MODE) {
229+
addressingMode = (pi_addressing_mode)sampler_properties[++i];
230+
} else if (sampler_properties[i] == PI_SAMPLER_FILTER_MODE) {
231+
filterMode = (pi_filter_mode)sampler_properties[++i];
232232
} else {
233233
PI_ASSERT(false, "Cannot recognize sampler property");
234234
}

sycl/source/detail/sampler_impl.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) {
2424
RT::PiSampler Sampler = pi::cast<RT::PiSampler>(clSampler);
2525
m_contextToSampler[syclContext] = Sampler;
2626
PI_CALL(RT::piSamplerRetain(Sampler));
27-
PI_CALL(RT::piSamplerGetInfo(Sampler, CL_SAMPLER_NORMALIZED_COORDS,
28-
sizeof(cl_bool), &m_CoordNormMode, nullptr));
29-
PI_CALL(RT::piSamplerGetInfo(Sampler, CL_SAMPLER_ADDRESSING_MODE,
30-
sizeof(cl_addressing_mode), &m_AddrMode,
27+
PI_CALL(RT::piSamplerGetInfo(Sampler, PI_SAMPLER_NORMALIZED_COORDS,
28+
sizeof(pi_bool), &m_CoordNormMode, nullptr));
29+
PI_CALL(RT::piSamplerGetInfo(Sampler, PI_SAMPLER_ADDRESSING_MODE,
30+
sizeof(pi_addressing_mode), &m_AddrMode,
3131
nullptr));
32-
PI_CALL(RT::piSamplerGetInfo(Sampler, CL_SAMPLER_FILTER_MODE,
33-
sizeof(cl_filter_mode), &m_FiltMode,
32+
PI_CALL(RT::piSamplerGetInfo(Sampler, PI_SAMPLER_FILTER_MODE,
33+
sizeof(pi_filter_mode), &m_FiltMode,
3434
nullptr));
3535
}
3636

@@ -45,13 +45,13 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) {
4545
if (m_contextToSampler[Context])
4646
return m_contextToSampler[Context];
4747

48-
const cl_sampler_properties sprops[] = {
49-
CL_SAMPLER_NORMALIZED_COORDS,
50-
static_cast<cl_sampler_properties>(m_CoordNormMode),
51-
CL_SAMPLER_ADDRESSING_MODE,
52-
static_cast<cl_sampler_properties>(m_AddrMode),
53-
CL_SAMPLER_FILTER_MODE,
54-
static_cast<cl_sampler_properties>(m_FiltMode),
48+
const pi_sampler_properties sprops[] = {
49+
PI_SAMPLER_NORMALIZED_COORDS,
50+
static_cast<pi_sampler_properties>(m_CoordNormMode),
51+
PI_SAMPLER_ADDRESSING_MODE,
52+
static_cast<pi_sampler_properties>(m_AddrMode),
53+
PI_SAMPLER_FILTER_MODE,
54+
static_cast<pi_sampler_properties>(m_FiltMode),
5555
0};
5656

5757
RT::PiResult errcode_ret = PI_SUCCESS;

0 commit comments

Comments
 (0)