-
Notifications
You must be signed in to change notification settings - Fork 337
Use spdlog for logging in Gloo #470
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
jackbondpreston-arm
wants to merge
4
commits into
pytorch:main
Choose a base branch
from
jackbondpreston-arm:jack/spdlog-main
base: main
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9facc40
Add third-party spdlog (v1.15.3) as a submodule
jackbondpreston-arm 2122920
build: Add spdlog build dependency
jackbondpreston-arm aeaea26
Use spdlog for logging in Gloo
jackbondpreston-arm 3b85da0
Replace cout usages with logger calls
jackbondpreston-arm 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,3 @@ | ||
| [submodule "third_party/spdlog"] | ||
| path = third_party/spdlog | ||
| url = https://github.com/gabime/spdlog.git |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #include "gloo/allreduce_bcube.h" | ||
|
|
||
| #include <string_view> | ||
|
|
||
| #include "gloo/common/log.h" | ||
|
|
||
| namespace gloo { | ||
|
|
||
| template <typename T> | ||
| void AllreduceBcube<T>::printElems(T* p, int count, int start) { | ||
| /* Early return if log level is not high enough, to prevent expensive code | ||
| * running. */ | ||
| if (!spdlog::should_log(spdlog::level::trace)) | ||
| return; | ||
|
|
||
| const std::size_t alignedStart = (start / wordsPerLine) * wordsPerLine; | ||
| fmt::memory_buffer line{}; | ||
|
|
||
| /* Logs/flushes the line buffer - starting a new line */ | ||
| auto printLine = [&]() { | ||
| if (!line.size()) | ||
| return; | ||
| std::string_view sv{line.data(), line.size()}; | ||
| GLOO_TRACE("{}", sv); | ||
| line.clear(); | ||
| }; | ||
|
|
||
| for (std::size_t x = alignedStart; x < start + count; ++x) { | ||
| if (x % wordsPerLine == 0) { | ||
| if (x != alignedStart) | ||
| printLine(); | ||
| fmt::format_to( | ||
| std::back_inserter(line), "{} {:05}: ", fmt::ptr(&p[x]), x); | ||
| } else if (x % wordsPerSection == 0) { | ||
| fmt::format_to(std::back_inserter(line), "- "); | ||
| } | ||
|
|
||
| if (x < start) | ||
| fmt::format_to(std::back_inserter(line), "..... "); | ||
| else | ||
| fmt::format_to(std::back_inserter(line), "{:05} ", p[x]); | ||
| } | ||
| printLine(); | ||
| } | ||
|
|
||
| template <typename T> | ||
| void AllreduceBcube<T>::printStageBuffer(const std::string& msg) { | ||
| if (printCheck(myRank_)) { | ||
| GLOO_TRACE("rank ({}) {}:", myRank_, msg); | ||
| printElems(&ptrs_[0][0], totalNumElems_); | ||
| } | ||
| } | ||
|
|
||
| template <typename T> | ||
| void AllreduceBcube<T>::printStepBuffer( | ||
| const std::string& stage, | ||
| int step, | ||
| int srcRank, | ||
| int destRank, | ||
| T* p, | ||
| int count, | ||
| int start) { | ||
| if (printCheck(myRank_)) { | ||
| GLOO_TRACE( | ||
| "{}: step ({}) srcRank ({}) -> destRank ({})", | ||
| stage, | ||
| step, | ||
| srcRank, | ||
| destRank); | ||
| printElems(p, count, start); | ||
| } | ||
| } | ||
|
|
||
| } // namespace gloo |
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.
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.
nice