Implement new load map API.
Change-Id: I5f148fe66f899b2fa6a2e75430afa988f38db58d
[ROCm/ROCR-Runtime commit: 0e4cab3001]
This commit is contained in:
@@ -133,6 +133,7 @@ set ( CORE_SRCS ${CORE_SRCS} runtime/amd_gpu_agent.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/amd_aql_queue.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/amd_loader_context.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/hsa_ven_amd_loaded_code_object.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/hsa_ven_amd_loader.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/amd_memory_region.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/amd_topology.cpp )
|
||||
set ( CORE_SRCS ${CORE_SRCS} runtime/default_signal.cpp )
|
||||
|
||||
@@ -103,6 +103,7 @@ namespace amd {
|
||||
virtual uint64_t imageSize() const = 0;
|
||||
virtual uint64_t vaddr() const = 0;
|
||||
virtual uint64_t flags() const = 0;
|
||||
virtual uint64_t offset() const = 0;
|
||||
virtual const char* data() const = 0;
|
||||
virtual uint16_t getSegmentIndex() = 0;
|
||||
virtual bool updateAddSection(Section *section) = 0;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <cstdint>
|
||||
#include "hsa.h"
|
||||
#include "hsa_ext_image.h"
|
||||
#include "hsa_ven_amd_loader.h"
|
||||
#include "amd_hsa_elf.h"
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
@@ -317,6 +318,13 @@ public:
|
||||
void *data),
|
||||
void *data) = 0;
|
||||
|
||||
virtual size_t GetNumSegmentDescriptors() = 0;
|
||||
|
||||
virtual size_t QuerySegmentDescriptors(
|
||||
hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors,
|
||||
size_t total_num_segment_descriptors,
|
||||
size_t first_empty_segment_descriptor) = 0;
|
||||
|
||||
virtual uint64_t FindHostAddress(uint64_t device_address) = 0;
|
||||
|
||||
virtual void Print(std::ostream& out) = 0;
|
||||
@@ -368,6 +376,11 @@ public:
|
||||
void *data),
|
||||
void *data) = 0;
|
||||
|
||||
/// @brief same as hsa_ven_amd_loader_query_segment_descriptors.
|
||||
virtual hsa_status_t QuerySegmentDescriptors(
|
||||
hsa_ven_amd_loader_segment_descriptor_t *segment_descriptors,
|
||||
size_t *num_segment_descriptors) = 0;
|
||||
|
||||
/// @brief Returns host address given @p device_address. If @p device_address
|
||||
/// is already host address, returns null pointer. If @p device_address is
|
||||
/// invalid address, returns null pointer.
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "core/inc/interrupt_signal.h"
|
||||
#include "core/inc/amd_loader_context.hpp"
|
||||
#include "inc/hsa_ven_amd_loaded_code_object.h"
|
||||
#include "inc/hsa_ven_amd_loader.h"
|
||||
|
||||
using namespace amd::hsa::code;
|
||||
|
||||
@@ -168,9 +169,7 @@ hsa_status_t
|
||||
uint16_t version_minor, bool* result) {
|
||||
IS_OPEN();
|
||||
|
||||
if ((extension > HSA_EXTENSION_AMD_PROFILER &&
|
||||
extension != HSA_EXTENSION_AMD_LOADED_CODE_OBJECT) ||
|
||||
(result == NULL)) {
|
||||
if (extension >= HSA_EXTENSION_COUNT || result == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
@@ -213,9 +212,6 @@ hsa_status_t
|
||||
}
|
||||
|
||||
if (supported) {
|
||||
ExtTable& runtime_ext_table =
|
||||
core::Runtime::runtime_singleton_->extensions_.table;
|
||||
|
||||
if (extension == HSA_EXTENSION_IMAGES) {
|
||||
// Currently there is only version 1.00.
|
||||
hsa_ext_images_1_00_pfn_t* ext_table =
|
||||
@@ -253,6 +249,14 @@ hsa_status_t
|
||||
hsa_ven_amd_loaded_code_object_query_host_address;
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
} else if (extension == HSA_EXTENSION_AMD_LOADER) {
|
||||
// Currently there is only version 1.00.
|
||||
hsa_ven_amd_loader_1_00_pfn_t* ext_table =
|
||||
reinterpret_cast<hsa_ven_amd_loader_1_00_pfn_t*>(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;
|
||||
} else {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The University of Illinois/NCSA
|
||||
// Open Source License (NCSA)
|
||||
//
|
||||
// Copyright (c) 2014-2015, Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Developed by:
|
||||
//
|
||||
// AMD Research and AMD HSA Software Development
|
||||
//
|
||||
// Advanced Micro Devices, Inc.
|
||||
//
|
||||
// www.amd.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal with the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimers.
|
||||
// - Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimers in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
// - Neither the names of Advanced Micro Devices, Inc,
|
||||
// nor the names of its contributors may be used to endorse or promote
|
||||
// products derived from this Software without specific prior written
|
||||
// permission.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS WITH THE SOFTWARE.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsa_ven_amd_loader.h"
|
||||
|
||||
#include "core/inc/amd_hsa_loader.hpp"
|
||||
#include "core/inc/runtime.h"
|
||||
|
||||
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) {
|
||||
if (false == core::Runtime::runtime_singleton_->IsOpen()) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (nullptr == device_address) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (nullptr == host_address) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
uint64_t udaddr = reinterpret_cast<uint64_t>(device_address);
|
||||
uint64_t uhaddr = Runtime::runtime_singleton_->loader()->FindHostAddress(udaddr);
|
||||
if (0 == uhaddr) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
*host_address = reinterpret_cast<void*>(uhaddr);
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user