Skip to content

Commit

Permalink
Using tracy::GetQueue instead of the sketchy static variable referenc…
Browse files Browse the repository at this point in the history
…e. (#19653)
  • Loading branch information
benvanik authored Jan 10, 2025
1 parent 1d91bec commit 039b8b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions runtime/src/iree/base/tracing/tracy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
// HACK: tracy doesn't let us at this but we need it in order to create new
// queue contexts. It's an implementation detail we have to take a dependency on
// because tracy does not have an API for what we're doing (yet).
extern tracy::moodycamel::ConcurrentQueue<tracy::QueueItem> tracy::s_queue;
namespace tracy {
moodycamel::ConcurrentQueue<QueueItem>& GetQueue();
} // namespace tracy
#endif // TRACY_ENABLE && IREE_TRACING_EXPERIMENTAL_CONTEXT_API

#ifdef __cplusplus
Expand Down Expand Up @@ -457,8 +459,8 @@ struct iree_tracing_context_t {
tracy::ProducerWrapper token;
uint32_t thread_id = 0;
iree_tracing_context_t()
: token_detail(tracy::s_queue),
token({tracy::s_queue.get_explicit_producer(token_detail)}),
: token_detail(tracy::GetQueue()),
token({tracy::GetQueue().get_explicit_producer(token_detail)}),
thread_id(iree_tracing_context_t::next_tracing_thread_id++) {
token.ptr->threadId = thread_id;
}
Expand Down
6 changes: 4 additions & 2 deletions runtime/src/iree/base/tracing/tracy.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ void* iree_tracing_obscure_ptr(void* ptr);
// an API for what we're doing. We could propose one and try to get it landed
// such that we at least did not need to manually write out structs and manage
// the concurrent queues.
#define IREE_TRACING_EXPERIMENTAL_CONTEXT_API 1
#if !defined(IREE_TRACING_EXPERIMENTAL_CONTEXT_API)
#define IREE_TRACING_EXPERIMENTAL_CONTEXT_API 0
#endif // !IREE_TRACING_EXPERIMENTAL_CONTEXT_API

typedef struct iree_tracing_context_t iree_tracing_context_t;

Expand Down Expand Up @@ -434,7 +436,7 @@ static inline iree_tracing_context_t* iree_tracing_context_allocate(
return NULL;
}
static inline void iree_tracing_context_free(iree_tracing_context_t* context) {}
void iree_tracing_context_calibrate_executor(
static inline void iree_tracing_context_calibrate_executor(
iree_tracing_context_t* context, iree_tracing_executor_id_t executor_id,
int64_t cpu_delta, uint64_t host_timestamp, uint64_t executor_timestamp) {}
static inline void iree_tracing_context_zone_begin(
Expand Down

0 comments on commit 039b8b4

Please sign in to comment.