Skip to content

Commit 2047fc8

Browse files
Move execution environment helper to shared
Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 38ad58b commit 2047fc8

21 files changed

+199
-103
lines changed

opencl/test/unit_test/command_stream/create_command_stream_receiver_tests.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
#include "shared/source/execution_environment/execution_environment.h"
1111
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
1212
#include "shared/test/common/helpers/debug_manager_state_restore.h"
13+
#include "shared/test/common/helpers/execution_environment_helper.h"
1314
#include "shared/test/common/helpers/ult_hw_config.h"
1415
#include "shared/test/common/helpers/variable_backup.h"
1516
#include "shared/test/common/libult/create_command_stream.h"
1617
#include "shared/test/common/test_macros/test.h"
1718
#include "shared/test/unit_test/fixtures/mock_aub_center_fixture.h"
1819

19-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
20-
2120
using namespace NEO;
2221

2322
struct CreateCommandStreamReceiverTest : public ::testing::TestWithParam<CommandStreamReceiverType> {};
@@ -26,21 +25,26 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
2625
DebugManagerStateRestore stateRestorer;
2726
HardwareInfo *hwInfo = nullptr;
2827
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
28+
ASSERT_NE(nullptr, executionEnvironment->memoryManager.get());
29+
executionEnvironment->incRefInternal();
2930
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
3031

3132
CommandStreamReceiverType csrType = GetParam();
3233

3334
VariableBackup<UltHwConfig> backup(&ultHwConfig);
3435
ultHwConfig.useHwCsr = true;
3536
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
36-
auto csr = std::unique_ptr<CommandStreamReceiver>(createCommandStream(*executionEnvironment, 0, 1));
37-
38-
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
39-
EXPECT_NE(nullptr, csr.get());
40-
} else {
41-
EXPECT_EQ(nullptr, csr.get());
37+
{
38+
auto csr = std::unique_ptr<CommandStreamReceiver>(createCommandStream(*executionEnvironment, 0, 1));
39+
40+
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
41+
EXPECT_NE(nullptr, csr.get());
42+
} else {
43+
EXPECT_EQ(nullptr, csr.get());
44+
}
4245
}
43-
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
46+
47+
executionEnvironment->decRefInternal();
4448
}
4549

4650
static CommandStreamReceiverType commandStreamReceiverTypes[] = {

opencl/test/unit_test/fixtures/buffer_enqueue_fixture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "shared/test/common/test_macros/test.h"
1515

1616
#include "opencl/test/unit_test/fixtures/buffer_fixture.h"
17+
#include "opencl/test/unit_test/helpers/cl_execution_environment_helper.h"
1718
#include "opencl/test/unit_test/helpers/cl_hw_parse.h"
18-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
1919
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
2020

2121
using namespace NEO;
@@ -27,7 +27,7 @@ struct BufferEnqueueFixture : public ClHardwareParse,
2727
}
2828

2929
void SetUp() override {
30-
executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
30+
executionEnvironment = getClExecutionEnvironmentImpl(hwInfo, 1);
3131
}
3232

3333
void TearDown() override {

opencl/test/unit_test/fixtures/device_instrumentation_fixture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
#include "opencl/test/unit_test/fixtures/device_instrumentation_fixture.h"
99

10+
#include "shared/test/common/helpers/execution_environment_helper.h"
1011
#include "shared/test/common/mocks/mock_device.h"
1112

1213
#include "opencl/source/cl_device/cl_device.h"
13-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
1414
#include "opencl/test/unit_test/mocks/mock_platform.h"
1515

1616
namespace NEO {

opencl/test/unit_test/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
#include "shared/source/helpers/windows/gmm_callbacks.h"
1414
#include "shared/source/os_interface/windows/wddm_device_command_stream.h"
1515
#include "shared/test/common/cmd_parse/hw_parse.h"
16+
#include "shared/test/common/fixtures/gmm_callbacks_fixture.h"
1617
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1718
#include "shared/test/common/helpers/default_hw_info.h"
1819
#include "shared/test/common/libult/ult_command_stream_receiver.h"
1920
#include "shared/test/common/test_macros/test.h"
2021

21-
#include "opencl/source/platform/platform.h"
22-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
23-
#include "opencl/test/unit_test/mocks/mock_platform.h"
24-
2522
using namespace NEO;
2623

27-
using Gen12LpGmmCallbacksTests = ::testing::Test;
24+
using Gen12LpGmmCallbacksTests = ::Test<GmmCallbacksFixture>;
2825

2926
template <typename GfxFamily>
3027
struct MockAubCsrToTestNotifyAubCapture : public AUBCommandStreamReceiverHw<GfxFamily> {
@@ -33,9 +30,6 @@ struct MockAubCsrToTestNotifyAubCapture : public AUBCommandStreamReceiverHw<GfxF
3330
};
3431

3532
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCsrWithoutAubDumpWhenNotifyAubCaptureCallbackIsCalledThenDoNothing) {
36-
HardwareInfo *hwInfo = nullptr;
37-
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
38-
executionEnvironment->initializeMemoryManager();
3933
auto csr = std::make_unique<WddmCommandStreamReceiver<FamilyType>>(*executionEnvironment, 0, 1);
4034
uint64_t address = 0xFEDCBA9876543210;
4135
size_t size = 1024;
@@ -46,9 +40,8 @@ GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCsrWithoutAubDumpWhenNotifyAubCaptu
4640
}
4741

4842
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenWddmCsrWhenWriteL3CalledThenWriteTwoMmio) {
49-
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
50-
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
51-
executionEnvironment->initializeMemoryManager();
43+
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
44+
5245
UltCommandStreamReceiver<FamilyType> csr(*executionEnvironment, 0, 1);
5346
uint8_t buffer[128] = {};
5447
csr.commandStream.replaceBuffer(buffer, 128);

opencl/test/unit_test/helpers/execution_environment_helper.cpp renamed to opencl/test/unit_test/helpers/cl_execution_environment_helper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
*
66
*/
77

8-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
8+
#include "opencl/test/unit_test/helpers/cl_execution_environment_helper.h"
99

10+
#include "shared/source/execution_environment/execution_environment.h"
1011
#include "shared/source/execution_environment/root_device_environment.h"
1112
#include "shared/source/os_interface/device_factory.h"
1213
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1314

14-
#include "opencl/source/platform/platform.h"
1515
#include "opencl/test/unit_test/mocks/mock_platform.h"
1616

1717
namespace NEO {
1818

19-
ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_t rootDeviceEnvironments) {
19+
ExecutionEnvironment *getClExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_t rootDeviceEnvironments) {
2020
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
2121
executionEnvironment->prepareRootDeviceEnvironments(rootDeviceEnvironments);
2222
DebugManagerStateRestore restorer;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2018-2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <cstdint>
11+
12+
namespace NEO {
13+
class ExecutionEnvironment;
14+
struct HardwareInfo;
15+
ExecutionEnvironment *getClExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_t rootDeviceEnvironments);
16+
} // namespace NEO

opencl/test/unit_test/libult/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ set(IGDRCL_SRCS_LIB_ULT
2323
${NEO_SOURCE_DIR}/opencl/source/helpers/implicit_scaling_ocl.cpp
2424
${NEO_SOURCE_DIR}/opencl/source/memory_manager/compression_selector_ocl.cpp
2525
${NEO_SOURCE_DIR}/opencl/source/memory_manager/cpu_page_fault_manager_memory_sync.cpp
26-
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/execution_environment_helper.cpp
27-
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/execution_environment_helper.h
2826
${NEO_SOURCE_DIR}/shared/source/helpers/allow_deferred_deleter.cpp
27+
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/cl_execution_environment_helper.cpp
28+
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/cl_execution_environment_helper.h
2929
)
3030

3131
add_library(igdrcl_libult OBJECT EXCLUDE_FROM_ALL

opencl/test/unit_test/memory_manager/memory_manager_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "shared/source/program/program_initialization.h"
1919
#include "shared/test/common/helpers/debug_manager_state_restore.h"
2020
#include "shared/test/common/helpers/engine_descriptor_helper.h"
21+
#include "shared/test/common/helpers/execution_environment_helper.h"
2122
#include "shared/test/common/helpers/variable_backup.h"
2223
#include "shared/test/common/mocks/mock_allocation_properties.h"
2324
#include "shared/test/common/mocks/mock_csr.h"
@@ -46,7 +47,6 @@
4647
#include "opencl/test/unit_test/fixtures/memory_allocator_fixture.h"
4748
#include "opencl/test/unit_test/fixtures/memory_manager_fixture.h"
4849
#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
49-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
5050
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
5151
#include "opencl/test/unit_test/mocks/mock_context.h"
5252
#include "opencl/test/unit_test/mocks/mock_kernel.h"

opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
#include "shared/source/os_interface/linux/drm_neo.h"
1515
#include "shared/source/os_interface/os_interface.h"
1616
#include "shared/test/common/helpers/debug_manager_state_restore.h"
17+
#include "shared/test/common/helpers/execution_environment_helper.h"
1718
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
1819
#include "shared/test/common/test_macros/test.h"
1920
#include "shared/test/unit_test/fixtures/mock_aub_center_fixture.h"
2021

21-
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
22-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
23-
2422
#include "gtest/gtest.h"
2523

2624
#include <memory>
@@ -31,9 +29,14 @@ struct DeviceCommandStreamLeaksTest : ::testing::Test {
3129
void SetUp() override {
3230
HardwareInfo *hwInfo = nullptr;
3331
executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
32+
executionEnvironment->incRefInternal();
3433
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
3534
}
3635

36+
void TearDown() override {
37+
executionEnvironment->decRefInternal();
38+
}
39+
3740
ExecutionEnvironment *executionEnvironment;
3841
};
3942

opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "shared/test/common/helpers/debug_manager_state_restore.h"
2626
#include "shared/test/common/helpers/dispatch_flags_helper.h"
2727
#include "shared/test/common/helpers/engine_descriptor_helper.h"
28+
#include "shared/test/common/helpers/execution_environment_helper.h"
2829
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
2930
#include "shared/test/common/mocks/mock_allocation_properties.h"
3031
#include "shared/test/common/mocks/mock_gmm.h"
@@ -35,7 +36,6 @@
3536

3637
#include "opencl/source/mem_obj/buffer.h"
3738
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
38-
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
3939
#include "opencl/test/unit_test/mocks/mock_buffer.h"
4040
#include "opencl/test/unit_test/mocks/mock_program.h"
4141
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"

0 commit comments

Comments
 (0)