Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/plugins/intel_cpu/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <map>
#include <memory>
#include <set>
Expand All @@ -22,6 +23,7 @@
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/env_util.hpp"
#include "utils/debug_capabilities.h"
#include "utils/general_utils.h"
#include "utils/precision_support.h"
Expand Down Expand Up @@ -49,12 +51,16 @@ Config::Config() {
*/
void Config::applyDebugCapsProperties() {
// always enable perf counters for verbose, performance summary and average counters
if (!debugCaps.verbose.empty() || debugCaps.summaryPerf || !debugCaps.averageCountersPath.empty()) {
if (!verbose.empty() || debugCaps.summaryPerf || !debugCaps.averageCountersPath.empty()) {
collectPerfCounters = true;
}
}
#endif

void Config::readEnvProperties() {
verbose = ov::util::getenv_string("OV_CPU_VERBOSE");
}

void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
const auto streamExecutorConfigKeys =
streamExecutorConfig.get_property(ov::supported_properties.name()).as<std::vector<std::string>>();
Expand Down Expand Up @@ -558,6 +564,9 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
this->modelType = modelType;

CPU_DEBUG_CAP_ENABLE(applyDebugCapsProperties());

readEnvProperties();

updateProperties();
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/intel_cpu/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct Config {
SnippetsMode snippetsMode = SnippetsMode::Enable;
std::string dumpToDot;
std::string device_id;
std::string verbose;
float fcSparseWeiDecompressionRate = 1.0F;
uint64_t fcDynamicQuantizationGroupSize = 32;
bool fcDynamicQuantizationGroupSizeSetExplicitly = false;
Expand Down Expand Up @@ -127,6 +128,7 @@ struct Config {
// is reserved.
bool DAZOn = false;

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

void updateProperties();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_cpu/src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#include "utils/debug_capabilities.h"
#include "utils/general_utils.h"
#include "utils/node_dumper.h"
#include "utils/verbose.h"
#include "utils/verbose_helper.h"
#include "weights_cache.hpp"

#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO || OV_THREAD == OV_THREAD_TBB_ADAPTIVE || \
Expand Down Expand Up @@ -1600,7 +1600,7 @@ class UpdateNodes : public UpdateNodesBase {
/* group all the profiling macros into a single one
* to avoid cluttering a core logic */
#define VERBOSE_PERF_DUMP_ITT_DEBUG_LOG(ittScope, node, config) \
VERBOSE(node, (config).debugCaps.verbose); \
VERBOSE(node, (config).verbose); \
PERF(node, (config).collectPerfCounters); \
DUMP(node, (config).debugCaps, infer_count); \
OV_ITT_SCOPED_TASK_BASE(ittScope, (node)->perfCounters().execute); \
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/intel_cpu/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <unordered_map>
#include <utility>
#include <vector>

#include "utils/verbose.h"
#if defined(__APPLE__)
# include <sys/sysctl.h>
# include <sys/types.h>
Expand Down Expand Up @@ -240,6 +242,7 @@ Plugin::Plugin() : deviceFullName(getDeviceFullName()), specialSetup(new CPUSpec
const auto& ov_version = ov::get_openvino_version();
m_compiled_model_runtime_properties["OV_VERSION"] = std::string(ov_version.buildNumber);
m_msg_manager = ov::threading::message_manager();
printPluginInfoOnce();
}

Plugin::~Plugin() {
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/intel_cpu/src/utils/debug_caps_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ void DebugCapsConfig::readProperties() {
execGraphPath = envVarValue;
}

if (const auto* envVarValue = readEnv("OV_CPU_VERBOSE")) {
verbose = envVarValue;
}

if (const auto* envVarValue = readEnv("OV_CPU_BLOB_DUMP_DIR")) {
blobDumpDir = envVarValue;
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/intel_cpu/src/utils/debug_caps_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class DebugCapsConfig {

std::string execGraphPath;
std::string averageCountersPath;
std::string verbose;
std::string blobDumpDir = "cpu_dump";
FORMAT blobDumpFormat = FORMAT::TEXT;
std::unordered_map<FILTER, std::string> blobDumpFilters;
Expand Down
30 changes: 30 additions & 0 deletions src/plugins/intel_cpu/src/utils/threading.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "openvino/core/parallel.hpp"

namespace ov::intel_cpu {

constexpr const char* threadingType() {
constexpr auto tbb_mode = OV_THREAD;

switch (tbb_mode) {
case OV_THREAD_TBB:
return "TBB";
case OV_THREAD_OMP:
return "OMP";
case OV_THREAD_SEQ:
return "SEQ";
case OV_THREAD_TBB_AUTO:
return "TBB_AUTO";
case OV_THREAD_TBB_ADAPTIVE:
return "TBB_ADAPTIVE";
default: // never expected, but cannot throw in constexpr context
return "UNKNOWN";
}
}

} // namespace ov::intel_cpu
105 changes: 69 additions & 36 deletions src/plugins/intel_cpu/src/utils/verbose.cpp
Original file line number Diff line number Diff line change
@@ -1,55 +1,44 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "verbose.h"

#include <node.h>

#include <algorithm>
#include <atomic>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>

#include "common/c_types_map.hpp"
#include "common/verbose.hpp"
#include "cpu/platform.hpp"
#include "cpu_types.h"
#include "dnnl_extension_utils.h"
#include "memory_desc/cpu_memory_desc.h"
#include "memory_desc/cpu_memory_desc_utils.h"
#include "oneapi/dnnl/dnnl.hpp"
#include "onednn/iml_type_mapper.h"
#include "utils/general_utils.h"
#ifdef CPU_DEBUG_CAPS

# include <node.h>

# include <cstdlib>
# include <iostream>
# include <sstream>
# include <string>

# include "common/c_types_map.hpp"
# include "common/verbose.hpp"
# include "cpu_types.h"
# include "memory_desc/cpu_memory_desc_utils.h"
# include "verbose.h"
#include "openvino/core/log_util.hpp"
#include "openvino/core/version.hpp"
#include "openvino/util/env_util.hpp"
#include "utils/threading.hpp"

namespace ov::intel_cpu {

bool Verbose::shouldBePrinted() const {
if (lvl < 1) {
return false;
}

if (lvl < 2 && any_of(node->getType(), Type::Input, Type::Output)) {
return false;
}

const bool low_level = lvl < 3;
const bool is_constant = node->isConstant();
const bool skip_node = low_level && is_constant;
return !skip_node;
}

/**
* Print node verbose execution information to cout.
* Similiar to DNNL_VERBOSE output
* Formating written in C using oneDNN format functions.
* Can be rewritten in pure C++ if necessary
*/
void Verbose::printInfo() {
std::stringstream& printInfo(std::stringstream& stream, const NodePtr& node, bool colorUp) {
enum Color : uint8_t { RED, GREEN, YELLOW, BLUE, PURPLE, CYAN };

auto colorize = [&](const Color color, const std::string& str) {
Expand Down Expand Up @@ -185,17 +174,61 @@ void Verbose::printInfo() {

stream << "ov_cpu_verbose" << ',' << "exec" << ',' << nodeImplementer << ',' << nodeName << ":" << nodeType << ":"
<< nodeAlg << ',' << nodePrimImplType << ',' << portsInfo << ',' << post_ops << ',';
return stream;
}

void Verbose::printDuration() {
std::stringstream& printDuration(std::stringstream& stream, const NodePtr& node) {
const auto& duration = node->PerfCounter().duration().count();
stream << duration << "ms";
return stream;
}

void Verbose::flush() const {
std::cout << stream.rdbuf() << "\n";
template <typename... Args>
void log(Args&&... args) {
std::ostringstream oss;
(oss << ... << std::forward<Args>(args));
ov::util::log_message(oss.str());
}

} // namespace ov::intel_cpu
static void printPluginInfo() {
const auto& ov_version = ov::get_openvino_version();
const auto& dnnl_version = dnnl::version();
log("ov_cpu_verbose,info,intel_cpu_plugin,version: ", ov_version.buildNumber);
log("ov_cpu_verbose,info,onednn,version: ",
dnnl_version->major,
".",
dnnl_version->minor,
".",
dnnl_version->patch,
" (commit ",
dnnl_version->hash,
")");
// @todo add more info regarding other backends if available
log("ov_cpu_verbose,info,isa: ", dnnl::impl::cpu::platform::get_isa_info());
log("ov_cpu_verbose,info,intel_cpu_plugin,runtime: ", threadingType());
}

void printPluginInfoOnce() {
static std::atomic_flag infoPrinted = ATOMIC_FLAG_INIT;
if (infoPrinted.test_and_set()) {
return;
}

// @todo To avoid dealing with environment variables in multiple places
// read them all in one place and pass to CPU plugin / config as a parameter
const auto& ovCpuVerbose = ov::util::getenv_string("OV_CPU_VERBOSE");
#if defined(CPU_DEBUG_CAPS)
// in case of debug caps enabled print info if OV_CPU_VERBOSE is set to any value
if (ovCpuVerbose.empty()) {
return;
}
#else
if (ovCpuVerbose != "info") {
return;
}
#endif

#endif // CPU_DEBUG_CAPS
printPluginInfo();
}

} // namespace ov::intel_cpu
52 changes: 5 additions & 47 deletions src/plugins/intel_cpu/src/utils/verbose.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <sstream>

#ifdef CPU_DEBUG_CAPS

# include <node.h>

# include <cstdlib>
# include <sstream>
# include <string>
#include "node.h"

namespace ov::intel_cpu {

class Verbose {
public:
Verbose(const NodePtr& _node, const std::string& _lvl)
: node(_node),
lvl(atoi(_lvl.c_str()) % 10),
/* 1, 2, 3, etc -> no color. 11, 22, 33, etc -> colorize */
colorUp((atoi(_lvl.c_str()) / 10) != 0) {
if (!shouldBePrinted()) {
return;
}
printInfo();
}

~Verbose() {
if (!shouldBePrinted()) {
return;
}

printDuration();
flush();
}

private:
const NodePtr& node;
const int lvl;
const bool colorUp;
std::stringstream stream;

bool shouldBePrinted() const;
void printInfo();
void printDuration();
void flush() const;
};

// use heap allocation instead of stack to align with PERF macro (to have proper destruction order)
# define VERBOSE(...) const auto verbose = std::unique_ptr<Verbose>(new Verbose(__VA_ARGS__));
std::stringstream& printInfo(std::stringstream& stream, const NodePtr& node, bool colorUp);
std::stringstream& printDuration(std::stringstream& stream, const NodePtr& node);
void printPluginInfoOnce();
} // namespace ov::intel_cpu

#else
# define VERBOSE(...)
#endif // CPU_DEBUG_CAPS
42 changes: 42 additions & 0 deletions src/plugins/intel_cpu/src/utils/verbose_helper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#ifdef CPU_DEBUG_CAPS
# include "verbose_helper.h"

# include <node.h>

# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <iostream>
# include <ostream>
# include <sstream>

# include "cpu_types.h"
# include "utils/general_utils.h"

namespace ov::intel_cpu {

bool Verbose::shouldBePrinted() const {
if (m_lvl < 1) {
return false;
}

if (m_lvl < 2 && any_of(m_node->getType(), Type::Input, Type::Output)) {
return false;
}

const bool low_level = m_lvl < 3;
const bool is_constant = m_node->isConstant();
const bool skip_node = low_level && is_constant;
return !skip_node;
}

void Verbose::flush() const {
std::cout << m_stream.rdbuf() << '\n';
}

} // namespace ov::intel_cpu

#endif // CPU_DEBUG_CAPS
Loading
Loading