diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp index 08852b9b40..fdb40b68cd 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -358,7 +358,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v if (extension == HSA_EXTENSION_IMAGES) { if (version_major > 1) return HSA_STATUS_ERROR; - hsa_ext_images_1_00_pfn_t ext_table; + hsa_ext_images_1_pfn_t ext_table; ext_table.hsa_ext_image_clear = hsa_ext_image_clear; ext_table.hsa_ext_image_copy = hsa_ext_image_copy; ext_table.hsa_ext_image_create = hsa_ext_image_create; @@ -369,6 +369,9 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v ext_table.hsa_ext_image_import = hsa_ext_image_import; ext_table.hsa_ext_sampler_create = hsa_ext_sampler_create; ext_table.hsa_ext_sampler_destroy = hsa_ext_sampler_destroy; + ext_table.hsa_ext_image_get_capability_with_layout = hsa_ext_image_get_capability_with_layout; + ext_table.hsa_ext_image_data_get_info_with_layout = hsa_ext_image_data_get_info_with_layout; + ext_table.hsa_ext_image_create_with_layout = hsa_ext_image_create_with_layout; memcpy(table, &ext_table, Min(sizeof(ext_table), table_length)); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp index 75ecb0b8f4..39dc71fb50 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp @@ -207,6 +207,9 @@ void ExtensionEntryPoints::InitImageExtTable() { image_api.hsa_ext_sampler_create_fn = hsa_ext_null; image_api.hsa_ext_sampler_destroy_fn = hsa_ext_null; image_api.hsa_amd_image_get_info_max_dim_fn = hsa_ext_null; + image_api.hsa_ext_image_get_capability_with_layout_fn = hsa_ext_null; + image_api.hsa_ext_image_data_get_info_with_layout_fn = hsa_ext_null; + image_api.hsa_ext_image_create_with_layout_fn = hsa_ext_null; } // Initialize Amd Ext table for Api related to Images @@ -346,6 +349,32 @@ bool ExtensionEntryPoints::LoadImage(std::string library_name) { (decltype(::hsa_ext_sampler_destroy)*)ptr; } + ptr = os::GetExportAddress(lib, "hsa_ext_image_get_capability_with_layout_impl"); + if (ptr != NULL) { + assert(image_api.hsa_ext_image_get_capability_with_layout_fn == + (decltype(::hsa_ext_image_get_capability_with_layout)*)hsa_ext_null && + "Duplicate load of extension import."); + image_api.hsa_ext_image_get_capability_with_layout_fn = + (decltype(::hsa_ext_image_get_capability_with_layout)*)ptr; + } + + ptr = os::GetExportAddress(lib, "hsa_ext_image_data_get_info_with_layout_impl"); + if (ptr != NULL) { + assert(image_api.hsa_ext_image_data_get_info_with_layout_fn == + (decltype(::hsa_ext_image_data_get_info_with_layout)*)hsa_ext_null && + "Duplicate load of extension import."); + image_api.hsa_ext_image_data_get_info_with_layout_fn = + (decltype(::hsa_ext_image_data_get_info_with_layout)*)ptr; + } + + ptr = os::GetExportAddress(lib, "hsa_ext_image_create_with_layout_impl"); + if (ptr != NULL) { + assert(image_api.hsa_ext_image_create_with_layout_fn == + (decltype(::hsa_ext_image_create_with_layout)*)hsa_ext_null && + "Duplicate load of extension import."); + image_api.hsa_ext_image_create_with_layout_fn = (decltype(::hsa_ext_image_create_with_layout)*)ptr; + } + ptr = os::GetExportAddress(lib, "hsa_amd_image_get_info_max_dim_impl"); if (ptr != NULL) { assert(image_api.hsa_amd_image_get_info_max_dim_fn == @@ -588,6 +617,44 @@ hsa_status_t hsa_ext_sampler_destroy(hsa_agent_t agent, .hsa_ext_sampler_destroy_fn(agent, sampler); } +hsa_status_t hsa_ext_image_get_capability_with_layout( + hsa_agent_t agent, hsa_ext_image_geometry_t geometry, + const hsa_ext_image_format_t* image_format, + hsa_ext_image_data_layout_t image_data_layout, + uint32_t* capability_mask) { + return core::Runtime::runtime_singleton_->extensions_.image_api + .hsa_ext_image_get_capability_with_layout_fn(agent, geometry, image_format, + image_data_layout, capability_mask); +} + +hsa_status_t hsa_ext_image_data_get_info_with_layout( + hsa_agent_t agent, const hsa_ext_image_descriptor_t* image_descriptor, + hsa_access_permission_t access_permission, + hsa_ext_image_data_layout_t image_data_layout, + size_t image_data_row_pitch, + size_t image_data_slice_pitch, + hsa_ext_image_data_info_t* image_data_info) { + return core::Runtime::runtime_singleton_->extensions_.image_api + .hsa_ext_image_data_get_info_with_layout_fn(agent, image_descriptor, + access_permission, image_data_layout, + image_data_row_pitch, image_data_slice_pitch, + image_data_info); +} + +hsa_status_t hsa_ext_image_create_with_layout( + hsa_agent_t agent, const hsa_ext_image_descriptor_t* image_descriptor, + const void* image_data, hsa_access_permission_t access_permission, + hsa_ext_image_data_layout_t image_data_layout, + size_t image_data_row_pitch, + size_t image_data_slice_pitch, + hsa_ext_image_t* image) { + return core::Runtime::runtime_singleton_->extensions_.image_api + .hsa_ext_image_create_with_layout_fn(agent, image_descriptor, image_data, + access_permission, image_data_layout, + image_data_row_pitch, image_data_slice_pitch, + image); +} + //---------------------------------------------------------------------------// // Stubs for internal extension functions //---------------------------------------------------------------------------// diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h index d4e42ee7bd..6581e10957 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h @@ -109,6 +109,9 @@ struct ImageExtTable { decltype(hsa_ext_image_destroy)* hsa_ext_image_destroy_fn; decltype(hsa_ext_sampler_create)* hsa_ext_sampler_create_fn; decltype(hsa_ext_sampler_destroy)* hsa_ext_sampler_destroy_fn; + decltype(hsa_ext_image_get_capability_with_layout)* hsa_ext_image_get_capability_with_layout_fn; + decltype(hsa_ext_image_data_get_info_with_layout)* hsa_ext_image_data_get_info_with_layout_fn; + decltype(hsa_ext_image_create_with_layout)* hsa_ext_image_create_with_layout_fn; }; // Table to export AMD Extension Apis diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h index a0babdfa17..de358c3dbd 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h @@ -655,6 +655,7 @@ hsa_status_t HSA_API hsa_ext_image_data_get_info( * or @p image_data_info is NULL. */ hsa_status_t HSA_API hsa_ext_image_data_get_info_with_layout( + hsa_agent_t agent, const hsa_ext_image_descriptor_t *image_descriptor, hsa_access_permission_t access_permission, hsa_ext_image_data_layout_t image_data_layout, @@ -1425,6 +1426,7 @@ typedef struct hsa_ext_images_1_pfn_s { uint32_t *capability_mask); hsa_status_t (*hsa_ext_image_data_get_info_with_layout)( + hsa_agent_t agent, const hsa_ext_image_descriptor_t *image_descriptor, hsa_access_permission_t access_permission, hsa_ext_image_data_layout_t image_data_layout,