You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by cj...@apache.org on 2018/03/11 11:01:06 UTC
[incubator-mxnet] branch master updated: Fixes for profiler (#9932)
This is an automated email from the ASF dual-hosted git repository.
cjolivier01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 94f68fc Fixes for profiler (#9932)
94f68fc is described below
commit 94f68fc8fd21611b7f5c148cb0e5d134efe58f87
Author: Rahul Huilgol <ra...@gmail.com>
AuthorDate: Sun Mar 11 04:00:55 2018 -0700
Fixes for profiler (#9932)
* hash tid
* remove first flag conditions to fix missing commas
* hash tid
* remove first flag conditions to fix missing commas
* update comment
* CI restart
* address review comments
---
src/profiler/profiler.cc | 16 ++--------------
src/profiler/profiler.h | 8 +++++---
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/src/profiler/profiler.cc b/src/profiler/profiler.cc
index 82d1744..e6dafb3 100644
--- a/src/profiler/profiler.cc
+++ b/src/profiler/profiler.cc
@@ -205,7 +205,6 @@ void Profiler::DumpProfile(bool peform_cleanup) {
// If aggregate stats aren't enabled, this won't cause a locked instruction
std::shared_ptr<AggregateStats> ptr_aggregate_stats = aggregate_stats_.get()
? aggregate_stats_ : nullptr;
- bool first_flag = !first_pass && !num_records_emitted_;
for (uint32_t i = 0; i < dev_num; ++i) {
DeviceStats &d = profile_stat[i];
ProfileStat *_opr_stat;
@@ -213,12 +212,7 @@ void Profiler::DumpProfile(bool peform_cleanup) {
CHECK_NOTNULL(_opr_stat);
std::unique_ptr<ProfileStat> opr_stat(_opr_stat); // manage lifecycle
opr_stat->process_id_ = i; // lie and set process id to be the device number
- if (first_flag) {
- first_flag = false;
- } else {
- file << ",\n";
- }
- file << std::endl;
+ file << ",\n" << std::endl;
opr_stat->EmitEvents(&file);
++num_records_emitted_;
if (ptr_aggregate_stats) {
@@ -231,13 +225,7 @@ void Profiler::DumpProfile(bool peform_cleanup) {
ProfileStat *_profile_stat;
while (general_stats_.opr_exec_stats_->try_dequeue(_profile_stat)) {
CHECK_NOTNULL(_profile_stat);
-
- if (first_flag) {
- first_flag = false;
- } else {
- file << ",";
- }
-
+ file << ",";
std::unique_ptr<ProfileStat> profile_stat(_profile_stat); // manage lifecycle
CHECK_NE(profile_stat->categories_.c_str()[0], '\0') << "Category must be set";
// Currently, category_to_pid_ is only accessed here, so it is protected by this->m_ above
diff --git a/src/profiler/profiler.h b/src/profiler/profiler.h
index 1224231..768a0bc 100644
--- a/src/profiler/profiler.h
+++ b/src/profiler/profiler.h
@@ -130,7 +130,9 @@ struct ProfileStat {
/* !\brief Process id */
size_t process_id_ = current_process_id();
- /*! \brief id of thread which operation run on */
+ /*! \brief id of thread which operation run on.
+ *
+ * */
std::thread::id thread_id_ = std::this_thread::get_id(); // Not yet seen a
// case where this isn't valid
@@ -209,7 +211,7 @@ struct ProfileStat {
<< " \"ts\": " << ev.timestamp_ << ",\n";
EmitExtra(os, idx);
*os << " \"pid\": " << process_id_ << ",\n"
- << " \"tid\": " << thread_id_ << "\n"
+ << " \"tid\": " << std::hash<std::thread::id>{}(thread_id_) << "\n"
<< " }\n";
}
}
@@ -794,7 +796,7 @@ struct ProfileTask : public ProfileDuration {
}
void EmitExtra(std::ostream *os, size_t idx) override {
DurationStat::EmitExtra(os, idx);
- *os << " \"id\": " << thread_id_ << ",\n";
+ *os << " \"id\": " << std::hash<std::thread::id>{}(thread_id_) << ",\n";
}
};
--
To stop receiving notification emails like this one, please contact
cjolivier01@apache.org.