From e2d7634dd53884a79a99ee2ea96e00d2944a4fce Mon Sep 17 00:00:00 2001 From: Krzysztof Gibala Date: Wed, 15 Jan 2020 16:37:10 +0100 Subject: [PATCH] Remove limitation for write combined flag Allow usage of WC in clHostMemAllocINTEL & clSharedMemAllocINTEL Related-To: NEO-3374 Change-Id: I82f0be3f67b26bd19195d374b40f73e8f8a50b01 Signed-off-by: Krzysztof Gibala --- runtime/api/api.cpp | 10 ---------- .../api/cl_unified_shared_memory_tests.inl | 20 ++++++++++++------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 1ca97664d8..b34cae65c6 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -3464,11 +3464,6 @@ void *clHostMemAllocINTEL( return nullptr; } - if (isValueSet(unifiedMemoryProperties.allocationFlags.allAllocFlags, CL_MEM_ALLOC_WRITE_COMBINED_INTEL)) { - err.set(CL_INVALID_VALUE); - return nullptr; - } - return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(neoContext->getDevice(0)->getRootDeviceIndex(), size, unifiedMemoryProperties); } @@ -3544,11 +3539,6 @@ void *clSharedMemAllocINTEL( return nullptr; } - if (isValueSet(unifiedMemoryProperties.allocationFlags.allAllocFlags, CL_MEM_ALLOC_WRITE_COMBINED_INTEL)) { - err.set(CL_INVALID_VALUE); - return nullptr; - } - unifiedMemoryProperties.device = device; unifiedMemoryProperties.subdeviceBitfield = neoDevice->getDefaultEngine().osContext->getDeviceBitfield(); diff --git a/unit_tests/api/cl_unified_shared_memory_tests.inl b/unit_tests/api/cl_unified_shared_memory_tests.inl index c31880c839..9386c18500 100644 --- a/unit_tests/api/cl_unified_shared_memory_tests.inl +++ b/unit_tests/api/cl_unified_shared_memory_tests.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -230,15 +230,18 @@ TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidPropertiesTokenThenE EXPECT_EQ(CL_INVALID_VALUE, retVal); } -TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) { +TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidWriteCombinedTokenThenSuccessIsReturned) { MockContext mockContext; cl_int retVal = CL_SUCCESS; cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0}; auto unifiedMemoryHostAllocation = clHostMemAllocINTEL(&mockContext, properties, 4, 0, &retVal); - EXPECT_EQ(nullptr, unifiedMemoryHostAllocation); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_NE(nullptr, unifiedMemoryHostAllocation); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clMemFreeINTEL(&mockContext, unifiedMemoryHostAllocation); + EXPECT_EQ(CL_SUCCESS, retVal); } TEST(clUnifiedSharedMemoryTests, whenDeviceMemAllocWithInvalidPropertiesTokenThenErrorIsReturned) { @@ -264,15 +267,18 @@ TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidPropertiesTokenThe EXPECT_EQ(CL_INVALID_VALUE, retVal); } -TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) { +TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidWriteCombinedTokenThenSuccessIsReturned) { MockContext mockContext; cl_int retVal = CL_SUCCESS; cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0}; auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, 4, 0, &retVal); - EXPECT_EQ(nullptr, unifiedMemorySharedAllocation); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_NE(nullptr, unifiedMemorySharedAllocation); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clMemFreeINTEL(&mockContext, unifiedMemorySharedAllocation); + EXPECT_EQ(CL_SUCCESS, retVal); } TEST(clUnifiedSharedMemoryTests, givenUnifiedMemoryAllocWithoutPropertiesWhenGetMemAllocFlagsThenDefaultValueIsReturned) {