Skip to content

Commit 249e57b

Browse files
committed
[SYCL] Untie PI functions from OpenCL
* Introduce pi_buffer_region type and use it instead of cl_buffer_region * Introduce pi_fp_capabilities enum and use it in PI functions * Fix type of mem advice parameter in piextUSMEnqueueMemAdvise * Use pi_event_info instead of cl_event_info * Extend pi_device_info with subgroup properties * Extend pi_device_info with enum values to query subgroup information and IL version, this values are going to be used level zero plugin Signed-off-by: Artur Gainullin <[email protected]>
1 parent 4e6cf6f commit 249e57b

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
lines changed

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ typedef enum {
224224
PI_DEVICE_INFO_BUILT_IN_KERNELS = CL_DEVICE_BUILT_IN_KERNELS,
225225
PI_DEVICE_INFO_PLATFORM = CL_DEVICE_PLATFORM,
226226
PI_DEVICE_INFO_REFERENCE_COUNT = CL_DEVICE_REFERENCE_COUNT,
227+
PI_DEVICE_INFO_IL_VERSION = CL_DEVICE_IL_VERSION_KHR,
227228
PI_DEVICE_INFO_NAME = CL_DEVICE_NAME,
228229
PI_DEVICE_INFO_VENDOR = CL_DEVICE_VENDOR,
229230
PI_DEVICE_INFO_DRIVER_VERSION = CL_DRIVER_VERSION,
@@ -241,6 +242,10 @@ typedef enum {
241242
PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN =
242243
CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
243244
PI_DEVICE_INFO_PARTITION_TYPE = CL_DEVICE_PARTITION_TYPE,
245+
PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS = CL_DEVICE_MAX_NUM_SUB_GROUPS,
246+
PI_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS =
247+
CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
248+
PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = CL_DEVICE_SUB_GROUP_SIZES_INTEL,
244249
PI_DEVICE_INFO_USM_HOST_SUPPORT = CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL,
245250
PI_DEVICE_INFO_USM_DEVICE_SUPPORT = CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL,
246251
PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT =
@@ -299,6 +304,16 @@ typedef enum {
299304
PI_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE = CL_KERNEL_PRIVATE_MEM_SIZE
300305
} _pi_kernel_group_info;
301306

307+
typedef enum {
308+
PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT,
309+
PI_FP_ROUND_TO_NEAREST = CL_FP_ROUND_TO_NEAREST,
310+
PI_FP_ROUND_TO_ZERO = CL_FP_ROUND_TO_ZERO,
311+
PI_FP_ROUND_TO_INF = CL_FP_ROUND_TO_INF,
312+
PI_FP_INF_NAN = CL_FP_INF_NAN,
313+
PI_FP_DENORM = CL_FP_DENORM,
314+
PI_FP_FMA = CL_FP_FMA
315+
} _pi_fp_capabilities;
316+
302317
typedef enum {
303318
PI_IMAGE_INFO_FORMAT = CL_IMAGE_FORMAT,
304319
PI_IMAGE_INFO_ELEMENT_SIZE = CL_IMAGE_ELEMENT_SIZE,
@@ -512,6 +527,7 @@ using pi_image_info = _pi_image_info;
512527
using pi_kernel_info = _pi_kernel_info;
513528
using pi_kernel_group_info = _pi_kernel_group_info;
514529
using pi_kernel_sub_group_info = _pi_kernel_sub_group_info;
530+
using pi_fp_capabilities = _pi_fp_capabilities;
515531
using pi_event_info = _pi_event_info;
516532
using pi_command_type = _pi_command_type;
517533
using pi_mem_type = _pi_mem_type;
@@ -678,6 +694,13 @@ struct pi_device_binary_struct {
678694
};
679695
using pi_device_binary = pi_device_binary_struct *;
680696

697+
// pi_buffer_region structure repeats cl_buffer_region
698+
struct pi_buffer_region_struct {
699+
size_t origin;
700+
size_t size;
701+
};
702+
using pi_buffer_region_struct *pi_buffer_region;
703+
681704
// Offload binaries descriptor version supported by this library.
682705
static const uint16_t PI_DEVICE_BINARIES_VERSION = 1;
683706

@@ -1118,10 +1141,10 @@ __SYCL_EXPORT pi_result piKernelSetExecInfo(pi_kernel kernel,
11181141
//
11191142
__SYCL_EXPORT pi_result piEventCreate(pi_context context, pi_event *ret_event);
11201143

1121-
__SYCL_EXPORT pi_result piEventGetInfo(
1122-
pi_event event,
1123-
cl_event_info param_name, // TODO: untie from OpenCL
1124-
size_t param_value_size, void *param_value, size_t *param_value_size_ret);
1144+
__SYCL_EXPORT pi_result piEventGetInfo(pi_event event, pi_event_info param_name,
1145+
size_t param_value_size,
1146+
void *param_value,
1147+
size_t *param_value_size_ret);
11251148

11261149
__SYCL_EXPORT pi_result piEventGetProfilingInfo(pi_event event,
11271150
pi_profiling_info param_name,
@@ -1439,7 +1462,8 @@ __SYCL_EXPORT pi_result piextUSMEnqueuePrefetch(
14391462
// USM memadvise API to govern behavior of automatic migration mechanisms
14401463
__SYCL_EXPORT pi_result piextUSMEnqueueMemAdvise(pi_queue queue,
14411464
const void *ptr, size_t length,
1442-
int advice, pi_event *event);
1465+
pi_mem_advice advice,
1466+
pi_event *event);
14431467

14441468
/// API to query information about USM allocated pointers
14451469
/// Valid Queries:

sycl/include/CL/sycl/info/info_desc.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,20 @@ enum class device : cl_device_info {
117117
partition_affinity_domains = CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
118118
partition_type_affinity_domain = CL_DEVICE_PARTITION_TYPE,
119119
reference_count = CL_DEVICE_REFERENCE_COUNT,
120+
il_version =
121+
CL_DEVICE_IL_VERSION_KHR, // Same as CL_DEVICE_IL_VERSION for >=OpenCL 2.1
120122
max_num_sub_groups = CL_DEVICE_MAX_NUM_SUB_GROUPS,
121123
sub_group_independent_forward_progress =
122124
CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
123125
sub_group_sizes = CL_DEVICE_SUB_GROUP_SIZES_INTEL,
124126
partition_type_property,
125127
kernel_kernel_pipe_support,
126128
// USM
127-
usm_device_allocations = PI_USM_DEVICE_SUPPORT,
128-
usm_host_allocations = PI_USM_HOST_SUPPORT,
129-
usm_shared_allocations = PI_USM_SINGLE_SHARED_SUPPORT,
129+
usm_device_allocations = PI_USM_DEVICE_SUPPORT,
130+
usm_host_allocations = PI_USM_HOST_SUPPORT,
131+
usm_shared_allocations = PI_USM_SINGLE_SHARED_SUPPORT,
130132
usm_restricted_shared_allocations = PI_USM_CROSS_SHARED_SUPPORT,
131-
usm_system_allocator = PI_USM_SYSTEM_SHARED_SUPPORT
133+
usm_system_allocator = PI_USM_SYSTEM_SHARED_SUPPORT
132134
};
133135

134136
enum class device_type : pi_uint64 {

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,15 +1029,15 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
10291029
}
10301030
case PI_DEVICE_INFO_SINGLE_FP_CONFIG: {
10311031
// TODO: is this config consistent across all NVIDIA GPUs?
1032-
auto config = CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST |
1033-
CL_FP_ROUND_TO_ZERO | CL_FP_ROUND_TO_INF | CL_FP_FMA |
1034-
CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT;
1032+
auto config = PI_FP_DENORM | PI_FP_INF_NAN | PI_FP_ROUND_TO_NEAREST |
1033+
PI_FP_ROUND_TO_ZERO | PI_FP_ROUND_TO_INF | PI_FP_FMA |
1034+
PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT;
10351035
return getInfo(param_value_size, param_value, param_value_size_ret, config);
10361036
}
10371037
case PI_DEVICE_INFO_DOUBLE_FP_CONFIG: {
10381038
// TODO: is this config consistent across all NVIDIA GPUs?
1039-
auto config = CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST |
1040-
CL_FP_ROUND_TO_ZERO | CL_FP_ROUND_TO_INF | CL_FP_FMA;
1039+
auto config = PI_FP_DENORM | PI_FP_INF_NAN | PI_FP_ROUND_TO_NEAREST |
1040+
PI_FP_ROUND_TO_ZERO | PI_FP_ROUND_TO_INF | PI_FP_FMA;
10411041
return getInfo(param_value_size, param_value, param_value_size_ret, config);
10421042
}
10431043
case PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: {
@@ -1674,7 +1674,7 @@ pi_result cuda_piMemBufferPartition(pi_mem parent_buffer, pi_mem_flags flags,
16741674
assert(memObj != nullptr);
16751675

16761676
const auto bufferRegion =
1677-
*reinterpret_cast<const cl_buffer_region *>(buffer_create_info);
1677+
*reinterpret_cast<const pi_buffer_region>(buffer_create_info);
16781678
assert((bufferRegion.size != 0u) && "PI_INVALID_BUFFER_SIZE");
16791679

16801680
assert((bufferRegion.origin <= (bufferRegion.origin + bufferRegion.size)) &&
@@ -3596,7 +3596,7 @@ pi_result cuda_piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr,
35963596

35973597
/// USM: memadvise API to govern behavior of automatic migration mechanisms
35983598
pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
3599-
size_t length, int advice,
3599+
size_t length, pi_mem_advice advice,
36003600
pi_event *event) {
36013601
assert(queue != nullptr);
36023602
assert(ptr != nullptr);

sycl/plugins/opencl/pi_opencl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size,
939939
/// \param event is the event that represents this operation
940940
// USM memadvise API to govern behavior of automatic migration mechanisms
941941
pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
942-
size_t length, int advice, pi_event *event) {
942+
size_t length, pi_mem_advice advice,
943+
pi_event *event) {
943944

944945
return cast<pi_result>(
945946
clEnqueueMarkerWithWaitList(cast<cl_command_queue>(queue), 0, nullptr,

sycl/source/detail/memory_manager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext,
189189
SizeInBytes *= Range[I];
190190

191191
RT::PiResult Error = PI_SUCCESS;
192-
// TODO replace with pi_buffer_region
193-
cl_buffer_region Region{Offset, SizeInBytes};
192+
pi_buffer_region_struct Region{Offset, SizeInBytes};
194193
RT::PiMem NewMem;
195194
const detail::plugin &Plugin = TargetContext->getPlugin();
196195
Error = Plugin.call_nocheck<PiApiKind::piMemBufferPartition>(

0 commit comments

Comments
 (0)