From 83d9c273a540c15ee25ec88e152b1d7d271c2edb Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 19 Jul 2016 13:01:08 -0400 Subject: [PATCH] Reorder loader extension functions to maintain backwards compatibility Change-Id: I93f0899cdece4bab167290085da67d1a1770eb9b [ROCm/ROCR-Runtime commit: 49a6a3972455a5aa055c3237888211cc9301ceb2] --- .../runtime/hsa-runtime/core/runtime/hsa.cpp | 6 +- .../core/runtime/hsa_ven_amd_loader.cpp | 22 ++--- .../hsa-runtime/inc/hsa_ven_amd_loader.h | 80 +++++++++---------- 3 files changed, 54 insertions(+), 54 deletions(-) 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 d48af4f4d6..fdda3cf61b 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -228,7 +228,7 @@ hsa_status_t return HSA_STATUS_SUCCESS; } - + if (extension == HSA_EXTENSION_FINALIZER) { // Currently there is only version 1.00. hsa_ext_finalizer_1_00_pfn_s* ext_table = @@ -248,10 +248,10 @@ hsa_status_t // Currently there is only version 1.00. hsa_ven_amd_loader_1_00_pfn_t* ext_table = reinterpret_cast(table); - ext_table->hsa_ven_amd_loader_query_segment_descriptors = - hsa_ven_amd_loader_query_segment_descriptors; ext_table->hsa_ven_amd_loader_query_host_address = hsa_ven_amd_loader_query_host_address; + ext_table->hsa_ven_amd_loader_query_segment_descriptors = + hsa_ven_amd_loader_query_segment_descriptors; return HSA_STATUS_SUCCESS; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ven_amd_loader.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ven_amd_loader.cpp index 15ea754b3a..ba951053e3 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ven_amd_loader.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ven_amd_loader.cpp @@ -47,17 +47,6 @@ using namespace core; -hsa_status_t HSA_API hsa_ven_amd_loader_query_segment_descriptors( - hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors, - size_t *num_segment_descriptors) { - if (false == core::Runtime::runtime_singleton_->IsOpen()) { - return HSA_STATUS_ERROR_NOT_INITIALIZED; - } - - // Arguments are checked by the loader. - return Runtime::runtime_singleton_->loader()->QuerySegmentDescriptors(segment_descriptors, num_segment_descriptors); -} - hsa_status_t HSA_API hsa_ven_amd_loader_query_host_address( const void *device_address, const void **host_address) { @@ -80,3 +69,14 @@ hsa_status_t HSA_API hsa_ven_amd_loader_query_host_address( *host_address = reinterpret_cast(uhaddr); return HSA_STATUS_SUCCESS; } + +hsa_status_t HSA_API hsa_ven_amd_loader_query_segment_descriptors( + hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors, + size_t *num_segment_descriptors) { + if (false == core::Runtime::runtime_singleton_->IsOpen()) { + return HSA_STATUS_ERROR_NOT_INITIALIZED; + } + + // Arguments are checked by the loader. + return Runtime::runtime_singleton_->loader()->QuerySegmentDescriptors(segment_descriptors, num_segment_descriptors); +} diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_loader.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_loader.h index a566f2ee25..804a360a2b 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_loader.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_loader.h @@ -51,6 +51,42 @@ extern "C" { #endif /* __cplusplus */ +/** + * @brief Queries equivalent host address for given @p device_address, and + * records it in @p host_address. + * + * + * @details Contents of memory pointed to by @p host_address would be identical + * to contents of memory pointed to by @p device_address. Only difference + * between the two is host accessibility: @p host_address is always accessible + * from host, @p device_address might not be accessible from host. + * + * If @p device_address already points to host accessible memory, then the value + * of @p device_address is simply copied into @p host_address. + * + * The lifetime of @p host_address is the same as the lifetime of @p + * device_address, and both lifetimes are limited by the lifetime of the + * executable that is managing these addresses. + * + * + * @param[in] device_address Device address to query equivalent host address + * for. + * + * @param[out] host_address Pointer to application-allocated buffer to record + * queried equivalent host address in. + * + * + * @retval HSA_STATUS_SUCCESS Function is executed successfully. + * + * @retval HSA_STATUS_ERROR_NOT_INITIALIZED Runtime is not initialized. + * + * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p device_address is invalid or + * null, or @p host_address is null. + */ +hsa_status_t HSA_API hsa_ven_amd_loader_query_host_address( + const void *device_address, + const void **host_address); + /** * @brief The storage type of the code object that is backing loaded memory * segment. @@ -188,42 +224,6 @@ hsa_status_t HSA_API hsa_ven_amd_loader_query_segment_descriptors( hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors, size_t *num_segment_descriptors); -/** - * @brief Queries equivalent host address for given @p device_address, and - * records it in @p host_address. - * - * - * @details Contents of memory pointed to by @p host_address would be identical - * to contents of memory pointed to by @p device_address. Only difference - * between the two is host accessibility: @p host_address is always accessible - * from host, @p device_address might not be accessible from host. - * - * If @p device_address already points to host accessible memory, then the value - * of @p device_address is simply copied into @p host_address. - * - * The lifetime of @p host_address is the same as the lifetime of @p - * device_address, and both lifetimes are limited by the lifetime of the - * executable that is managing these addresses. - * - * - * @param[in] device_address Device address to query equivalent host address - * for. - * - * @param[out] host_address Pointer to application-allocated buffer to record - * queried equivalent host address in. - * - * - * @retval HSA_STATUS_SUCCESS Function is executed successfully. - * - * @retval HSA_STATUS_ERROR_NOT_INITIALIZED Runtime is not initialized. - * - * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p device_address is invalid or - * null, or @p host_address is null. - */ -hsa_status_t HSA_API hsa_ven_amd_loader_query_host_address( - const void *device_address, - const void **host_address); - /** * @brief Extension version. */ @@ -233,13 +233,13 @@ hsa_status_t HSA_API hsa_ven_amd_loader_query_host_address( * @brief Extension function table. */ typedef struct hsa_ven_amd_loader_1_00_pfn_s { - hsa_status_t (*hsa_ven_amd_loader_query_segment_descriptors)( - hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors, - size_t *num_segment_descriptors); - hsa_status_t (*hsa_ven_amd_loader_query_host_address)( const void *device_address, const void **host_address); + + hsa_status_t (*hsa_ven_amd_loader_query_segment_descriptors)( + hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors, + size_t *num_segment_descriptors); } hsa_ven_amd_loader_1_00_pfn_t; #ifdef __cplusplus