Skip to content

Commit b0c915c

Browse files
jchodorCompute-Runtime-Automation
authored andcommitted
Optimizing binary size
Signed-off-by: Jaroslaw Chodor <[email protected]>
1 parent 5c9d43e commit b0c915c

File tree

8 files changed

+56
-18
lines changed

8 files changed

+56
-18
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2017-2020 Intel Corporation
2+
# Copyright (C) 2017-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -199,6 +199,12 @@ if(MSVC)
199199
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
200200
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
201201
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
202+
203+
string(REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
204+
add_definitions(-D_HAS_STATIC_RTTI=0)
205+
add_definitions(-DPURGE_DEBUG_KEY_NAMES=1)
206+
else()
207+
add_definitions(-DPURGE_DEBUG_KEY_NAMES=0)
202208
endif()
203209

204210
if(NOT SKIP_UNIT_TESTS)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ HWTEST_F(WddmDefaultTest, givenFtrWddmHwQueuesFlagWhenCreatingCsrThenPickWddmVer
912912
WddmCommandStreamReceiver<FamilyType> wddmCsr(*pDevice->executionEnvironment, 0, 1);
913913

914914
auto wddmFromCsr = wddmCsr.peekWddm();
915-
EXPECT_EQ(typeid(*wddmFromCsr), typeid(WddmMock));
915+
EXPECT_NE(nullptr, wddmFromCsr);
916916
}
917917

918918
struct WddmCsrCompressionTests : ::testing::Test {

opencl/test/unit_test/windows/wddm_create_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -23,5 +23,5 @@ TEST(wddmCreateTests, givenInputVersionWhenCreatingThenCreateRequestedObject) {
2323
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
2424
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
2525
std::unique_ptr<Wddm> wddm(Wddm::createWddm(std::move(hwDeviceIds[0]), rootDeviceEnvironment));
26-
EXPECT_EQ(typeid(*wddm.get()), typeid(Wddm));
26+
EXPECT_NE(nullptr, wddm);
2727
}

shared/source/debug_settings/debug_settings_manager.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -71,28 +71,41 @@ void DebugSettingsManager<DebugLevel>::dumpFlags() const {
7171
std::ofstream settingsDumpFile{settingsDumpFileName, std::ios::out};
7272
DEBUG_BREAK_IF(!settingsDumpFile.good());
7373

74-
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
75-
settingsDumpFile << #variableName << " = " << flags.variableName.get() << '\n'; \
76-
dumpNonDefaultFlag<dataType>(#variableName, flags.variableName.get(), defaultValue);
74+
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
75+
settingsDumpFile << getNonReleaseKeyName(#variableName) << " = " << flags.variableName.get() << '\n'; \
76+
dumpNonDefaultFlag<dataType>(getNonReleaseKeyName(#variableName), flags.variableName.get(), defaultValue);
77+
7778
if (registryReadAvailable() || isDebugKeysReadEnabled()) {
7879
#include "debug_variables.inl"
7980
}
81+
#undef DECLARE_DEBUG_VARIABLE
82+
83+
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
84+
settingsDumpFile << #variableName << " = " << flags.variableName.get() << '\n'; \
85+
dumpNonDefaultFlag<dataType>(#variableName, flags.variableName.get(), defaultValue);
8086
#include "release_variables.inl"
8187
#undef DECLARE_DEBUG_VARIABLE
8288
}
8389

8490
template <DebugFunctionalityLevel DebugLevel>
8591
void DebugSettingsManager<DebugLevel>::injectSettingsFromReader() {
8692
#undef DECLARE_DEBUG_VARIABLE
87-
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
88-
{ \
89-
dataType tempData = readerImpl->getSetting(#variableName, flags.variableName.get()); \
90-
flags.variableName.set(tempData); \
93+
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
94+
{ \
95+
dataType tempData = readerImpl->getSetting(getNonReleaseKeyName(#variableName), flags.variableName.get()); \
96+
flags.variableName.set(tempData); \
9197
}
9298

9399
if (registryReadAvailable() || isDebugKeysReadEnabled()) {
94100
#include "debug_variables.inl"
95101
}
102+
103+
#undef DECLARE_DEBUG_VARIABLE
104+
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
105+
{ \
106+
dataType tempData = readerImpl->getSetting(#variableName, flags.variableName.get()); \
107+
flags.variableName.set(tempData); \
108+
}
96109
#include "release_variables.inl"
97110
#undef DECLARE_DEBUG_VARIABLE
98111
}

shared/source/debug_settings/debug_settings_manager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -106,6 +106,10 @@ class DebugSettingsManager {
106106
return readerImpl.get();
107107
}
108108

109+
static constexpr const char *getNonReleaseKeyName(const char *key) {
110+
return (disabled() && PURGE_DEBUG_KEY_NAMES) ? "" : key;
111+
}
112+
109113
protected:
110114
std::unique_ptr<SettingsReader> readerImpl;
111115
std::mutex mtx;

shared/source/helpers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ set(NEO_CORE_HELPERS
8080
${CMAKE_CURRENT_SOURCE_DIR}/preamble.h
8181
${CMAKE_CURRENT_SOURCE_DIR}/preamble_base.inl
8282
${CMAKE_CURRENT_SOURCE_DIR}/preamble_bdw_plus.inl
83+
${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.h
8384
${CMAKE_CURRENT_SOURCE_DIR}/ptr_math.h
8485
${CMAKE_CURRENT_SOURCE_DIR}/register_offsets.h
8586
${CMAKE_CURRENT_SOURCE_DIR}/registered_method_dispatcher.h

shared/source/helpers/debug_helpers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
99
#include "shared/source/helpers/abort.h"
10+
#include "shared/source/helpers/preprocessor.h"
1011

11-
#define UNRECOVERABLE_IF(expression) \
12-
\
13-
if (expression) { \
14-
NEO::abortUnrecoverable(__LINE__, __FILE__); \
12+
#define UNRECOVERABLE_IF(expression) \
13+
if (expression) { \
14+
NEO::abortUnrecoverable(__LINE__, NEO_SOURCE_FILE_PATH); \
1515
}
1616

1717
#define UNREACHABLE(...) std::abort()
Lines changed: 14 additions & 0 deletions
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+
8+
#pragma once
9+
10+
#ifndef NEO_DISABLE_SOURCE_FILE_PATHS
11+
#define NEO_SOURCE_FILE_PATH __FILE__
12+
#else
13+
#define NEO_SOURCE_FILE_PATH ""
14+
#endif

0 commit comments

Comments
 (0)