diff --git a/public/cl_ext_private.h b/public/cl_ext_private.h index e400677eb4..4801ee884f 100644 --- a/public/cl_ext_private.h +++ b/public/cl_ext_private.h @@ -43,6 +43,9 @@ using cl_mem_properties_intel = cl_bitfield; using cl_mem_flags_intel = cl_mem_flags; +using cl_mem_info_intel = cl_uint; +using cl_mem_advice_intel = cl_uint; +using cl_unified_shared_memory_type_intel = cl_uint; /****************************** * Internal only cl_mem_flags * @@ -67,4 +70,4 @@ using cl_mem_flags_intel = cl_mem_flags; #define CL_KERNEL_EXEC_INFO_INDIRECT_HOST_ACCESS_INTEL 0x10000 #define CL_KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL 0x10001 #define CL_KERNEL_EXEC_INFO_INDIRECT_SHARED_ACCESS_INTEL 0x10002 -#define CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL 0x10003 +#define CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL 0x10003 \ No newline at end of file diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index bcb88da142..1a47e89cd7 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -3357,6 +3357,109 @@ clSetPerformanceConfigurationINTEL( return retVal; } +void *clHostMemAllocINTEL( + cl_context context, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet) { + cl_int retVal = CL_OUT_OF_HOST_MEMORY; + *errcodeRet = retVal; + return nullptr; +} + +void *clDeviceMemAllocINTEL( + cl_context context, + cl_device_id device, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet) { + cl_int retVal = CL_OUT_OF_HOST_MEMORY; + *errcodeRet = retVal; + return nullptr; +} + +void *clSharedMemAllocINTEL( + cl_context context, + cl_device_id device, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet) { + cl_int retVal = CL_OUT_OF_HOST_MEMORY; + *errcodeRet = retVal; + return nullptr; +} + +cl_int clMemFreeINTEL( + cl_context context, + const void *ptr) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clGetMemAllocInfoINTEL( + cl_context context, + const void *ptr, + cl_mem_info_intel paramName, + size_t paramValueSize, + void *paramValue, + size_t *paramValueSizeRet) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clSetKernelArgMemPointerINTEL( + cl_kernel kernel, + cl_uint argIndex, + const void *argValue) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clEnqueueMemsetINTEL( + cl_command_queue commandQueue, + void *dstPtr, + cl_int value, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clEnqueueMemcpyINTEL( + cl_command_queue commandQueue, + cl_bool blocking, + void *dstPtr, + const void *srcPtr, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clEnqueueMigrateMemINTEL( + cl_command_queue commandQueue, + const void *ptr, + size_t size, + cl_mem_migration_flags flags, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) { + return CL_OUT_OF_HOST_MEMORY; +} + +cl_int clEnqueueMemAdviseINTEL( + cl_command_queue commandQueue, + const void *ptr, + size_t size, + cl_mem_advice_intel advice, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event) { + return CL_OUT_OF_HOST_MEMORY; +} + cl_command_queue CL_API_CALL clCreateCommandQueueWithPropertiesKHR(cl_context context, cl_device_id device, const cl_queue_properties_khr *properties, @@ -3553,6 +3656,17 @@ void *CL_API_CALL clGetExtensionFunctionAddress(const char *funcName) { RETURN_FUNC_PTR_IF_EXIST(clDisableTracingINTEL); RETURN_FUNC_PTR_IF_EXIST(clGetTracingStateINTEL); + RETURN_FUNC_PTR_IF_EXIST(clHostMemAllocINTEL); + RETURN_FUNC_PTR_IF_EXIST(clDeviceMemAllocINTEL); + RETURN_FUNC_PTR_IF_EXIST(clSharedMemAllocINTEL); + RETURN_FUNC_PTR_IF_EXIST(clMemFreeINTEL); + RETURN_FUNC_PTR_IF_EXIST(clGetMemAllocInfoINTEL); + RETURN_FUNC_PTR_IF_EXIST(clSetKernelArgMemPointerINTEL); + RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemsetINTEL); + RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemcpyINTEL); + RETURN_FUNC_PTR_IF_EXIST(clEnqueueMigrateMemINTEL); + RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemAdviseINTEL); + void *ret = sharingFactory.getExtensionFunctionAddress(funcName); if (ret != nullptr) { TRACING_EXIT(clGetExtensionFunctionAddress, &ret); diff --git a/runtime/api/api.h b/runtime/api/api.h index de64944441..ea89f0e095 100644 --- a/runtime/api/api.h +++ b/runtime/api/api.h @@ -915,6 +915,83 @@ extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithILKHR( const void *il, size_t length, cl_int *errcodeRet) CL_API_SUFFIX__VERSION_1_2; + +void *clHostMemAllocINTEL( + cl_context context, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet); + +void *clDeviceMemAllocINTEL( + cl_context context, + cl_device_id device, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet); + +void *clSharedMemAllocINTEL( + cl_context context, + cl_device_id device, + cl_mem_properties_intel *properties, + size_t size, + cl_uint alignment, + cl_int *errcodeRet); + +cl_int clMemFreeINTEL( + cl_context context, + const void *ptr); + +cl_int clGetMemAllocInfoINTEL( + cl_context context, + const void *ptr, + cl_mem_info_intel paramName, + size_t paramValueSize, + void *paramValue, + size_t *paramValueSizeRet); + +cl_int clSetKernelArgMemPointerINTEL( + cl_kernel kernel, + cl_uint argIndex, + const void *argValue); + +cl_int clEnqueueMemsetINTEL( + cl_command_queue commandQueue, + void *dstPtr, + cl_int value, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event); + +cl_int clEnqueueMemcpyINTEL( + cl_command_queue commandQueue, + cl_bool blocking, + void *dstPtr, + const void *srcPtr, + size_t size, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event); + +cl_int clEnqueueMigrateMemINTEL( + cl_command_queue commandQueue, + const void *ptr, + size_t size, + cl_mem_migration_flags flags, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event); + +cl_int clEnqueueMemAdviseINTEL( + cl_command_queue commandQueue, + const void *ptr, + size_t size, + cl_mem_advice_intel advice, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event); } // OpenCL 2.2 diff --git a/unit_tests/api/api_tests_wrapper1.cpp b/unit_tests/api/api_tests_wrapper1.cpp index 976c11319c..f6c80063f5 100644 --- a/unit_tests/api/api_tests_wrapper1.cpp +++ b/unit_tests/api/api_tests_wrapper1.cpp @@ -35,3 +35,4 @@ #include "unit_tests/api/cl_enqueue_map_image_tests.inl" #include "unit_tests/api/cl_enqueue_marker_tests.inl" #include "unit_tests/api/cl_enqueue_marker_with_wait_list_tests.inl" +#include "unit_tests/api/cl_unified_shared_memory_tests.inl" 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 b104e2fe8a..5a5b463e81 100644 --- a/unit_tests/api/cl_get_extension_function_address_tests.inl +++ b/unit_tests/api/cl_get_extension_function_address_tests.inl @@ -92,4 +92,54 @@ TEST_F(clGetExtensionFunctionAddressTests, GivenClGetTracingStateINTELWhenGettin auto retVal = clGetExtensionFunctionAddress("clGetTracingStateINTEL"); EXPECT_EQ(retVal, reinterpret_cast(clGetTracingStateINTEL)); } + +TEST_F(clGetExtensionFunctionAddressTests, GivenClHostMemAllocINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clHostMemAllocINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clHostMemAllocINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClDeviceMemAllocINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clDeviceMemAllocINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clDeviceMemAllocINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClSharedMemAllocINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clSharedMemAllocINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clSharedMemAllocINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClMemFreeINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clMemFreeINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clMemFreeINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClGetMemAllocInfoINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clGetMemAllocInfoINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clGetMemAllocInfoINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClSetKernelArgMemPointerINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clSetKernelArgMemPointerINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clSetKernelArgMemPointerINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemsetINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clEnqueueMemsetINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemsetINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemcpyINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clEnqueueMemcpyINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemcpyINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMigrateMemINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clEnqueueMigrateMemINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMigrateMemINTEL)); +} + +TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemAdviseINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) { + auto retVal = clGetExtensionFunctionAddress("clEnqueueMemAdviseINTEL"); + EXPECT_EQ(retVal, reinterpret_cast(clEnqueueMemAdviseINTEL)); +} } // namespace ULT diff --git a/unit_tests/api/cl_unified_shared_memory_tests.inl b/unit_tests/api/cl_unified_shared_memory_tests.inl new file mode 100644 index 0000000000..ba1928f6c3 --- /dev/null +++ b/unit_tests/api/cl_unified_shared_memory_tests.inl @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/api/api.h" + +using namespace NEO; + +TEST(clUnifiedSharedMemoryTests, whenClHostMemAllocINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + cl_int retVal = CL_SUCCESS; + clHostMemAllocINTEL(0, nullptr, 0, 0, &retVal); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClDeviceMemAllocINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + cl_int retVal = CL_SUCCESS; + clDeviceMemAllocINTEL(0, 0, nullptr, 0, 0, &retVal); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClSharedMemAllocINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + cl_int retVal = CL_SUCCESS; + clSharedMemAllocINTEL(0, 0, nullptr, 0, 0, &retVal); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClMemFreeINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clMemFreeINTEL(0, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clGetMemAllocInfoINTEL(0, nullptr, 0, 0, nullptr, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClSetKernelArgMemPointerINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clSetKernelArgMemPointerINTEL(0, 0, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemsetINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clEnqueueMemsetINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemcpyINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clEnqueueMemcpyINTEL(0, 0, nullptr, nullptr, 0, 0, nullptr, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClEnqueueMigrateMemINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clEnqueueMigrateMemINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +} + +TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemAdviseINTELisCalledThenOutOfHostMemoryErrorIsReturned) { + auto retVal = clEnqueueMemAdviseINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr); + EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal); +}