Skip to content

Commit 03540d5

Browse files
Refactor per platform extra settings in ocloc
Signed-off-by: Kamil Kopryk <[email protected]> Related-To: NEO-6382
1 parent 515130d commit 03540d5

35 files changed

+359
-138
lines changed

level_zero/core/test/unit_tests/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ TestEnvironment *environment = nullptr;
5656
using namespace L0::ult;
5757

5858
PRODUCT_FAMILY productFamily = NEO::DEFAULT_TEST_PLATFORM::hwInfo.platform.eProductFamily;
59-
GFXCORE_FAMILY renderCoreFamily = NEO::DEFAULT_TEST_PLATFORM::hwInfo.platform.eRenderCoreFamily;
59+
extern GFXCORE_FAMILY renderCoreFamily;
6060
int32_t revId = -1;
6161
uint32_t euPerSubSlice = 0;
6262
uint32_t sliceCount = 0;

opencl/test/unit_test/gen12lp/rkl/test_hw_info_config_rkl.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "shared/source/helpers/compiler_hw_info_config.h"
89
#include "shared/source/os_interface/hw_info_config.h"
910
#include "shared/test/common/helpers/default_hw_info.h"
1011

@@ -37,3 +38,8 @@ RKLTEST_F(RklHwInfoConfig, givenHwInfoConfigWhenAskedIf3DPipelineSelectWAIsRequi
3738
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
3839
EXPECT_TRUE(hwInfoConfig.is3DPipelineSelectWARequired());
3940
}
41+
42+
using CompilerHwInfoConfigHelperTestsRkl = ::testing::Test;
43+
RKLTEST_F(CompilerHwInfoConfigHelperTestsRkl, givenRklWhenIsForceEmuInt32DivRemSPRequiredIsCalledThenReturnsTrue) {
44+
EXPECT_TRUE(CompilerHwInfoConfig::get(productFamily)->isForceEmuInt32DivRemSPRequired());
45+
}

opencl/test/unit_test/gen8/bdw/test_hw_info_config_bdw.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "shared/source/helpers/compiler_hw_info_config.h"
89
#include "shared/test/common/helpers/default_hw_info.h"
910

1011
#include "test.h"
@@ -77,3 +78,8 @@ BDWTEST_F(BdwHwInfo, givenHwInfoConfigStringThenAfterSetupResultingVmeIsDisabled
7778
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcPreemption);
7879
EXPECT_FALSE(hwInfo.capabilityTable.supportsVme);
7980
}
81+
82+
using CompilerHwInfoConfigHelperTestsBdw = ::testing::Test;
83+
BDWTEST_F(CompilerHwInfoConfigHelperTestsBdw, givenBdwWhenIsStatelessToStatefulBufferOffsetSupportedIsCalledThenReturnsTrue) {
84+
EXPECT_FALSE(CompilerHwInfoConfig::get(productFamily)->isStatelessToStatefulBufferOffsetSupported());
85+
}

opencl/test/unit_test/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool disabled = false;
6464
using namespace NEO;
6565

6666
PRODUCT_FAMILY productFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eProductFamily;
67-
GFXCORE_FAMILY renderCoreFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eRenderCoreFamily;
67+
extern GFXCORE_FAMILY renderCoreFamily;
6868

6969
extern std::string lastTest;
7070
bool generateRandomInput = false;

opencl/test/unit_test/offline_compiler/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set(IGDRCL_SRCS_offline_compiler_tests
6666
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.h
6767
${NEO_SHARED_TEST_DIRECTORY}/unit_test/device_binary_format/zebin_tests.h
6868
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/test_files.cpp
69+
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_excludes.cpp
6970
${IGDRCL_SRCS_cloc}
7071
${IGDRCL_SRCS_offline_compiler_mock}
7172
${NEO_CORE_tests_compiler_mocks}
@@ -90,9 +91,11 @@ link_directories(${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
9091
add_executable(ocloc_tests ${IGDRCL_SRCS_offline_compiler_tests})
9192

9293
target_include_directories(ocloc_tests PRIVATE
94+
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/header${BRANCH_DIR_SUFFIX}
95+
${NEO_SHARED_TEST_DIRECTORY}/common/test_configuration/unit_tests
9396
$<TARGET_PROPERTY:ocloc_lib,INCLUDE_DIRECTORIES>
9497
)
95-
target_compile_definitions(ocloc_tests PUBLIC MOCKABLE_VIRTUAL=virtual $<TARGET_PROPERTY:ocloc_lib,INTERFACE_COMPILE_DEFINITIONS>)
98+
target_compile_definitions(ocloc_tests PUBLIC MOCKABLE_VIRTUAL=virtual $<TARGET_PROPERTY:ocloc_lib,INTERFACE_COMPILE_DEFINITIONS> ${TESTED_GEN_FLAGS_DEFINITONS})
9699

97100
target_link_libraries(ocloc_tests gmock-gtest)
98101

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_GEN12LP)
8+
set(IGDRCL_SRCS_offline_compiler_tests_gen12lp
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
)
11+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_gen12lp})
12+
add_subdirectories()
13+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_RKL)
8+
set(IGDRCL_SRCS_offline_compiler_tests_rkl
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_rkl.cpp
11+
)
12+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_rkl})
13+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/compiler_interface/compiler_options/compiler_options.h"
9+
10+
#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h"
11+
#include "opencl/test/unit_test/offline_compiler/offline_compiler_tests.h"
12+
#include "test.h"
13+
14+
using namespace NEO;
15+
16+
using MockOfflineCompilerRklTests = ::testing::Test;
17+
RKLTEST_F(MockOfflineCompilerRklTests, givenRklWhenAppendExtraInternalOptionsThenForceEmuInt32DivRemSPIsApplied) {
18+
19+
MockOfflineCompiler mockOfflineCompiler;
20+
mockOfflineCompiler.deviceName = " rkl";
21+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
22+
std::string internalOptions = mockOfflineCompiler.internalOptions;
23+
mockOfflineCompiler.appendExtraInternalOptions(mockOfflineCompiler.hwInfo, internalOptions);
24+
size_t found = internalOptions.find(NEO::CompilerOptions::forceEmuInt32DivRemSP.data());
25+
EXPECT_NE(std::string::npos, found);
26+
}

opencl/test/unit_test/offline_compiler/gen8/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
if(TESTS_GEN8)
88
set(IGDRCL_SRCS_offline_compiler_tests_gen8
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10-
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_gen8.cpp
1110
)
1211
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_gen8})
12+
1313
add_subdirectories()
14+
1415
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_BDW)
8+
set(IGDRCL_SRCS_offline_compiler_tests_bdw
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_bdw.cpp
11+
)
12+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_bdw})
13+
14+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/compiler_interface/compiler_options/compiler_options.h"
9+
10+
#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h"
11+
#include "opencl/test/unit_test/offline_compiler/offline_compiler_tests.h"
12+
#include "test.h"
13+
14+
#include "gmock/gmock.h"
15+
16+
using namespace NEO;
17+
18+
using MockOfflineCompilerBdwTests = ::testing::Test;
19+
20+
BDWTEST_F(MockOfflineCompilerBdwTests, givenDebugOptionAndBdwThenInternalOptionShouldNotContainKernelDebugEnable) {
21+
std::vector<std::string> argv = {
22+
"ocloc",
23+
"-q",
24+
"-options",
25+
"-g",
26+
"-file",
27+
"test_files/copybuffer.cl",
28+
"-device",
29+
"bdw"};
30+
31+
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
32+
ASSERT_NE(nullptr, mockOfflineCompiler);
33+
mockOfflineCompiler->initialize(argv.size(), argv);
34+
35+
std::string internalOptions = mockOfflineCompiler->internalOptions;
36+
37+
EXPECT_THAT(internalOptions, Not(::testing::HasSubstr("-cl-kernel-debug-enable")));
38+
}
39+
40+
BDWTEST_F(MockOfflineCompilerBdwTests, GivenBdwWhenParseDebugSettingsThenContainsHasBufferOffsetArg) {
41+
MockOfflineCompiler mockOfflineCompiler;
42+
mockOfflineCompiler.deviceName = "bdw";
43+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
44+
45+
mockOfflineCompiler.parseDebugSettings();
46+
47+
std::string internalOptions = mockOfflineCompiler.internalOptions;
48+
size_t found = internalOptions.find(NEO::CompilerOptions::hasBufferOffsetArg.data());
49+
EXPECT_EQ(std::string::npos, found);
50+
}

opencl/test/unit_test/offline_compiler/gen8/offline_compiler_tests_gen8.cpp

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_GEN9)
8+
set(IGDRCL_SRCS_offline_compiler_tests_gen9
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
)
11+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_gen9})
12+
13+
add_subdirectories()
14+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_SKL)
8+
set(IGDRCL_SRCS_offline_compiler_tests_skl
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests_skl.cpp
11+
)
12+
target_sources(ocloc_tests PRIVATE ${IGDRCL_SRCS_offline_compiler_tests_skl})
13+
14+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/compiler_interface/compiler_options/compiler_options.h"
9+
#include "shared/source/debug_settings/debug_settings_manager.h"
10+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
11+
12+
#include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h"
13+
#include "opencl/test/unit_test/offline_compiler/offline_compiler_tests.h"
14+
#include "test.h"
15+
16+
namespace NEO {
17+
18+
using MockOfflineCompilerSklTests = ::testing::Test;
19+
20+
SKLTEST_F(MockOfflineCompilerSklTests, GivenSklWhenParseDebugSettingsThenStatelessToStatefullOptimizationIsEnabled) {
21+
MockOfflineCompiler mockOfflineCompiler;
22+
mockOfflineCompiler.deviceName = "skl";
23+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
24+
mockOfflineCompiler.parseDebugSettings();
25+
std::string internalOptions = mockOfflineCompiler.internalOptions;
26+
size_t found = internalOptions.find(NEO::CompilerOptions::hasBufferOffsetArg.data());
27+
EXPECT_NE(std::string::npos, found);
28+
}
29+
30+
SKLTEST_F(MockOfflineCompilerSklTests, GivenSklAndDisabledViaDebugThenStatelessToStatefullOptimizationDisabled) {
31+
DebugManagerStateRestore stateRestore;
32+
MockOfflineCompiler mockOfflineCompiler;
33+
mockOfflineCompiler.deviceName = "skl";
34+
DebugManager.flags.EnableStatelessToStatefulBufferOffsetOpt.set(0);
35+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
36+
mockOfflineCompiler.setStatelessToStatefullBufferOffsetFlag();
37+
std::string internalOptions = mockOfflineCompiler.internalOptions;
38+
size_t found = internalOptions.find(NEO::CompilerOptions::hasBufferOffsetArg.data());
39+
EXPECT_EQ(std::string::npos, found);
40+
}
41+
42+
SKLTEST_F(MockOfflineCompilerSklTests, givenSklWhenAppendExtraInternalOptionsThenForceEmuInt32DivRemSPIsNotApplied) {
43+
MockOfflineCompiler mockOfflineCompiler;
44+
mockOfflineCompiler.deviceName = "skl";
45+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
46+
std::string internalOptions = mockOfflineCompiler.internalOptions;
47+
mockOfflineCompiler.appendExtraInternalOptions(mockOfflineCompiler.hwInfo, internalOptions);
48+
size_t found = internalOptions.find(NEO::CompilerOptions::forceEmuInt32DivRemSP.data());
49+
EXPECT_EQ(std::string::npos, found);
50+
}
51+
52+
SKLTEST_F(MockOfflineCompilerSklTests, givenSklWhenAppendExtraInternalOptionsThenGreaterThan4gbBuffersRequiredIsNotSet) {
53+
MockOfflineCompiler mockOfflineCompiler;
54+
mockOfflineCompiler.deviceName = "skl";
55+
mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName);
56+
std::string internalOptions = mockOfflineCompiler.internalOptions;
57+
mockOfflineCompiler.forceStatelessToStatefulOptimization = false;
58+
mockOfflineCompiler.appendExtraInternalOptions(mockOfflineCompiler.hwInfo, internalOptions);
59+
size_t found = internalOptions.find(NEO::CompilerOptions::greaterThan4gbBuffersRequired.data());
60+
EXPECT_EQ(std::string::npos, found);
61+
}
62+
63+
} // namespace NEO

opencl/test/unit_test/offline_compiler/main.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const char *fSeparator = "/";
1919
#endif
2020

2121
Environment *gEnvironment;
22+
extern GFXCORE_FAMILY renderCoreFamily;
2223

2324
std::string getRunPath() {
2425
char *cwd;
@@ -79,6 +80,15 @@ int main(int argc, char **argv) {
7980
}
8081
}
8182

83+
for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) {
84+
if (NEO::hardwarePrefix[productId] && (0 == strcmp(devicePrefix.c_str(), NEO::hardwarePrefix[productId]))) {
85+
if (NEO::hardwareInfoTable[productId]) {
86+
renderCoreFamily = NEO::hardwareInfoTable[productId]->platform.eRenderCoreFamily;
87+
break;
88+
}
89+
}
90+
}
91+
8292
// we look for test files always relative to binary location
8393
// this simplifies multi-process execution and using different
8494
// working directories

opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ namespace NEO {
1414

1515
class MockOfflineCompiler : public OfflineCompiler {
1616
public:
17+
using OfflineCompiler::appendExtraInternalOptions;
1718
using OfflineCompiler::argHelper;
1819
using OfflineCompiler::deviceName;
1920
using OfflineCompiler::elfBinary;
2021
using OfflineCompiler::fclDeviceCtx;
22+
using OfflineCompiler::forceStatelessToStatefulOptimization;
2123
using OfflineCompiler::genBinary;
2224
using OfflineCompiler::genBinarySize;
2325
using OfflineCompiler::generateFilePathForIr;
2426
using OfflineCompiler::generateOptsSuffix;
25-
using OfflineCompiler::getHardwareInfo;
2627
using OfflineCompiler::getStringWithinDelimiters;
2728
using OfflineCompiler::hwInfo;
2829
using OfflineCompiler::igcDeviceCtx;
30+
using OfflineCompiler::initHardwareInfo;
2931
using OfflineCompiler::inputFileLlvm;
3032
using OfflineCompiler::inputFileSpirV;
3133
using OfflineCompiler::internalOptions;
@@ -37,6 +39,7 @@ class MockOfflineCompiler : public OfflineCompiler {
3739
using OfflineCompiler::outputFile;
3840
using OfflineCompiler::parseCommandLine;
3941
using OfflineCompiler::parseDebugSettings;
42+
using OfflineCompiler::setStatelessToStatefullBufferOffsetFlag;
4043
using OfflineCompiler::sourceCode;
4144
using OfflineCompiler::storeBinary;
4245
using OfflineCompiler::updateBuildLog;

0 commit comments

Comments
 (0)