@@ -129,8 +129,8 @@ void *OmptTracingBufferMgr::assignCursor(ompt_callbacks_t Type,
129129 lck.unlock ();
130130
131131 // Schedule the full buffer for flushing till the corresponding cursor.
132- if (ToBeFlushedCursor)
133- setComplete (ToBeFlushedCursor, ToBeFlushedBuf);
132+ if (OMPX_FlushOnBufferFull && ToBeFlushedCursor)
133+ triggerFlushOnBufferFull (ToBeFlushedCursor, ToBeFlushedBuf);
134134
135135 DP (" Thread %lu: Assigned %lu bytes at %p in new buffer with id %lu for "
136136 " device %ld\n " ,
@@ -148,10 +148,10 @@ void *OmptTracingBufferMgr::assignCursor(ompt_callbacks_t Type,
148148 * called without holding any lock.
149149 * Note lock order: buf_lock -> flush_lock
150150 */
151- void OmptTracingBufferMgr::setComplete (void *cursor, BufPtr Buf) {
151+ void OmptTracingBufferMgr::triggerFlushOnBufferFull (void *cursor, BufPtr Buf) {
152152 std::unique_lock<std::mutex> buf_lock (BufferMgrMutex);
153153
154- // Between calling setComplete and this check, a flush-all may have
154+ // Between calling this function and this check, a flush-all may have
155155 // delivered this buffer to the tool and deleted it. So the buffer
156156 // may not exist.
157157 if (Id2BufferMap.find (Buf->Id ) == Id2BufferMap.end ())
@@ -729,7 +729,8 @@ void OmptTracingBufferMgr::shutdownHelperThreads() {
729729void OmptTracingBufferMgr::flushAndShutdownHelperThreads () {
730730 std::unique_lock<std::mutex> Lock (llvm::omp::target::ompt::TraceControlMutex);
731731 // Flush buffers for all devices.
732- flushAllBuffers (MAX_NUM_DEVICES);
732+ if (OMPX_FlushOnShutdown)
733+ flushAllBuffers (MAX_NUM_DEVICES);
733734 shutdownHelperThreads ();
734735}
735736
@@ -747,9 +748,4 @@ void OmptTracingBufferMgr::destroyHelperThreads() {
747748 CompletionThreads.clear ();
748749 HelperThreadIdMap.clear ();
749750}
750-
751- OmptTracingBufferMgr::OmptTracingBufferMgr () {
752- // no need to hold locks for init() since object is getting constructed here
753- init ();
754- }
755751#endif
0 commit comments