File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -574,9 +574,6 @@ int OmptTracingBufferMgr::flushAllBuffers(ompt_device_t *device) {
574
574
++curr_buf_id;
575
575
}
576
576
577
- // Wake up all helper threads to invoke buffer-completion callbacks
578
- FlushCv.notify_all ();
579
-
580
577
// This is best effort. It is possible that some trace records are
581
578
// not flushed when the wait is done.
582
579
waitForFlushCompletion ();
@@ -585,10 +582,22 @@ int OmptTracingBufferMgr::flushAllBuffers(ompt_device_t *device) {
585
582
}
586
583
587
584
void OmptTracingBufferMgr::waitForFlushCompletion () {
588
- std::unique_lock<std::mutex> flush_lock (FlushMutex);
589
- for (uint32_t i = 0 ; i < OMPT_NUM_HELPER_THREADS; ++i)
590
- setThreadFlush (i);
591
- ThreadFlushCv.wait (flush_lock, [this ] { return ThreadFlushTracker == 0 ; });
585
+ {
586
+ std::unique_lock<std::mutex> flush_lock (FlushMutex);
587
+ // Setting the flush bit for a given helper thread indicates that the worker
588
+ // thread is ready for the helper thread to do some work.
589
+ for (uint32_t i = 0 ; i < OMPT_NUM_HELPER_THREADS; ++i)
590
+ setThreadFlush (i);
591
+ }
592
+
593
+ // Wake up all helper threads to invoke buffer-completion callbacks.
594
+ FlushCv.notify_all ();
595
+
596
+ // Now wait for all helper threads to complete flushing.
597
+ {
598
+ std::unique_lock<std::mutex> flush_lock (FlushMutex);
599
+ ThreadFlushCv.wait (flush_lock, [this ] { return ThreadFlushTracker == 0 ; });
600
+ }
592
601
}
593
602
594
603
void OmptTracingBufferMgr::init () {
You can’t perform that action at this time.
0 commit comments