Skip to content

Commit dd0597b

Browse files
committed
readability run 1
1 parent 1cc0502 commit dd0597b

File tree

247 files changed

+2798
-2457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+2798
-2457
lines changed

src/plugins/intel_cpu/src/.clang-tidy

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
### NOTE:
44
# The 'Checks: >' is a multiline string here. Comment must not be moved into the string.
55
#
6-
### Scopes to be enabled:
7-
#
8-
# readability-*,
9-
#
106
### Checks that are turned off for a reason:
117
#
128
# -cppcoreguidelines-avoid-c-arrays. There are a lot of code which uses C-style arrays
@@ -52,8 +48,18 @@
5248
# -misc-header-include-cycle,
5349
# -misc-non-private-member-variables-in-classes,
5450
# -misc-use-anonymous-namespace,
55-
# -readability-magic-numbers, cppcoreguidelines-avoid-magic-numbers
51+
# -readability-avoid-nested-conditional-operator
52+
# -readability-avoid-return-with-void-value
53+
# -readability-const-return-type
54+
# -readability-convert-member-functions-to-static
5655
# -readability-function-cognitive-complexity. Reasonable way to enforce splitting complex code into simple functions
56+
# -readability-inconsistent-declaration-parameter-name
57+
# -readability-isolate-declaration
58+
# -readability-magic-numbers, cppcoreguidelines-avoid-magic-numbers
59+
# -readability-simplify-boolean-expr
60+
# -readability-static-accessed-through-instance
61+
# -readability-suspicious-call-argument
62+
# -readability-use-anyofallof
5763
# Remove warning disablement after CI pipeline migrates to C++17 from C++20 for:
5864
# -modernize-use-constraints,
5965
# -modernize-use-std-numbers
@@ -66,10 +72,7 @@ Checks: >
6672
google-*,
6773
modernize-*,
6874
misc-*,
69-
readability-container-size-empty,
70-
readability-else-after-return,
71-
readability-implicit-bool-conversion,
72-
readability-qualified-auto,
75+
readability-*,
7376
-bugprone-easily-swappable-parameters,
7477
-bugprone-exception-escape,
7578
-bugprone-implicit-widening-of-multiplication-result,
@@ -79,6 +82,7 @@ Checks: >
7982
-cppcoreguidelines-avoid-c-arrays,
8083
-cppcoreguidelines-avoid-const-or-ref-data-members,
8184
-cppcoreguidelines-avoid-do-while,
85+
-cppcoreguidelines-avoid-magic-numbers,
8286
-cppcoreguidelines-avoid-non-const-global-variables,
8387
-cppcoreguidelines-explicit-virtual-functions,
8488
-cppcoreguidelines-init-variables,
@@ -111,11 +115,20 @@ Checks: >
111115
-misc-no-recursion,
112116
-misc-non-private-member-variables-in-classes,
113117
-misc-use-anonymous-namespace,
118+
-readability-avoid-nested-conditional-operator,
119+
-readability-avoid-return-with-void-value,
120+
-readability-const-return-type,
121+
-readability-convert-member-functions-to-static,
122+
-readability-function-cognitive-complexity,
114123
-readability-identifier-length,
124+
-readability-inconsistent-declaration-parameter-name,
125+
-readability-isolate-declaration,
115126
-readability-magic-numbers,
116-
-cppcoreguidelines-avoid-magic-numbers,
127+
-readability-simplify-boolean-expr,
128+
-readability-static-accessed-through-instance,
129+
-readability-suspicious-call-argument,
117130
-readability-uppercase-literal-suffix,
118-
-readability-function-cognitive-complexity,
131+
-readability-use-anyofallof,
119132
# Treat warnings as errors
120133
WarningsAsErrors: '*'
121134
# Use clang-format for applied fixes
@@ -153,8 +166,7 @@ CheckOptions:
153166
.*/selective_build.h;
154167
src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_emitter.hpp;
155168
src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_emitter.cpp;
156-
### To be considered to enable:
157169
# Reasonable way to enforce splitting complex code into simple functions
158-
# - key: google-readability-function-size.StatementThreshold
159-
# value: "800"
170+
- key: readability-function-size.StatementThreshold
171+
value: "800"
160172
---

src/plugins/intel_cpu/src/compiled_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ CompiledModel::GraphGuard::Lock CompiledModel::get_graph() const {
192192
try {
193193
GraphContext::Ptr ctx;
194194
{
195-
std::lock_guard<std::mutex> lock{*m_mutex.get()};
195+
std::lock_guard<std::mutex> lock{*m_mutex};
196196
auto isQuantizedFlag = (m_cfg.lpTransformsMode == Config::On) &&
197197
ov::pass::low_precision::LowPrecision::isFunctionQuantized(m_model);
198198
ctx = std::make_shared<GraphContext>(m_cfg,

src/plugins/intel_cpu/src/config.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
177177
". Expected only true/false.");
178178
}
179179
} else if (key == ov::intel_cpu::sparse_weights_decompression_rate.name()) {
180-
float val_f = 0.0f;
180+
float val_f = 0.0F;
181181
try {
182182
val_f = val.as<float>();
183183
} catch (const ov::Exception&) {
184184
OPENVINO_THROW("Wrong value for property key ",
185185
ov::intel_cpu::sparse_weights_decompression_rate.name(),
186186
". Expected only float numbers");
187187
}
188-
if (val_f < 0.f || val_f > 1.f) {
188+
if (val_f < 0.F || val_f > 1.F) {
189189
OPENVINO_THROW("Wrong value for property key ",
190190
ov::intel_cpu::sparse_weights_decompression_rate.name(),
191191
". Sparse rate must be in range [0.0f,1.0f]");
@@ -523,12 +523,12 @@ void Config::updateProperties() {
523523
return;
524524
}
525525

526-
if (collectPerfCounters == true) {
526+
if (collectPerfCounters) {
527527
_config.insert({ov::enable_profiling.name(), "YES"});
528528
} else {
529529
_config.insert({ov::enable_profiling.name(), "NO"});
530530
}
531-
if (exclusiveAsyncRequests == true) {
531+
if (exclusiveAsyncRequests) {
532532
_config.insert({ov::internal::exclusive_async_requests.name(), "YES"});
533533
} else {
534534
_config.insert({ov::internal::exclusive_async_requests.name(), "NO"});

src/plugins/intel_cpu/src/cpu_memory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ BlockedMemoryDescPtr IMemory::getDescWithType<BlockedMemoryDesc, 0, 0>() const {
5858
namespace {
5959
inline void setSubnormalsToZeroAndbf16Saturation(float* data, size_t size, bool ftz, bool bf16saturation) {
6060
auto* u32data = reinterpret_cast<uint32_t*>(data);
61-
auto* floatdata = reinterpret_cast<float*>(data);
61+
auto* floatdata = data;
6262
if (ftz && bf16saturation) {
6363
for (size_t i = 0; i < size; ++i) {
6464
if ((u32data[i] & (0xFF << 23)) == 0) {
@@ -292,7 +292,7 @@ bool MemoryBlockWithReuse::hasExtBuffer() const noexcept {
292292

293293
void MemoryBlockWithReuse::free() {
294294
m_data = decltype(m_data)(nullptr, release);
295-
m_memUpperBound = 0ul;
295+
m_memUpperBound = 0UL;
296296
m_useExternalStorage = false;
297297
}
298298

@@ -627,7 +627,7 @@ bool mbind_move(void* data, size_t size, int targetNode) {
627627
mask = -1;
628628
flags = 0;
629629
} else {
630-
mask = 1ul << realNode;
630+
mask = 1UL << realNode;
631631
flags = MPOL_MF_MOVE | MPOL_MF_STRICT;
632632
}
633633

src/plugins/intel_cpu/src/cpu_streams_calculation.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ void sort_table_by_numa_node_id(const int current_numa_node, std::vector<std::ve
5252
}
5353
}
5454
}
55-
56-
return;
5755
};
5856

5957
std::vector<std::vector<int>> get_streams_info_table(
@@ -220,9 +218,8 @@ std::vector<std::vector<int>> get_streams_info_table(
220218
}
221219
}
222220

223-
if (((input_streams_changed == false) &&
224-
(input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY))) ||
225-
((input_streams_changed == true) && (input_streams == 1))) {
221+
if (((!input_streams_changed) && (input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY))) ||
222+
((input_streams_changed) && (input_streams == 1))) {
226223
n_streams = 1;
227224
stream_info[NUMBER_OF_STREAMS] = n_streams;
228225
for (auto& n : proc_socket_table) {
@@ -301,14 +298,14 @@ std::vector<std::vector<int>> get_streams_info_table(
301298
} else {
302299
n_threads =
303300
input_threads > 0 ? std::min(proc_type_table[0][ALL_PROC], input_threads) : proc_type_table[0][ALL_PROC];
304-
if ((input_streams_changed == true) && (input_streams > 0)) {
301+
if ((input_streams_changed) && (input_streams > 0)) {
305302
n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, input_streams) : input_streams;
306303
if (n_streams >= n_threads) {
307304
n_streams = n_threads;
308305
n_threads_per_stream = 1;
309306
} else {
310307
n_threads_per_stream =
311-
std::min(static_cast<int>(n_threads / n_streams),
308+
std::min((n_threads / n_streams),
312309
proc_type_table[0][MAIN_CORE_PROC] == 0 ? proc_type_table[0][EFFICIENT_CORE_PROC]
313310
: proc_type_table[0][MAIN_CORE_PROC]);
314311
check_threads_per_stream();
@@ -336,20 +333,20 @@ std::vector<std::vector<int>> get_streams_info_table(
336333
} else if (proc_type_table.size() == 1) {
337334
n_threads_per_stream = n_proc;
338335
} else {
339-
n_threads_per_stream = (n_proc > 16) ? 4 : std::max(1, static_cast<int>(n_proc / 4));
336+
n_threads_per_stream = (n_proc > 16) ? 4 : std::max(1, (n_proc / 4));
340337
}
341-
n_streams = static_cast<int>(n_threads / n_threads_per_stream);
338+
n_streams = (n_threads / n_threads_per_stream);
342339
if ((input_infer_requests > 0) && (n_streams > input_infer_requests)) {
343340
n_streams = input_infer_requests;
344341
if (proc_type_table.size() == 1) {
345-
n_threads_per_stream = std::min(static_cast<int>(n_threads / n_streams), n_proc);
342+
n_threads_per_stream = std::min((n_threads / n_streams), n_proc);
346343
} else {
347-
n_threads_per_stream = static_cast<int>(n_threads / n_streams);
344+
n_threads_per_stream = (n_threads / n_streams);
348345
}
349346
} else {
350347
while ((n_streams * 2 <= n_threads_per_stream) && (n_threads_per_stream > 1)) {
351-
n_threads_per_stream = static_cast<int>(n_threads_per_stream / 2);
352-
n_streams = static_cast<int>(n_threads / n_threads_per_stream);
348+
n_threads_per_stream = (n_threads_per_stream / 2);
349+
n_streams = (n_threads / n_threads_per_stream);
353350
}
354351
}
355352
} else if ((1 == model_prefer_threads) &&
@@ -358,8 +355,8 @@ std::vector<std::vector<int>> get_streams_info_table(
358355
(proc_type_table[0][MAIN_CORE_PROC] > 0) && (n_threads > proc_type_table[0][MAIN_CORE_PROC])) {
359356
n_streams = (n_threads >= proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][EFFICIENT_CORE_PROC] +
360357
proc_type_table[0][LP_EFFICIENT_CORE_PROC])
361-
? static_cast<int>(n_threads - proc_type_table[0][EFFICIENT_CORE_PROC] / 2 -
362-
proc_type_table[0][LP_EFFICIENT_CORE_PROC] / 2)
358+
? (n_threads - proc_type_table[0][EFFICIENT_CORE_PROC] / 2 -
359+
proc_type_table[0][LP_EFFICIENT_CORE_PROC] / 2)
363360
: static_cast<int>(proc_type_table[0][MAIN_CORE_PROC] +
364361
(n_threads - proc_type_table[0][MAIN_CORE_PROC]) / 2);
365362
n_streams = input_infer_requests > 0 ? std::min(n_streams, input_infer_requests) : n_streams;
@@ -371,10 +368,10 @@ std::vector<std::vector<int>> get_streams_info_table(
371368
n_streams = ((n_threads + model_threads - 1) / model_threads);
372369
if ((input_infer_requests > 0) && (n_streams > input_infer_requests)) {
373370
n_streams = input_infer_requests;
374-
n_threads_per_stream = static_cast<int>(n_threads / n_streams);
371+
n_threads_per_stream = (n_threads / n_streams);
375372
check_threads_per_stream();
376373
} else {
377-
n_threads_per_stream = model_threads > 0 ? model_threads : static_cast<int>(n_threads / n_streams);
374+
n_threads_per_stream = model_threads > 0 ? model_threads : (n_threads / n_streams);
378375
}
379376
}
380377
}
@@ -592,25 +589,25 @@ int get_model_prefer_threads(const int num_streams,
592589
}
593590
#else
594591
const auto isa = dnnl::get_effective_cpu_isa();
595-
float isaSpecificThreshold = 1.0f;
592+
float isaSpecificThreshold = 1.0F;
596593
switch (isa) {
597594
case dnnl::cpu_isa::sse41:
598-
isaSpecificThreshold = 0.5f;
595+
isaSpecificThreshold = 0.5F;
599596
break;
600597
case dnnl::cpu_isa::avx2:
601598
case dnnl::cpu_isa::avx512_core:
602-
isaSpecificThreshold = 1.0f;
599+
isaSpecificThreshold = 1.0F;
603600
break;
604601
case dnnl::cpu_isa::avx512_core_vnni:
605602
case dnnl::cpu_isa::avx2_vnni:
606603
case dnnl::cpu_isa::avx2_vnni_2:
607-
isaSpecificThreshold = 2.0f;
604+
isaSpecificThreshold = 2.0F;
608605
break;
609606
case dnnl::cpu_isa::avx512_core_amx:
610-
isaSpecificThreshold = 4.0f;
607+
isaSpecificThreshold = 4.0F;
611608
break;
612609
default:
613-
isaSpecificThreshold = 1.0f;
610+
isaSpecificThreshold = 1.0F;
614611
}
615612
// the more "capable" the CPU in general, the more streams we may want to keep to keep it utilized
616613
const float memThresholdAssumeLimitedForISA = ov::MemBandwidthPressure::LIMITED / isaSpecificThreshold;

src/plugins/intel_cpu/src/dnnl_extension_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ uint8_t DnnlExtensionUtils::sizeOfDataType(dnnl::memory::data_type dataType) {
6565

6666
std::optional<dnnl::memory::data_type> DnnlExtensionUtils::ElementTypeToDataType(
6767
const ov::element::Type& elementType,
68-
DnnlExtensionUtils::nothrow_tag) noexcept {
68+
DnnlExtensionUtils::nothrow_tag /*unused*/) noexcept {
6969
switch (elementType) {
7070
case ov::element::f32:
7171
return memory::data_type::f32;
@@ -105,7 +105,7 @@ std::optional<dnnl::memory::data_type> DnnlExtensionUtils::ElementTypeToDataType
105105
}
106106

107107
dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::element::Type& elementType,
108-
DnnlExtensionUtils::throw_tag) {
108+
DnnlExtensionUtils::throw_tag /*unused*/) {
109109
auto&& result = ElementTypeToDataType(elementType, nothrow_tag{});
110110
OPENVINO_ASSERT(result, "CPU plugin does not support ", elementType.to_string(), " for use with oneDNN.");
111111
return result.value();

0 commit comments

Comments
 (0)