fix link-time ordering condition
This fixes a segfault error in cases where the linking order of
compilation unit varies. Reason behind the segfault is that one
global variable in one compilation unit depends on another global
variable in another compilation unit, but there is no guarantee that
this other compilation unit is initialized first. The fix forces a
reinitialization at the first invocation of the library.
Change-Id: I1428592c6898bca13a330c4588941de260ff0370
[ROCm/ROCR-Runtime commit: d220e16000]
This commit is contained in:
committed by
Jeremy Newton
parent
175265aef4
commit
4a7c3a2607
@@ -58,7 +58,15 @@ const HsaApiTable* hsa_table_interface_get_table() {
|
||||
}
|
||||
|
||||
// Pass through stub functions
|
||||
hsa_status_t HSA_API hsa_init() { return coreApiTable->hsa_init_fn(); }
|
||||
hsa_status_t HSA_API hsa_init() {
|
||||
// We initialize the api tables here once more since the code above is prone to a
|
||||
// link-time ordering condition: This compilation unit here may get its global
|
||||
// variables initialized earlier than the global objects in other compilation units.
|
||||
// In particular Init::Init may get called earlier than that the underlying hsa_api_table_
|
||||
// object in hsa_api_trace.cpp has been initialized.
|
||||
rocr::core::LoadInitialHsaApiTable();
|
||||
return coreApiTable->hsa_init_fn();
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API hsa_shut_down() { return coreApiTable->hsa_shut_down_fn(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user