Skip to content

Commit

Permalink
Fix thread-limit bug in roctracer (#326)
Browse files Browse the repository at this point in the history
Update roctracer.cpp

- fix call to hip_exec_activity_callbacks when more runtime threads than compile time max
  • Loading branch information
jrmadsen authored Jan 11, 2024
1 parent cfaace3 commit edd6f57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/lib/omnitrace/library/components/roctracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ roctracer::flush()
// make sure all async operations are executed
for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i)
hip_exec_activity_callbacks(i);

OMNITRACE_VERBOSE_F(2, "roctracer flush completed\n");
}

void
Expand Down
11 changes: 11 additions & 0 deletions source/lib/omnitrace/library/roctracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ get_hip_activity_callbacks(int64_t _tid = threading::get_id())
return thread_data_t::instance(construct_on_thread{ _tid });
}

size_t
get_hip_activity_callbacks_size()
{
using thread_data_t =
thread_data<std::vector<std::function<void()>>, category::roctracer>;
return thread_data_t::size();
}

using hip_activity_mutex_t = std::decay_t<decltype(get_hip_activity_callbacks())>;
using key_data_mutex_t = std::decay_t<decltype(get_roctracer_key_data())>;

Expand Down Expand Up @@ -430,6 +438,9 @@ hsa_activity_callback(uint32_t op, const void* vrecord, void* arg)
void
hip_exec_activity_callbacks(int64_t _tid)
{
// guard against initialization of structure when trying to exec
if(static_cast<size_t>(_tid) >= get_hip_activity_callbacks_size()) return;

// OMNITRACE_ROCTRACER_CALL(roctracer_flush_activity());
locking::atomic_lock _lk{ get_hip_activity_mutex(_tid) };
auto& _async_ops = get_hip_activity_callbacks(_tid);
Expand Down

0 comments on commit edd6f57

Please sign in to comment.