Export Amd Extension APIs including support for Version Control

Change-Id: I8c03cbd4049e8115ae00d51f193b9c31ac941f21


[ROCm/ROCR-Runtime commit: 95dc97da7b]
Tento commit je obsažen v:
Ramesh Errabolu
2016-06-10 17:31:13 -05:00
rodič 0bbc303295
revize d260c22467
13 změnil soubory, kde provedl 1278 přidání a 449 odebrání
+20 -9
Zobrazit soubor
@@ -47,17 +47,28 @@
#include "core/inc/hsa_internal.h"
namespace core {
struct ApiTable {
::ApiTable table;
ExtTable extension_backup;
struct HsaApiTable {
ApiTable();
void Reset();
void LinkExts(ExtTable* ptr);
};
static const uint32_t HSA_EXT_FINALIZER_API_TABLE_ID = 0;
static const uint32_t HSA_EXT_IMAGE_API_TABLE_ID = 1;
extern ApiTable hsa_api_table_;
extern ApiTable hsa_internal_api_table_;
::HsaApiTable hsa_api;
::CoreApiTable core_api;
::AmdExtTable amd_ext_api;
::FinalizerExtTable finalizer_api;
::ImageExtTable image_api;
HsaApiTable();
void Init();
void UpdateCore();
void UpdateAmdExts();
void CloneExts(void* ptr, uint32_t table_id);
void LinkExts(void* ptr, uint32_t table_id);
void Reset();
};
extern HsaApiTable hsa_api_table_;
extern HsaApiTable hsa_internal_api_table_;
}
#endif
+186
Zobrazit soubor
@@ -0,0 +1,186 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
////////////////////////////////////////////////////////////////////////////////
// HSA AMD extension.
#ifndef HSA_RUNTIME_CORE_INC_EXT_AMD_H_
#define HSA_RUNTIME_CORE_INC_EXT_AMD_H_
#include "hsa.h"
#include "hsa_ext_image.h"
#include "hsa_ext_amd.h"
// Wrap internal implementation inside AMD namespace
namespace AMD {
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_coherency_get_type(hsa_agent_t agent,
hsa_amd_coherency_type_t* type);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_coherency_set_type(hsa_agent_t agent,
hsa_amd_coherency_type_t type);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_profiling_set_profiler_enabled(hsa_queue_t* queue, int enable);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_profiling_async_copy_enable(bool enable);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_profiling_get_dispatch_time(
hsa_agent_t agent, hsa_signal_t signal,
hsa_amd_profiling_dispatch_time_t* time);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_profiling_get_async_copy_time(
hsa_signal_t signal, hsa_amd_profiling_async_copy_time_t* time);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_profiling_convert_tick_to_system_domain(hsa_agent_t agent,
uint64_t agent_tick,
uint64_t* system_tick);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_signal_async_handler(hsa_signal_t signal,
hsa_signal_condition_t cond,
hsa_signal_value_t value,
hsa_amd_signal_handler handler, void* arg);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_async_function(void (*callback)(void* arg), void* arg);
// Mirrors Amd Extension Apis
uint32_t HSA_API
hsa_amd_signal_wait_any(uint32_t signal_count, hsa_signal_t* signals,
hsa_signal_condition_t* conds,
hsa_signal_value_t* values, uint64_t timeout_hint,
hsa_wait_state_t wait_hint,
hsa_signal_value_t* satisfying_value);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_queue_cu_set_mask(const hsa_queue_t* queue,
uint32_t num_cu_mask_count,
const uint32_t* cu_mask);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_memory_pool_get_info(hsa_amd_memory_pool_t memory_pool,
hsa_amd_memory_pool_info_t attribute,
void* value);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_agent_iterate_memory_pools(
hsa_agent_t agent,
hsa_status_t (*callback)(hsa_amd_memory_pool_t memory_pool, void* data),
void* data);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, size_t size,
uint32_t flags, void** ptr);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_memory_pool_free(void* ptr);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_memory_async_copy(void* dst, hsa_agent_t dst_agent, const void* src,
hsa_agent_t src_agent, size_t size,
uint32_t num_dep_signals,
const hsa_signal_t* dep_signals,
hsa_signal_t completion_signal);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_agent_memory_pool_get_info(
hsa_agent_t agent, hsa_amd_memory_pool_t memory_pool,
hsa_amd_agent_memory_pool_info_t attribute, void* value);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_agents_allow_access(uint32_t num_agents, const hsa_agent_t* agents,
const uint32_t* flags, const void* ptr);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_memory_pool_can_migrate(hsa_amd_memory_pool_t src_memory_pool,
hsa_amd_memory_pool_t dst_memory_pool,
bool* result);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_memory_migrate(const void* ptr,
hsa_amd_memory_pool_t memory_pool,
uint32_t flags);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_memory_lock(void* host_ptr, size_t size,
hsa_agent_t* agents, int num_agent,
void** agent_ptr);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_memory_unlock(void* host_ptr);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API
hsa_amd_memory_fill(void* ptr, uint32_t value, size_t count);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_interop_map_buffer(uint32_t num_agents,
hsa_agent_t* agents,
int interop_handle,
uint32_t flags,
size_t* size,
void** ptr,
size_t* metadata_size,
const void** metadata);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_interop_unmap_buffer(void* ptr);
} // end of AMD namespace
#endif // header guard
+22 -6
Zobrazit soubor
@@ -52,27 +52,43 @@
#include "core/util/utils.h"
namespace core {
struct ExtTableInternal : public ExtTable {
struct ImageExtTableInternal : public ImageExtTable {
decltype(::hsa_amd_image_get_info_max_dim)* hsa_amd_image_get_info_max_dim_fn;
decltype(::hsa_amd_image_create)* hsa_amd_image_create_fn;
};
class ExtensionEntryPoints {
public:
ExtTableInternal table;
// Table of function pointers for Hsa Extension Image
ImageExtTableInternal image_api;
// Table of function pointers for Hsa Extension Finalizer
FinalizerExtTable finalizer_api;
ExtensionEntryPoints();
bool Load(std::string library_name);
bool LoadFinalizer(std::string library_name);
bool LoadImage(std::string library_name);
void Unload();
private:
typedef void (*Load_t)(const ::ApiTable* table);
typedef void (*Load_t)(const ::HsaApiTable* table);
typedef void (*Unload_t)();
std::vector<os::LibHandle> libs_;
void InitTable();
// Initialize table for HSA Finalizer Extension Api's
void InitFinalizerExtTable();
// Initialize table for HSA Image Extension Api's
void InitImageExtTable();
// Initialize Amd Ext table for Api related to Images
void InitAmdExtTable();
// Update Amd Ext table for Api related to Images
void UpdateAmdExtTable(void *func_ptr);
DISALLOW_COPY_AND_ASSIGN(ExtensionEntryPoints);
};
}
@@ -42,6 +42,6 @@
#include "hsa_api_trace.h"
void hsa_table_interface_init(const ApiTable* table);
void hsa_table_interface_init(const HsaApiTable* apiTable);
const ApiTable* hsa_table_interface_get_table();
const HsaApiTable* hsa_table_interface_get_table();