Skip to content

Commit

Permalink
Fixes for PR cross-platform build, cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
ivberg committed Dec 20, 2023
1 parent d8097b2 commit 718ffb1
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 30 deletions.
3 changes: 2 additions & 1 deletion include/onnxruntime/core/common/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ unsigned int GetProcessId();
/**
If the ONNXRuntimeTraceLoggingProvider ETW Provider is enabled, then adds to the existing logger.
*/
std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogger, logging::Severity originalSeverity, logging::Severity etwSeverity);
std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogger, logging::Severity originalSeverity,
logging::Severity etwSeverity);

/**
If the ONNXRuntimeTraceLoggingProvider ETW Provider is enabled, then can override the logging level.
Expand Down
5 changes: 4 additions & 1 deletion onnxruntime/core/common/logging/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ unsigned int GetProcessId() {
#endif
}

std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogger, logging::Severity originalSeverity, logging::Severity etwSeverity) {
std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogger, logging::Severity originalSeverity,
logging::Severity etwSeverity) {
#ifdef _WIN32
auto& manager = EtwRegistrationManager::Instance();
if (manager.IsEnabled()) {
Expand All @@ -258,6 +259,8 @@ std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogge
}
#else
// On non-Windows platforms, just return the existing logger
(void)originalSeverity;
(void)etwSeverity;
return existingLogger;
#endif // _WIN32
}
Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/core/common/logging/sinks/composite_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <string>
#include <vector>
#include <utility>
#include <memory>

#include "core/common/logging/isink.h"
#include "core/common/logging/logging.h"
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/framework/execution_providers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include "core/graph/graph_viewer.h"
#include "core/common/logging/logging.h"
#ifdef _WIN32
#include <winmeta.h>
#include "core/platform/tracing.h"
#include "winmeta.h"
#endif

namespace onnxruntime {
Expand Down Expand Up @@ -48,7 +48,7 @@ class ExecutionProviders {
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptions",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(provider_id.c_str(), "ProviderId"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/framework/sequential_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class SessionScope {
}

auto& logger = session_state_.Logger();
VLOGS(logger, VERBOSE) << "Begin execution";
VLOGS(logger, 0) << "Begin execution";
const SequentialExecutionPlan& seq_exec_plan = *session_state_.GetExecutionPlan();
const auto& exec_plan_vec = seq_exec_plan.execution_plan;
VLOGS(logger, 1) << "Size of execution plan vector: " << exec_plan_vec.size();
Expand Down Expand Up @@ -515,7 +515,7 @@ onnxruntime::Status ExecuteKernel(StreamExecutionContext& ctx,
return Status(status.Category(), status.Code(), msg_string);
}
ctx.RecycleNodeInputs(idx);
VLOGS(logger, VERBOSE) << "stream " << stream_idx << " launch kernel with idx " << idx;
VLOGS(logger, 0) << "stream " << stream_idx << " launch kernel with idx " << idx;
return Status::OK();
}

Expand All @@ -531,7 +531,7 @@ onnxruntime::Status ExecuteThePlan(const SessionState& session_state, gsl::span<
const bool only_execute_path_to_fetches,
bool single_thread_mode) {
auto* execution_plan = session_state.GetExecutionPlan();
VLOGS(logger, VERBOSE) << "Number of streams: " << execution_plan->execution_plan.size();
VLOGS(logger, 0) << "Number of streams: " << execution_plan->execution_plan.size();
int32_t valid_streams = 0;
for (auto& stream : execution_plan->execution_plan) {
if (stream && stream->steps_.size() > 0)
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/framework/stream_execution_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void StreamExecutionContext::RecycleNodeInputs(onnxruntime::NodeIndex node_index
for (auto idx : execution_plan->node_release_list[node_index]) {
if (--release_plan_[idx] == 0) {
ORT_ENFORCE(frame_.ReleaseMLValue(static_cast<int>(execution_plan->release_actions[idx].value_index)).IsOK());
VLOGS(*logger_, VERBOSE) << "ort value " << execution_plan->release_actions[idx].value_index << " released";
VLOGS(*logger_, 0) << "ort value " << execution_plan->release_actions[idx].value_index << " released";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/platform/telemetry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ unsigned char Telemetry::Level() const {
}

// Get the current keyword
unsigned long long Telemetry::Keyword() const {
uint64_t Telemetry::Keyword() const {
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/platform/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Telemetry {
virtual unsigned char Level() const;

// Get the current keyword
virtual unsigned long long Keyword() const;
virtual uint64_t Keyword() const;

virtual void LogProcessInfo() const;

Expand Down
18 changes: 10 additions & 8 deletions onnxruntime/core/platform/windows/logging/etw_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ void EtwRegistrationManager::LazyInitialize() {
}
}

void EtwRegistrationManager::InvokeCallbacks(LPCGUID SourceId, ULONG IsEnabled, UCHAR Level, ULONGLONG MatchAnyKeyword, ULONGLONG MatchAllKeyword, PEVENT_FILTER_DESCRIPTOR FilterData, PVOID CallbackContext) {
void EtwRegistrationManager::InvokeCallbacks(LPCGUID SourceId, ULONG IsEnabled, UCHAR Level, ULONGLONG MatchAnyKeyword,
ULONGLONG MatchAllKeyword, PEVENT_FILTER_DESCRIPTOR FilterData,
PVOID CallbackContext) {
std::lock_guard<OrtMutex> lock(callbacks_mutex_);
for (const auto& callback : callbacks_) {
callback(SourceId, IsEnabled, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext);
Expand Down Expand Up @@ -176,13 +178,13 @@ void EtwSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id,
// TraceLoggingWrite requires (painfully) a compile time constant for the TraceLoggingLevel,
// forcing us to use an ugly macro for the call.
#define ETW_EVENT_NAME "ONNXRuntimeLogEvent"
#define TRACE_LOG_WRITE(level) \
TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \
TraceLoggingKeyword(static_cast<ULONGLONG>(onnxruntime::logging::TLKeyword::Logs)), \
TraceLoggingLevel(level), \
TraceLoggingString(logger_id.c_str(), "logger"), \
TraceLoggingString(message.Category(), "category"), \
TraceLoggingString(message.Location().ToString().c_str(), "location"), \
#define TRACE_LOG_WRITE(level) \
TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Logs)), \
TraceLoggingLevel(level), \
TraceLoggingString(logger_id.c_str(), "logger"), \
TraceLoggingString(message.Category(), "category"), \
TraceLoggingString(message.Location().ToString().c_str(), "location"), \
TraceLoggingString(message.Message().c_str(), "message"))

const auto severity{message.Severity()};
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/platform/windows/logging/etw_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class EtwRegistrationManager {
Severity MapLevelToSeverity();

// Get the current keyword
ULONGLONG Keyword() const;
uint64_t Keyword() const;

// Get the ETW registration status
HRESULT Status() const;
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/platform/windows/telemetry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ uint32_t WindowsTelemetry::global_register_count_ = 0;
bool WindowsTelemetry::enabled_ = true;
uint32_t WindowsTelemetry::projection_ = 0;
UCHAR WindowsTelemetry::level_ = 0;
ULONGLONG WindowsTelemetry::keyword_ = 0;
UINT64 WindowsTelemetry::keyword_ = 0;

WindowsTelemetry::WindowsTelemetry() {
std::lock_guard<OrtMutex> lock(mutex_);
Expand Down Expand Up @@ -95,7 +95,7 @@ UCHAR WindowsTelemetry::Level() const {
return level_;
}

ULONGLONG WindowsTelemetry::Keyword() const {
UINT64 WindowsTelemetry::Keyword() const {
std::lock_guard<OrtMutex> lock(provider_change_mutex_);
return keyword_;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ void WindowsTelemetry::LogSessionCreation(uint32_t session_id, int64_t ir_versio
TraceLoggingBool(true, "UTCReplace_AppSessionGuid"),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
// Telemetry info
TraceLoggingUInt8(0, "schemaVersion"),
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/platform/windows/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class WindowsTelemetry : public Telemetry {
unsigned char Level() const override;

// Get the current keyword
unsigned long long Keyword() const override;
UINT64 Keyword() const override;

// Get the ETW registration status
// static HRESULT Status();
Expand Down
10 changes: 8 additions & 2 deletions onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "core/providers/qnn/builder/onnx_ctx_model_helper.h"

#ifdef _WIN32
#include <winmeta.h>
#include "core/platform/tracing.h"
#include "winmeta.h"
#endif

// Flag to determine if Backend should do node validation for each opNode added
Expand Down Expand Up @@ -943,6 +943,10 @@ Status QnnBackendManager::ExtractProfilingEventBasic(
std::string message = GetEventTypeString(event_data.type);
std::string unit = GetUnitString(event_data.unit);

#ifndef _WIN32
tracelogging_provider_ep_enabled = false;
#endif

if (!tracelogging_provider_ep_enabled) {
outfile << "UNKNOWN"
<< ","
Expand Down Expand Up @@ -1013,10 +1017,11 @@ void QnnBackendManager::LogQnnProfileEventAsTraceLogging(
const std::string& timingSource,
const std::string& eventLevel,
const char* eventIdentifier) {
#ifdef _WIN32
TraceLoggingWrite(
telemetry_provider_handle,
"QNNProfilingEvent",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Profiling)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Profiling)),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingValue(timestamp, "Timestamp"),
TraceLoggingString(message.c_str(), "Message"),
Expand All @@ -1025,6 +1030,7 @@ void QnnBackendManager::LogQnnProfileEventAsTraceLogging(
TraceLoggingString(timingSource.c_str(), "Timing Source"),
TraceLoggingString(eventLevel.c_str(), "Event Level"),
TraceLoggingString(eventIdentifier, "Event Identifier"));
#endif
}

const std::string& QnnBackendManager::GetUnitString(QnnProfile_EventUnit_t unitType) {
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/session/inference_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
#ifdef _WIN32
TraceLoggingWrite(telemetry_provider_handle,
"SessionOptions",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingUInt8(static_cast<UINT8>(session_options.execution_mode), "execution_mode"),
TraceLoggingUInt8(static_cast<UINT8>(session_options.execution_order), "execution_order"),
Expand All @@ -501,7 +501,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
TraceLoggingWrite(
telemetry_provider_handle,
"SessionOptions_IntraOrtThreadPoolParams",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingInt32(session_options.intra_op_param.thread_pool_size, "thread_pool_size"),
TraceLoggingBoolean(session_options.intra_op_param.auto_set_affinity, "auto_set_affinity"),
Expand All @@ -515,7 +515,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
TraceLoggingWrite(
telemetry_provider_handle,
"SessionOptions_ConfigEntry",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(config_pair.first.c_str(), "Key"),
TraceLoggingString(config_pair.second.c_str(), "Value"));
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/session/provider_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider,
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptionsAppendExecutionProvider",
TraceLoggingKeyword(static_cast<unsigned long long>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TLKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(provider_name, "ProviderName"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The ETW Sink (ONNXRuntimeTraceLoggingProvider) allows ONNX semi-structured print
ETW makes it easy and useful to only enable and listen for events with great performance, and when you need them instead of only at compile time.
Therefore ONNX will preserve any existing loggers and log severity [provided at compile time](docs/FAQ.md?plain=1#L7).

However, when the provider is enabled a new ETW logger sink will also be added and the severity seperately controlled via ETW dynamically.
However, when the provider is enabled a new ETW logger sink will also be added and the severity separately controlled via ETW dynamically.

- Provider GUID: 929DD115-1ECB-4CB5-B060-EBD4983C421D
- Keyword: Logs (0x2) keyword per [logging.h](include\onnxruntime\core\common\logging\logging.h)
Expand Down

0 comments on commit 718ffb1

Please sign in to comment.