adding aqlprofile member to HsaApiTable
Change-Id: Id674186dfa2e83295a51f770ccc0400f1cb51a98
This commit is contained in:
@@ -778,6 +778,10 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||
setFlag(HSA_EXTENSION_IMAGES);
|
||||
}
|
||||
|
||||
if (core::hsa_internal_api_table_.aqlprofile_api.hsa_ven_amd_aqlprofile_error_string_fn != NULL) {
|
||||
setFlag(HSA_EXTENSION_AMD_AQLPROFILE);
|
||||
}
|
||||
|
||||
setFlag(HSA_EXTENSION_AMD_PROFILER);
|
||||
|
||||
break;
|
||||
|
||||
@@ -74,11 +74,12 @@ void HsaApiTable::Init() {
|
||||
UpdateAmdExts();
|
||||
hsa_api.amd_ext_ = &amd_ext_api;
|
||||
|
||||
// Initialize Api tables for Finalizer and Image to NULL
|
||||
// Tables for Finalizer and Images are initialized as part
|
||||
// Initialize Api tables for Finalizer, Image, AqlProfile to NULL
|
||||
// The tables are initialized as part
|
||||
// of Hsa Runtime initialization, including their major ids
|
||||
hsa_api.finalizer_ext_ = NULL;
|
||||
hsa_api.image_ext_ = NULL;
|
||||
hsa_api.aqlprofile_ext_ = NULL;
|
||||
}
|
||||
|
||||
void HsaApiTable::Reset() {
|
||||
@@ -102,6 +103,13 @@ void HsaApiTable::CloneExts(void* ext_table, uint32_t table_id) {
|
||||
hsa_api.image_ext_ = &image_api;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update HSA Extension AqlProfile Api table
|
||||
if (table_id == HSA_EXT_AQLPROFILE_API_TABLE_ID) {
|
||||
aqlprofile_api = (*(AqlProfileExtTable *)ext_table);
|
||||
hsa_api.aqlprofile_ext_ = &aqlprofile_api;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void HsaApiTable::LinkExts(void* ext_table, uint32_t table_id) {
|
||||
@@ -121,6 +129,13 @@ void HsaApiTable::LinkExts(void* ext_table, uint32_t table_id) {
|
||||
hsa_api.image_ext_ = (ImageExtTable *)ext_table;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update HSA Extension AqlProfile Api table
|
||||
if (table_id == HSA_EXT_AQLPROFILE_API_TABLE_ID) {
|
||||
aqlprofile_api = (*(AqlProfileExtTable *)ext_table);
|
||||
hsa_api.aqlprofile_ext_ = (AqlProfileExtTable *)ext_table;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Update Api table for Hsa Core Runtime
|
||||
|
||||
@@ -271,6 +271,7 @@ void ExtensionEntryPoints::Unload() {
|
||||
|
||||
InitFinalizerExtTable();
|
||||
InitImageExtTable();
|
||||
InitAqlProfileExtTable();
|
||||
InitAmdExtTable();
|
||||
core::hsa_internal_api_table_.Reset();
|
||||
}
|
||||
|
||||
@@ -569,6 +569,10 @@ hsa_status_t Runtime::GetSystemInfo(hsa_system_info_t attribute, void* value) {
|
||||
setFlag(HSA_EXTENSION_IMAGES);
|
||||
}
|
||||
|
||||
if (hsa_internal_api_table_.aqlprofile_api.hsa_ven_amd_aqlprofile_error_string_fn != NULL) {
|
||||
setFlag(HSA_EXTENSION_AMD_AQLPROFILE);
|
||||
}
|
||||
|
||||
setFlag(HSA_EXTENSION_AMD_PROFILER);
|
||||
|
||||
break;
|
||||
@@ -1062,6 +1066,8 @@ void Runtime::LoadExtensions() {
|
||||
|
||||
// Update Hsa Api Table with handle of AqlProfile extension Apis
|
||||
extensions_.LoadAqlProfileApi(kAqlProfileLib[os_index(os::current_os)]);
|
||||
hsa_api_table_.LinkExts(&extensions_.aqlprofile_api,
|
||||
core::HsaApiTable::HSA_EXT_AQLPROFILE_API_TABLE_ID);
|
||||
}
|
||||
|
||||
void Runtime::UnloadExtensions() { extensions_.Unload(); }
|
||||
|
||||
@@ -365,6 +365,8 @@ struct HsaApiTable {
|
||||
// Table of function pointers to HSA Image Extension
|
||||
ImageExtTable* image_ext_;
|
||||
|
||||
// Table of function pointers to AqlProfile AMD Extension
|
||||
AqlProfileExtTable* aqlprofile_ext_;
|
||||
};
|
||||
|
||||
// Structure containing instances of different api tables
|
||||
@@ -374,6 +376,7 @@ struct HsaApiTableContainer {
|
||||
AmdExtTable amd_ext;
|
||||
FinalizerExtTable finalizer_ext;
|
||||
ImageExtTable image_ext;
|
||||
AqlProfileExtTable aqlprofile_ext;
|
||||
|
||||
// Default initialization of a container instance
|
||||
HsaApiTableContainer() {
|
||||
@@ -400,12 +403,18 @@ struct HsaApiTableContainer {
|
||||
image_ext.version.minor_id = sizeof(ImageExtTable);
|
||||
image_ext.version.step_id = HSA_IMAGE_API_TABLE_STEP_VERSION;
|
||||
root.image_ext_ = &image_ext;
|
||||
|
||||
aqlprofile_ext.version.major_id = HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION;
|
||||
aqlprofile_ext.version.minor_id = sizeof(AqlProfileExtTable);
|
||||
aqlprofile_ext.version.step_id = HSA_AQLPROFILE_API_TABLE_STEP_VERSION;
|
||||
root.aqlprofile_ext_ = &aqlprofile_ext;
|
||||
}
|
||||
};
|
||||
|
||||
// Api to copy function pointers of a table
|
||||
static
|
||||
void inline copyApi(void* src, void* dest, size_t size) {
|
||||
assert(size >= sizeof(ApiTableVersion));
|
||||
memcpy((char*)src + sizeof(ApiTableVersion),
|
||||
(char*)dest + sizeof(ApiTableVersion),
|
||||
(size - sizeof(ApiTableVersion)));
|
||||
@@ -413,7 +422,7 @@ void inline copyApi(void* src, void* dest, size_t size) {
|
||||
|
||||
// Copy Api child tables if valid.
|
||||
static void inline copyElement(ApiTableVersion* dest, ApiTableVersion* src) {
|
||||
if (dest->major_id == src->major_id) {
|
||||
if (src->major_id && (dest->major_id == src->major_id)) {
|
||||
dest->step_id = src->step_id;
|
||||
dest->minor_id = Min(dest->minor_id, src->minor_id);
|
||||
copyApi(dest, src, dest->minor_id);
|
||||
@@ -454,5 +463,7 @@ static void inline copyTables(const HsaApiTable* src, HsaApiTable* dest) {
|
||||
copyElement(&dest->finalizer_ext_->version, &src->finalizer_ext_->version);
|
||||
if ((offsetof(HsaApiTable, image_ext_) < dest->version.minor_id))
|
||||
copyElement(&dest->image_ext_->version, &src->image_ext_->version);
|
||||
if ((offsetof(HsaApiTable, aqlprofile_ext_) < dest->version.minor_id))
|
||||
copyElement(&dest->aqlprofile_ext_->version, &src->aqlprofile_ext_->version);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user