Skip to content

Commit 5e142af

Browse files
committed
[CPU] Enable OV_CPU_VERBOSE=info to print plugin relevant info
1 parent 3ed6162 commit 5e142af

File tree

9 files changed

+113
-48
lines changed

9 files changed

+113
-48
lines changed

src/core/include/openvino/core/parallel.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
#define OV_THREAD_SEQ 2
2323
#define OV_THREAD_TBB_AUTO 3
2424

25+
#if (OV_THREAD == OV_THREAD_TBB)
26+
# define OV_THREAD_NAME "TBB"
27+
#elif (OV_THREAD == OV_THREAD_OMP)
28+
# define OV_THREAD_NAME "OMP"
29+
#elif (OV_THREAD == OV_THREAD_SEQ)
30+
# define OV_THREAD_NAME "SEQ"
31+
#elif (OV_THREAD == OV_THREAD_TBB_AUTO)
32+
# define OV_THREAD_NAME "TBB_AUTO"
33+
#else
34+
# define OV_THREAD_NAME "UNKNOWN"
35+
#endif
36+
2537
#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO)
2638
# ifndef NOMINMAX
2739
# define NOMINMAX

src/plugins/intel_cpu/src/config.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <algorithm>
88
#include <cstdint>
9+
#include <cstdlib>
910
#include <map>
1011
#include <memory>
1112
#include <set>
@@ -21,6 +22,7 @@
2122
#include "openvino/runtime/intel_cpu/properties.hpp"
2223
#include "openvino/runtime/internal_properties.hpp"
2324
#include "openvino/runtime/properties.hpp"
25+
#include "openvino/util/env_util.hpp"
2426
#include "utils/debug_capabilities.h"
2527
#include "utils/general_utils.h"
2628
#include "utils/precision_support.h"
@@ -48,12 +50,16 @@ Config::Config() {
4850
*/
4951
void Config::applyDebugCapsProperties() {
5052
// always enable perf counters for verbose, performance summary and average counters
51-
if (!debugCaps.verbose.empty() || debugCaps.summaryPerf || !debugCaps.averageCountersPath.empty()) {
53+
if (!verbose.empty() || debugCaps.summaryPerf || !debugCaps.averageCountersPath.empty()) {
5254
collectPerfCounters = true;
5355
}
5456
}
5557
#endif
5658

59+
void Config::readEnvProperties() {
60+
verbose = ov::util::getenv_string("OV_CPU_VERBOSE");
61+
}
62+
5763
void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
5864
const auto streamExecutorConfigKeys =
5965
streamExecutorConfig.get_property(ov::supported_properties.name()).as<std::vector<std::string>>();
@@ -537,6 +543,9 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
537543
this->modelType = modelType;
538544

539545
CPU_DEBUG_CAP_ENABLE(applyDebugCapsProperties());
546+
547+
readEnvProperties();
548+
540549
updateProperties();
541550
}
542551

src/plugins/intel_cpu/src/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct Config {
5454
SnippetsMode snippetsMode = SnippetsMode::Enable;
5555
std::string dumpToDot;
5656
std::string device_id;
57+
std::string verbose;
5758
float fcSparseWeiDecompressionRate = 1.0F;
5859
uint64_t fcDynamicQuantizationGroupSize = 32;
5960
bool fcDynamicQuantizationGroupSizeSetExplicitly = false;
@@ -125,6 +126,7 @@ struct Config {
125126
// is reserved.
126127
bool DAZOn = false;
127128

129+
void readEnvProperties();
128130
void readProperties(const ov::AnyMap& prop, ModelType modelType = ModelType::Unknown);
129131

130132
void updateProperties();

src/plugins/intel_cpu/src/graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ class UpdateNodes : public UpdateNodesBase {
15911591
/* group all the profiling macros into a single one
15921592
* to avoid cluttering a core logic */
15931593
#define VERBOSE_PERF_DUMP_ITT_DEBUG_LOG(ittScope, node, config) \
1594-
VERBOSE(node, (config).debugCaps.verbose); \
1594+
VERBOSE(node, (config).verbose); \
15951595
PERF(node, (config).collectPerfCounters); \
15961596
DUMP(node, (config).debugCaps, infer_count); \
15971597
OV_ITT_SCOPED_TASK(ittScope, (node)->profiling.execute); \

src/plugins/intel_cpu/src/plugin.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
#include <fstream>
1010
#include <istream>
1111
#include <memory>
12+
#include <ostream>
1213
#include <set>
1314
#include <string>
1415
#include <tuple>
1516
#include <unordered_map>
1617
#include <utility>
1718
#include <vector>
19+
20+
#include "common/z_magic.hpp"
21+
#include "oneapi/dnnl/dnnl.hpp"
22+
#include "openvino/util/env_util.hpp"
1823
#if defined(__APPLE__)
1924
# include <sys/sysctl.h>
2025
# include <sys/types.h>
@@ -227,8 +232,41 @@ static std::string getDeviceFullName() {
227232
return brand_string;
228233
}
229234

235+
// Print basic CPU information once when OV_CPU_VERBOSE=info is set
236+
static void print_plugin_info_once() {
237+
static std::atomic_flag info_printed = ATOMIC_FLAG_INIT;
238+
// @todo To avoid dealing with environment variables in multiple places
239+
// read them all here and pass to CPU config as a parameter
240+
const auto& ov_cpu_verbose = ov::util::getenv_string("OV_CPU_VERBOSE");
241+
#if defined(CPU_DEBUG_CAPS)
242+
// in case of debug caps enabled print info if OV_CPU_VERBOSE is set to any value
243+
if (ov_cpu_verbose.empty()) {
244+
return;
245+
}
246+
#else
247+
if (ov_cpu_verbose != "info") {
248+
return;
249+
}
250+
#endif
251+
252+
// Print info only once
253+
if (info_printed.test_and_set()) {
254+
return;
255+
}
256+
257+
const auto& ov_version = ov::get_openvino_version();
258+
const auto& dnnl_version = dnnl::version();
259+
std::cout << "ov_cpu_verbose,info,intel_cpu_plugin,version: " << ov_version.buildNumber << '\n';
260+
std::cout << "ov_cpu_verbose,info,onednn,version: " << dnnl_version->major << "." << dnnl_version->minor << "."
261+
<< dnnl_version->patch << " (commit " << dnnl_version->hash << ")" << '\n';
262+
// @todo add more info regarding other backends if available
263+
std::cout << "ov_cpu_verbose,info,isa: " << dnnl::impl::cpu::x64::get_isa_info() << '\n';
264+
std::cout << "ov_cpu_verbose,info,intel_cpu_plugin,runtime: " << OV_THREAD_NAME << std::endl;
265+
}
266+
230267
Plugin::Plugin() : deviceFullName(getDeviceFullName()), specialSetup(new CPUSpecialSetup) {
231268
set_device_name("CPU");
269+
print_plugin_info_once();
232270
// Initialize Xbyak::util::Cpu object on Pcore for hybrid cores machine
233271
get_executor_manager()->execute_task_by_streams_executor(ov::hint::SchedulingCoreType::PCORE_ONLY, [] {
234272
dnnl::impl::cpu::x64::cpu();

src/plugins/intel_cpu/src/utils/debug_caps_config.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ void DebugCapsConfig::readProperties() {
3737
execGraphPath = envVarValue;
3838
}
3939

40-
if (const auto* envVarValue = readEnv("OV_CPU_VERBOSE")) {
41-
verbose = envVarValue;
42-
}
43-
4440
if (const auto* envVarValue = readEnv("OV_CPU_BLOB_DUMP_DIR")) {
4541
blobDumpDir = envVarValue;
4642
}

src/plugins/intel_cpu/src/utils/debug_caps_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class DebugCapsConfig {
4444

4545
std::string execGraphPath;
4646
std::string averageCountersPath;
47-
std::string verbose;
4847
std::string blobDumpDir = "cpu_dump";
4948
FORMAT blobDumpFormat = FORMAT::TEXT;
5049
std::unordered_map<FILTER, std::string> blobDumpFilters;

src/plugins/intel_cpu/src/utils/verbose.cpp

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
// Copyright (C) 2018-2025 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33
//
4-
#include <algorithm>
5-
#include <cstdint>
6-
#include <cstdio>
7-
#include <cstring>
8-
#include <utility>
9-
10-
#include "dnnl_extension_utils.h"
11-
#include "memory_desc/cpu_memory_desc.h"
12-
#include "onednn/iml_type_mapper.h"
13-
#include "utils/general_utils.h"
144
#ifdef CPU_DEBUG_CAPS
5+
# include "common/verbose.hpp"
156

167
# include <node.h>
178

9+
# include <algorithm>
10+
# include <cstdint>
11+
# include <cstdio>
1812
# include <cstdlib>
13+
# include <cstring>
1914
# include <iostream>
2015
# include <sstream>
2116
# include <string>
17+
# include <utility>
2218

2319
# include "common/c_types_map.hpp"
24-
# include "common/verbose.hpp"
2520
# include "cpu_types.h"
21+
# include "dnnl_extension_utils.h"
22+
# include "memory_desc/cpu_memory_desc.h"
2623
# include "memory_desc/cpu_memory_desc_utils.h"
24+
# include "onednn/iml_type_mapper.h"
25+
# include "utils/general_utils.h"
2726
# include "verbose.h"
2827

2928
namespace ov::intel_cpu {
3029

3130
bool Verbose::shouldBePrinted() const {
32-
if (lvl < 1) {
31+
if (m_lvl < 1) {
3332
return false;
3433
}
3534

36-
if (lvl < 2 && any_of(node->getType(), Type::Input, Type::Output)) {
35+
if (m_lvl < 2 && any_of(m_node->getType(), Type::Input, Type::Output)) {
3736
return false;
3837
}
3938

40-
const bool low_level = lvl < 3;
41-
const bool is_constant = node->isConstant();
39+
const bool low_level = m_lvl < 3;
40+
const bool is_constant = m_node->isConstant();
4241
const bool skip_node = low_level && is_constant;
4342
return !skip_node;
4443
}
@@ -53,7 +52,7 @@ void Verbose::printInfo() {
5352
enum Color : uint8_t { RED, GREEN, YELLOW, BLUE, PURPLE, CYAN };
5453

5554
auto colorize = [&](const Color color, const std::string& str) {
56-
if (!colorUp) {
55+
if (!m_colorUp) {
5756
return str;
5857
}
5958

@@ -146,22 +145,22 @@ void Verbose::printInfo() {
146145
shift(written);
147146
};
148147

149-
for (size_t i = 0; i < node->getParentEdges().size(); i++) {
148+
for (size_t i = 0; i < m_node->getParentEdges().size(); i++) {
150149
std::string prefix("src:" + std::to_string(i) + ':');
151-
const auto& desc = node->getParentEdgeAt(i)->getMemory().getDescPtr();
150+
const auto& desc = m_node->getParentEdgeAt(i)->getMemory().getDescPtr();
152151
formatMemDesc(desc, prefix);
153152
}
154153

155-
for (size_t i = 0; i < node->getChildEdges().size(); i++) {
154+
for (size_t i = 0; i < m_node->getChildEdges().size(); i++) {
156155
std::string prefix("dst:" + std::to_string(i) + ':');
157-
const auto& desc = node->getChildEdgeAt(i)->getMemory().getDescPtr();
156+
const auto& desc = m_node->getChildEdgeAt(i)->getMemory().getDescPtr();
158157
formatMemDesc(desc, prefix);
159158
}
160159

161160
std::string post_ops;
162-
if (!node->getFusedWith().empty()) {
161+
if (!m_node->getFusedWith().empty()) {
163162
post_ops += "post_ops:'";
164-
for (const auto& fusedNode : node->getFusedWith()) {
163+
for (const auto& fusedNode : m_node->getFusedWith()) {
165164
post_ops.append(colorize(GREEN, fusedNode->getName()))
166165
.append(":")
167166
.append(colorize(CYAN, NameFromType(fusedNode->getType())))
@@ -173,27 +172,27 @@ void Verbose::printInfo() {
173172
}
174173

175174
std::string nodeImplementer = "cpu";
176-
if (node->getType() == Type::Reference) {
175+
if (m_node->getType() == Type::Reference) {
177176
nodeImplementer = "ngraph_ref"; // ngraph reference
178177
}
179178

180-
const std::string& nodeName = colorize(GREEN, node->getName());
181-
const std::string& nodeType = colorize(CYAN, NameFromType(node->getType()));
182-
const std::string& nodeAlg = algToString(node->getAlgorithm());
179+
const std::string& nodeName = colorize(GREEN, m_node->getName());
180+
const std::string& nodeType = colorize(CYAN, NameFromType(m_node->getType()));
181+
const std::string& nodeAlg = algToString(m_node->getAlgorithm());
183182
const std::string& nodePrimImplType =
184-
impl_type_to_string(node->getSelectedPrimitiveDescriptor()->getImplementationType());
183+
impl_type_to_string(m_node->getSelectedPrimitiveDescriptor()->getImplementationType());
185184

186-
stream << "ov_cpu_verbose" << ',' << "exec" << ',' << nodeImplementer << ',' << nodeName << ":" << nodeType << ":"
187-
<< nodeAlg << ',' << nodePrimImplType << ',' << portsInfo << ',' << post_ops << ',';
185+
m_stream << "ov_cpu_verbose" << ',' << "exec" << ',' << nodeImplementer << ',' << nodeName << ":" << nodeType << ":"
186+
<< nodeAlg << ',' << nodePrimImplType << ',' << portsInfo << ',' << post_ops << ',';
188187
}
189188

190189
void Verbose::printDuration() {
191-
const auto& duration = node->PerfCounter().duration().count();
192-
stream << duration << "ms";
190+
const auto& duration = m_node->PerfCounter().duration().count();
191+
m_stream << duration << "ms";
193192
}
194193

195194
void Verbose::flush() const {
196-
std::cout << stream.rdbuf() << "\n";
195+
std::cout << m_stream.rdbuf() << "\n";
197196
}
198197

199198
} // namespace ov::intel_cpu

src/plugins/intel_cpu/src/utils/verbose.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,38 @@
44
#pragma once
55

66
#ifdef CPU_DEBUG_CAPS
7-
87
# include <node.h>
98

9+
# include <charconv>
1010
# include <cstdlib>
1111
# include <sstream>
1212
# include <string>
1313

1414
namespace ov::intel_cpu {
1515

16+
static int getLevel(const std::string& str) {
17+
int value = 0;
18+
19+
std::from_chars(str.data(), str.data() + str.size(), value);
20+
21+
return value;
22+
}
23+
1624
class Verbose {
1725
public:
18-
Verbose(const NodePtr& _node, const std::string& _lvl)
19-
: node(_node),
20-
lvl(atoi(_lvl.c_str()) % 10),
26+
Verbose(const NodePtr& _node, int _lvl)
27+
: m_node(_node),
28+
m_lvl(_lvl % 10),
2129
/* 1, 2, 3, etc -> no color. 11, 22, 33, etc -> colorize */
22-
colorUp((atoi(_lvl.c_str()) / 10) != 0) {
30+
m_colorUp(_lvl != 0) {
2331
if (!shouldBePrinted()) {
2432
return;
2533
}
2634
printInfo();
2735
}
2836

37+
Verbose(const NodePtr& _node, const std::string& _lvl) : Verbose(_node, getLevel(_lvl)) {}
38+
2939
~Verbose() {
3040
if (!shouldBePrinted()) {
3141
return;
@@ -36,10 +46,10 @@ class Verbose {
3646
}
3747

3848
private:
39-
const NodePtr& node;
40-
const int lvl;
41-
const bool colorUp;
42-
std::stringstream stream;
49+
const NodePtr& m_node;
50+
const int m_lvl;
51+
const bool m_colorUp;
52+
std::stringstream m_stream;
4353

4454
bool shouldBePrinted() const;
4555
void printInfo();

0 commit comments

Comments
 (0)