Remove OCL object from MemoryProperties 1/n

Create struct MemoryPropertiesFlags and helper for it

Related-To: NEO-3132
Change-Id: If303a563d7dbae8cf897aa8182b9caab08593c75
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2019-08-05 15:16:57 +02:00
committed by sys_ocldev
parent 6ae0ca3c56
commit c3a54dd5ad
11 changed files with 290 additions and 4 deletions

View File

@@ -740,10 +740,11 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif()
# Project-wide include paths
# Please keep alphabetical order
include_directories(${IGDRCL_SOURCE_DIR})
include_directories(${IGDRCL_BUILD_DIR})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/os_interface/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/core/memory_properties${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/built_ins/builtinops${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/command_stream/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gen_common/reg_configs${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/${BRANCH_DIR_SUFFIX})
@@ -751,7 +752,8 @@ include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/client_context${BRAN
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/gmm_memory${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/mem_obj/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/memory_manager/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/built_ins/builtinops${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/os_interface/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX})
set(HW_SRC_INCLUDE_PATH ${IGDRCL_SOURCE_DIR}/runtime/gen_common)

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_MEMORY_PROPERTIES
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_properties_flags.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_common.inl
)
set_property(GLOBAL PROPERTY NEO_CORE_MEMORY_PROPERTIES ${NEO_CORE_MEMORY_PROPERTIES})
add_subdirectories()

View File

@@ -0,0 +1,16 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/memory_properties/memory_properties_flags_common.inl"
namespace NEO {
struct MemoryPropertiesFlags : MemoryPropertiesFlagsBase {
};
} // namespace NEO

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
namespace NEO {
struct MemoryPropertiesFlagsBase {
bool readWrite = false;
bool writeOnly = false;
bool readOnly = false;
bool useHostPtr = false;
bool allocHostPtr = false;
bool copyHostPtr = false;
bool hostWriteOnly = false;
bool hostReadOnly = false;
bool hostNoAccess = false;
bool kernelReadAndWrite = false;
bool forceLinearStorage = false;
bool accessFlagsUnrestricted = false;
bool noAccess = false;
bool locallyUncachedResource = false;
bool allowUnrestrictedSize = false;
};
} // namespace NEO

View File

@@ -58,8 +58,11 @@ set(RUNTIME_SRCS_HELPERS_BASE
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/kernel_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.h
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mem_properties_parser_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_properties_flags_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/mipmap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mipmap.h
${CMAKE_CURRENT_SOURCE_DIR}/options.cpp

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/memory_properties_flags_helpers_base.inl"
namespace NEO {
void MemoryPropertiesFlagsParser::addExtraMemoryPropertiesFlags(MemoryPropertiesFlags &propertiesFlag, MemoryProperties properties) {
}
} // namespace NEO

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "mem_obj_types.h"
#include "memory_properties_flags.h"
namespace NEO {
class MemoryPropertiesFlagsParser {
public:
static void addExtraMemoryPropertiesFlags(MemoryPropertiesFlags &propertiesFlags, MemoryProperties properties);
static MemoryPropertiesFlags createMemoryPropertiesFlags(MemoryProperties properties);
};
} // namespace NEO

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "common/helpers/bit_helpers.h"
#include "public/cl_ext_private.h"
#include "runtime/helpers/memory_properties_flags_helpers.h"
#include "CL/cl_ext_intel.h"
namespace NEO {
MemoryPropertiesFlags MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(MemoryProperties properties) {
MemoryPropertiesFlags memoryPropertiesFlags;
if (isValueSet(properties.flags, CL_MEM_READ_WRITE)) {
memoryPropertiesFlags.readWrite = true;
}
if (isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) {
memoryPropertiesFlags.writeOnly = true;
}
if (isValueSet(properties.flags, CL_MEM_READ_ONLY)) {
memoryPropertiesFlags.readOnly = true;
}
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
memoryPropertiesFlags.useHostPtr = true;
}
if (isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR)) {
memoryPropertiesFlags.allocHostPtr = true;
}
if (isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR)) {
memoryPropertiesFlags.copyHostPtr = true;
}
if (isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY)) {
memoryPropertiesFlags.hostWriteOnly = true;
}
if (isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY)) {
memoryPropertiesFlags.hostReadOnly = true;
}
if (isValueSet(properties.flags, CL_MEM_HOST_NO_ACCESS)) {
memoryPropertiesFlags.hostNoAccess = true;
}
if (isValueSet(properties.flags, CL_MEM_KERNEL_READ_AND_WRITE)) {
memoryPropertiesFlags.kernelReadAndWrite = true;
}
if (isValueSet(properties.flags, CL_MEM_FORCE_LINEAR_STORAGE_INTEL) ||
isValueSet(properties.flags_intel, CL_MEM_FORCE_LINEAR_STORAGE_INTEL)) {
memoryPropertiesFlags.forceLinearStorage = true;
}
if (isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) {
memoryPropertiesFlags.accessFlagsUnrestricted = true;
}
if (isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL)) {
memoryPropertiesFlags.noAccess = true;
}
if (isValueSet(properties.flags, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
isValueSet(properties.flags_intel, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL)) {
memoryPropertiesFlags.allowUnrestrictedSize = true;
}
if (isValueSet(properties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE)) {
memoryPropertiesFlags.locallyUncachedResource = true;
}
addExtraMemoryPropertiesFlags(memoryPropertiesFlags, properties);
return memoryPropertiesFlags;
}
} // namespace NEO

View File

@@ -56,6 +56,9 @@ list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_UNIFIED_MEMORY})
get_property(NEO_CORE_MEMORY_MANAGER GLOBAL PROPERTY NEO_CORE_MEMORY_MANAGER)
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_CORE_MEMORY_MANAGER})
get_property(NEO_CORE_MEMORY_PROPERTIES GLOBAL PROPERTY NEO_CORE_MEMORY_PROPERTIES)
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_CORE_MEMORY_PROPERTIES})
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_MEMORY_MANAGER})
set_property(GLOBAL PROPERTY RUNTIME_SRCS_MEMORY_MANAGER ${RUNTIME_SRCS_MEMORY_MANAGER})
add_subdirectories()

View File

@@ -34,6 +34,7 @@ set(IGDRCL_SRCS_tests_helpers
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.inl
${CMAKE_CURRENT_SOURCE_DIR}/kernel_filename_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_management_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp

View File

@@ -0,0 +1,108 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/memory_properties_flags_helpers.h"
#include "CL/cl_ext_intel.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(MemoryPropertiesFlags, givenValidPropertiesWhenCreateMemoryPropertiesFlagsThenTrueIsReturned) {
MemoryPropertiesFlags properties;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE);
EXPECT_TRUE(properties.readWrite);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_WRITE_ONLY);
EXPECT_TRUE(properties.writeOnly);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_ONLY);
EXPECT_TRUE(properties.readOnly);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR);
EXPECT_TRUE(properties.useHostPtr);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_ALLOC_HOST_PTR);
EXPECT_TRUE(properties.allocHostPtr);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_COPY_HOST_PTR);
EXPECT_TRUE(properties.copyHostPtr);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_HOST_WRITE_ONLY);
EXPECT_TRUE(properties.hostWriteOnly);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_HOST_READ_ONLY);
EXPECT_TRUE(properties.hostReadOnly);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_HOST_NO_ACCESS);
EXPECT_TRUE(properties.hostNoAccess);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_KERNEL_READ_AND_WRITE);
EXPECT_TRUE(properties.kernelReadAndWrite);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL);
EXPECT_TRUE(properties.accessFlagsUnrestricted);
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_NO_ACCESS_INTEL);
EXPECT_TRUE(properties.noAccess);
MemoryProperties memoryProperties;
memoryProperties.flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.locallyUncachedResource);
}
TEST(MemoryPropertiesFlags, givenClMemForceLinearStorageFlagWhenCreateMemoryPropertiesFlagsThenReturnProperValue) {
MemoryPropertiesFlags properties;
MemoryProperties memoryProperties;
memoryProperties.flags |= CL_MEM_FORCE_LINEAR_STORAGE_INTEL;
memoryProperties.flags_intel = 0;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.forceLinearStorage);
memoryProperties.flags = 0;
memoryProperties.flags_intel |= CL_MEM_FORCE_LINEAR_STORAGE_INTEL;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.forceLinearStorage);
memoryProperties.flags |= CL_MEM_FORCE_LINEAR_STORAGE_INTEL;
memoryProperties.flags_intel |= CL_MEM_FORCE_LINEAR_STORAGE_INTEL;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.forceLinearStorage);
memoryProperties.flags = 0;
memoryProperties.flags_intel = 0;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_FALSE(properties.forceLinearStorage);
}
TEST(MemoryPropertiesFlags, givenClAllowUnrestrictedSizeFlagWhenCreateMemoryPropertiesFlagsThenReturnProperValue) {
MemoryPropertiesFlags properties;
MemoryProperties memoryProperties;
memoryProperties.flags |= CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL;
memoryProperties.flags_intel = 0;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.allowUnrestrictedSize);
memoryProperties.flags = 0;
memoryProperties.flags_intel |= CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.allowUnrestrictedSize);
memoryProperties.flags |= CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL;
memoryProperties.flags_intel |= CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_TRUE(properties.allowUnrestrictedSize);
memoryProperties.flags = 0;
memoryProperties.flags_intel = 0;
properties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memoryProperties);
EXPECT_FALSE(properties.allowUnrestrictedSize);
}