diff --git a/source/adapters/opencl/CMakeLists.txt b/source/adapters/opencl/CMakeLists.txt index b2db1f5bcd..7c976ec78e 100644 --- a/source/adapters/opencl/CMakeLists.txt +++ b/source/adapters/opencl/CMakeLists.txt @@ -54,7 +54,7 @@ if(UR_OPENCL_INCLUDE_DIR) else() FetchContent_Declare(OpenCL-Headers GIT_REPOSITORY "https://github.com/KhronosGroup/OpenCL-Headers.git" - GIT_TAG 1e193332d02e27e15812d24ff2a3a7a908eb92a3 + GIT_TAG 542d7a8f65ecfd88b38de35d8b10aa67b36b33b2 ) FetchContent_MakeAvailable(OpenCL-Headers) FetchContent_GetProperties(OpenCL-Headers diff --git a/source/adapters/opencl/command_buffer.cpp b/source/adapters/opencl/command_buffer.cpp index 5698f36928..79454506ad 100644 --- a/source/adapters/opencl/command_buffer.cpp +++ b/source/adapters/opencl/command_buffer.cpp @@ -156,7 +156,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( cl_mutable_command_khr *OutCommandHandle = hCommandBuffer->IsUpdatable ? &CommandHandle : nullptr; - cl_ndrange_kernel_command_properties_khr UpdateProperties[] = { + cl_command_properties_khr UpdateProperties[] = { CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR, CL_MUTABLE_DISPATCH_GLOBAL_OFFSET_KHR | CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR | @@ -164,7 +164,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( CL_MUTABLE_DISPATCH_ARGUMENTS_KHR | CL_MUTABLE_DISPATCH_EXEC_INFO_KHR, 0}; - cl_ndrange_kernel_command_properties_khr *Properties = + cl_command_properties_khr *Properties = hCommandBuffer->IsUpdatable ? UpdateProperties : nullptr; CL_RETURN_ON_FAILURE(clCommandNDRangeKernelKHR( hCommandBuffer->CLCommandBuffer, nullptr, Properties, @@ -176,8 +176,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( auto URCommandHandle = std::make_unique( hCommandBuffer, CommandHandle, workDim, pLocalWorkSize != nullptr); - *phCommandHandle = URCommandHandle.release(); - hCommandBuffer->CommandHandles.push_back(*phCommandHandle); + ur_exp_command_buffer_command_handle_t Handle = URCommandHandle.release(); + hCommandBuffer->CommandHandles.push_back(Handle); + if (phCommandHandle) { + *phCommandHandle = Handle; + } } catch (...) { return UR_RESULT_ERROR_OUT_OF_RESOURCES; } @@ -222,7 +225,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR)); CL_RETURN_ON_FAILURE(clCommandCopyBufferKHR( - hCommandBuffer->CLCommandBuffer, nullptr, + hCommandBuffer->CLCommandBuffer, nullptr, nullptr, cl_adapter::cast(hSrcMem), cl_adapter::cast(hDstMem), srcOffset, dstOffset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint, nullptr)); @@ -256,7 +259,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR)); CL_RETURN_ON_FAILURE(clCommandCopyBufferRectKHR( - hCommandBuffer->CLCommandBuffer, nullptr, + hCommandBuffer->CLCommandBuffer, nullptr, nullptr, cl_adapter::cast(hSrcMem), cl_adapter::cast(hDstMem), OpenCLOriginRect, OpenCLDstRect, OpenCLRegion, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch, numSyncPointsInWaitList, pSyncPointWaitList, @@ -274,9 +277,6 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( [[maybe_unused]] const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, [[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) { - - cl_adapter::die("Experimental Command-buffer feature is not " - "implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -343,7 +343,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( cl_ext::CommandFillBufferName, &clCommandFillBufferKHR)); CL_RETURN_ON_FAILURE(clCommandFillBufferKHR( - hCommandBuffer->CLCommandBuffer, nullptr, + hCommandBuffer->CLCommandBuffer, nullptr, nullptr, cl_adapter::cast(hBuffer), pPattern, patternSize, offset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint, nullptr)); @@ -556,8 +556,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( cl_mutable_command_khr command = cl_adapter::cast(hCommand->CLMutableCommand); cl_mutable_dispatch_config_khr dispatch_config = { - CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, - nullptr, command, static_cast(CLArgs.size()), // num_args static_cast(CLUSMArgs.size()), // num_svm_args @@ -570,10 +568,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( CLGlobalWorkSize.data(), // global_work_size CLLocalWorkSize.data(), // local_work_size }; - cl_mutable_base_config_khr config = { - CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR, nullptr, 1, &dispatch_config}; - CL_RETURN_ON_FAILURE( - clUpdateMutableCommandsKHR(hCommandBuffer->CLCommandBuffer, &config)); + cl_uint num_configs = 1; + cl_command_buffer_update_type_khr config_types[1] = { + CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR}; + const void *configs[1] = {&dispatch_config}; + CL_RETURN_ON_FAILURE(clUpdateMutableCommandsKHR( + hCommandBuffer->CLCommandBuffer, num_configs, config_types, configs)); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/common.hpp b/source/adapters/opencl/common.hpp index 18b08bf095..3533f5faaf 100644 --- a/source/adapters/opencl/common.hpp +++ b/source/adapters/opencl/common.hpp @@ -272,8 +272,8 @@ cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer); using clCommandNDRangeKernelKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( cl_command_buffer_khr command_buffer, cl_command_queue command_queue, - const cl_ndrange_kernel_command_properties_khr *properties, - cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, + const cl_command_properties_khr *properties, cl_kernel kernel, + cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_sync_points_in_wait_list, const cl_sync_point_khr *sync_point_wait_list, @@ -281,24 +281,27 @@ using clCommandNDRangeKernelKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( using clCommandCopyBufferKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( cl_command_buffer_khr command_buffer, cl_command_queue command_queue, - cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, - size_t size, cl_uint num_sync_points_in_wait_list, + const cl_command_properties_khr *properties, cl_mem src_buffer, + cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t size, + cl_uint num_sync_points_in_wait_list, const cl_sync_point_khr *sync_point_wait_list, cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle); using clCommandCopyBufferRectKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( cl_command_buffer_khr command_buffer, cl_command_queue command_queue, - cl_mem src_buffer, cl_mem dst_buffer, const size_t *src_origin, - const size_t *dst_origin, const size_t *region, size_t src_row_pitch, - size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, + const cl_command_properties_khr *properties, cl_mem src_buffer, + cl_mem dst_buffer, const size_t *src_origin, const size_t *dst_origin, + const size_t *region, size_t src_row_pitch, size_t src_slice_pitch, + size_t dst_row_pitch, size_t dst_slice_pitch, cl_uint num_sync_points_in_wait_list, const cl_sync_point_khr *sync_point_wait_list, cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle); using clCommandFillBufferKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( cl_command_buffer_khr command_buffer, cl_command_queue command_queue, - cl_mem buffer, const void *pattern, size_t pattern_size, size_t offset, - size_t size, cl_uint num_sync_points_in_wait_list, + const cl_command_properties_khr *properties, cl_mem buffer, + const void *pattern, size_t pattern_size, size_t offset, size_t size, + cl_uint num_sync_points_in_wait_list, const cl_sync_point_khr *sync_point_wait_list, cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle); @@ -313,8 +316,9 @@ using clGetCommandBufferInfoKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)( size_t param_value_size, void *param_value, size_t *param_value_size_ret); using clUpdateMutableCommandsKHR_fn = CL_API_ENTRY -cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer, - const cl_mutable_base_config_khr *mutable_config); +cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer, cl_uint num_configs, + const cl_command_buffer_update_type_khr *config_types, + const void **configs); template struct FuncPtrCache { std::map Map;