diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index d79025bf7d306..26b6695c21b96 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -52,9 +52,10 @@ // 10.13 Added new PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS queue property. // 10.14 Add PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY as an extension for // piDeviceGetInfo. +// 11.15 piEventCreate creates even in the signalled state now. -#define _PI_H_VERSION_MAJOR 10 -#define _PI_H_VERSION_MINOR 14 +#define _PI_H_VERSION_MAJOR 11 +#define _PI_H_VERSION_MINOR 15 #define _PI_STRING_HELPER(a) #a #define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b) @@ -1397,6 +1398,11 @@ piextKernelGetNativeHandle(pi_kernel kernel, pi_native_handle *nativeHandle); // // Events // + +/// Create PI event object in a signalled/completed state. +/// +/// \param context is the PI context of the event. +/// \param ret_event is the PI even created. __SYCL_EXPORT pi_result piEventCreate(pi_context context, pi_event *ret_event); __SYCL_EXPORT pi_result piEventGetInfo(pi_event event, pi_event_info param_name, diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 659675af7c6db..28de622547c11 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -5632,7 +5632,10 @@ static pi_result EventCreate(pi_context Context, pi_queue Queue, pi_result piEventCreate(pi_context Context, pi_event *RetEvent) { pi_result Result = EventCreate(Context, nullptr, true, RetEvent); (*RetEvent)->RefCountExternal++; - return Result; + if (Result != PI_SUCCESS) + return Result; + ZE_CALL(zeEventHostSignal, ((*RetEvent)->ZeEvent)); + return PI_SUCCESS; } pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName, diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 07fd25da52f35..f26bc5516c8c4 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -973,8 +973,13 @@ pi_result piKernelGetSubGroupInfo(pi_kernel kernel, pi_device device, pi_result piEventCreate(pi_context context, pi_event *ret_event) { pi_result ret_err = PI_ERROR_INVALID_OPERATION; - *ret_event = cast( - clCreateUserEvent(cast(context), cast(&ret_err))); + auto *cl_err = cast(&ret_err); + + cl_event e = clCreateUserEvent(cast(context), cl_err); + *ret_event = cast(e); + if (*cl_err != CL_SUCCESS) + return ret_err; + *cl_err = clSetUserEventStatus(e, CL_COMPLETE); return ret_err; }