d0252dfa79
* Revert "Revert "Use COMgr to read Kernel Args Metadata (#1006)"" This reverts commit62e96cb4cf. * Revert "Use COMgr to read Kernel Args Metadata (#1006)" This reverts commit882006555b. * Revert "improve program state commentary" This reverts commitfb2beb0c88. * Revert "load program state once per agent" This reverts commit21f5e142f5. * start moving function_names() into the hip shared lib * start moving code_object_blobs to a new "state" object * Consolidate various program state related static objects into a single program_state object * minor clean up * move more stuffs from functional_grid_launch into program_state * debug make_kernarg * moving lookup for kernargs size_align into program_state * clean up old code for kernarg size and alignment * update hip_module to use newer api in program_state * Create public member functions for program_state * move most program state functions into shared library * Pass the data buffer size to load_executable Otherwise, it can't figure what the data size is just from the char* (since the data is not really a string) * turning free functions in program state into members of program_state_impl * change the free function globals() into a member of program_state_impl * replace the static mutex used for populating globals * moving associate_code_object_symbols_with_host_allocation into program_state_impl * move load_code_object_and_freeze_executable into program_state_impl * moving executables and functions_names into program_state_impl * moving kernels() into program_state_impl * moving functions() into program_state_impl * move get_kernargs into program_state_impl * moving kernel_descriptor into program_state_impl * moving kernargs_size_align calculation into program_state_impl * Changing the handle to program_state_impl to a pointer * moving program_state_impl into a separate inline source file * fixing/cleaning up some header file includes * moving member function for kernargs_size_align into program_state.cpp * moving Kernel_descriptor into program_state.inl * add a new class to manage agent globals * moving all agent globals processing functions into agent_globals_impl * load program state once per agent re-merging PR991 against other program state changes * fix per-agent program state member initialization * cache executables based on elf name, isa, and agent. This avoids program state reloading executables after a shared library is dlopened. re-merging PR1057 against other program state changes * protect executables cache by a global mutex * return ref to executables cache * adapt PR#981 Make hipModuleGetGlobal be in HIP runtime [ROCm/hip commit:f5eb91d53d]
64 строки
2.0 KiB
C++
64 строки
2.0 KiB
C++
#include "../include/hip/hcc_detail/program_state.hpp"
|
|
|
|
#include <hsa/hsa.h>
|
|
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
// contains implementation of program_state_impl
|
|
#include "program_state.inl"
|
|
|
|
namespace hip_impl {
|
|
|
|
std::size_t kernargs_size_align::kernargs_size_align::size(std::size_t n) const{
|
|
return (*reinterpret_cast<const std::vector<std::pair<std::size_t, std::size_t>>*>(handle))[n].first;
|
|
}
|
|
|
|
std::size_t kernargs_size_align::alignment(std::size_t n) const{
|
|
return (*reinterpret_cast<const std::vector<std::pair<std::size_t, std::size_t>>*>(handle))[n].second;
|
|
}
|
|
|
|
program_state::program_state() :
|
|
impl(new program_state_impl) {
|
|
if (!impl) hip_throw(std::runtime_error {
|
|
"Unknown error when constructing program state."});
|
|
}
|
|
|
|
program_state::~program_state() {
|
|
delete(impl);
|
|
}
|
|
|
|
void* program_state::global_addr_by_name(const char* name) {
|
|
const auto it = impl->get_globals().find(name);
|
|
if (it == impl->get_globals().end())
|
|
return nullptr;
|
|
else
|
|
return it->second;
|
|
}
|
|
|
|
hsa_executable_t program_state::load_executable(const char* data,
|
|
const size_t data_size,
|
|
hsa_executable_t executable,
|
|
hsa_agent_t agent) {
|
|
return impl->load_executable(data, data_size, executable, agent);
|
|
}
|
|
|
|
const std::vector<hsa_executable_t>& program_state::executables(hsa_agent_t agent) {
|
|
return impl->get_executables(agent);
|
|
}
|
|
|
|
hipFunction_t program_state::kernel_descriptor(std::uintptr_t function_address,
|
|
hsa_agent_t agent) {
|
|
auto& kd = impl->kernel_descriptor(function_address, agent);
|
|
return kd;
|
|
}
|
|
|
|
kernargs_size_align program_state::get_kernargs_size_align(std::uintptr_t kernel) {
|
|
kernargs_size_align t;
|
|
t.handle = reinterpret_cast<const void*>(&impl->kernargs_size_align(kernel));
|
|
return t;
|
|
}
|
|
};
|