Skip to content

Commit c3a54dd

Browse files
kgibalaCompute-Runtime-Automation
authored andcommitted
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 <[email protected]>
1 parent 6ae0ca3 commit c3a54dd

11 files changed

+290
-4
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,18 +740,20 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
740740
endif()
741741

742742
# Project-wide include paths
743+
# Please keep alphabetical order
743744
include_directories(${IGDRCL_SOURCE_DIR})
744745
include_directories(${IGDRCL_BUILD_DIR})
745-
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX})
746-
include_directories(${IGDRCL_SOURCE_DIR}/runtime/os_interface/definitions${BRANCH_DIR_SUFFIX})
746+
include_directories(${IGDRCL_SOURCE_DIR}/core/memory_properties${BRANCH_DIR_SUFFIX})
747+
include_directories(${IGDRCL_SOURCE_DIR}/runtime/built_ins/builtinops${BRANCH_DIR_SUFFIX})
747748
include_directories(${IGDRCL_SOURCE_DIR}/runtime/command_stream/definitions${BRANCH_DIR_SUFFIX})
748749
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gen_common/reg_configs${BRANCH_DIR_SUFFIX})
749750
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/${BRANCH_DIR_SUFFIX})
750751
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/client_context${BRANCH_DIR_SUFFIX})
751752
include_directories(${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/gmm_memory${BRANCH_DIR_SUFFIX})
752753
include_directories(${IGDRCL_SOURCE_DIR}/runtime/mem_obj/definitions${BRANCH_DIR_SUFFIX})
753754
include_directories(${IGDRCL_SOURCE_DIR}/runtime/memory_manager/definitions${BRANCH_DIR_SUFFIX})
754-
include_directories(${IGDRCL_SOURCE_DIR}/runtime/built_ins/builtinops${BRANCH_DIR_SUFFIX})
755+
include_directories(${IGDRCL_SOURCE_DIR}/runtime/os_interface/definitions${BRANCH_DIR_SUFFIX})
756+
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX})
755757

756758
set(HW_SRC_INCLUDE_PATH ${IGDRCL_SOURCE_DIR}/runtime/gen_common)
757759

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(NEO_CORE_MEMORY_PROPERTIES
8+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_properties_flags.h
10+
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_common.inl
11+
)
12+
13+
set_property(GLOBAL PROPERTY NEO_CORE_MEMORY_PROPERTIES ${NEO_CORE_MEMORY_PROPERTIES})
14+
add_subdirectories()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "core/memory_properties/memory_properties_flags_common.inl"
10+
11+
namespace NEO {
12+
13+
struct MemoryPropertiesFlags : MemoryPropertiesFlagsBase {
14+
};
15+
16+
} // namespace NEO
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
namespace NEO {
9+
10+
struct MemoryPropertiesFlagsBase {
11+
bool readWrite = false;
12+
bool writeOnly = false;
13+
bool readOnly = false;
14+
bool useHostPtr = false;
15+
bool allocHostPtr = false;
16+
bool copyHostPtr = false;
17+
18+
bool hostWriteOnly = false;
19+
bool hostReadOnly = false;
20+
bool hostNoAccess = false;
21+
22+
bool kernelReadAndWrite = false;
23+
24+
bool forceLinearStorage = false;
25+
bool accessFlagsUnrestricted = false;
26+
bool noAccess = false;
27+
28+
bool locallyUncachedResource = false;
29+
bool allowUnrestrictedSize = false;
30+
};
31+
32+
} // namespace NEO

runtime/helpers/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ set(RUNTIME_SRCS_HELPERS_BASE
5858
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/kernel_helpers.cpp
5959
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.h
6060
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.cpp
61-
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper.h
6261
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mem_properties_parser_helper.cpp
62+
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper.h
63+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_properties_flags_helpers.cpp
64+
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers.h
65+
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers_base.inl
6366
${CMAKE_CURRENT_SOURCE_DIR}/mipmap.cpp
6467
${CMAKE_CURRENT_SOURCE_DIR}/mipmap.h
6568
${CMAKE_CURRENT_SOURCE_DIR}/options.cpp
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "runtime/helpers/memory_properties_flags_helpers_base.inl"
9+
10+
namespace NEO {
11+
12+
void MemoryPropertiesFlagsParser::addExtraMemoryPropertiesFlags(MemoryPropertiesFlags &propertiesFlag, MemoryProperties properties) {
13+
}
14+
15+
} // namespace NEO
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "mem_obj_types.h"
10+
#include "memory_properties_flags.h"
11+
12+
namespace NEO {
13+
14+
class MemoryPropertiesFlagsParser {
15+
public:
16+
static void addExtraMemoryPropertiesFlags(MemoryPropertiesFlags &propertiesFlags, MemoryProperties properties);
17+
18+
static MemoryPropertiesFlags createMemoryPropertiesFlags(MemoryProperties properties);
19+
};
20+
} // namespace NEO
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "common/helpers/bit_helpers.h"
9+
#include "public/cl_ext_private.h"
10+
#include "runtime/helpers/memory_properties_flags_helpers.h"
11+
12+
#include "CL/cl_ext_intel.h"
13+
14+
namespace NEO {
15+
16+
MemoryPropertiesFlags MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(MemoryProperties properties) {
17+
MemoryPropertiesFlags memoryPropertiesFlags;
18+
19+
if (isValueSet(properties.flags, CL_MEM_READ_WRITE)) {
20+
memoryPropertiesFlags.readWrite = true;
21+
}
22+
if (isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) {
23+
memoryPropertiesFlags.writeOnly = true;
24+
}
25+
if (isValueSet(properties.flags, CL_MEM_READ_ONLY)) {
26+
memoryPropertiesFlags.readOnly = true;
27+
}
28+
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
29+
memoryPropertiesFlags.useHostPtr = true;
30+
}
31+
if (isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR)) {
32+
memoryPropertiesFlags.allocHostPtr = true;
33+
}
34+
if (isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR)) {
35+
memoryPropertiesFlags.copyHostPtr = true;
36+
}
37+
if (isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY)) {
38+
memoryPropertiesFlags.hostWriteOnly = true;
39+
}
40+
if (isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY)) {
41+
memoryPropertiesFlags.hostReadOnly = true;
42+
}
43+
if (isValueSet(properties.flags, CL_MEM_HOST_NO_ACCESS)) {
44+
memoryPropertiesFlags.hostNoAccess = true;
45+
}
46+
if (isValueSet(properties.flags, CL_MEM_KERNEL_READ_AND_WRITE)) {
47+
memoryPropertiesFlags.kernelReadAndWrite = true;
48+
}
49+
if (isValueSet(properties.flags, CL_MEM_FORCE_LINEAR_STORAGE_INTEL) ||
50+
isValueSet(properties.flags_intel, CL_MEM_FORCE_LINEAR_STORAGE_INTEL)) {
51+
memoryPropertiesFlags.forceLinearStorage = true;
52+
}
53+
if (isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) {
54+
memoryPropertiesFlags.accessFlagsUnrestricted = true;
55+
}
56+
if (isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL)) {
57+
memoryPropertiesFlags.noAccess = true;
58+
}
59+
if (isValueSet(properties.flags, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
60+
isValueSet(properties.flags_intel, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL)) {
61+
memoryPropertiesFlags.allowUnrestrictedSize = true;
62+
}
63+
if (isValueSet(properties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE)) {
64+
memoryPropertiesFlags.locallyUncachedResource = true;
65+
}
66+
67+
addExtraMemoryPropertiesFlags(memoryPropertiesFlags, properties);
68+
69+
return memoryPropertiesFlags;
70+
}
71+
72+
} // namespace NEO

runtime/memory_manager/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_UNIFIED_MEMORY})
5656
get_property(NEO_CORE_MEMORY_MANAGER GLOBAL PROPERTY NEO_CORE_MEMORY_MANAGER)
5757
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_CORE_MEMORY_MANAGER})
5858

59+
get_property(NEO_CORE_MEMORY_PROPERTIES GLOBAL PROPERTY NEO_CORE_MEMORY_PROPERTIES)
60+
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_CORE_MEMORY_PROPERTIES})
61+
5962
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_MEMORY_MANAGER})
6063
set_property(GLOBAL PROPERTY RUNTIME_SRCS_MEMORY_MANAGER ${RUNTIME_SRCS_MEMORY_MANAGER})
6164
add_subdirectories()

unit_tests/helpers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set(IGDRCL_SRCS_tests_helpers
3434
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.inl
3535
${CMAKE_CURRENT_SOURCE_DIR}/kernel_filename_helper.h
3636
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_tests.cpp
37+
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_helpers_tests.cpp
3738
${CMAKE_CURRENT_SOURCE_DIR}/mem_properties_parser_helper_tests.cpp
3839
${CMAKE_CURRENT_SOURCE_DIR}/memory_management_tests.cpp
3940
${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp

0 commit comments

Comments
 (0)