Store queues in unique_ptr so they are destroyed when the global DeviceInfo is. Currently they leak which raises an assert in debug builds of hsa.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp | ||
---|---|---|
856–857 | Storing (most) state in a global variable that closes hsa in the destructor make it difficult to use raii classes to manage hsa resources. We could change to using multiple calls to hsa_init/destroy, since it's internally reference counted, and that would give us the last one to destroy closes hsa. Better is probably to nest the lifetime - would like hsa_init to occur before any other objects are constructed and hsa_shut_down after they've all been torn down. Will think about how best to represent that (separate to this patch) |
D109512 rearranges rtl.cpp so that hsa is reliably constructed before other member variables in the big global object. If we land that, this signal pool can be refactored to free the signals in the destructor again. Still some care needed to ensure it doesn't try to create any without checking hsa is available, i.e. don't prepopulate the pool in the constructor, but at least cleanup can be implicit.
Likewise could put queue in a unique_ptr or similar to reliably cleanup.
Storing (most) state in a global variable that closes hsa in the destructor make it difficult to use raii classes to manage hsa resources.
We could change to using multiple calls to hsa_init/destroy, since it's internally reference counted, and that would give us the last one to destroy closes hsa.
Better is probably to nest the lifetime - would like hsa_init to occur before any other objects are constructed and hsa_shut_down after they've all been torn down. Will think about how best to represent that (separate to this patch)