cjolivier01 closed pull request #9932: Fixes for profiler
URL: https://github.com/apache/incubator-mxnet/pull/9932
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/profiler/profiler.cc b/src/profiler/profiler.cc
index 82d1744d7b4..e6dafb3d091 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 1224231761b..768a0bc7d71 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";
     }
   };
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to