diff --git a/public/cl_ext_private.h b/public/cl_ext_private.h index 7f1b4d0504..7fa2ce5a65 100644 --- a/public/cl_ext_private.h +++ b/public/cl_ext_private.h @@ -114,6 +114,7 @@ typedef cl_uint cl_execution_info_intel; /* cl_command_type */ #define CL_COMMAND_MEMSET_INTEL 0x4204 +#define CL_COMMAND_MEMFILL_INTEL 0x4204 #define CL_COMMAND_MEMCPY_INTEL 0x4205 #define CL_COMMAND_MIGRATEMEM_INTEL 0x4206 #define CL_COMMAND_MEMADVISE_INTEL 0x4207 diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 601378f6f3..9f90def16a 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -3590,6 +3590,32 @@ cl_int clEnqueueMemsetINTEL( return retVal; } +cl_int clEnqueueMemFillINTEL( + cl_command_queue commandQueue, + void *dstPtr, + const void *pattern, + size_t pattern_size, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) { + + auto retVal = clEnqueueSVMMemFill(commandQueue, + dstPtr, + pattern, + pattern_size, + size, + numEventsInWaitList, + eventWaitList, + event); + if (retVal == CL_SUCCESS && event) { + auto pEvent = castToObjectOrAbort(*event); + pEvent->setCmdType(CL_COMMAND_MEMFILL_INTEL); + } + + return retVal; +} + cl_int clEnqueueMemcpyINTEL( cl_command_queue commandQueue, cl_bool blocking, @@ -3869,6 +3895,7 @@ void *CL_API_CALL clGetExtensionFunctionAddress(const char *funcName) { RETURN_FUNC_PTR_IF_EXIST(clGetMemAllocInfoINTEL); RETURN_FUNC_PTR_IF_EXIST(clSetKernelArgMemPointerINTEL); RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemsetINTEL); + RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemFillINTEL); RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemcpyINTEL); RETURN_FUNC_PTR_IF_EXIST(clEnqueueMigrateMemINTEL); RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemAdviseINTEL); diff --git a/runtime/api/api.h b/runtime/api/api.h index 0a3893df4c..7be002f114 100644 --- a/runtime/api/api.h +++ b/runtime/api/api.h @@ -973,6 +973,16 @@ cl_int clEnqueueMemsetINTEL( const cl_event *eventWaitList, cl_event *event); +cl_int clEnqueueMemFillINTEL( + cl_command_queue command_queue, + void *dst_ptr, + const void *pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event); + cl_int clEnqueueMemcpyINTEL( cl_command_queue commandQueue, cl_bool blocking, diff --git a/unit_tests/api/cl_get_extension_function_address_tests.inl b/unit_tests/api/cl_get_extension_function_address_tests.inl index fa403b4d35..9376245978 100644 --- a/unit_tests/api/cl_get_extension_function_address_tests.inl +++ b/unit_tests/api/cl_get_extension_function_address_tests.inl @@ -133,6 +133,11 @@ TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemsetINTELWhenGettingE EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemsetINTEL)); } +TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemFillINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clEnqueueMemFillINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemFillINTEL)); +} + TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemcpyINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { auto retVal = clGetExtensionFunctionAddress("clEnqueueMemcpyINTEL"); EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemcpyINTEL)); diff --git a/unit_tests/api/cl_unified_shared_memory_tests.inl b/unit_tests/api/cl_unified_shared_memory_tests.inl index 4ccad769e8..af278e81e9 100644 --- a/unit_tests/api/cl_unified_shared_memory_tests.inl +++ b/unit_tests/api/cl_unified_shared_memory_tests.inl @@ -493,6 +493,48 @@ TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemsetINTELisCalledWithProperParam clMemFreeINTEL(mockContext.get(), unfiedMemoryDeviceAllocation); } +TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemFillINTELisCalledWithoutIncorrectCommandQueueThenInvaliQueueErrorIsReturned) { + cl_int setValue = 12u; + auto retVal = clEnqueueMemFillINTEL(0, nullptr, &setValue, 0u, 0u, 0u, nullptr, nullptr); + EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemFillINTELisCalledWithProperParametersThenParametersArePassedCorrectly) { + auto mockContext = std::make_unique(); + cl_int retVal = CL_SUCCESS; + + auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal); + + struct MockedCommandQueue : public CommandQueue { + cl_int enqueueSVMMemFill(void *svmPtr, + const void *pattern, + size_t patternSize, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) override { + + EXPECT_EQ(12, *reinterpret_cast(pattern)); + EXPECT_EQ(expectedDstPtr, svmPtr); + EXPECT_EQ(400u, size); + EXPECT_EQ(4u, patternSize); + EXPECT_EQ(0u, numEventsInWaitList); + EXPECT_EQ(nullptr, eventWaitList); + EXPECT_EQ(nullptr, event); + return CL_SUCCESS; + } + void *expectedDstPtr = nullptr; + }; + + MockedCommandQueue queue; + queue.expectedDstPtr = unfiedMemoryDeviceAllocation; + cl_int setValue = 12u; + + retVal = clEnqueueMemFillINTEL(&queue, unfiedMemoryDeviceAllocation, &setValue, sizeof(setValue), 400u, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + clMemFreeINTEL(mockContext.get(), unfiedMemoryDeviceAllocation); +} + TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemcpyINTELisCalledWithWrongQueueThenInvalidQueueErrorIsReturned) { auto retVal = clEnqueueMemcpyINTEL(0, 0, nullptr, nullptr, 0, 0, nullptr, nullptr); EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal); @@ -628,3 +670,18 @@ TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemsetINTELIsCalledWithEven EXPECT_EQ(expectedCmd, actualCmd); clMemFreeINTEL(this->context, unfiedMemorySharedAllocation); } + +TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemFillINTELIsCalledWithEventThenProperCmdTypeIsSet) { + cl_int retVal = CL_SUCCESS; + + auto unfiedMemorySharedAllocation = clSharedMemAllocINTEL(this->context, this->context->getDevice(0u), nullptr, 400, 0, &retVal); + cl_int setValue = 12u; + + retVal = clEnqueueMemFillINTEL(this->pCmdQ, unfiedMemorySharedAllocation, &setValue, sizeof(setValue), 400u, 0, nullptr, &event); + EXPECT_EQ(CL_SUCCESS, retVal); + + constexpr cl_command_type expectedCmd = CL_COMMAND_MEMFILL_INTEL; + cl_command_type actualCmd = castToObjectOrAbort(event)->getCommandType(); + EXPECT_EQ(expectedCmd, actualCmd); + clMemFreeINTEL(this->context, unfiedMemorySharedAllocation); +}