-
Notifications
You must be signed in to change notification settings - Fork 11
Add Debug.profiling_runtime_config consumer for aie_dtrace #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jyothees99
wants to merge
1
commit into
Xilinx:master
Choose a base branch
from
jyothees99:aie-dtrace-profiling-runtime-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved | ||
|
|
||
| #define XDP_CORE_SOURCE | ||
|
|
||
| #include <set> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| #include <boost/property_tree/json_parser.hpp> | ||
| #include <boost/property_tree/ptree.hpp> | ||
|
|
||
| #include "core/common/config_reader.h" | ||
| #include "core/common/message.h" | ||
|
|
||
| #include "xdp/profile/plugin/vp_base/profiling_runtime_config.h" | ||
|
|
||
| namespace xdp::profiling_runtime_config { | ||
|
|
||
| using severity_level = xrt_core::message::severity_level; | ||
| namespace pt = boost::property_tree; | ||
|
|
||
| namespace { | ||
|
|
||
| struct parsed_blob_t { | ||
| bool is_set = false; | ||
| bool has_ci = false; | ||
| control_instrumentation_t ci{}; | ||
| }; | ||
|
|
||
| // These helpers are only called from inside get_parsed()'s cached static | ||
| // initializer, so every message they emit fires at most once per process. | ||
| void | ||
| warn(const std::string& msg) | ||
| { | ||
| xrt_core::message::send(severity_level::warning, "XRT", msg); | ||
| } | ||
|
|
||
| void | ||
| info(const std::string& msg) | ||
| { | ||
| xrt_core::message::send(severity_level::info, "XRT", msg); | ||
| } | ||
|
|
||
| // Parse the control_instrumentation subtree: copy known string keys into | ||
| // the returned struct and warn about any unknown keys. | ||
| control_instrumentation_t | ||
| parse_control_instrumentation(const pt::ptree& ci_tree) | ||
| { | ||
| static const std::set<std::string> known_keys{ | ||
| "aie_tile", "mem_tile", "interface_tile" | ||
| }; | ||
|
|
||
| control_instrumentation_t ci; | ||
|
|
||
| for (const auto& kv : ci_tree) { | ||
| const auto& key = kv.first; | ||
| const auto value = kv.second.get_value<std::string>(""); | ||
|
|
||
| if (key == "aie_tile") { | ||
| ci.aie_tile = value; | ||
| if (!value.empty()) | ||
| info("profiling_runtime_config.control_instrumentation.aie_tile='" + value + "'"); | ||
| } | ||
| else if (key == "mem_tile") { | ||
| ci.mem_tile = value; | ||
| if (!value.empty()) | ||
| info("profiling_runtime_config.control_instrumentation.mem_tile='" + value + "'"); | ||
| } | ||
| else if (key == "interface_tile") { | ||
| ci.interface_tile = value; | ||
| if (!value.empty()) | ||
| info("profiling_runtime_config.control_instrumentation.interface_tile='" + value + "'"); | ||
| } | ||
| else { | ||
| std::stringstream msg; | ||
| msg << "Unknown key 'profiling_runtime_config.control_instrumentation." | ||
| << key << "' ignored. Supported keys:"; | ||
| const char* sep = " "; | ||
| for (const auto& k : known_keys) { | ||
| msg << sep << k; | ||
| sep = ", "; | ||
| } | ||
| warn(msg.str()); | ||
| } | ||
| } | ||
|
|
||
| return ci; | ||
| } | ||
|
|
||
| // Parse the root blob exactly once. | ||
| const parsed_blob_t& | ||
| get_parsed() | ||
| { | ||
| static const parsed_blob_t cached = [] { | ||
| parsed_blob_t out; | ||
|
|
||
| const std::string raw = xrt_core::config::get_profiling_runtime_config(); | ||
| if (raw.empty()) | ||
| return out; | ||
|
|
||
| try { | ||
| pt::ptree root; | ||
| std::istringstream is(raw); | ||
| pt::read_json(is, root); | ||
|
|
||
| out.is_set = true; | ||
|
|
||
| if (const auto ci_opt = root.get_child_optional("control_instrumentation")) { | ||
| out.ci = parse_control_instrumentation(*ci_opt); | ||
| out.has_ci = out.ci.aie_tile.has_value() | ||
| || out.ci.mem_tile.has_value() | ||
| || out.ci.interface_tile.has_value(); | ||
| } | ||
| } | ||
| catch (const std::exception& ex) { | ||
| warn(std::string("Failed to parse Debug.profiling_runtime_config " | ||
| "as JSON; ignoring runtime config. Details: ") | ||
| + ex.what()); | ||
| return parsed_blob_t{}; | ||
| } | ||
|
|
||
| return out; | ||
| }(); | ||
|
|
||
| return cached; | ||
| } | ||
|
|
||
| } // anonymous namespace | ||
|
|
||
| bool | ||
| is_set() | ||
| { | ||
| return get_parsed().is_set; | ||
| } | ||
|
|
||
| bool | ||
| has_control_instrumentation() | ||
| { | ||
| return get_parsed().has_ci; | ||
| } | ||
|
|
||
| const control_instrumentation_t& | ||
| control_instrumentation() | ||
| { | ||
| return get_parsed().ci; | ||
| } | ||
|
|
||
| bool | ||
| aie_dtrace_enabled() | ||
| { | ||
| static bool value = xrt_core::config::get_aie_dtrace() || has_control_instrumentation(); | ||
| return value; | ||
| } | ||
|
|
||
| } // namespace xdp::profiling_runtime_config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved | ||
|
|
||
| #ifndef PROFILING_RUNTIME_CONFIG_DOT_H | ||
| #define PROFILING_RUNTIME_CONFIG_DOT_H | ||
|
|
||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| #include "xdp/config.h" | ||
|
|
||
| // Parser for the XRT INI option Debug.profiling_runtime_config which holds | ||
| // an inline JSON blob describing XDP runtime configuration. Only the | ||
| // control_instrumentation section is consumed by this change; other top-level | ||
| // keys (event_trace, etc.) are accepted but ignored and may be wired up in a | ||
| // follow-up. | ||
| // | ||
| // The parser lives on the XDP side (xdp_core) so this code can evolve quickly | ||
| // without churning the stable xrt_coreutil interface. core/common/xdp/profile.cpp | ||
| // keeps a minimal independent probe for the load-time gate. | ||
| // | ||
| // Example blob: | ||
| // {"control_instrumentation":{"aie_tile":"func_stalls","mem_tile":"","interface_tile":"ddr_bandwidth"},"event_trace":{}} | ||
|
|
||
| namespace xdp::profiling_runtime_config { | ||
|
|
||
| struct control_instrumentation_t { | ||
| std::optional<std::string> aie_tile; // maps to "core" module internally | ||
| std::optional<std::string> mem_tile; // maps to "mem_tile" module internally | ||
| std::optional<std::string> interface_tile; // maps to "shim" module internally | ||
| }; | ||
|
|
||
| // True when the xrt.ini value is non-empty and parsed successfully. | ||
| XDP_CORE_EXPORT bool is_set(); | ||
|
|
||
| // True when is_set() and the blob contained a control_instrumentation object | ||
| // with at least one recognized key (aie_tile / mem_tile / interface_tile). | ||
| XDP_CORE_EXPORT bool has_control_instrumentation(); | ||
|
|
||
| // Returns the cached control_instrumentation view. Safe to call even when | ||
| // has_control_instrumentation() is false (all members will be empty). | ||
| XDP_CORE_EXPORT const control_instrumentation_t& control_instrumentation(); | ||
|
|
||
| // True if aie_dtrace should be active: either Debug.aie_dtrace is set in | ||
| // xrt.ini, or the runtime config blob carries a control_instrumentation | ||
| // section. Intended as the single gate for the aie_dtrace plugin guards. | ||
| XDP_CORE_EXPORT bool aie_dtrace_enabled(); | ||
|
|
||
| } // namespace xdp::profiling_runtime_config | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jyothees99 We want to keep supporting enabling dtrace with xrt.ini for non-VAIML flow. So, we need to include the xrt ini config check too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IshitaGhosh I am using xrt.ini value also to determine aie_dtrace_enabled. It's OR of xrt.ini and profile_runtime_config.