Skip to content

Commit

Permalink
Fix roctracer data race (#309)
Browse files Browse the repository at this point in the history
- roctracer_type_mutex was per-thread, causing lack of sync b/t callback and activity
  • Loading branch information
jrmadsen committed Sep 27, 2023
1 parent f88614d commit 227980f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions source/lib/omnitrace/library/roctracer.cpp
Expand Up @@ -69,12 +69,12 @@ namespace omnitrace
{
namespace
{
template <typename Tp, typename CategoryT = category::roctracer>
template <typename Tp>
auto&
roctracer_type_mutex(uint64_t _n = threading::get_id())
roctracer_type_mutex()
{
return tim::type_mutex<Tp, CategoryT, max_supported_threads, locking::atomic_mutex>(
_n % max_supported_threads);
return tim::type_mutex<Tp, category::roctracer, max_supported_threads,
locking::atomic_mutex>();
}

std::string
Expand Down Expand Up @@ -173,7 +173,9 @@ using key_data_mutex_t = std::decay_t<decltype(get_roctracer_key_data())>;
auto&
get_hip_activity_mutex(int64_t _tid = threading::get_id())
{
return roctracer_type_mutex<hip_activity_mutex_t, category::roctracer>(_tid);
return tim::type_mutex<hip_activity_mutex_t, category::roctracer,
max_supported_threads, locking::atomic_mutex>(
_tid % max_supported_threads);
}
} // namespace

Expand Down

0 comments on commit 227980f

Please sign in to comment.