Skip to content

Commit e9061fd

Browse files
committed
[SYCL] Isolate OpenCL types and enums
1 parent 1927d21 commit e9061fd

File tree

11 files changed

+427
-469
lines changed

11 files changed

+427
-469
lines changed

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

Lines changed: 345 additions & 395 deletions
Large diffs are not rendered by default.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
#pragma once
1515

16+
#ifdef PI_OPENCL_AVAILABLE
17+
#include <CL/sycl/detail/cl.h>
18+
#endif // PI_OPENCL_AVAILABLE
1619
#include <CL/sycl/backend_types.hpp>
1720
#include <CL/sycl/detail/export.hpp>
1821
#include <CL/sycl/detail/os_util.hpp>
@@ -420,6 +423,8 @@ template <class To, class From> inline To cast(From value) {
420423
return (To)(value);
421424
}
422425

426+
#ifdef PI_OPENCL_AVAILABLE
427+
423428
// Cast for std::vector<cl_event>, according to the spec, make_event
424429
// should create one(?) event from a vector of cl_event
425430
template <class To> inline To cast(std::vector<cl_event> value) {
@@ -439,6 +444,7 @@ template <> inline pi::PiDevice cast(cl_device_id) {
439444
RT::assertion(false, "pi::cast -> use piextCreateDeviceWithNativeHandle");
440445
return {};
441446
}
447+
#endif // PI_OPENCL_AVAILABLE
442448

443449
} // namespace pi
444450
} // namespace detail

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,8 @@ pi_result cuda_piextContextSetExtendedDeleter(
971971
}
972972

973973
/// Not applicable to CUDA, devices cannot be partitioned.
974-
/// TODO: untie cl_device_partition_property from OpenCL
975-
///
976974
pi_result cuda_piDevicePartition(pi_device,
977-
const cl_device_partition_property *,
975+
const pi_device_partition_property *,
978976
pi_uint32, pi_device *, pi_uint32 *) {
979977
return {};
980978
}
@@ -1462,7 +1460,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
14621460
case PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: {
14631461
// TODO: is this config consistent across all NVIDIA GPUs?
14641462
return getInfo(param_value_size, param_value, param_value_size_ret,
1465-
CL_READ_WRITE_CACHE);
1463+
PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE);
14661464
}
14671465
case PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: {
14681466
// The value is documented for all existing GPUs in the CUDA programming
@@ -1569,20 +1567,20 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
15691567
PI_TRUE);
15701568
}
15711569
case PI_DEVICE_INFO_EXECUTION_CAPABILITIES: {
1572-
auto capability = CL_EXEC_KERNEL;
1570+
auto capability = PI_DEVICE_EXEC_CAPABILITIES_KERNEL;
15731571
return getInfo(param_value_size, param_value, param_value_size_ret,
15741572
capability);
15751573
}
15761574
case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: {
15771575
// The mandated minimum capability:
15781576
auto capability =
1579-
CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
1577+
PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
15801578
return getInfo(param_value_size, param_value, param_value_size_ret,
15811579
capability);
15821580
}
15831581
case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: {
15841582
// The mandated minimum capability:
1585-
auto capability = CL_QUEUE_PROFILING_ENABLE;
1583+
auto capability = PI_QUEUE_PROFILING_ENABLE;
15861584
return getInfo(param_value_size, param_value, param_value_size_ret,
15871585
capability);
15881586
}
@@ -1670,15 +1668,15 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
16701668
}
16711669
case PI_DEVICE_INFO_PARTITION_PROPERTIES: {
16721670
return getInfo(param_value_size, param_value, param_value_size_ret,
1673-
static_cast<cl_device_partition_property>(0u));
1671+
static_cast<pi_device_partition_property>(0u));
16741672
}
16751673
case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: {
16761674
return getInfo(param_value_size, param_value, param_value_size_ret, 0u);
16771675
}
16781676
case PI_DEVICE_INFO_PARTITION_TYPE: {
16791677
// TODO: uncouple from OpenCL
16801678
return getInfo(param_value_size, param_value, param_value_size_ret,
1681-
static_cast<cl_device_partition_property>(0u));
1679+
static_cast<pi_device_partition_property>(0u));
16821680
}
16831681

16841682
// Intel USM extensions
@@ -3313,7 +3311,7 @@ pi_result cuda_piProgramCompile(
33133311
}
33143312

33153313
pi_result cuda_piProgramGetBuildInfo(pi_program program, pi_device device,
3316-
cl_program_build_info param_name,
3314+
pi_program_build_info param_name,
33173315
size_t param_value_size, void *param_value,
33183316
size_t *param_value_size_ret) {
33193317
// Ignore unused parameter
@@ -3580,7 +3578,7 @@ pi_result cuda_piEventGetInfo(pi_event event, pi_event_info param_name,
35803578
}
35813579

35823580
/// Obtain profiling information from PI CUDA events
3583-
/// \TODO Untie from OpenCL, timings from CUDA are only elapsed time.
3581+
/// \TODO Timings from CUDA are only elapsed time.
35843582
pi_result cuda_piEventGetProfilingInfo(pi_event event,
35853583
pi_profiling_info param_name,
35863584
size_t param_value_size,
@@ -3794,11 +3792,13 @@ pi_result cuda_piSamplerCreate(pi_context context,
37943792
}
37953793

37963794
if (!propSeen[0]) {
3797-
retImplSampl->props_ |= CL_TRUE;
3795+
retImplSampl->props_ |= PI_TRUE;
37983796
}
3799-
// Default filter mode to CL_FILTER_NEAREST
3797+
// Default filter mode to PI_SAMPLER_FILTER_MODE_NEAREST
38003798
if (!propSeen[2]) {
3801-
retImplSampl->props_ |= (CL_ADDRESS_CLAMP % CL_ADDRESS_NONE) << 2;
3799+
retImplSampl->props_ |=
3800+
(PI_SAMPLER_ADDRESSING_MODE_CLAMP % PI_SAMPLER_ADDRESSING_MODE_NONE)
3801+
<< 2;
38023802
}
38033803

38043804
*result_sampler = retImplSampl.release();
@@ -3814,7 +3814,7 @@ pi_result cuda_piSamplerCreate(pi_context context,
38143814
/// \param[out] param_value_size_ret Set to the size of the information value.
38153815
///
38163816
/// \return PI_SUCCESS on success.
3817-
pi_result cuda_piSamplerGetInfo(pi_sampler sampler, cl_sampler_info param_name,
3817+
pi_result cuda_piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name,
38183818
size_t param_value_size, void *param_value,
38193819
size_t *param_value_size_ret) {
38203820
assert(sampler != nullptr);
@@ -4528,7 +4528,7 @@ pi_result cuda_piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image,
45284528
return retErr;
45294529
}
45304530

4531-
/// \TODO Not implemented in CUDA, requires untie from OpenCL
4531+
/// \TODO Not implemented in CUDA.
45324532
pi_result cuda_piEnqueueMemImageFill(pi_queue, pi_mem, const void *,
45334533
const size_t *, const size_t *, pi_uint32,
45344534
const pi_event *, pi_event *) {
@@ -4540,7 +4540,6 @@ pi_result cuda_piEnqueueMemImageFill(pi_queue, pi_mem, const void *,
45404540
/// Mapped pointers are stored in the pi_mem object.
45414541
/// If the buffer uses pinned host memory a pointer to that memory is returned
45424542
/// and no read operation is done.
4543-
/// \TODO Untie types from OpenCL
45444543
///
45454544
pi_result cuda_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer,
45464545
pi_bool blocking_map,

sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ pi_result piProgramBuild(pi_program, pi_uint32, const pi_device *, const char *,
13281328
DIE_NO_IMPLEMENTATION;
13291329
}
13301330

1331-
pi_result piProgramGetBuildInfo(pi_program, pi_device, cl_program_build_info,
1331+
pi_result piProgramGetBuildInfo(pi_program, pi_device, pi_program_build_info,
13321332
size_t, void *, size_t *) {
13331333
DIE_NO_IMPLEMENTATION;
13341334
}

sycl/plugins/hip/pi_hip.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,10 @@ pi_result hip_piextContextSetExtendedDeleter(
888888

889889
/// Not applicable to HIP, devices cannot be partitioned.
890890
///
891-
pi_result hip_piDevicePartition(
892-
pi_device device,
893-
const cl_device_partition_property *properties, // TODO: untie from OpenCL
894-
pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices) {
891+
pi_result hip_piDevicePartition(pi_device device,
892+
const pi_device_partition_property *properties,
893+
pi_uint32 num_devices, pi_device *out_devices,
894+
pi_uint32 *out_num_devices) {
895895
(void)device;
896896
(void)properties;
897897
(void)num_devices;
@@ -1339,7 +1339,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
13391339
}
13401340
case PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: {
13411341
return getInfo(param_value_size, param_value, param_value_size_ret,
1342-
CL_READ_WRITE_CACHE);
1342+
PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE);
13431343
}
13441344
case PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: {
13451345
// The value is dohipmented for all existing GPUs in the HIP programming
@@ -1450,20 +1450,20 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
14501450
PI_TRUE);
14511451
}
14521452
case PI_DEVICE_INFO_EXECUTION_CAPABILITIES: {
1453-
auto capability = CL_EXEC_KERNEL;
1453+
auto capability = PI_DEVICE_EXEC_CAPABILITIES_KERNEL;
14541454
return getInfo(param_value_size, param_value, param_value_size_ret,
14551455
capability);
14561456
}
14571457
case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: {
14581458
// The mandated minimum capability:
14591459
auto capability =
1460-
CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
1460+
PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
14611461
return getInfo(param_value_size, param_value, param_value_size_ret,
14621462
capability);
14631463
}
14641464
case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: {
14651465
// The mandated minimum capability:
1466-
auto capability = CL_QUEUE_PROFILING_ENABLE;
1466+
auto capability = PI_QUEUE_PROFILING_ENABLE;
14671467
return getInfo(param_value_size, param_value, param_value_size_ret,
14681468
capability);
14691469
}
@@ -1549,15 +1549,14 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
15491549
}
15501550
case PI_DEVICE_INFO_PARTITION_PROPERTIES: {
15511551
return getInfo(param_value_size, param_value, param_value_size_ret,
1552-
static_cast<cl_device_partition_property>(0u));
1552+
static_cast<pi_device_partition_property>(0u));
15531553
}
15541554
case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: {
15551555
return getInfo(param_value_size, param_value, param_value_size_ret, 0u);
15561556
}
15571557
case PI_DEVICE_INFO_PARTITION_TYPE: {
1558-
// TODO: uncouple from OpenCL
15591558
return getInfo(param_value_size, param_value, param_value_size_ret,
1560-
static_cast<cl_device_partition_property>(0u));
1559+
static_cast<pi_device_partition_property>(0u));
15611560
}
15621561

15631562
// Intel USM extensions
@@ -3107,7 +3106,7 @@ pi_result hip_piProgramCompile(
31073106
}
31083107

31093108
pi_result hip_piProgramGetBuildInfo(pi_program program, pi_device device,
3110-
cl_program_build_info param_name,
3109+
pi_program_build_info param_name,
31113110
size_t param_value_size, void *param_value,
31123111
size_t *param_value_size_ret) {
31133112
(void)device;
@@ -3461,7 +3460,7 @@ pi_result hip_piEventGetInfo(pi_event event, pi_event_info param_name,
34613460
}
34623461

34633462
/// Obtain profiling information from PI HIP events
3464-
/// \TODO Untie from OpenCL, timings from HIP are only elapsed time.
3463+
/// Timings from HIP are only elapsed time.
34653464
pi_result hip_piEventGetProfilingInfo(pi_event event,
34663465
pi_profiling_info param_name,
34673466
size_t param_value_size,
@@ -3685,11 +3684,13 @@ pi_result hip_piSamplerCreate(pi_context context,
36853684
}
36863685

36873686
if (!propSeen[0]) {
3688-
retImplSampl->props_ |= CL_TRUE;
3687+
retImplSampl->props_ |= PI_TRUE;
36893688
}
36903689
// Default filter mode to CL_FILTER_NEAREST
36913690
if (!propSeen[2]) {
3692-
retImplSampl->props_ |= (CL_ADDRESS_CLAMP % CL_ADDRESS_NONE) << 2;
3691+
retImplSampl->props_ |=
3692+
(PI_SAMPLER_ADDRESSING_MODE_CLAMP % PI_SAMPLER_ADDRESSING_MODE_NONE)
3693+
<< 2;
36933694
}
36943695

36953696
*result_sampler = retImplSampl.release();
@@ -3705,7 +3706,7 @@ pi_result hip_piSamplerCreate(pi_context context,
37053706
/// \param[out] param_value_size_ret Set to the size of the information value.
37063707
///
37073708
/// \return PI_SUCCESS on success.
3708-
pi_result hip_piSamplerGetInfo(pi_sampler sampler, cl_sampler_info param_name,
3709+
pi_result hip_piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name,
37093710
size_t param_value_size, void *param_value,
37103711
size_t *param_value_size_ret) {
37113712
assert(sampler != nullptr);
@@ -4444,7 +4445,7 @@ pi_result hip_piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image,
44444445
return retErr;
44454446
}
44464447

4447-
/// \TODO Not implemented in HIP, requires untie from OpenCL
4448+
/// \TODO Not implemented in HIP.
44484449
pi_result hip_piEnqueueMemImageFill(pi_queue command_queue, pi_mem image,
44494450
const void *fill_color,
44504451
const size_t *origin, const size_t *region,
@@ -4468,7 +4469,6 @@ pi_result hip_piEnqueueMemImageFill(pi_queue command_queue, pi_mem image,
44684469
/// Mapped pointers are stored in the pi_mem object.
44694470
/// If the buffer uses pinned host memory a pointer to that memory is returned
44704471
/// and no read operation is done.
4471-
/// \TODO Untie types from OpenCL
44724472
///
44734473
pi_result hip_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer,
44744474
pi_bool blocking_map,

0 commit comments

Comments
 (0)