From 3e0fe6a70aa5a9d4e1903e2bd27c264ac227a152 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 28 Nov 2022 13:20:09 -0800 Subject: [PATCH 01/23] WIP [SYCL][PI] Add PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES Always return 1. --- sycl/include/sycl/detail/pi.h | 3 +++ sycl/plugins/cuda/pi_cuda.cpp | 4 ++++ sycl/plugins/hip/pi_hip.cpp | 4 ++++ sycl/plugins/level_zero/pi_level_zero.cpp | 3 +++ sycl/plugins/opencl/pi_opencl.cpp | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 5c1aa007a315d..3fd034762859b 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -286,6 +286,9 @@ typedef enum { // Return 0 if device doesn't have any memory modules. Return the minimum of // the bus width values if there are several memory modules on the device. PI_EXT_INTEL_DEVICE_INFO_MEMORY_BUS_WIDTH = 0x10031, + // Return 1 if the device doesn't have a notion of a "queue index". Otherwise, + // return the number of queue indices that are available for this device. + PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = 0x10032, PI_DEVICE_INFO_ATOMIC_64 = 0x10110, PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 0x10111, PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 0x11000, diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 65883399041e4..f160dbb123868 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -1945,6 +1945,10 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, sycl::detail::pi::assertion(value >= 0); return getInfo(param_value_size, param_value, param_value_size_ret, value); } + case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + return getInfo(param_value_size, param_value, param_value_size_ret, + pi_int32{1}); + } // TODO: Investigate if this information is available on CUDA. case PI_DEVICE_INFO_DEVICE_ID: diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index ac40e32707ed8..a4aee74b78d8b 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -1841,6 +1841,10 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, sycl::detail::pi::assertion(value >= 0); return getInfo(param_value_size, param_value, param_value_size_ret, value); } + case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + return getInfo(param_value_size, param_value, param_value_size_ret, + pi_int32{1}); + } // TODO: Implement. case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 9516a29ffa583..a3393cb28a7c7 100755 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -3183,6 +3183,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, Device->ZeDeviceMemoryProperties->end(), Comp); return ReturnValue(pi_uint32{MinIt->maxBusWidth}); } + case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + return ReturnValue(pi_int32{1}); + } case PI_DEVICE_INFO_GPU_EU_COUNT: { pi_uint32 count = Device->ZeDeviceProperties->numEUsPerSubslice * Device->ZeDeviceProperties->numSubslicesPerSlice * diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index f26bc5516c8c4..f54816d7ad369 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -330,6 +330,11 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, out[2] = Max; return PI_SUCCESS; } + case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + pi_int32 result = 1; + std::memcpy(paramValue, &result, sizeof(pi_int32)); + return PI_SUCCESS; + } default: cl_int result = clGetDeviceInfo( From f642f25cbe3eb2dd3af537760f131986b34d593d Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 28 Nov 2022 13:34:01 -0800 Subject: [PATCH 02/23] WIP Add SYCL-level interface --- sycl/include/sycl/info/ext_intel_device_traits.def | 1 + sycl/source/detail/device_info.hpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/sycl/include/sycl/info/ext_intel_device_traits.def b/sycl/include/sycl/info/ext_intel_device_traits.def index 4b2ff5a4c2e15..e58b27af69756 100644 --- a/sycl/include/sycl/info/ext_intel_device_traits.def +++ b/sycl/include/sycl/info/ext_intel_device_traits.def @@ -15,6 +15,7 @@ __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, uuid, detail::uuid_type, PI_DEVICE_ __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, free_memory, pi_uint64, PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY) __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, memory_clock_rate, pi_uint32, PI_EXT_INTEL_DEVICE_INFO_MEMORY_CLOCK_RATE) __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, memory_bus_width, pi_uint32, PI_EXT_INTEL_DEVICE_INFO_MEMORY_BUS_WIDTH) +__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, max_compute_queue_indices, pi_int32, PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES) #ifdef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF #undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC #undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index fcf505dd9e042..8d29a5240ffbe 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1589,6 +1589,14 @@ get_device_info_host() { PI_ERROR_INVALID_DEVICE); } +template <> +inline int32_t +get_device_info_host() { + throw runtime_error( + "Obtaining max compute queue indices is not supported on HOST device", + PI_ERROR_INVALID_DEVICE); +} + } // namespace detail } // __SYCL_INLINE_VER_NAMESPACE(_V1) } // namespace sycl From fedf4673f756d6dc68d9fe7f9fd497bff2661f68 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 28 Nov 2022 15:20:32 -0800 Subject: [PATCH 03/23] WIP Add property, not passed to the plugin yet --- sycl/include/sycl/detail/property_helper.hpp | 3 ++- .../sycl/properties/queue_properties.hpp | 21 +++++++++++++++++++ sycl/source/detail/queue_impl.hpp | 12 +++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/property_helper.hpp b/sycl/include/sycl/detail/property_helper.hpp index 2a802fd1e7181..5c0724e683b2a 100644 --- a/sycl/include/sycl/detail/property_helper.hpp +++ b/sycl/include/sycl/detail/property_helper.hpp @@ -54,7 +54,8 @@ enum PropWithDataKind { ImageContextBound = 3, BufferMemChannel = 4, AccPropBufferLocation = 5, - PropWithDataKindSize = 6, + QueueComputeIndex = 6, + PropWithDataKindSize = 7, }; // Base class for dataless properties, needed to check that the type of an diff --git a/sycl/include/sycl/properties/queue_properties.hpp b/sycl/include/sycl/properties/queue_properties.hpp index 21a2c7fbdc086..2a9ebd548cf5b 100644 --- a/sycl/include/sycl/properties/queue_properties.hpp +++ b/sycl/include/sycl/properties/queue_properties.hpp @@ -54,6 +54,24 @@ class use_default_stream } // namespace queue } // namespace property +namespace ext { +namespace intel { +namespace property { +namespace queue { +class compute_index : public sycl::detail::PropertyWithData< + sycl::detail::PropWithDataKind::QueueComputeIndex> { +public: + compute_index(int idx) : idx(idx) {} + int get_index() { return idx; } + +private: + int idx; +}; +} // namespace queue +} // namespace property +} // namespace intel +} // namespace ext + // Forward declaration class queue; @@ -72,6 +90,9 @@ struct is_property_of template <> struct is_property_of : std::true_type {}; +template <> +struct is_property_of + : std::true_type {}; } // __SYCL_INLINE_VER_NAMESPACE(_V1) } // namespace sycl diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 6017dc30e1b09..f3d08980c3f12 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -104,6 +104,18 @@ class queue_impl { "Queue cannot be constructed with both of " "discard_events and enable_profiling."); } + if (has_property()) { + int Idx = get_property() + .get_index(); + int NumIndices = + createSyclObjFromImpl(Device) + .get_info(); + if (Idx < 0 || Idx >= NumIndices) + throw sycl::exception( + make_error_code(errc::invalid), + "Queue compute index must be a non-negative number less than " + "device's number of available compute queue indices."); + } if (!Context->isDeviceValid(Device)) { if (!Context->is_host() && Context->getPlugin().getBackend() == backend::opencl) From f1ff38bee0df08e62b077ff2c7c89bbed093d82c Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 28 Nov 2022 15:22:23 -0800 Subject: [PATCH 04/23] WIP Define feature macro --- sycl/include/sycl/feature_test.hpp.in | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/include/sycl/feature_test.hpp.in b/sycl/include/sycl/feature_test.hpp.in index a4e86b9a82b48..30c14ecbafc35 100644 --- a/sycl/include/sycl/feature_test.hpp.in +++ b/sycl/include/sycl/feature_test.hpp.in @@ -63,6 +63,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) { #define SYCL_EXT_INTEL_MEM_CHANNEL_PROPERTY 1 #define SYCL_EXT_INTEL_USM_ADDRESS_SPACES 1 #define SYCL_EXT_INTEL_RUNTIME_BUFFER_LOCATION 1 +#define SYCL_EXT_INTEL_QUEUE_INDEX 1 #define SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO 3 #define SYCL_EXT_ONEAPI_USM_DEVICE_READ_ONLY 1 #define SYCL_EXT_ONEAPI_KERNEL_PROPERTIES 1 From a34fc245b582d2bf163df1e0eb595bb2dd891cb1 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Tue, 29 Nov 2022 12:22:54 -0800 Subject: [PATCH 05/23] WIP Introduce piQueueCreateEx --- sycl/include/sycl/detail/pi.def | 1 + sycl/include/sycl/detail/pi.h | 6 +++++ sycl/plugins/cuda/pi_cuda.cpp | 11 ++++++++++ .../esimd_emulator/pi_esimd_emulator.cpp | 10 +++++++++ sycl/plugins/hip/pi_hip.cpp | 11 ++++++++++ sycl/plugins/level_zero/pi_level_zero.cpp | 22 ++++++++++++++----- sycl/plugins/opencl/pi_opencl.cpp | 10 +++++++++ sycl/unittests/helpers/PiMockPlugin.hpp | 6 +++++ 8 files changed, 71 insertions(+), 6 deletions(-) diff --git a/sycl/include/sycl/detail/pi.def b/sycl/include/sycl/detail/pi.def index 59dab0c4721a1..d8ed9910496ee 100644 --- a/sycl/include/sycl/detail/pi.def +++ b/sycl/include/sycl/detail/pi.def @@ -43,6 +43,7 @@ _PI_API(piextContextGetNativeHandle) _PI_API(piextContextCreateWithNativeHandle) // Queue _PI_API(piQueueCreate) +_PI_API(piQueueCreateEx) _PI_API(piQueueGetInfo) _PI_API(piQueueFinish) _PI_API(piQueueFlush) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 3fd034762859b..9ad6462f3a1f0 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -578,6 +578,7 @@ constexpr pi_usm_mem_properties PI_MEM_USM_ALLOC_BUFFER_LOCATION = 0x419E; // NOTE: queue properties are implemented this way to better support bit // manipulations using pi_queue_properties = pi_bitfield; +constexpr pi_queue_properties PI_QUEUE_FLAGS = -1; constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = (1 << 1); constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = (1 << 2); @@ -1112,9 +1113,14 @@ __SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( // // Queue // + +// TODO: Remove during next ABI break. __SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue); +__SYCL_EXPORT pi_result piQueueCreateEx(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue); __SYCL_EXPORT pi_result piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index f160dbb123868..11c339404ed47 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -2528,6 +2528,16 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, return PI_ERROR_OUT_OF_RESOURCES; } } +pi_result cuda_piQueueCreateEx(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { + PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + // Expect flags amsk to be passed first. + PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + pi_queue_properties Flags = Properties[1]; + // Extra data isn't supported yet. + PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + return cuda_piQueueCreate(Context, Device, Flags, Queue); +} pi_result cuda_piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, size_t param_value_size, void *param_value, @@ -5456,6 +5466,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { cuda_piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, cuda_piQueueCreate) + _PI_CL(piQueueCreateEx, cuda_piQueueCreateEx) _PI_CL(piQueueGetInfo, cuda_piQueueGetInfo) _PI_CL(piQueueFinish, cuda_piQueueFinish) _PI_CL(piQueueFlush, cuda_piQueueFlush) diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index 2d3e78edae683..d807943a6e6da 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -923,6 +923,16 @@ bool _pi_context::checkSurfaceArgument(pi_mem_flags Flags, void *HostPtr) { return true; } +pi_result piQueueCreateEx(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { + PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + // Expect flags amsk to be passed first. + PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + pi_queue_properties Flags = Properties[1]; + // Extra data isn't supported yet. + PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + return piQueueCreate(Context, Device, Flags, Queue); +} pi_result piQueueCreate(pi_context Context, pi_device Device, pi_queue_properties Properties, pi_queue *Queue) { ARG_UNUSED(Device); diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index a4aee74b78d8b..982f301736232 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -2405,6 +2405,16 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, return PI_ERROR_OUT_OF_RESOURCES; } } +pi_result hip_piQueueCreateEx(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { + PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + // Expect flags amsk to be passed first. + PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + pi_queue_properties Flags = Properties[1]; + // Extra data isn't supported yet. + PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + return hip_piQueueCreate(Context, Device, Flags, Queue); +} pi_result hip_piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, size_t param_value_size, void *param_value, @@ -5190,6 +5200,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { hip_piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, hip_piQueueCreate) + _PI_CL(piQueueCreateEx, hip_piQueueCreateEx) _PI_CL(piQueueGetInfo, hip_piQueueGetInfo) _PI_CL(piQueueFinish, hip_piQueueFinish) _PI_CL(piQueueFlush, hip_piQueueFlush) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index a3393cb28a7c7..876c80d70ce24 100755 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -3519,14 +3519,24 @@ pi_result piContextRelease(pi_context Context) { return ContextReleaseHelper(Context); } +pi_result piQueueCreateEx(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { + PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + // Expect flags amsk to be passed first. + PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + pi_queue_properties Flags = Properties[1]; + // Extra data isn't supported yet. + PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + return piQueueCreate(Context, Device, Flags, Queue); +} pi_result piQueueCreate(pi_context Context, pi_device Device, - pi_queue_properties Properties, pi_queue *Queue) { + pi_queue_properties Flags, pi_queue *Queue) { // Check that unexpected bits are not set. - PI_ASSERT(!(Properties & ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | - PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_ON_DEVICE | - PI_QUEUE_ON_DEVICE_DEFAULT | - PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS)), + PI_ASSERT(!(Flags & ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | + PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_ON_DEVICE | + PI_QUEUE_ON_DEVICE_DEFAULT | + PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS)), PI_ERROR_INVALID_VALUE); PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); @@ -3557,7 +3567,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, try { *Queue = new _pi_queue(ZeComputeCommandQueues, ZeCopyCommandQueues, Context, - Device, true, Properties); + Device, true, Flags); } catch (const std::bad_alloc &) { return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index f54816d7ad369..46e14b32d84f2 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -462,6 +462,16 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, return PI_SUCCESS; } +pi_result piQueueCreateEx(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { + assert(Properties); + // Expect flags amsk to be passed first. + assert(Properties[0] == PI_QUEUE_FLAGS); + pi_queue_properties Flags = Properties[1]; + // Extra data isn't supported yet. + assert(Properties[2] == 0); + return piQueueCreate(Context, Device, Flags, Queue); +} pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); diff --git a/sycl/unittests/helpers/PiMockPlugin.hpp b/sycl/unittests/helpers/PiMockPlugin.hpp index 84c776333aa94..e1a3a22ef89b0 100644 --- a/sycl/unittests/helpers/PiMockPlugin.hpp +++ b/sycl/unittests/helpers/PiMockPlugin.hpp @@ -322,6 +322,12 @@ inline pi_result mock_piQueueCreate(pi_context context, pi_device device, *queue = createDummyHandle(); return PI_SUCCESS; } +inline pi_result mock_piQueueCreateEx(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { + *queue = createDummyHandle(); + return PI_SUCCESS; +} inline pi_result mock_piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, From 00fa9bf725e4e9470d76b532b9ce5860654a3b2c Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Tue, 29 Nov 2022 13:16:26 -0800 Subject: [PATCH 06/23] WIP Change SYCL RT to use piQueueCreateEx --- sycl/source/detail/queue_impl.hpp | 5 +++-- sycl/unittests/queue/EventClear.cpp | 12 +++++++----- sycl/unittests/queue/Wait.cpp | 12 +++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index f3d08980c3f12..61c668af9f83c 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -330,8 +330,9 @@ class queue_impl { const detail::plugin &Plugin = getPlugin(); assert(Plugin.getBackend() == MDevice->getPlugin().getBackend()); - RT::PiResult Error = Plugin.call_nocheck( - Context, Device, CreationFlags, &Queue); + RT::PiQueueProperties Properties[] = {PI_QUEUE_FLAGS, CreationFlags, 0}; + RT::PiResult Error = Plugin.call_nocheck( + Context, Device, Properties, &Queue); // If creating out-of-order queue failed and this property is not // supported (for example, on FPGA), it will return diff --git a/sycl/unittests/queue/EventClear.cpp b/sycl/unittests/queue/EventClear.cpp index 043616100518e..49935fac23c2c 100644 --- a/sycl/unittests/queue/EventClear.cpp +++ b/sycl/unittests/queue/EventClear.cpp @@ -25,12 +25,13 @@ std::unique_ptr TestContext; const int ExpectedEventThreshold = 128; -pi_result redefinedQueueCreate(pi_context context, pi_device device, - pi_queue_properties properties, - pi_queue *queue) { +pi_result redefinedQueueCreateEx(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { + assert(properties && properties[0] == PI_QUEUE_FLAGS); // Use in-order queues to force storing events for calling wait on them, // rather than calling piQueueFinish. - if (properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + if (properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; @@ -71,7 +72,8 @@ pi_result redefinedEventRelease(pi_event event) { } void preparePiMock(unittest::PiMock &Mock) { - Mock.redefineBefore(redefinedQueueCreate); + Mock.redefineBefore( + redefinedQueueCreateEx); Mock.redefineBefore(redefinedEventsWait); Mock.redefineAfter( redefinedEventGetInfoAfter); diff --git a/sycl/unittests/queue/Wait.cpp b/sycl/unittests/queue/Wait.cpp index e32e2c8ad2a33..1b6395c5f6412 100644 --- a/sycl/unittests/queue/Wait.cpp +++ b/sycl/unittests/queue/Wait.cpp @@ -26,11 +26,12 @@ struct TestCtx { }; static TestCtx TestContext; -pi_result redefinedQueueCreate(pi_context context, pi_device device, - pi_queue_properties properties, - pi_queue *queue) { +pi_result redefinedQueueCreateEx(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { + assert(properties && properties[0] == PI_QUEUE_FLAGS); if (!TestContext.SupportOOO && - properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; @@ -77,7 +78,8 @@ pi_result redefinedEventRelease(pi_event event) { TEST(QueueWait, QueueWaitTest) { sycl::unittest::PiMock Mock; sycl::platform Plt = Mock.getPlatform(); - Mock.redefineBefore(redefinedQueueCreate); + Mock.redefineBefore( + redefinedQueueCreateEx); Mock.redefineBefore(redefinedQueueFinish); Mock.redefineBefore( redefinedUSMEnqueueMemset); From 971ef1af5e6bf6b6e4135cc6b5decf2781fff3a8 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 14:07:12 -0800 Subject: [PATCH 07/23] WIP Final piece? --- sycl/include/sycl/detail/pi.h | 1 + sycl/plugins/level_zero/pi_level_zero.cpp | 41 ++++++++++++++++++----- sycl/plugins/level_zero/pi_level_zero.hpp | 2 +- sycl/source/detail/queue_impl.hpp | 9 ++++- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 9ad6462f3a1f0..bda8ebb5f9f84 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -579,6 +579,7 @@ constexpr pi_usm_mem_properties PI_MEM_USM_ALLOC_BUFFER_LOCATION = 0x419E; // manipulations using pi_queue_properties = pi_bitfield; constexpr pi_queue_properties PI_QUEUE_FLAGS = -1; +constexpr pi_queue_properties PI_QUEUE_COMPUTE_INDEX = -2; constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = (1 << 1); constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = (1 << 2); diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 876c80d70ce24..9c91ce7e539ed 100755 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -1182,7 +1182,8 @@ _pi_queue::_pi_queue(std::vector &ComputeQueues, std::vector &CopyQueues, pi_context Context, pi_device Device, bool OwnZeCommandQueue, - pi_queue_properties PiQueueProperties) + pi_queue_properties PiQueueProperties, + int ForceComputeIndex) : Context{Context}, Device{Device}, OwnZeCommandQueue{OwnZeCommandQueue}, Properties(PiQueueProperties) { @@ -1192,9 +1193,19 @@ _pi_queue::_pi_queue(std::vector &ComputeQueues, auto &ComputeQueueGroupInfo = Device->QueueGroup[queue_type::Compute]; ComputeQueueGroup.ZeQueues = ComputeQueues; if (ComputeQueueGroupInfo.ZeIndex >= 0) { + // Sub-sub-device + + // sycl::ext::intel::property::queue::compute_index works with any + // backend/device by allowing single zero index if multiple compute CCSes + // are not supported. Sub-sub-device falls into the same bucket. + assert(ForceComputeIndex <= 0); ComputeQueueGroup.LowerIndex = ComputeQueueGroupInfo.ZeIndex; ComputeQueueGroup.UpperIndex = ComputeQueueGroupInfo.ZeIndex; ComputeQueueGroup.NextIndex = ComputeQueueGroupInfo.ZeIndex; + } else if (ForceComputeIndex >= 0) { + ComputeQueueGroup.LowerIndex = ForceComputeIndex; + ComputeQueueGroup.UpperIndex = ForceComputeIndex; + ComputeQueueGroup.NextIndex = ForceComputeIndex; } else { // Set-up to round-robin across allowed range of engines. uint32_t FilterLowerIndex = getRangeOfAllowedComputeEngines().first; @@ -3184,7 +3195,13 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, return ReturnValue(pi_uint32{MinIt->maxBusWidth}); } case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { - return ReturnValue(pi_int32{1}); + if (Device->QueueGroup[_pi_queue::queue_type::Compute].ZeIndex >= 0) + // Sub-sub-device represents a particular compute index already. + return ReturnValue(pi_int32{1}); + + auto ZeDeviceNumIndices = Device->QueueGroup[_pi_queue::queue_type::Compute] + .ZeProperties.numQueues; + return ReturnValue(pi_cast(ZeDeviceNumIndices)); } case PI_DEVICE_INFO_GPU_EU_COUNT: { pi_uint32 count = Device->ZeDeviceProperties->numEUsPerSubslice * @@ -3519,18 +3536,24 @@ pi_result piContextRelease(pi_context Context) { return ContextReleaseHelper(Context); } +pi_result piQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties Flags, pi_queue *Queue) { + pi_queue_properties Properties[] = {PI_QUEUE_FLAGS, Flags, 0}; + return piQueueCreateEx(Context, Device, Properties, Queue); +} pi_result piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); // Expect flags amsk to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); pi_queue_properties Flags = Properties[1]; - // Extra data isn't supported yet. - PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) - return piQueueCreate(Context, Device, Flags, Queue); -} -pi_result piQueueCreate(pi_context Context, pi_device Device, - pi_queue_properties Flags, pi_queue *Queue) { + + PI_ASSERT(Properties[2] == 0 || + (Properties[2] == PI_QUEUE_COMPUTE_INDEX && Properties[4] == 0), + PI_ERROR_INVALID_VALUE); + auto ForceComputeIndex = Properties[2] == PI_QUEUE_COMPUTE_INDEX + ? static_cast(Properties[3]) + : -1; // Use default/round-robin. // Check that unexpected bits are not set. PI_ASSERT(!(Flags & ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | @@ -3567,7 +3590,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, try { *Queue = new _pi_queue(ZeComputeCommandQueues, ZeCopyCommandQueues, Context, - Device, true, Flags); + Device, true, Flags, ForceComputeIndex); } catch (const std::bad_alloc &) { return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { diff --git a/sycl/plugins/level_zero/pi_level_zero.hpp b/sycl/plugins/level_zero/pi_level_zero.hpp index 7a34d86c9e7ed..786941c1ace12 100644 --- a/sycl/plugins/level_zero/pi_level_zero.hpp +++ b/sycl/plugins/level_zero/pi_level_zero.hpp @@ -644,7 +644,7 @@ struct _pi_queue : _pi_object { _pi_queue(std::vector &ComputeQueues, std::vector &CopyQueues, pi_context Context, pi_device Device, bool OwnZeCommandQueue, - pi_queue_properties Properties = 0); + pi_queue_properties Properties = 0, int ForceComputeIndex = -1); using queue_type = _pi_device::queue_group_info_t::type; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 61c668af9f83c..37ae5ff4143aa 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -330,7 +330,14 @@ class queue_impl { const detail::plugin &Plugin = getPlugin(); assert(Plugin.getBackend() == MDevice->getPlugin().getBackend()); - RT::PiQueueProperties Properties[] = {PI_QUEUE_FLAGS, CreationFlags, 0}; + RT::PiQueueProperties Properties[] = {PI_QUEUE_FLAGS, CreationFlags, 0, 0, + 0}; + if (has_property()) { + int Idx = get_property() + .get_index(); + Properties[2] = PI_QUEUE_COMPUTE_INDEX; + Properties[3] = static_cast(Idx); + } RT::PiResult Error = Plugin.call_nocheck( Context, Device, Properties, &Queue); From 19ddea02e7ddbc6b702dc2e9a01eddacef12975f Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 14:27:15 -0800 Subject: [PATCH 08/23] Fix typo --- sycl/plugins/cuda/pi_cuda.cpp | 2 +- sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp | 2 +- sycl/plugins/hip/pi_hip.cpp | 2 +- sycl/plugins/level_zero/pi_level_zero.cpp | 2 +- sycl/plugins/opencl/pi_opencl.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 11c339404ed47..c42523be3f6b8 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -2531,7 +2531,7 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, pi_result cuda_piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); - // Expect flags amsk to be passed first. + // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index d807943a6e6da..edd13da6d788a 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -926,7 +926,7 @@ bool _pi_context::checkSurfaceArgument(pi_mem_flags Flags, void *HostPtr) { pi_result piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); - // Expect flags amsk to be passed first. + // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index 982f301736232..429a157314d9b 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -2408,7 +2408,7 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, pi_result hip_piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); - // Expect flags amsk to be passed first. + // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 9c91ce7e539ed..638c49bf84f09 100755 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -3544,7 +3544,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, pi_result piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); - // Expect flags amsk to be passed first. + // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); pi_queue_properties Flags = Properties[1]; diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 46e14b32d84f2..56e0e7c70c5e3 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -465,7 +465,7 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_result piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { assert(Properties); - // Expect flags amsk to be passed first. + // Expect flags mask to be passed first. assert(Properties[0] == PI_QUEUE_FLAGS); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. From 3d6892b122f0c7a6e8385a4d506b847d59c44bf3 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 14:32:04 -0800 Subject: [PATCH 09/23] Add PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES case for ESIMD_EMULATOR --- sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index edd13da6d788a..ce1276470d527 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -785,6 +785,8 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, return ReturnValue(pi_uint32{0}); case PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: return ReturnValue(size_t{1}); + case PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: + return ReturnValue(pi_int32{1}); CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS) CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS) From ebb1f30dd273c3a647a034bac33717b2c47d04af Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 14:57:10 -0800 Subject: [PATCH 10/23] Update TODO comment --- sycl/include/sycl/detail/pi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 8c4bbd488dc06..7e2e52786c317 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -1119,7 +1119,8 @@ __SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( // Queue // -// TODO: Remove during next ABI break. +// TODO: Remove during next ABI break and rename piQueueCreateEx to +// piQueueCreate. __SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue); From 48c8b8142650c72ddbcc34cec461f5ebf6be67c5 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 15:01:58 -0800 Subject: [PATCH 11/23] clang-format --- sycl/plugins/cuda/pi_cuda.cpp | 3 ++- sycl/plugins/hip/pi_hip.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 16494dd7e82a1..5ece6c45120cb 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -2529,7 +2529,8 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, } } pi_result cuda_piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, pi_queue *Queue) { + pi_queue_properties *Properties, + pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index b591eae9fc94a..a1ac6ff58272f 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -2406,7 +2406,8 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, } } pi_result hip_piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, pi_queue *Queue) { + pi_queue_properties *Properties, + pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); From ae6d72af5726f589e22584fbc2f6766048d1a8af Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 15:19:09 -0800 Subject: [PATCH 12/23] Fix CUDA/HIP build --- sycl/plugins/cuda/pi_cuda.cpp | 6 +++--- sycl/plugins/hip/pi_hip.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 5ece6c45120cb..fca1a21334029 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -2531,12 +2531,12 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, pi_result cuda_piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { - PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + assert(Properties); // Expect flags mask to be passed first. - PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + assert(Properties[0] == PI_QUEUE_FLAGS); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. - PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + assert(Properties[2] == 0); return cuda_piQueueCreate(Context, Device, Flags, Queue); } diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index a1ac6ff58272f..6dd3ac0aa3150 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -2408,12 +2408,12 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, pi_result hip_piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { - PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + assert(Properties); // Expect flags mask to be passed first. - PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + assert(Properties[0] == PI_QUEUE_FLAGS); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. - PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + assert(Properties[2] == 0); return hip_piQueueCreate(Context, Device, Flags, Queue); } From 0acba892286bfcd6d6da8ae527075b3d758f925c Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 15:30:31 -0800 Subject: [PATCH 13/23] Same for ESIMD_EMULATOR --- sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index ce1276470d527..d64d65a61af74 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -927,12 +927,12 @@ bool _pi_context::checkSurfaceArgument(pi_mem_flags Flags, void *HostPtr) { pi_result piQueueCreateEx(pi_context Context, pi_device Device, pi_queue_properties *Properties, pi_queue *Queue) { - PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); + assert(Properties); // Expect flags mask to be passed first. - PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); + assert(Properties[0] == PI_QUEUE_FLAGS); pi_queue_properties Flags = Properties[1]; // Extra data isn't supported yet. - PI_ASSERT(Properties[2] == 0, PI_ERROR_INVALID_VALUE) + assert(Properties[2] == 0); return piQueueCreate(Context, Device, Flags, Queue); } pi_result piQueueCreate(pi_context Context, pi_device Device, From b3c49ff5e3a9913b169b7c188235701382cc4ff8 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 30 Nov 2022 16:31:01 -0800 Subject: [PATCH 14/23] Update Linux symbols --- sycl/test/abi/pi_level_zero_symbol_check.dump | 3 ++- sycl/test/abi/pi_opencl_symbol_check.dump | 3 ++- sycl/test/abi/sycl_symbols_linux.dump | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sycl/test/abi/pi_level_zero_symbol_check.dump b/sycl/test/abi/pi_level_zero_symbol_check.dump index 2cde4ca788830..245670e9b0791 100644 --- a/sycl/test/abi/pi_level_zero_symbol_check.dump +++ b/sycl/test/abi/pi_level_zero_symbol_check.dump @@ -58,6 +58,7 @@ piMemRelease piMemRetain piPlatformGetInfo piPlatformsGet +piPluginGetLastError piPluginInit piProgramBuild piProgramCompile @@ -69,6 +70,7 @@ piProgramLink piProgramRelease piProgramRetain piQueueCreate +piQueueCreateEx piQueueFinish piQueueFlush piQueueGetInfo @@ -78,7 +80,6 @@ piSamplerCreate piSamplerGetInfo piSamplerRelease piSamplerRetain -piPluginGetLastError piTearDown piclProgramCreateWithSource piextContextCreateWithNativeHandle diff --git a/sycl/test/abi/pi_opencl_symbol_check.dump b/sycl/test/abi/pi_opencl_symbol_check.dump index f7c2736a1432b..d64b86d339aa2 100644 --- a/sycl/test/abi/pi_opencl_symbol_check.dump +++ b/sycl/test/abi/pi_opencl_symbol_check.dump @@ -20,13 +20,14 @@ piMemBufferCreate piMemBufferPartition piMemImageCreate piPlatformsGet +piPluginGetLastError piPluginInit piProgramCreate piProgramCreateWithBinary piProgramLink piQueueCreate +piQueueCreateEx piSamplerCreate -piPluginGetLastError piTearDown piclProgramCreateWithSource piextContextCreateWithNativeHandle diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index d8304a7f85068..0668f2be18597 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -4188,6 +4188,7 @@ _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device17memory_clock_rateEEENS _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device21gpu_hw_threads_per_euEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device23gpu_subslices_per_sliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device25gpu_eu_count_per_subsliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv +_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device25max_compute_queue_indicesEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device4uuidEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device9device_idEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi1EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv From 0f36b154cca871724b3685cddcd58814c84d4dfb Mon Sep 17 00:00:00 2001 From: "Elovikov, Andrei" Date: Wed, 30 Nov 2022 16:48:46 -0800 Subject: [PATCH 15/23] Windows symbols --- sycl/test/abi/sycl_symbols_windows.dump | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 0e3c931ea6852..225fe4a2f2706 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -97,6 +97,7 @@ ??$get_info@Ulocal_mem_size@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_KXZ ??$get_info@Ulocal_mem_type@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AW4local_mem_type@info@12@XZ ??$get_info@Umax_clock_frequency@device@info@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ +??$get_info@Umax_compute_queue_indices@device@info@intel@ext@_V1@sycl@@@device@_V1@sycl@@QEBAHXZ ??$get_info@Umax_compute_units@device@info@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ ??$get_info@Umax_constant_args@device@info@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ ??$get_info@Umax_constant_buffer_size@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_KXZ From ca1eea86704b8454fdf592bca10da9ceb5d2910b Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Thu, 1 Dec 2022 12:25:27 -0800 Subject: [PATCH 16/23] Add sycl/unittests/queue/InOrderQueue.cpp --- sycl/unittests/queue/CMakeLists.txt | 1 + sycl/unittests/queue/InOrderQueue.cpp | 31 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 sycl/unittests/queue/InOrderQueue.cpp diff --git a/sycl/unittests/queue/CMakeLists.txt b/sycl/unittests/queue/CMakeLists.txt index e284c07766903..4092a144d4fcd 100644 --- a/sycl/unittests/queue/CMakeLists.txt +++ b/sycl/unittests/queue/CMakeLists.txt @@ -5,4 +5,5 @@ add_sycl_unittest(QueueTests OBJECT Wait.cpp GetProfilingInfo.cpp ShortcutFunctions.cpp + InOrderQueue.cpp ) diff --git a/sycl/unittests/queue/InOrderQueue.cpp b/sycl/unittests/queue/InOrderQueue.cpp new file mode 100644 index 0000000000000..330ac1d8efe5a --- /dev/null +++ b/sycl/unittests/queue/InOrderQueue.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +using namespace sycl; + +static bool InOrderFlagSeen = false; +pi_result piQueueCreateExRedefineBefore(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { + EXPECT_TRUE(properties != nullptr); + EXPECT_TRUE(properties[0] == PI_QUEUE_FLAGS); + InOrderFlagSeen = !(properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); + return PI_SUCCESS; +} + +TEST(InOrderQueue, CheckFlagIsPassed) { + unittest::PiMock Mock; + platform Plt = Mock.getPlatform(); + + Mock.redefineBefore( + piQueueCreateExRedefineBefore); + + + EXPECT_FALSE(InOrderFlagSeen); + queue q1{}; + EXPECT_FALSE(InOrderFlagSeen); + queue q2{property::queue::in_order{}}; + EXPECT_TRUE(InOrderFlagSeen); +} From fb9841b0c92ad5c522096786f610562dd3a2c13e Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Thu, 1 Dec 2022 13:33:18 -0800 Subject: [PATCH 17/23] Add missing PI entry for opencl plugin --- sycl/plugins/opencl/pi_opencl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 2729ee8416595..daea42018ac56 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -1564,6 +1564,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piextContextCreateWithNativeHandle, piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, piQueueCreate) + _PI_CL(piQueueCreateEx, piQueueCreateEx) _PI_CL(piQueueGetInfo, clGetCommandQueueInfo) _PI_CL(piQueueFinish, clFinish) _PI_CL(piQueueFlush, clFlush) From 312388e172e844408cd7547f0768a1d212697a62 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Thu, 1 Dec 2022 13:46:45 -0800 Subject: [PATCH 18/23] clang-format --- sycl/unittests/queue/InOrderQueue.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/unittests/queue/InOrderQueue.cpp b/sycl/unittests/queue/InOrderQueue.cpp index 330ac1d8efe5a..8becdc7cd0a02 100644 --- a/sycl/unittests/queue/InOrderQueue.cpp +++ b/sycl/unittests/queue/InOrderQueue.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include using namespace sycl; @@ -22,7 +22,6 @@ TEST(InOrderQueue, CheckFlagIsPassed) { Mock.redefineBefore( piQueueCreateExRedefineBefore); - EXPECT_FALSE(InOrderFlagSeen); queue q1{}; EXPECT_FALSE(InOrderFlagSeen); From fb22a45c4351fb1fe77a08ecf889a4e9c06803b9 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 5 Dec 2022 16:56:03 -0800 Subject: [PATCH 19/23] Bump _PI_H_VERSION_MINOR --- sycl/include/sycl/detail/pi.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 2d31ee0024181..18d1854089417 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -60,9 +60,12 @@ // PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH queue properties. // 11.18 Add new parameter name PI_EXT_ONEAPI_QUEUE_INFO_EMPTY to // _pi_queue_info. +// 11.19 Added piQueueCreateEx API to be used instead of piQueueCreate, also +// added PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES for piDeviceGetInfo. +// Both are needed to support sycl_ext_intel_queue_index extension. #define _PI_H_VERSION_MAJOR 11 -#define _PI_H_VERSION_MINOR 18 +#define _PI_H_VERSION_MINOR 19 #define _PI_STRING_HELPER(a) #a #define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b) From 9892278dc7f4999789274efc99f585fbe049bf95 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Fri, 9 Dec 2022 10:15:53 -0800 Subject: [PATCH 20/23] Move the extension to "supported" --- .../sycl_ext_intel_queue_index.asciidoc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) rename sycl/doc/extensions/{proposed => supported}/sycl_ext_intel_queue_index.asciidoc (95%) diff --git a/sycl/doc/extensions/proposed/sycl_ext_intel_queue_index.asciidoc b/sycl/doc/extensions/supported/sycl_ext_intel_queue_index.asciidoc similarity index 95% rename from sycl/doc/extensions/proposed/sycl_ext_intel_queue_index.asciidoc rename to sycl/doc/extensions/supported/sycl_ext_intel_queue_index.asciidoc index 245583276aabc..ed808e32589dc 100644 --- a/sycl/doc/extensions/proposed/sycl_ext_intel_queue_index.asciidoc +++ b/sycl/doc/extensions/supported/sycl_ext_intel_queue_index.asciidoc @@ -43,11 +43,7 @@ SYCL specification refer to that revision. == Status -This is a proposed extension specification, intended to gather community -feedback. Interfaces defined in this specification may not be implemented yet -or may be in a preliminary state. The specification itself may also change in -incompatible ways before it is finalized. *Shipping software products should -not rely on APIs defined in this specification.* +This extension is implemented and fully supported by DPC++. == Overview From 7cfb199a589fbe754209343fcfd468d609a8d9f2 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Sat, 10 Dec 2022 16:54:21 -0800 Subject: [PATCH 21/23] Rename piQueueCreateEx -> piextQueueCreate --- sycl/include/sycl/detail/pi.def | 2 +- sycl/include/sycl/detail/pi.h | 10 +++++----- sycl/plugins/cuda/pi_cuda.cpp | 8 ++++---- sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp | 4 ++-- sycl/plugins/hip/pi_hip.cpp | 8 ++++---- sycl/plugins/level_zero/pi_level_zero.cpp | 6 +++--- sycl/plugins/opencl/pi_opencl.cpp | 6 +++--- sycl/source/detail/queue_impl.hpp | 2 +- sycl/test/abi/pi_level_zero_symbol_check.dump | 2 +- sycl/test/abi/pi_opencl_symbol_check.dump | 2 +- sycl/unittests/helpers/PiMockPlugin.hpp | 6 +++--- sycl/unittests/queue/EventClear.cpp | 2 +- sycl/unittests/queue/InOrderQueue.cpp | 10 +++++----- sycl/unittests/queue/Wait.cpp | 2 +- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/sycl/include/sycl/detail/pi.def b/sycl/include/sycl/detail/pi.def index d8ed9910496ee..2717d82bc5607 100644 --- a/sycl/include/sycl/detail/pi.def +++ b/sycl/include/sycl/detail/pi.def @@ -43,7 +43,7 @@ _PI_API(piextContextGetNativeHandle) _PI_API(piextContextCreateWithNativeHandle) // Queue _PI_API(piQueueCreate) -_PI_API(piQueueCreateEx) +_PI_API(piextQueueCreate) _PI_API(piQueueGetInfo) _PI_API(piQueueFinish) _PI_API(piQueueFlush) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 18d1854089417..3339d8955156f 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -60,7 +60,7 @@ // PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH queue properties. // 11.18 Add new parameter name PI_EXT_ONEAPI_QUEUE_INFO_EMPTY to // _pi_queue_info. -// 11.19 Added piQueueCreateEx API to be used instead of piQueueCreate, also +// 11.19 Added piextQueueCreate API to be used instead of piQueueCreate, also // added PI_EXT_INTEL_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES for piDeviceGetInfo. // Both are needed to support sycl_ext_intel_queue_index extension. @@ -1127,14 +1127,14 @@ __SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( // Queue // -// TODO: Remove during next ABI break and rename piQueueCreateEx to +// TODO: Remove during next ABI break and rename piextQueueCreate to // piQueueCreate. __SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue); -__SYCL_EXPORT pi_result piQueueCreateEx(pi_context context, pi_device device, - pi_queue_properties *properties, - pi_queue *queue); +__SYCL_EXPORT pi_result piextQueueCreate(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue); __SYCL_EXPORT pi_result piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 293c3bc9ba46d..07601945741af 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -2528,9 +2528,9 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, return PI_ERROR_OUT_OF_RESOURCES; } } -pi_result cuda_piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, - pi_queue *Queue) { +pi_result cuda_piextQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties *Properties, + pi_queue *Queue) { assert(Properties); // Expect flags mask to be passed first. assert(Properties[0] == PI_QUEUE_FLAGS); @@ -5488,7 +5488,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { cuda_piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, cuda_piQueueCreate) - _PI_CL(piQueueCreateEx, cuda_piQueueCreateEx) + _PI_CL(piextQueueCreate, cuda_piextQueueCreate) _PI_CL(piQueueGetInfo, cuda_piQueueGetInfo) _PI_CL(piQueueFinish, cuda_piQueueFinish) _PI_CL(piQueueFlush, cuda_piQueueFlush) diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index b3dc9ccc3c10c..4c33846348478 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -925,8 +925,8 @@ bool _pi_context::checkSurfaceArgument(pi_mem_flags Flags, void *HostPtr) { return true; } -pi_result piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, pi_queue *Queue) { +pi_result piextQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { assert(Properties); // Expect flags mask to be passed first. assert(Properties[0] == PI_QUEUE_FLAGS); diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index 86e8afcc9026a..f4bcae3dcf7fa 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -2405,9 +2405,9 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, return PI_ERROR_OUT_OF_RESOURCES; } } -pi_result hip_piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, - pi_queue *Queue) { +pi_result hip_piextQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties *Properties, + pi_queue *Queue) { assert(Properties); // Expect flags mask to be passed first. assert(Properties[0] == PI_QUEUE_FLAGS); @@ -5216,7 +5216,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { hip_piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, hip_piQueueCreate) - _PI_CL(piQueueCreateEx, hip_piQueueCreateEx) + _PI_CL(piextQueueCreate, hip_piextQueueCreate) _PI_CL(piQueueGetInfo, hip_piQueueGetInfo) _PI_CL(piQueueFinish, hip_piQueueFinish) _PI_CL(piQueueFlush, hip_piQueueFlush) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index d531c63e6cbb7..203d94a86e572 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -3574,10 +3574,10 @@ pi_result piContextRelease(pi_context Context) { pi_result piQueueCreate(pi_context Context, pi_device Device, pi_queue_properties Flags, pi_queue *Queue) { pi_queue_properties Properties[] = {PI_QUEUE_FLAGS, Flags, 0}; - return piQueueCreateEx(Context, Device, Properties, Queue); + return piextQueueCreate(Context, Device, Properties, Queue); } -pi_result piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, pi_queue *Queue) { +pi_result piextQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { PI_ASSERT(Properties, PI_ERROR_INVALID_VALUE); // Expect flags mask to be passed first. PI_ASSERT(Properties[0] == PI_QUEUE_FLAGS, PI_ERROR_INVALID_VALUE); diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 6af1da4dc65c1..ff4a9798c14bc 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -466,8 +466,8 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, return PI_SUCCESS; } -pi_result piQueueCreateEx(pi_context Context, pi_device Device, - pi_queue_properties *Properties, pi_queue *Queue) { +pi_result piextQueueCreate(pi_context Context, pi_device Device, + pi_queue_properties *Properties, pi_queue *Queue) { assert(Properties); // Expect flags mask to be passed first. assert(Properties[0] == PI_QUEUE_FLAGS); @@ -1586,7 +1586,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piextContextCreateWithNativeHandle, piextContextCreateWithNativeHandle) // Queue _PI_CL(piQueueCreate, piQueueCreate) - _PI_CL(piQueueCreateEx, piQueueCreateEx) + _PI_CL(piextQueueCreate, piextQueueCreate) _PI_CL(piQueueGetInfo, piQueueGetInfo) _PI_CL(piQueueFinish, clFinish) _PI_CL(piQueueFlush, clFlush) diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index a291931cdb89c..bd94616b16339 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -363,7 +363,7 @@ class queue_impl { Properties[2] = PI_QUEUE_COMPUTE_INDEX; Properties[3] = static_cast(Idx); } - RT::PiResult Error = Plugin.call_nocheck( + RT::PiResult Error = Plugin.call_nocheck( Context, Device, Properties, &Queue); // If creating out-of-order queue failed and this property is not diff --git a/sycl/test/abi/pi_level_zero_symbol_check.dump b/sycl/test/abi/pi_level_zero_symbol_check.dump index 245670e9b0791..e6573b638e9f2 100644 --- a/sycl/test/abi/pi_level_zero_symbol_check.dump +++ b/sycl/test/abi/pi_level_zero_symbol_check.dump @@ -70,7 +70,7 @@ piProgramLink piProgramRelease piProgramRetain piQueueCreate -piQueueCreateEx +piextQueueCreate piQueueFinish piQueueFlush piQueueGetInfo diff --git a/sycl/test/abi/pi_opencl_symbol_check.dump b/sycl/test/abi/pi_opencl_symbol_check.dump index 8a7bb8e571b0e..3bfece8f62ed4 100644 --- a/sycl/test/abi/pi_opencl_symbol_check.dump +++ b/sycl/test/abi/pi_opencl_symbol_check.dump @@ -26,7 +26,7 @@ piProgramCreate piProgramCreateWithBinary piProgramLink piQueueCreate -piQueueCreateEx +piextQueueCreate piQueueGetInfo piSamplerCreate piTearDown diff --git a/sycl/unittests/helpers/PiMockPlugin.hpp b/sycl/unittests/helpers/PiMockPlugin.hpp index e1a3a22ef89b0..6663df7f852bd 100644 --- a/sycl/unittests/helpers/PiMockPlugin.hpp +++ b/sycl/unittests/helpers/PiMockPlugin.hpp @@ -322,9 +322,9 @@ inline pi_result mock_piQueueCreate(pi_context context, pi_device device, *queue = createDummyHandle(); return PI_SUCCESS; } -inline pi_result mock_piQueueCreateEx(pi_context context, pi_device device, - pi_queue_properties *properties, - pi_queue *queue) { +inline pi_result mock_piextQueueCreate(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { *queue = createDummyHandle(); return PI_SUCCESS; } diff --git a/sycl/unittests/queue/EventClear.cpp b/sycl/unittests/queue/EventClear.cpp index 49935fac23c2c..5feb38d3f237d 100644 --- a/sycl/unittests/queue/EventClear.cpp +++ b/sycl/unittests/queue/EventClear.cpp @@ -72,7 +72,7 @@ pi_result redefinedEventRelease(pi_event event) { } void preparePiMock(unittest::PiMock &Mock) { - Mock.redefineBefore( + Mock.redefineBefore( redefinedQueueCreateEx); Mock.redefineBefore(redefinedEventsWait); Mock.redefineAfter( diff --git a/sycl/unittests/queue/InOrderQueue.cpp b/sycl/unittests/queue/InOrderQueue.cpp index 8becdc7cd0a02..8ab56175866ae 100644 --- a/sycl/unittests/queue/InOrderQueue.cpp +++ b/sycl/unittests/queue/InOrderQueue.cpp @@ -6,9 +6,9 @@ using namespace sycl; static bool InOrderFlagSeen = false; -pi_result piQueueCreateExRedefineBefore(pi_context context, pi_device device, - pi_queue_properties *properties, - pi_queue *queue) { +pi_result piextQueueCreateRedefineBefore(pi_context context, pi_device device, + pi_queue_properties *properties, + pi_queue *queue) { EXPECT_TRUE(properties != nullptr); EXPECT_TRUE(properties[0] == PI_QUEUE_FLAGS); InOrderFlagSeen = !(properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); @@ -19,8 +19,8 @@ TEST(InOrderQueue, CheckFlagIsPassed) { unittest::PiMock Mock; platform Plt = Mock.getPlatform(); - Mock.redefineBefore( - piQueueCreateExRedefineBefore); + Mock.redefineBefore( + piextQueueCreateRedefineBefore); EXPECT_FALSE(InOrderFlagSeen); queue q1{}; diff --git a/sycl/unittests/queue/Wait.cpp b/sycl/unittests/queue/Wait.cpp index 1b6395c5f6412..255564840c689 100644 --- a/sycl/unittests/queue/Wait.cpp +++ b/sycl/unittests/queue/Wait.cpp @@ -78,7 +78,7 @@ pi_result redefinedEventRelease(pi_event event) { TEST(QueueWait, QueueWaitTest) { sycl::unittest::PiMock Mock; sycl::platform Plt = Mock.getPlatform(); - Mock.redefineBefore( + Mock.redefineBefore( redefinedQueueCreateEx); Mock.redefineBefore(redefinedQueueFinish); Mock.redefineBefore( From 622c991704278027b6ae76a62824d649e777febd Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Sat, 10 Dec 2022 17:07:38 -0800 Subject: [PATCH 22/23] Rename PI QUEUE flags --- sycl/include/sycl/detail/pi.h | 16 +++++---- sycl/plugins/cuda/pi_cuda.cpp | 17 +++++----- .../esimd_emulator/pi_esimd_emulator.cpp | 4 +-- sycl/plugins/hip/pi_hip.cpp | 17 +++++----- sycl/plugins/level_zero/pi_level_zero.cpp | 33 ++++++++++--------- sycl/plugins/level_zero/pi_level_zero.hpp | 2 +- sycl/plugins/opencl/pi_opencl.cpp | 7 ++-- sycl/source/detail/queue_impl.hpp | 10 +++--- sycl/unittests/queue/EventClear.cpp | 2 +- sycl/unittests/queue/InOrderQueue.cpp | 3 +- sycl/unittests/queue/Wait.cpp | 2 +- 11 files changed, 61 insertions(+), 52 deletions(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 3339d8955156f..56740ce3ee446 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -590,13 +590,15 @@ constexpr pi_usm_mem_properties PI_MEM_USM_ALLOC_BUFFER_LOCATION = 0x419E; using pi_queue_properties = pi_bitfield; constexpr pi_queue_properties PI_QUEUE_FLAGS = -1; constexpr pi_queue_properties PI_QUEUE_COMPUTE_INDEX = -2; -constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); -constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = (1 << 1); -constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = (1 << 2); -constexpr pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT = (1 << 3); -constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS = (1 << 4); -constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_PRIORITY_LOW = (1 << 5); -constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH = (1 << 6); +// clang-format off +constexpr pi_queue_properties PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); +constexpr pi_queue_properties PI_QUEUE_FLAG_PROFILING_ENABLE = (1 << 1); +constexpr pi_queue_properties PI_QUEUE_FLAG_ON_DEVICE = (1 << 2); +constexpr pi_queue_properties PI_QUEUE_FLAG_ON_DEVICE_DEFAULT = (1 << 3); +constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_FLAG_DISCARD_EVENTS = (1 << 4); +constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_LOW = (1 << 5); +constexpr pi_queue_properties PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_HIGH = (1 << 6); +// clang-format on using pi_result = _pi_result; using pi_platform_info = _pi_platform_info; diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 07601945741af..8fb2368995b62 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -489,7 +489,7 @@ _pi_event::_pi_event(pi_command_type type, pi_context context, pi_queue queue, streamToken_{stream_token}, evEnd_{nullptr}, evStart_{nullptr}, evQueued_{nullptr}, queue_{queue}, stream_{stream}, context_{context} { - bool profilingEnabled = queue_->properties_ & PI_QUEUE_PROFILING_ENABLE; + bool profilingEnabled = queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE; PI_CHECK_ERROR(cuEventCreate( &evEnd_, profilingEnabled ? CU_EVENT_DEFAULT : CU_EVENT_DISABLE_TIMING)); @@ -526,7 +526,7 @@ pi_result _pi_event::start() { pi_result result = PI_SUCCESS; try { - if (queue_->properties_ & PI_QUEUE_PROFILING_ENABLE) { + if (queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE) { // NOTE: This relies on the default stream to be unused. result = PI_CHECK_ERROR(cuEventRecord(evQueued_, 0)); result = PI_CHECK_ERROR(cuEventRecord(evStart_, stream_)); @@ -633,7 +633,7 @@ pi_result _pi_event::release() { PI_CHECK_ERROR(cuEventDestroy(evEnd_)); - if (queue_->properties_ & PI_QUEUE_PROFILING_ENABLE) { + if (queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE) { PI_CHECK_ERROR(cuEventDestroy(evQueued_)); PI_CHECK_ERROR(cuEventDestroy(evStart_)); } @@ -1681,14 +1681,14 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, } case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { // The mandated minimum capability: - auto capability = - PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + auto capability = PI_QUEUE_FLAG_PROFILING_ENABLE | + PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { // The mandated minimum capability: - auto capability = PI_QUEUE_PROFILING_ENABLE; + auto capability = PI_QUEUE_FLAG_PROFILING_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } @@ -2505,7 +2505,7 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, } const bool is_out_of_order = - properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + properties & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; std::vector computeCuStreams( is_out_of_order ? _pi_queue::default_num_compute_streams : 1); @@ -3864,7 +3864,8 @@ pi_result cuda_piEventGetProfilingInfo(pi_event event, assert(event != nullptr); pi_queue queue = event->get_queue(); - if (queue == nullptr || !(queue->properties_ & PI_QUEUE_PROFILING_ENABLE)) { + if (queue == nullptr || + !(queue->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE)) { return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index 4c33846348478..88e49410a800f 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -663,7 +663,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, case PI_DEVICE_INFO_OPENCL_C_VERSION: return ReturnValue(""); case PI_DEVICE_INFO_QUEUE_PROPERTIES: - return ReturnValue(pi_queue_properties{PI_QUEUE_ON_DEVICE}); + return ReturnValue(pi_queue_properties{PI_QUEUE_FLAG_ON_DEVICE}); case PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES: { struct { size_t Arr[3]; @@ -939,7 +939,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, pi_queue_properties Properties, pi_queue *Queue) { ARG_UNUSED(Device); - if (Properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + if (Properties & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { // TODO : Support Out-of-order Queue *Queue = nullptr; return PI_ERROR_INVALID_QUEUE_PROPERTIES; diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index f4bcae3dcf7fa..845c2a60dcb08 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -534,7 +534,7 @@ _pi_event::_pi_event(pi_command_type type, pi_context context, pi_queue queue, assert(type != PI_COMMAND_TYPE_USER); - bool profilingEnabled = queue_->properties_ & PI_QUEUE_PROFILING_ENABLE; + bool profilingEnabled = queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE; PI_CHECK_ERROR(hipEventCreateWithFlags( &evEnd_, profilingEnabled ? hipEventDefault : hipEventDisableTiming)); @@ -562,7 +562,7 @@ pi_result _pi_event::start() { pi_result result = PI_SUCCESS; try { - if (queue_->properties_ & PI_QUEUE_PROFILING_ENABLE) { + if (queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE) { // NOTE: This relies on the default stream to be unused. PI_CHECK_ERROR(hipEventRecord(evQueued_, 0)); PI_CHECK_ERROR(hipEventRecord(evStart_, queue_->get())); @@ -663,7 +663,7 @@ pi_result _pi_event::release() { assert(queue_ != nullptr); PI_CHECK_ERROR(hipEventDestroy(evEnd_)); - if (queue_->properties_ & PI_QUEUE_PROFILING_ENABLE) { + if (queue_->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE) { PI_CHECK_ERROR(hipEventDestroy(evQueued_)); PI_CHECK_ERROR(hipEventDestroy(evStart_)); } @@ -1588,14 +1588,14 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, } case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { // The mandated minimum capability: - auto capability = - PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + auto capability = PI_QUEUE_FLAG_PROFILING_ENABLE | + PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { // The mandated minimum capability: - auto capability = PI_QUEUE_PROFILING_ENABLE; + auto capability = PI_QUEUE_FLAG_PROFILING_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } @@ -2382,7 +2382,7 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, unsigned int flags = 0; const bool is_out_of_order = - properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + properties & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; std::vector computeHipStreams( is_out_of_order ? _pi_queue::default_num_compute_streams : 1); @@ -3689,7 +3689,8 @@ pi_result hip_piEventGetProfilingInfo(pi_event event, assert(event != nullptr); pi_queue queue = event->get_queue(); - if (queue == nullptr || !(queue->properties_ & PI_QUEUE_PROFILING_ENABLE)) { + if (queue == nullptr || + !(queue->properties_ & PI_QUEUE_FLAG_PROFILING_ENABLE)) { return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 203d94a86e572..1e9668efdbe31 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -995,19 +995,20 @@ bool pi_command_list_info_t::isCopy(pi_queue Queue) const { bool _pi_queue::isInOrderQueue() const { // If out-of-order queue property is not set, then this is a in-order queue. - return ((this->Properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) == 0); + return ((this->Properties & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) == + 0); } bool _pi_queue::isDiscardEvents() const { - return ((this->Properties & PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS) != 0); + return ((this->Properties & PI_EXT_ONEAPI_QUEUE_FLAG_DISCARD_EVENTS) != 0); } bool _pi_queue::isPriorityLow() const { - return ((this->Properties & PI_EXT_ONEAPI_QUEUE_PRIORITY_LOW) != 0); + return ((this->Properties & PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_LOW) != 0); } bool _pi_queue::isPriorityHigh() const { - return ((this->Properties & PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH) != 0); + return ((this->Properties & PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_HIGH) != 0); } pi_result @@ -2915,8 +2916,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, // TODO: To find out correct value return ReturnValue(""); case PI_DEVICE_INFO_QUEUE_PROPERTIES: - return ReturnValue(pi_queue_properties{ - PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | PI_QUEUE_PROFILING_ENABLE}); + return ReturnValue( + pi_queue_properties{PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE | + PI_QUEUE_FLAG_PROFILING_ENABLE}); case PI_DEVICE_INFO_EXECUTION_CAPABILITIES: return ReturnValue( pi_device_exec_capabilities{PI_DEVICE_EXEC_CAPABILITIES_NATIVE_KERNEL}); @@ -3591,13 +3593,14 @@ pi_result piextQueueCreate(pi_context Context, pi_device Device, : -1; // Use default/round-robin. // Check that unexpected bits are not set. - PI_ASSERT(!(Flags & ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | - PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_ON_DEVICE | - PI_QUEUE_ON_DEVICE_DEFAULT | - PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS | - PI_EXT_ONEAPI_QUEUE_PRIORITY_LOW | - PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH)), - PI_ERROR_INVALID_VALUE); + PI_ASSERT( + !(Flags & ~(PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE | + PI_QUEUE_FLAG_PROFILING_ENABLE | PI_QUEUE_FLAG_ON_DEVICE | + PI_QUEUE_FLAG_ON_DEVICE_DEFAULT | + PI_EXT_ONEAPI_QUEUE_FLAG_DISCARD_EVENTS | + PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_LOW | + PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_HIGH)), + PI_ERROR_INVALID_VALUE); PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); @@ -5783,7 +5786,7 @@ void _pi_context::addEventToContextCache(pi_event Event) { static pi_result EventCreate(pi_context Context, pi_queue Queue, bool HostVisible, pi_event *RetEvent) { bool ProfilingEnabled = - !Queue || (Queue->Properties & PI_QUEUE_PROFILING_ENABLE) != 0; + !Queue || (Queue->Properties & PI_QUEUE_FLAG_PROFILING_ENABLE) != 0; if (auto CachedEvent = Context->getEventFromContextCache(HostVisible, ProfilingEnabled)) { @@ -5926,7 +5929,7 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName, std::shared_lock EventLock(Event->Mutex); if (Event->Queue && - (Event->Queue->Properties & PI_QUEUE_PROFILING_ENABLE) == 0) { + (Event->Queue->Properties & PI_QUEUE_FLAG_PROFILING_ENABLE) == 0) { return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } diff --git a/sycl/plugins/level_zero/pi_level_zero.hpp b/sycl/plugins/level_zero/pi_level_zero.hpp index 91bdd29c6f9b2..b221367d6d2ce 100644 --- a/sycl/plugins/level_zero/pi_level_zero.hpp +++ b/sycl/plugins/level_zero/pi_level_zero.hpp @@ -1257,7 +1257,7 @@ struct _pi_event : _pi_object { // Tells if this event is with profiling capabilities. bool isProfilingEnabled() const { return !Queue || // tentatively assume user events are profiling enabled - (Queue->Properties & PI_QUEUE_PROFILING_ENABLE) != 0; + (Queue->Properties & PI_QUEUE_FLAG_PROFILING_ENABLE) != 0; } // Keeps the command-queue and command associated with the event. diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index ff4a9798c14bc..83ac889876167 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -489,9 +489,10 @@ pi_result piQueueCreate(pi_context context, pi_device device, // Check that unexpected bits are not set. assert(!(properties & - ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | - PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_ON_DEVICE | - PI_QUEUE_ON_DEVICE_DEFAULT | PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS))); + ~(PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE | + PI_QUEUE_FLAG_PROFILING_ENABLE | PI_QUEUE_FLAG_ON_DEVICE | + PI_QUEUE_FLAG_ON_DEVICE_DEFAULT | + PI_EXT_ONEAPI_QUEUE_FLAG_DISCARD_EVENTS))); // Properties supported by OpenCL backend. cl_command_queue_properties SupportByOpenCL = diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index bd94616b16339..e0a296a8ede3c 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -309,10 +309,10 @@ class queue_impl { RT::PiQueueProperties CreationFlags = 0; if (Order == QueueOrder::OOO) { - CreationFlags = PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + CreationFlags = PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; } if (MPropList.has_property()) { - CreationFlags |= PI_QUEUE_PROFILING_ENABLE; + CreationFlags |= PI_QUEUE_FLAG_PROFILING_ENABLE; } if (MPropList.has_property< ext::oneapi::cuda::property::queue::use_default_stream>()) { @@ -322,7 +322,7 @@ class queue_impl { .has_property()) { // Pass this flag to the Level Zero plugin to be able to check it from // queue property. - CreationFlags |= PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS; + CreationFlags |= PI_EXT_ONEAPI_QUEUE_FLAG_DISCARD_EVENTS; } // Track that priority settings are not ambiguous. bool PrioritySeen = false; @@ -337,7 +337,7 @@ class queue_impl { make_error_code(errc::invalid), "Queue cannot be constructed with different priorities."); } - CreationFlags |= PI_EXT_ONEAPI_QUEUE_PRIORITY_LOW; + CreationFlags |= PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_LOW; PrioritySeen = true; } if (MPropList.has_property()) { @@ -346,7 +346,7 @@ class queue_impl { make_error_code(errc::invalid), "Queue cannot be constructed with different priorities."); } - CreationFlags |= PI_EXT_ONEAPI_QUEUE_PRIORITY_HIGH; + CreationFlags |= PI_EXT_ONEAPI_QUEUE_FLAG_PRIORITY_HIGH; PrioritySeen = true; } RT::PiQueue Queue{}; diff --git a/sycl/unittests/queue/EventClear.cpp b/sycl/unittests/queue/EventClear.cpp index 5feb38d3f237d..9dba15d63be69 100644 --- a/sycl/unittests/queue/EventClear.cpp +++ b/sycl/unittests/queue/EventClear.cpp @@ -31,7 +31,7 @@ pi_result redefinedQueueCreateEx(pi_context context, pi_device device, assert(properties && properties[0] == PI_QUEUE_FLAGS); // Use in-order queues to force storing events for calling wait on them, // rather than calling piQueueFinish. - if (properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + if (properties[1] & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; diff --git a/sycl/unittests/queue/InOrderQueue.cpp b/sycl/unittests/queue/InOrderQueue.cpp index 8ab56175866ae..684eae329d819 100644 --- a/sycl/unittests/queue/InOrderQueue.cpp +++ b/sycl/unittests/queue/InOrderQueue.cpp @@ -11,7 +11,8 @@ pi_result piextQueueCreateRedefineBefore(pi_context context, pi_device device, pi_queue *queue) { EXPECT_TRUE(properties != nullptr); EXPECT_TRUE(properties[0] == PI_QUEUE_FLAGS); - InOrderFlagSeen = !(properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); + InOrderFlagSeen = + !(properties[1] & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE); return PI_SUCCESS; } diff --git a/sycl/unittests/queue/Wait.cpp b/sycl/unittests/queue/Wait.cpp index 255564840c689..7b1c48a262ab4 100644 --- a/sycl/unittests/queue/Wait.cpp +++ b/sycl/unittests/queue/Wait.cpp @@ -31,7 +31,7 @@ pi_result redefinedQueueCreateEx(pi_context context, pi_device device, pi_queue *queue) { assert(properties && properties[0] == PI_QUEUE_FLAGS); if (!TestContext.SupportOOO && - properties[1] & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + properties[1] & PI_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; From 423a8f2cc840c4a5673c93bb26c7255b35da3d09 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Sat, 10 Dec 2022 17:17:26 -0800 Subject: [PATCH 23/23] Extra doc comments --- sycl/include/sycl/detail/pi.h | 3 +++ sycl/plugins/level_zero/pi_level_zero.hpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 56740ce3ee446..a46913b21868c 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -1134,6 +1134,9 @@ __SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( __SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, pi_queue_properties properties, pi_queue *queue); +/// \param properties points to a zero-terminated array of extra data describing +/// desired queue properties. Format is +/// {[PROPERTY[, property-specific elements of data]*,]* 0} __SYCL_EXPORT pi_result piextQueueCreate(pi_context context, pi_device device, pi_queue_properties *properties, pi_queue *queue); diff --git a/sycl/plugins/level_zero/pi_level_zero.hpp b/sycl/plugins/level_zero/pi_level_zero.hpp index b221367d6d2ce..c064be916d22f 100644 --- a/sycl/plugins/level_zero/pi_level_zero.hpp +++ b/sycl/plugins/level_zero/pi_level_zero.hpp @@ -641,6 +641,8 @@ struct _pi_context : _pi_object { }; struct _pi_queue : _pi_object { + // ForceComputeIndex, if non-negative, indicates that the queue must be fixed + // to that particular compute CCS. _pi_queue(std::vector &ComputeQueues, std::vector &CopyQueues, pi_context Context, pi_device Device, bool OwnZeCommandQueue,