rocr/dtif: add CreateThunkInstance/DestroyThunkInstance interfaces

Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Reviewed-by: David Yat Sin <David.YatSin@amd.com>
このコミットが含まれているのは:
Aaron Liu
2024-12-19 15:49:37 +08:00
committed by Yat Sin, David
コミット e9088d6e47
3個のファイルの変更44行の追加0行の削除
+6
ファイルの表示
@@ -46,6 +46,10 @@
#include <amdgpu.h>
#include "hsakmt/hsakmttypes.h"
class DtifPlatform;
typedef DtifPlatform* (DtifCreateFunc)(const char*);
typedef void (DtifDestroyFunc)();
namespace rocr {
namespace core {
@@ -356,6 +360,8 @@ class ThunkLoader {
~ThunkLoader();
void LoadThunkApiTable();
bool CreateThunkInstance();
bool DestroyThunkInstance();
HSAKMT_DEF(hsaKmtOpenKFD)* HSAKMT_PFN(hsaKmtOpenKFD);
HSAKMT_DEF(hsaKmtCloseKFD)* HSAKMT_PFN(hsaKmtCloseKFD);
+6
ファイルの表示
@@ -2044,6 +2044,10 @@ hsa_status_t Runtime::Load() {
thunkLoader_ = new ThunkLoader();
thunkLoader_->LoadThunkApiTable();
if (!thunkLoader_->CreateThunkInstance()) {
return HSA_STATUS_ERROR_NOT_INITIALIZED;
}
g_use_interrupt_wait = flag_.enable_interrupt();
g_use_mwaitx = flag_.check_mwaitx(cpuinfo.mwaitx);
@@ -2140,6 +2144,8 @@ void Runtime::Unload() {
DestroyDrivers();
thunkLoader_->DestroyThunkInstance();
delete thunkLoader_;
}
+32
ファイルの表示
@@ -485,5 +485,37 @@ ERROR:
}
}
bool ThunkLoader::CreateThunkInstance() {
if (!core::Runtime::runtime_singleton_->flag().enable_dtif())
return true;
DtifCreateFunc* pfnDtifCreate = (DtifCreateFunc*)dlsym(dtif_handle, "DtifCreate");
if (pfnDtifCreate != NULL) {
if (pfnDtifCreate("HSA") != NULL) {
debug_print("DtifCreate OK!\n");
return true;
} else {
debug_print("DtifCreate failed!\n");
return false;
}
}
return false;
}
bool ThunkLoader::DestroyThunkInstance() {
if (!core::Runtime::runtime_singleton_->flag().enable_dtif())
return true;
if (dtif_handle == NULL)
return false;
DtifDestroyFunc* pfnDtifDestroy = (DtifDestroyFunc*)dlsym(dtif_handle, "DtifDestroy");
if (pfnDtifDestroy != NULL) {
pfnDtifDestroy();
debug_print("DtifDestroy OK!\n");
return true;
}
return false;
}
} // namespace core
} // namespace rocr