Fix a RCCL initialization to avoid a deadlock (#136)

Also fixes: 

- crash while finalizing rocprof-sys-causal

[ROCm/rocprofiler-systems commit: 26bb604215]
This commit is contained in:
ajanicijamd
2025-03-19 14:48:04 -04:00
committed by GitHub
parent 516c3b11f8
commit df729548d0
7 changed files with 77 additions and 19 deletions
@@ -105,6 +105,8 @@ delay::setup()
void
delay::process()
{
if(!is_local_available()) return;
if(causal::experiment::is_active())
{
if(get_global() < get_local())
@@ -130,6 +132,8 @@ delay::process()
void
delay::credit()
{
if(!is_local_available()) return;
auto _diff = get_global() - get_local();
if(_diff > 0)
{
@@ -140,6 +144,8 @@ delay::credit()
void
delay::preblock()
{
if(!is_local_available()) return;
auto _diff = get_global() - get_local();
if(_diff > 0)
{
@@ -150,6 +156,7 @@ delay::preblock()
void
delay::postblock(int64_t _preblock_global_delay_value)
{
if(!is_local_available()) return;
get_local() += (get_global() - _preblock_global_delay_value);
}
@@ -168,18 +175,36 @@ delay::get_global()
return _v;
}
int64_t&
delay::get_local(int64_t _tid)
static void
thr_init()
{
auto& _data = get_delay_data();
static thread_local auto _thr_init = []() {
using thread_data_t = thread_data<identity<int64_t>, delay>;
thread_data_t::construct(construct_on_thread{ threading::get_id() },
get_global().load());
delay::get_global().load());
return true;
}();
(void) _thr_init; // To make compiler happy.
}
bool
delay::is_local_available()
{
thr_init();
auto& _data = get_delay_data();
return _data != nullptr;
}
int64_t&
delay::get_local(int64_t _tid)
{
thr_init();
auto& _data = get_delay_data();
if(_data == nullptr)
{
throw std::runtime_error("No data: get_delay_data() returned nullptr");
}
return _data->at(_tid);
(void) _thr_init;
}
uint64_t