2222#include < limits>
2323
2424// When set to true, helper threads terminate their work
25- static bool done_tracing {false };
25+ static bool DoneTracing {false };
2626
2727// Unique buffer id in creation order
28- static std::atomic<uint64_t > buf_id {0 };
28+ static std::atomic<uint64_t > BufId {0 };
2929
3030// Unique id in buffer flush order
31- static std::atomic<uint64_t > flush_id {0 };
31+ static std::atomic<uint64_t > FlushId {0 };
3232
3333thread_local OmptTracingBufferMgr::BufPtr
3434 OmptTracingBufferMgr::ArrayOfBufPtr[MAX_NUM_DEVICES];
3535
36- static uint64_t get_and_inc_buf_id () { return buf_id ++; }
36+ static uint64_t get_and_inc_buf_id () { return BufId ++; }
3737
38- static uint64_t get_and_inc_flush_id () { return flush_id ++; }
39- static uint64_t get_flush_id () { return flush_id ; }
38+ static uint64_t get_and_inc_flush_id () { return FlushId ++; }
39+ static uint64_t get_flush_id () { return FlushId ; }
4040
4141/*
4242 * Used by OpenMP threads for assigning space for a trace record. If
@@ -97,7 +97,7 @@ void *OmptTracingBufferMgr::assignCursor(ompt_callbacks_t Type,
9797 // because the helper thread uses this info to decide whether a buffer
9898 // can be scheduled for removal. In the worst case, the buffer will be
9999 // removed late.
100- DeviceBuf->isFull .store (true , std::memory_order_release);
100+ DeviceBuf->IsFull .store (true , std::memory_order_release);
101101 }
102102 }
103103 void *NewBuffer = nullptr ;
@@ -115,7 +115,7 @@ void *OmptTracingBufferMgr::assignCursor(ompt_callbacks_t Type,
115115 NewBufId, DeviceId, /* Start=*/ NewBuffer, TotalBytes,
116116 /* RemainingBytes=*/ TotalBytes - RecSize,
117117 /* Cursor=*/ NewBuffer,
118- /* isFull =*/ false );
118+ /* IsFull =*/ false );
119119
120120 // Initialize trace record status before publishing it to helper threads.
121121 initTraceRecordMetaData (new_buf->Cursor .load (std::memory_order_acquire));
@@ -142,7 +142,7 @@ void *OmptTracingBufferMgr::assignCursor(ompt_callbacks_t Type,
142142
143143/*
144144 * Called by an OpenMP thread when a buffer fills up and should be
145- * flushed. This function assigns a new flush_id to the buffer, adds
145+ * flushed. This function assigns a new FlushId to the buffer, adds
146146 * to the flush-related metadata and wakes up a helper thread to
147147 * dispatch a buffer-completion callback. This function should be
148148 * called without holding any lock.
@@ -191,15 +191,15 @@ void OmptTracingBufferMgr::driveCompletion() {
191191 while (true ) {
192192 bool should_signal_workers = false ;
193193 std::unique_lock<std::mutex> flush_lock (FlushMutex);
194- if (done_tracing ) {
194+ if (DoneTracing ) {
195195 // An upper layer serializes flush_trace and stop_trace. In
196- // addition, before done_tracing is set, a flush is performed as
196+ // addition, before DoneTracing is set, a flush is performed as
197197 // part of stop_trace. So assert that no flush is in progress.
198198 assert (ThreadFlushTracker == 0 );
199199 break ;
200200 }
201201 FlushCv.wait (flush_lock, [this ] {
202- return done_tracing ||
202+ return DoneTracing ||
203203 (!Id2FlushMdMap.empty () &&
204204 llvm::omp::target::ompt::TracingActive) ||
205205 isThisThreadFlushWaitedUpon ();
@@ -225,7 +225,7 @@ void OmptTracingBufferMgr::driveCompletion() {
225225 }
226226 bool is_last_helper = false ;
227227 std::unique_lock<std::mutex> flush_lock (FlushMutex);
228- assert (done_tracing && " Helper thread exiting but not yet done" );
228+ assert (DoneTracing && " Helper thread exiting but not yet done" );
229229 assert (isThisThreadShutdownWaitedUpon () &&
230230 " Helper thread exiting but not waited upon" );
231231 resetThisThreadShutdown ();
@@ -362,28 +362,28 @@ void OmptTracingBufferMgr::flushBuffer(FlushInfo flush_info) {
362362}
363363
364364// Given a range of trace records, dispatch a buffer-completion callback
365- void OmptTracingBufferMgr::dispatchCallback (int64_t DeviceId, void *buffer ,
366- void *first_cursor ,
367- void *last_cursor ) {
368- assert (first_cursor != nullptr && last_cursor != nullptr &&
365+ void OmptTracingBufferMgr::dispatchCallback (int64_t DeviceId, void *Buffer ,
366+ void *FirstCursor ,
367+ void *LastCursor ) {
368+ assert (FirstCursor != nullptr && LastCursor != nullptr &&
369369 " Callback with nullptr" );
370- addLastCursor (last_cursor );
370+ addLastCursor (LastCursor );
371371
372372 // This is best effort.
373373 // There is a small window when the buffer-completion callback may
374374 // be invoked even after tracing has been disabled.
375375 // Note that we don't want to hold a lock when dispatching the callback.
376376 if (llvm::omp::target::ompt::isTracedDevice (DeviceId)) {
377377 DP (" Dispatch callback w/ range (inclusive) to be flushed: %p -> %p\n " ,
378- first_cursor, last_cursor );
378+ FirstCursor, LastCursor );
379379 llvm::omp::target::ompt::ompt_callback_buffer_complete (
380- DeviceId, buffer ,
380+ DeviceId, Buffer ,
381381 /* bytes returned in this callback */
382- (char *)getNextTR (last_cursor ) - (char *)first_cursor ,
383- (ompt_buffer_cursor_t )first_cursor , false /* buffer_owned */ );
382+ (char *)getNextTR (LastCursor ) - (char *)FirstCursor ,
383+ (ompt_buffer_cursor_t )FirstCursor , false /* buffer_owned */ );
384384 }
385385
386- removeLastCursor (last_cursor );
386+ removeLastCursor (LastCursor );
387387}
388388
389389// Dispatch a buffer-completion callback with buffer_owned set so that
@@ -438,15 +438,15 @@ OmptTracingBufferMgr::TRStatus OmptTracingBufferMgr::getTRStatus(void *Rec) {
438438 std::memory_order_acquire);
439439}
440440
441- void *OmptTracingBufferMgr::getNextTR (void *Rec ) {
442- size_t rec_size = getTRSize ();
441+ void *OmptTracingBufferMgr::getNextTR (void *TR ) {
442+ size_t RecSize = getTRSize ();
443443 // warning: no overflow check done
444- return (char *)Rec + rec_size ;
444+ return (char *)TR + RecSize ;
445445}
446446
447447bool OmptTracingBufferMgr::isBufferFull (const FlushInfo &flush_info) {
448448 std::unique_lock<std::mutex> buf_lock (BufferMgrMutex);
449- return flush_info.FlushBuf ->isFull ;
449+ return flush_info.FlushBuf ->IsFull ;
450450}
451451
452452void *OmptTracingBufferMgr::getBufferCursor (BufPtr buf) {
@@ -484,10 +484,10 @@ bool OmptTracingBufferMgr::isBufferOwned(const FlushInfo &flush_info) {
484484 * list of buffers to be flushed.
485485 */
486486OmptTracingBufferMgr::FlushInfo
487- OmptTracingBufferMgr::findAndReserveFlushedBuf (uint64_t flush_id ) {
487+ OmptTracingBufferMgr::findAndReserveFlushedBuf (uint64_t FlushId ) {
488488 std::unique_lock<std::mutex> flush_lock (FlushMutex);
489489 MapId2Md::iterator flush_itr;
490- if (flush_id == std::numeric_limits<uint64_t >::max ()) {
490+ if (FlushId == std::numeric_limits<uint64_t >::max ()) {
491491 // Reserve the first waiting buffer and return it
492492 if (Id2FlushMdMap.empty ())
493493 return FlushInfo ();
@@ -500,7 +500,7 @@ OmptTracingBufferMgr::findAndReserveFlushedBuf(uint64_t flush_id) {
500500 if (flush_itr == Id2FlushMdMap.end ())
501501 return FlushInfo ();
502502 } else {
503- flush_itr = Id2FlushMdMap.find (flush_id );
503+ flush_itr = Id2FlushMdMap.find (FlushId );
504504 if (flush_itr == Id2FlushMdMap.end () ||
505505 flush_itr->second .FlushStatus == Flush_processing)
506506 return FlushInfo ();
@@ -562,16 +562,16 @@ void OmptTracingBufferMgr::destroyFlushedBuf(const FlushInfo &flush_info) {
562562 * Generate a new flush id and add the buffer to the flush metadata
563563 * maps. This function must be called while holding the flush lock.
564564 */
565- uint64_t OmptTracingBufferMgr::addNewFlushEntry (BufPtr buf , void *cursor ) {
566- assert (FlushBufPtr2IdMap.find (buf ) == FlushBufPtr2IdMap.end ());
567- uint64_t flush_id = get_and_inc_flush_id ();
568- FlushBufPtr2IdMap.emplace (buf, flush_id );
569- assert (Id2FlushMdMap.find (flush_id ) == Id2FlushMdMap.end ());
570- Id2FlushMdMap.emplace (flush_id , FlushMd (cursor, buf , Flush_waiting));
565+ uint64_t OmptTracingBufferMgr::addNewFlushEntry (BufPtr Buf , void *Cursor ) {
566+ assert (FlushBufPtr2IdMap.find (Buf ) == FlushBufPtr2IdMap.end ());
567+ uint64_t FlushId = get_and_inc_flush_id ();
568+ FlushBufPtr2IdMap.emplace (Buf, FlushId );
569+ assert (Id2FlushMdMap.find (FlushId ) == Id2FlushMdMap.end ());
570+ Id2FlushMdMap.emplace (FlushId , FlushMd (Cursor, Buf , Flush_waiting));
571571
572- DP (" Added new flush id %lu cursor %p buf %p\n " , flush_id, cursor, buf ->Start );
572+ DP (" Added new flush id %lu cursor %p buf %p\n " , FlushId, Cursor, Buf ->Start );
573573
574- return flush_id ;
574+ return FlushId ;
575575}
576576
577577/*
@@ -674,7 +674,7 @@ void OmptTracingBufferMgr::init() {
674674 ArrayOfBufPtr[i] = nullptr ;
675675 ThreadFlushTracker = 0 ;
676676 ThreadShutdownTracker = 0 ;
677- done_tracing = false ; // TODO make it a class member
677+ DoneTracing = false ; // TODO make it a class member
678678}
679679
680680void OmptTracingBufferMgr::startHelperThreads () {
@@ -683,7 +683,7 @@ void OmptTracingBufferMgr::startHelperThreads() {
683683 // repeated calls to start-trace.
684684 std::unique_lock<std::mutex> flush_lock (FlushMutex);
685685 if (!HelperThreadIdMap.empty ()) {
686- assert (!done_tracing && " Helper threads exist but tracing is done" );
686+ assert (!DoneTracing && " Helper threads exist but tracing is done" );
687687 return ;
688688 }
689689 init ();
@@ -692,7 +692,7 @@ void OmptTracingBufferMgr::startHelperThreads() {
692692
693693bool OmptTracingBufferMgr::areHelperThreadsAvailable () {
694694 std::unique_lock<std::mutex> flush_lock (FlushMutex);
695- if (done_tracing // If another thread called stop, assume there are no threads
695+ if (DoneTracing // If another thread called stop, assume there are no threads
696696 || HelperThreadIdMap.empty () // Threads were never started
697697 ) {
698698 // Don't assert on HelperThreadIdMap since shutdown by another
@@ -713,11 +713,11 @@ void OmptTracingBufferMgr::shutdownHelperThreads() {
713713 assert (ThreadShutdownTracker == 0 );
714714
715715 // Set the done flag which helper threads will look at
716- done_tracing = true ;
716+ DoneTracing = true ;
717717 // Wait to make sure all helper threads exit
718718 for (uint32_t i = 0 ; i < OMPT_NUM_HELPER_THREADS; ++i)
719719 setThreadShutdown (i);
720- // Signal indicating that done_tracing is set
720+ // Signal indicating that DoneTracing is set
721721 FlushCv.notify_all ();
722722 ThreadShutdownCv.wait (flush_lock,
723723 [this ] { return ThreadShutdownTracker == 0 ; });
0 commit comments