Switch to per-executable contexts in the loader

- Per-executable contexts should be used from now on
  - Global contexts are left as is for now for backwards
    compatibility and will be phased out in follow up
    patches.

Change-Id: I6291abf865c7ed24ee71f5065e539afc23f5ce64
这个提交包含在:
Konstantin Zhuravlyov
2024-04-03 16:58:23 -04:00
提交者 Konstantin Zhuravlyov
父节点 244ad319ac
当前提交 b983c19729
修改 4 个文件,包含 50 行新增0 行删除
+28
查看文件
@@ -188,6 +188,18 @@ Executable* AmdHsaCodeLoader::CreateExecutable(
return executables.back();
}
Executable* AmdHsaCodeLoader::CreateExecutable(
std::unique_ptr<Context> isolated_context,
hsa_profile_t profile,
const char *options,
hsa_default_float_rounding_mode_t default_float_rounding_mode)
{
WriterLockGuard<ReaderWriterLock> writer_lock(rw_lock_);
executables.push_back(new ExecutableImpl(profile, std::move(isolated_context), executables.size(), default_float_rounding_mode));
return executables.back();
}
static void AddCodeObjectInfoIntoDebugMap(link_map* map) {
if (r_debug_tail) {
r_debug_tail->l_next = map;
@@ -740,6 +752,22 @@ ExecutableImpl::ExecutableImpl(
{
}
ExecutableImpl::ExecutableImpl(
const hsa_profile_t &_profile,
std::unique_ptr<Context> unique_context,
size_t id,
hsa_default_float_rounding_mode_t default_float_rounding_mode)
: Executable()
, profile_(_profile)
, unique_context_(std::move(unique_context))
, id_(id)
, default_float_rounding_mode_(default_float_rounding_mode)
, state_(HSA_EXECUTABLE_STATE_UNFROZEN)
, program_allocation_segment(nullptr)
{
context_ = unique_context_.get();
}
ExecutableImpl::~ExecutableImpl() {
for (ExecutableObject* o : objects) {
o->Destroy();