From 4ad96b75f586275ffab033bf070bd20359dc36af Mon Sep 17 00:00:00 2001 From: "Zdanowicz, Zbigniew" Date: Tue, 23 Jan 2018 21:42:40 +0100 Subject: [PATCH] Make base class for gmm_memory Change-Id: I307f616be27d5fed126f0e36bff0d182ab7a8b53 --- CMakeLists.txt | 3 +- manifests/manifest.yml | 2 +- runtime/CMakeLists.txt | 3 +- runtime/gmm_helper/gmm_memory.cpp | 4 +- runtime/gmm_helper/gmm_memory.h | 31 +--------- runtime/gmm_helper/gmm_memory_base.h | 58 +++++++++++++++++++ runtime/os_interface/windows/wddm.cpp | 1 - runtime/os_interface/windows/wddm.h | 4 +- unit_tests/CMakeLists.txt | 3 +- unit_tests/aub_tests/CMakeLists.txt | 8 ++- unit_tests/mocks/CMakeLists.txt | 4 +- unit_tests/mocks/mock_gmm_memory.cpp | 9 +-- unit_tests/mocks/mock_gmm_memory.h | 6 +- unit_tests/mt_tests/CMakeLists.txt | 5 +- .../os_interface/windows/wddm_fixture.h | 4 +- unit_tests/tbx/CMakeLists.txt | 7 ++- 16 files changed, 97 insertions(+), 55 deletions(-) create mode 100644 runtime/gmm_helper/gmm_memory_base.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c3ef6e5e1..4b58646444 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation +# Copyright (c) 2017 - 2018, Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -483,6 +483,7 @@ set(BRANCH_DIR_SUFFIX "/") 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/gmm_helper/${BRANCH_DIR_SUFFIX}) if(HAVE_INSTRUMENTATION) set(${IGDRCL__INSTRUMENTATION_DIR_SUFFIX} ${BRANCH_DIR_SUFFIX}) diff --git a/manifests/manifest.yml b/manifests/manifest.yml index 10fee3815c..7eaf2df303 100644 --- a/manifests/manifest.yml +++ b/manifests/manifest.yml @@ -36,7 +36,7 @@ components: internal: branch: master dest_dir: internal - revision: c7d627c913c36abaaf697ac38b4b8c3269900fe1 + revision: a1f0f0789e9520a075392e67bcebcdedc17428e7 type: git khronos: branch: master diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 7a8ae36778..eee5950bf2 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -381,7 +381,8 @@ set (RUNTIME_SRCS_GMM_HELPER if (WIN32) list (APPEND RUNTIME_SRCS_GMM_HELPER gmm_helper/page_table_mngr.h - gmm_helper/gmm_memory.h + gmm_helper${BRANCH_DIR_SUFFIX}/gmm_memory.h + gmm_helper/gmm_memory_base.h ) endif(WIN32) diff --git a/runtime/gmm_helper/gmm_memory.cpp b/runtime/gmm_helper/gmm_memory.cpp index ffb9bbb3c2..13a6e37d5d 100644 --- a/runtime/gmm_helper/gmm_memory.cpp +++ b/runtime/gmm_helper/gmm_memory.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,7 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/gmm_helper/gmm_memory.h" +#include "gmm_memory.h" namespace OCLRT { GmmMemory *GmmMemory::create() { diff --git a/runtime/gmm_helper/gmm_memory.h b/runtime/gmm_helper/gmm_memory.h index 635e9899c6..1073caeca1 100644 --- a/runtime/gmm_helper/gmm_memory.h +++ b/runtime/gmm_helper/gmm_memory.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,39 +21,14 @@ */ #pragma once -#include "runtime/gmm_helper/gmm_lib.h" -#include +#include "runtime/gmm_helper/gmm_memory_base.h" namespace OCLRT { -class GmmMemory { +class GmmMemory : public GmmMemoryBase { public: static GmmMemory *create(); - virtual ~GmmMemory() = default; - MOCKABLE_VIRTUAL bool configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, - GMM_ESCAPE_HANDLE hDevice, - GMM_ESCAPE_FUNC_TYPE pfnEscape, - GMM_GFX_SIZE_T SvmSize, - BOOLEAN FaultableSvm, - BOOLEAN SparseReady, - BOOLEAN BDWL3Coherency, - GMM_GFX_SIZE_T SizeOverride, - GMM_GFX_SIZE_T SlmGfxSpaceReserve) { - return GmmConfigureDeviceAddressSpace( - hAdapter, - hDevice, - pfnEscape, - SvmSize, - FaultableSvm, - SparseReady, - BDWL3Coherency, - SizeOverride, - SlmGfxSpaceReserve) != 0 - ? true - : false; - } - protected: GmmMemory() = default; }; diff --git a/runtime/gmm_helper/gmm_memory_base.h b/runtime/gmm_helper/gmm_memory_base.h new file mode 100644 index 0000000000..62c0769264 --- /dev/null +++ b/runtime/gmm_helper/gmm_memory_base.h @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2018, Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#pragma once +#include "runtime/gmm_helper/gmm_lib.h" +#include + +namespace OCLRT { +class GmmMemoryBase { + public: + virtual ~GmmMemoryBase() = default; + + MOCKABLE_VIRTUAL bool configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, + GMM_ESCAPE_HANDLE hDevice, + GMM_ESCAPE_FUNC_TYPE pfnEscape, + GMM_GFX_SIZE_T SvmSize, + BOOLEAN FaultableSvm, + BOOLEAN SparseReady, + BOOLEAN BDWL3Coherency, + GMM_GFX_SIZE_T SizeOverride, + GMM_GFX_SIZE_T SlmGfxSpaceReserve) { + return GmmConfigureDeviceAddressSpace( + hAdapter, + hDevice, + pfnEscape, + SvmSize, + FaultableSvm, + SparseReady, + BDWL3Coherency, + SizeOverride, + SlmGfxSpaceReserve) != 0 + ? true + : false; + } + + protected: + GmmMemoryBase() = default; +}; +} // namespace OCLRT diff --git a/runtime/os_interface/windows/wddm.cpp b/runtime/os_interface/windows/wddm.cpp index 16a0d30c75..2624f308ad 100644 --- a/runtime/os_interface/windows/wddm.cpp +++ b/runtime/os_interface/windows/wddm.cpp @@ -24,7 +24,6 @@ #include "runtime/helpers/options.h" #include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/gmm_helper/gmm_helper.h" -#include "runtime/gmm_helper/gmm_memory.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/gmm_helper/page_table_mngr.h" #include "runtime/os_interface/windows/wddm.h" diff --git a/runtime/os_interface/windows/wddm.h b/runtime/os_interface/windows/wddm.h index 2269f24732..fdd5a04d8a 100644 --- a/runtime/os_interface/windows/wddm.h +++ b/runtime/os_interface/windows/wddm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,7 +31,7 @@ #include "runtime/utilities/debug_settings_reader.h" #include "runtime/gmm_helper/gmm_lib.h" #include "runtime/gmm_helper/gmm_helper.h" -#include "runtime/gmm_helper/gmm_memory.h" +#include "gmm_memory.h" #include #include diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 8bd88657af..e771db181f 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation +# Copyright (c) 2017 - 2018, Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -222,6 +222,7 @@ target_include_directories(igdrcl_tests PRIVATE ${INSTRUMENTATION_INCLUDE_PATH} ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX} ) if(MSVC) diff --git a/unit_tests/aub_tests/CMakeLists.txt b/unit_tests/aub_tests/CMakeLists.txt index d03df34aeb..06a10188dd 100644 --- a/unit_tests/aub_tests/CMakeLists.txt +++ b/unit_tests/aub_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation +# Copyright (c) 2017 - 2018, Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -44,6 +44,12 @@ target_include_directories(igdrcl_aub_tests PRIVATE ${GMM_INCLUDE_PATHS} ) +if(WIN32) + target_include_directories(igdrcl_aub_tests PRIVATE + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX} + ) +endif(WIN32) + add_subdirectory(command_queue) add_subdirectory(command_stream) add_subdirectory(fixtures) diff --git a/unit_tests/mocks/CMakeLists.txt b/unit_tests/mocks/CMakeLists.txt index d994003f9c..ba25ab1971 100644 --- a/unit_tests/mocks/CMakeLists.txt +++ b/unit_tests/mocks/CMakeLists.txt @@ -60,8 +60,8 @@ if (WIN32) list (APPEND IGDRCL_SRCS_tests_mocks "${CMAKE_CURRENT_SOURCE_DIR}/mock_d3d_objects.h" "${CMAKE_CURRENT_SOURCE_DIR}/mock_ostime_win.h" - "${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_memory.h" - "${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_memory.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gmm_memory.h" + "${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gmm_memory.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.h" "${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp" ) diff --git a/unit_tests/mocks/mock_gmm_memory.cpp b/unit_tests/mocks/mock_gmm_memory.cpp index a1eac36839..9849f47a7b 100644 --- a/unit_tests/mocks/mock_gmm_memory.cpp +++ b/unit_tests/mocks/mock_gmm_memory.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,10 +20,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "unit_tests/mocks/mock_gmm_memory.h" +#include "mock_gmm_memory.h" using namespace ::testing; -using namespace OCLRT::MockGmmMemory; namespace OCLRT { @@ -32,13 +31,11 @@ MockType MockGmmMemoryFlag = MockType::MockDummy; } GmmMemory *GmmMemory::create() { - if (MockGmmMemoryFlag == MockType::MockDummy) { + if (MockGmmMemory::MockGmmMemoryFlag == MockGmmMemory::MockType::MockDummy) { return new MockGmmMemoryDummy(); } else { return new NiceMock(); } } -GmockGmmMemory::GmockGmmMemory() { -} } // namespace OCLRT diff --git a/unit_tests/mocks/mock_gmm_memory.h b/unit_tests/mocks/mock_gmm_memory.h index f71b0fd8d8..81e8ba9462 100644 --- a/unit_tests/mocks/mock_gmm_memory.h +++ b/unit_tests/mocks/mock_gmm_memory.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ */ #pragma once -#include "runtime/gmm_helper/gmm_memory.h" +#include "gmm_memory.h" #include "gmock/gmock.h" namespace OCLRT { @@ -58,7 +58,7 @@ class GmockGmmMemory : public GmmMemory { public: ~GmockGmmMemory() = default; - GmockGmmMemory(); + GmockGmmMemory() = default; MOCK_METHOD9(configureDeviceAddressSpace, bool(GMM_ESCAPE_HANDLE hAdapter, diff --git a/unit_tests/mt_tests/CMakeLists.txt b/unit_tests/mt_tests/CMakeLists.txt index 7a09e319cc..7796d0c162 100644 --- a/unit_tests/mt_tests/CMakeLists.txt +++ b/unit_tests/mt_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation +# Copyright (c) 2017 - 2018, Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -76,7 +76,7 @@ if(MSVC) ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/ult_dxgi_factory.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_create.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/mocks/mock_gmm_page_table_mngr.cpp - ${IGDRCL_SOURCE_DIR}/unit_tests/mocks/mock_gmm_memory.cpp + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX}/mock_gmm_memory.cpp ) else(MSVC) list(APPEND IGDRCL_SRCS_mt_tests @@ -116,6 +116,7 @@ if(MSVC) ${WDK_INCLUDE_PATHS} ${GMM_INCLUDE_PATHS} ${UMKM_SHAREDDATA_INCLUDE_PATHS} + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX} ) target_link_libraries (igdrcl_mt_tests Ws2_32.lib) else() diff --git a/unit_tests/os_interface/windows/wddm_fixture.h b/unit_tests/os_interface/windows/wddm_fixture.h index 8558325177..385ba60d65 100644 --- a/unit_tests/os_interface/windows/wddm_fixture.h +++ b/unit_tests/os_interface/windows/wddm_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -32,7 +32,7 @@ #include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/fixtures/gmm_fixture.h" #include "unit_tests/mock_gdi/mock_gdi.h" -#include "unit_tests/mocks/mock_gmm_memory.h" +#include "mock_gmm_memory.h" #include "unit_tests//os_interface/windows/mock_gdi_interface.h" #pragma warning(push) #pragma warning(disable : 4005) diff --git a/unit_tests/tbx/CMakeLists.txt b/unit_tests/tbx/CMakeLists.txt index a654e30fb3..b909f30fe7 100644 --- a/unit_tests/tbx/CMakeLists.txt +++ b/unit_tests/tbx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation +# Copyright (c) 2017 - 2018, Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -37,11 +37,14 @@ target_compile_definitions(igdrcl_tbx_tests PRIVATE MOCKABLE_VIRTUAL=virtual) if(UNIX) target_link_libraries(igdrcl_tbx_tests dl pthread) elseif(WIN32) + target_include_directories(igdrcl_tbx_tests PRIVATE + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX} + ) target_sources(igdrcl_tbx_tests PUBLIC ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_create.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/ult_dxgi_factory.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/mocks/mock_gmm_page_table_mngr.cpp - ${IGDRCL_SOURCE_DIR}/unit_tests/mocks/mock_gmm_memory.cpp + ${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX}/mock_gmm_memory.cpp ) target_link_libraries(igdrcl_tbx_tests Ws2_32) endif(UNIX)