Make base class for gmm_memory

Change-Id: I307f616be27d5fed126f0e36bff0d182ab7a8b53
This commit is contained in:
Zdanowicz, Zbigniew
2018-01-23 21:42:40 +01:00
committed by sys_ocldev
parent 377fc8d20b
commit 4ad96b75f5
16 changed files with 97 additions and 55 deletions

View File

@@ -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 # Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"), # 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_SOURCE_DIR})
include_directories(${IGDRCL_BUILD_DIR}) include_directories(${IGDRCL_BUILD_DIR})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX}) 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) if(HAVE_INSTRUMENTATION)
set(${IGDRCL__INSTRUMENTATION_DIR_SUFFIX} ${BRANCH_DIR_SUFFIX}) set(${IGDRCL__INSTRUMENTATION_DIR_SUFFIX} ${BRANCH_DIR_SUFFIX})

View File

@@ -36,7 +36,7 @@ components:
internal: internal:
branch: master branch: master
dest_dir: internal dest_dir: internal
revision: c7d627c913c36abaaf697ac38b4b8c3269900fe1 revision: a1f0f0789e9520a075392e67bcebcdedc17428e7
type: git type: git
khronos: khronos:
branch: master branch: master

View File

@@ -381,7 +381,8 @@ set (RUNTIME_SRCS_GMM_HELPER
if (WIN32) if (WIN32)
list (APPEND RUNTIME_SRCS_GMM_HELPER list (APPEND RUNTIME_SRCS_GMM_HELPER
gmm_helper/page_table_mngr.h 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) endif(WIN32)

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -20,7 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "runtime/gmm_helper/gmm_memory.h" #include "gmm_memory.h"
namespace OCLRT { namespace OCLRT {
GmmMemory *GmmMemory::create() { GmmMemory *GmmMemory::create() {

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -21,39 +21,14 @@
*/ */
#pragma once #pragma once
#include "runtime/gmm_helper/gmm_lib.h" #include "runtime/gmm_helper/gmm_memory_base.h"
#include <memory>
namespace OCLRT { namespace OCLRT {
class GmmMemory { class GmmMemory : public GmmMemoryBase {
public: public:
static GmmMemory *create(); static GmmMemory *create();
virtual ~GmmMemory() = default; 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: protected:
GmmMemory() = default; GmmMemory() = default;
}; };

View File

@@ -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 <memory>
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

View File

@@ -24,7 +24,6 @@
#include "runtime/helpers/options.h" #include "runtime/helpers/options.h"
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/gmm_helper/gmm_helper.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/resource_info.h"
#include "runtime/gmm_helper/page_table_mngr.h" #include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/os_interface/windows/wddm.h" #include "runtime/os_interface/windows/wddm.h"

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -31,7 +31,7 @@
#include "runtime/utilities/debug_settings_reader.h" #include "runtime/utilities/debug_settings_reader.h"
#include "runtime/gmm_helper/gmm_lib.h" #include "runtime/gmm_helper/gmm_lib.h"
#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/gmm_memory.h" #include "gmm_memory.h"
#include <memory> #include <memory>
#include <atomic> #include <atomic>

View File

@@ -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 # Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"), # copy of this software and associated documentation files (the "Software"),
@@ -222,6 +222,7 @@ target_include_directories(igdrcl_tests PRIVATE
${INSTRUMENTATION_INCLUDE_PATH} ${INSTRUMENTATION_INCLUDE_PATH}
${GTEST_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX}
) )
if(MSVC) if(MSVC)

View File

@@ -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 # Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"), # copy of this software and associated documentation files (the "Software"),
@@ -44,6 +44,12 @@ target_include_directories(igdrcl_aub_tests PRIVATE
${GMM_INCLUDE_PATHS} ${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_queue)
add_subdirectory(command_stream) add_subdirectory(command_stream)
add_subdirectory(fixtures) add_subdirectory(fixtures)

View File

@@ -60,8 +60,8 @@ if (WIN32)
list (APPEND IGDRCL_SRCS_tests_mocks list (APPEND IGDRCL_SRCS_tests_mocks
"${CMAKE_CURRENT_SOURCE_DIR}/mock_d3d_objects.h" "${CMAKE_CURRENT_SOURCE_DIR}/mock_d3d_objects.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_ostime_win.h" "${CMAKE_CURRENT_SOURCE_DIR}/mock_ostime_win.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_memory.h" "${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gmm_memory.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_memory.cpp" "${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.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp"
) )

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -20,10 +20,9 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "unit_tests/mocks/mock_gmm_memory.h" #include "mock_gmm_memory.h"
using namespace ::testing; using namespace ::testing;
using namespace OCLRT::MockGmmMemory;
namespace OCLRT { namespace OCLRT {
@@ -32,13 +31,11 @@ MockType MockGmmMemoryFlag = MockType::MockDummy;
} }
GmmMemory *GmmMemory::create() { GmmMemory *GmmMemory::create() {
if (MockGmmMemoryFlag == MockType::MockDummy) { if (MockGmmMemory::MockGmmMemoryFlag == MockGmmMemory::MockType::MockDummy) {
return new MockGmmMemoryDummy(); return new MockGmmMemoryDummy();
} else { } else {
return new NiceMock<GmockGmmMemory>(); return new NiceMock<GmockGmmMemory>();
} }
} }
GmockGmmMemory::GmockGmmMemory() {
}
} // namespace OCLRT } // namespace OCLRT

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -21,7 +21,7 @@
*/ */
#pragma once #pragma once
#include "runtime/gmm_helper/gmm_memory.h" #include "gmm_memory.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
namespace OCLRT { namespace OCLRT {
@@ -58,7 +58,7 @@ class GmockGmmMemory : public GmmMemory {
public: public:
~GmockGmmMemory() = default; ~GmockGmmMemory() = default;
GmockGmmMemory(); GmockGmmMemory() = default;
MOCK_METHOD9(configureDeviceAddressSpace, MOCK_METHOD9(configureDeviceAddressSpace,
bool(GMM_ESCAPE_HANDLE hAdapter, bool(GMM_ESCAPE_HANDLE hAdapter,

View File

@@ -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 # Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"), # 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/ult_dxgi_factory.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_create.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_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) else(MSVC)
list(APPEND IGDRCL_SRCS_mt_tests list(APPEND IGDRCL_SRCS_mt_tests
@@ -116,6 +116,7 @@ if(MSVC)
${WDK_INCLUDE_PATHS} ${WDK_INCLUDE_PATHS}
${GMM_INCLUDE_PATHS} ${GMM_INCLUDE_PATHS}
${UMKM_SHAREDDATA_INCLUDE_PATHS} ${UMKM_SHAREDDATA_INCLUDE_PATHS}
${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX}
) )
target_link_libraries (igdrcl_mt_tests Ws2_32.lib) target_link_libraries (igdrcl_mt_tests Ws2_32.lib)
else() else()

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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/helpers/debug_manager_state_restore.h"
#include "unit_tests/fixtures/gmm_fixture.h" #include "unit_tests/fixtures/gmm_fixture.h"
#include "unit_tests/mock_gdi/mock_gdi.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" #include "unit_tests//os_interface/windows/mock_gdi_interface.h"
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4005) #pragma warning(disable : 4005)

View File

@@ -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 # Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"), # 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) if(UNIX)
target_link_libraries(igdrcl_tbx_tests dl pthread) target_link_libraries(igdrcl_tbx_tests dl pthread)
elseif(WIN32) elseif(WIN32)
target_include_directories(igdrcl_tbx_tests PRIVATE
${IGDRCL_SOURCE_DIR}/unit_tests/mocks${BRANCH_DIR_SUFFIX}
)
target_sources(igdrcl_tbx_tests PUBLIC 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/wddm_create.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/ult_dxgi_factory.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_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) target_link_libraries(igdrcl_tbx_tests Ws2_32)
endif(UNIX) endif(UNIX)