Propagate errors from hsaKmtOpenKFD back to hsa_init
Errors are otherwise silently ignored and hsa_init completes successfully.
Change-Id: Ib1b7dbd7a65d40f869cdbb2792fa97132873d3d7
[ROCm/ROCR-Runtime commit: 0c9f96cfa4]
这个提交包含在:
@@ -94,8 +94,7 @@ class Runtime {
|
||||
};
|
||||
|
||||
/// @brief Open connection to kernel driver and increment reference count.
|
||||
/// @retval True if the connection to kernel driver is successfully opened.
|
||||
static bool Acquire();
|
||||
static hsa_status_t Acquire();
|
||||
|
||||
/// @brief Checks if connection to kernel driver is opened.
|
||||
/// @retval True if the connection to kernel driver is opened.
|
||||
@@ -108,8 +107,7 @@ class Runtime {
|
||||
static Runtime* runtime_singleton_;
|
||||
|
||||
/// @brief Decrement reference count and close connection to kernel driver.
|
||||
/// @retval True if reference count is larger than 0.
|
||||
bool Release();
|
||||
hsa_status_t Release();
|
||||
|
||||
/// @brief Insert agent into agent list ::agents_.
|
||||
/// @param [in] agent Pointer to the agent object.
|
||||
@@ -362,7 +360,7 @@ class Runtime {
|
||||
~Runtime() {}
|
||||
|
||||
/// @brief Open connection to kernel driver.
|
||||
void Load();
|
||||
hsa_status_t Load();
|
||||
|
||||
/// @brief Close connection to kernel driver and cleanup resources.
|
||||
void Unload();
|
||||
|
||||
@@ -195,15 +195,11 @@ namespace HSA {
|
||||
//---------------------------------------------------------------------------//
|
||||
// Init/Shutdown routines
|
||||
//---------------------------------------------------------------------------//
|
||||
hsa_status_t hsa_init() {
|
||||
if (core::Runtime::runtime_singleton_->Acquire()) return HSA_STATUS_SUCCESS;
|
||||
return HSA_STATUS_ERROR_REFCOUNT_OVERFLOW;
|
||||
}
|
||||
hsa_status_t hsa_init() { return core::Runtime::runtime_singleton_->Acquire(); }
|
||||
|
||||
hsa_status_t hsa_shut_down() {
|
||||
IS_OPEN();
|
||||
if (core::Runtime::runtime_singleton_->Release()) return HSA_STATUS_SUCCESS;
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
return core::Runtime::runtime_singleton_->Release();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
@@ -89,9 +89,9 @@ class RuntimeCleanup {
|
||||
|
||||
static RuntimeCleanup cleanup_at_unload_;
|
||||
|
||||
bool Runtime::Acquire() {
|
||||
hsa_status_t Runtime::Acquire() {
|
||||
// Check to see if HSA has been cleaned up (process exit)
|
||||
if (!loaded) return false;
|
||||
if (!loaded) return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
|
||||
// Handle initialization races
|
||||
ScopedAcquire<KernelMutex> boot(&bootstrap_lock_);
|
||||
@@ -104,22 +104,26 @@ bool Runtime::Acquire() {
|
||||
ScopedAcquire<KernelMutex> lock(&runtime_singleton_->kernel_lock_);
|
||||
|
||||
if (runtime_singleton_->ref_count_ == INT32_MAX) {
|
||||
return false;
|
||||
return HSA_STATUS_ERROR_REFCOUNT_OVERFLOW;
|
||||
}
|
||||
|
||||
runtime_singleton_->ref_count_++;
|
||||
|
||||
if (runtime_singleton_->ref_count_ == 1) {
|
||||
runtime_singleton_->Load();
|
||||
hsa_status_t status = runtime_singleton_->Load();
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Runtime::Release() {
|
||||
hsa_status_t Runtime::Release() {
|
||||
ScopedAcquire<KernelMutex> lock(&kernel_lock_);
|
||||
if (ref_count_ == 0) {
|
||||
return false;
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (ref_count_ == 1) {
|
||||
@@ -129,7 +133,7 @@ bool Runtime::Release() {
|
||||
|
||||
ref_count_--;
|
||||
|
||||
return true;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Runtime::IsOpen() {
|
||||
@@ -808,13 +812,13 @@ Runtime::Runtime()
|
||||
#endif
|
||||
}
|
||||
|
||||
void Runtime::Load() {
|
||||
hsa_status_t Runtime::Load() {
|
||||
flag_.Refresh();
|
||||
|
||||
g_use_interrupt_wait = flag_.enable_interrupt();
|
||||
|
||||
if (!amd::Load()) {
|
||||
return;
|
||||
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
loader_ = amd::hsa::loader::Loader::Create(&loader_context_);
|
||||
@@ -826,10 +830,15 @@ void Runtime::Load() {
|
||||
LoadTools();
|
||||
|
||||
for (core::Agent* agent : gpu_agents_) {
|
||||
const hsa_status_t stat =
|
||||
hsa_status_t status =
|
||||
reinterpret_cast<amd::GpuAgentInt*>(agent)->PostToolsInit();
|
||||
assert(HSA_STATUS_SUCCESS == stat);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void Runtime::Unload() {
|
||||
|
||||
在新工单中引用
屏蔽一个用户