Repository navigation
[rocprof-sys]: Replace CPU and sampling event timestamps with CLOCK_BOOTTIME to match GPU traces #11667
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
Merged
Merged
[rocprof-sys]: Replace CPU and sampling event timestamps with CLOCK_BOOTTIME to match GPU traces #11667
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3794382
Sync clock to CLOCK_BOOTTIME for CPU tracks
sputhala-amd 682bc77
clang-tidy fixes
sputhala-amd 0bdf50f
Revert sample timer changes
sputhala-amd b6572f3
Calng-tidy fixes
sputhala-amd 4c8ea46
Add stateless timeline function
sputhala-amd ef513c1
Remote BOOTTIME probe at initialize
sputhala-amd 388dfbd
Clang-tidy fixes
sputhala-amd 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
40 changes: 40 additions & 0 deletions
40
projects/rocprofiler-systems/source/lib/core/control/clocks/timeline.hpp
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,40 @@ | ||
| // Copyright (c) Advanced Micro Devices, Inc. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
| #include <cstdint> | ||
| #include <ctime> | ||
| #include <time.h> | ||
|
|
||
| namespace rocprofsys::control::clocks | ||
| { | ||
| /// Absolute timeline clock for CPU and call-stack event stamps. | ||
| /// Matches the host domain used by rocprofiler-sdk (`CLOCK_BOOTTIME`). | ||
| [[nodiscard]] inline bool | ||
| timeline_available() noexcept | ||
| { | ||
| struct timespec specs = {}; | ||
| return clock_gettime(CLOCK_BOOTTIME, &specs) == 0; | ||
| } | ||
|
|
||
| [[nodiscard]] inline std::chrono::nanoseconds | ||
| timeline_now() noexcept | ||
| { | ||
| struct timespec specs = {}; | ||
| if(clock_gettime(CLOCK_BOOTTIME, &specs) != 0) | ||
| { | ||
| return std::chrono::nanoseconds::zero(); | ||
| } | ||
| return std::chrono::seconds{ specs.tv_sec } + | ||
| std::chrono::nanoseconds{ specs.tv_nsec }; | ||
| } | ||
|
|
||
| template <typename Tp = std::uint64_t> | ||
| [[nodiscard]] inline Tp | ||
| timeline_ns() noexcept | ||
| { | ||
| return static_cast<Tp>(timeline_now().count()); | ||
| } | ||
| } // namespace rocprofsys::control::clocks |
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
43 changes: 43 additions & 0 deletions
43
projects/rocprofiler-systems/source/lib/core/control/tests/test_timeline.cpp
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,43 @@ | ||
| // Copyright (c) Advanced Micro Devices, Inc. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "core/control/clocks/timeline.hpp" | ||
|
|
||
| #include <cstdint> | ||
| #include <gtest/gtest.h> | ||
| #include <ratio> | ||
| #include <time.h> | ||
|
|
||
| namespace | ||
| { | ||
| using rocprofsys::control::clocks::timeline_available; | ||
| using rocprofsys::control::clocks::timeline_now; | ||
| using rocprofsys::control::clocks::timeline_ns; | ||
|
|
||
| std::uint64_t | ||
| read_boottime_ns() | ||
| { | ||
| timespec specs{}; | ||
| EXPECT_EQ(clock_gettime(CLOCK_BOOTTIME, &specs), 0); | ||
| return static_cast<std::uint64_t>(specs.tv_sec) * std::nano::den + | ||
| static_cast<std::uint64_t>(specs.tv_nsec); | ||
| } | ||
| } // namespace | ||
|
|
||
| TEST(timeline_clock_test, available_on_linux) { EXPECT_TRUE(timeline_available()); } | ||
|
|
||
| TEST(timeline_clock_test, uses_clock_boottime) | ||
| { | ||
| ASSERT_TRUE(timeline_available()); | ||
| const auto before_duration = read_boottime_ns(); | ||
| const auto now_duration = timeline_now(); | ||
| const auto after_duration = read_boottime_ns(); | ||
| EXPECT_LE(before_duration, static_cast<std::uint64_t>(now_duration.count())); | ||
| EXPECT_LE(static_cast<std::uint64_t>(now_duration.count()), after_duration); | ||
|
|
||
| const auto before_ns = read_boottime_ns(); | ||
| const auto now_ns = timeline_ns(); | ||
| const auto after_ns = read_boottime_ns(); | ||
| EXPECT_LE(before_ns, now_ns); | ||
| EXPECT_LE(now_ns, after_ns); | ||
| } |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.