Build ROCr core and image libraries as one shared object
Change-Id: I3a16c1227e7db2e386ab33886965596fa0fb0c87
[ROCm/ROCR-Runtime commit: 0ca0691ca7]
Este commit está contenido en:
cometido por
Sean Keely
padre
f80ce871b3
commit
c9f453a8a8
Archivo ejecutable → Archivo normal
+11
-66
@@ -18,7 +18,7 @@ if (ROCM_CCACHE_BUILD)
|
||||
endif() # if (ROCM_CCACHE_BUILD)
|
||||
|
||||
## Include the cmake_modules utils.cmake
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/cmake_modules" )
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules" )
|
||||
include ( utils )
|
||||
|
||||
## Compiler preproc definitions.
|
||||
@@ -46,25 +46,13 @@ endif ()
|
||||
set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}" )
|
||||
set( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${VERSION_JOB}-${VERSION_HASH}" )
|
||||
|
||||
## Find the hsakmt library and include files
|
||||
get_include_path( HSAKMT_INC_PATH "libhsakmt include path" NAMES "hsakmt.h" "libhsakmt/hsakmt.h" HINTS "${CMAKE_BINARY_DIR}/../../include" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../libhsakmt/include" PATHS "/opt/rocm/include")
|
||||
get_library_path( HSAKMT_LIB_PATH "libhsakmt library path" NAMES "libhsakmt.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../roct" PATHS "/opt/rocm/lib")
|
||||
include_directories( ${HSAKMT_INC_PATH} )
|
||||
link_directories( ${HSAKMT_LIB_PATH} )
|
||||
|
||||
## Find the hsa-runtime and include files
|
||||
get_include_path( HSA_INC_PATH "ROCr include path" NAMES "inc/hsa.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime" "${CMAKE_BINARY_DIR}/../../include" PATHS "/opt/rocm/include")
|
||||
get_library_path( HSA_LIB_PATH "ROCr library path" NAMES "libhsa-runtime64.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../hsa-core" "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/build" PATHS "/opt/rocm/lib")
|
||||
include_directories( ${HSA_INC_PATH} )
|
||||
link_directories( ${HSA_LIB_PATH} )
|
||||
|
||||
## Find self
|
||||
if( "${IMAGE_SOURCE_DIR}" STREQUAL "" )
|
||||
get_include_path( IMG_SOURCE_FILE null NAMES "image_runtime.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/image/" )
|
||||
get_filename_component( IMAGE_SOURCE_DIR "${IMG_SOURCE_FILE}" ABSOLUTE )
|
||||
unset( IMG_SOURCE_FILE CACHE )
|
||||
if( "${EXT_SOURCE_DIR}" STREQUAL "" )
|
||||
get_include_path( EXT_SOURCE_FILE null NAMES "image/hsa_ext_image.cpp" HINTS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../ext/" )
|
||||
get_filename_component( EXT_SOURCE_DIR "${EXT_SOURCE_FILE}/.." ABSOLUTE )
|
||||
unset( EXT_SOURCE_FILE CACHE )
|
||||
endif()
|
||||
set( IMAGE_SOURCE_DIR ${IMAGE_SOURCE_DIR} CACHE PATH "Image lib source dir" FORCE )
|
||||
set( EXT_SOURCE_DIR ${EXT_SOURCE_DIR} CACHE PATH "Image lib source dir" FORCE )
|
||||
|
||||
get_filename_component( OPEN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE CACHE )
|
||||
set( OPEN_SOURCE_DIR ${OPEN_SOURCE_DIR} CACHE PATH "Open source root dir" FORCE )
|
||||
@@ -87,61 +75,20 @@ if ( "${CMAKE_BUILD_TYPE}" STREQUAL Debug )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb" )
|
||||
endif ()
|
||||
|
||||
set ( DRVDEF "${IMAGE_SOURCE_DIR}/image.so.def" )
|
||||
set ( DRVDEF "${EXT_SOURCE_DIR}/image/image.so.def" )
|
||||
|
||||
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,--version-script=${DRVDEF} -Wl,--enable-new-dtags" )
|
||||
|
||||
## Library path(s).
|
||||
include_directories(${IMAGE_SOURCE_DIR}/)
|
||||
include_directories(${REG_INCLUDE})
|
||||
include_directories(${EXT_SOURCE_DIR}/..)
|
||||
include_directories(${EXT_SOURCE_DIR}/inc)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime/inc)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime/core/inc)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/inc)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/core)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/r800)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/gfx9)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/gfx10)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/r800)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/gfx9)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/gfx10)
|
||||
|
||||
set ( IMAGE_SRCS ${IMAGE_SOURCE_DIR}/addrlib/src/addrinterface.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/coord.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib1.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib2.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrobject.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrelemlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/ciaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/egbaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/siaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/gfx9/gfx9addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/gfx10/gfx10addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/amd_ext.cpp
|
||||
${IMAGE_SOURCE_DIR}/device_info.cpp
|
||||
${IMAGE_SOURCE_DIR}/hsa_ext_image.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_runtime.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_kv.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_ai.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_nv.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_lut_kv.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx7xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx8xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx9xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/opencl_blit_objects.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_kernel.cpp
|
||||
${OPEN_SOURCE_DIR}/hsa-runtime/core/common/shared.cpp
|
||||
${OPEN_SOURCE_DIR}/hsa-runtime/core/common/hsa_table_interface.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(${IMAGE_SOURCE_DIR}/blit_src ${CMAKE_CURRENT_BINARY_DIR}/image_blit)
|
||||
set_source_files_properties(${IMAGE_SOURCE_DIR}/opencl_blit_objects.cpp PROPERTIES GENERATED 1)
|
||||
set ( IMAGE_SRCS ${EXT_SOURCE_DIR}/image/hsa_ext_image.cpp)
|
||||
|
||||
add_library ( ${IMAGE_TARGET} SHARED ${IMAGE_SRCS} )
|
||||
add_dependencies( ${IMAGE_TARGET} opencl_blit_objects.cpp )
|
||||
|
||||
## Set the VERSION and SOVERSION values
|
||||
set_property ( TARGET ${IMAGE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" )
|
||||
@@ -150,8 +97,6 @@ set_property ( TARGET ${IMAGE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" )
|
||||
## Add the core runtime in the link
|
||||
target_link_libraries (
|
||||
${IMAGE_TARGET}
|
||||
PRIVATE hsa-runtime64
|
||||
PRIVATE hsakmt
|
||||
c dl pthread rt
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +46,13 @@ cmake_minimum_required ( VERSION 3.5.0 )
|
||||
set ( CORE_RUNTIME_NAME "hsa-runtime" )
|
||||
set ( CORE_RUNTIME_TARGET "${CORE_RUNTIME_NAME}64" )
|
||||
set ( CORE_RUNTIME_LIBRARY "lib${CORE_RUNTIME_TARGET}" )
|
||||
|
||||
## Set image module name
|
||||
set ( IMAGE_NAME "hsa-ext-image" )
|
||||
set ( IMAGE_TARGET "${IMAGE_NAME}64" )
|
||||
set ( IMAGE_LIBRARY "lib${IMAGE_TARGET}" )
|
||||
|
||||
## Set project name
|
||||
project( ${CORE_RUNTIME_TARGET} )
|
||||
|
||||
if ( NOT DEFINED BUILD_SHARED_LIBS )
|
||||
@@ -172,6 +179,14 @@ set ( SRCS "core/util/lnx/os_linux.cpp"
|
||||
|
||||
add_library( ${CORE_RUNTIME_TARGET} ${SRCS} )
|
||||
|
||||
## Build Blit kernels
|
||||
set(IMAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/image)
|
||||
add_subdirectory(${IMAGE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/image)
|
||||
|
||||
## Link Core runtime with Thunk (ROCt) and Image libraries
|
||||
#target_link_libraries ( ${CORE_RUNTIME_TARGET} PUBLIC ${IMAGE_SOURCE_DIR} )
|
||||
target_link_libraries ( ${CORE_RUNTIME_TARGET} PRIVATE ${IMAGE_TARGET} )
|
||||
#target_link_libraries ( ${CORE_RUNTIME_TARGET} ${IMAGE_TARGET} )
|
||||
target_link_libraries ( ${CORE_RUNTIME_TARGET}
|
||||
PRIVATE hsakmt
|
||||
elf dl pthread rt
|
||||
@@ -227,8 +242,21 @@ set ( CPACK_DEBIAN_PACKAGE_DEPENDS "hsakmt-roct" )
|
||||
set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCR-Runtime" )
|
||||
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm" )
|
||||
|
||||
# Declare that this package will replace functionality provided by hsa-ext-rocr-dev package
|
||||
set ( CPACK_DEBIAN_PACKAGE_BREAKS "hsa-ext-rocr-dev" )
|
||||
set ( CPACK_DEBIAN_PACKAGE_PROVIDES "hsa-ext-rocr-dev" )
|
||||
set ( CPACK_DEBIAN_PACKAGE_REPLACES "hsa-ext-rocr-dev" )
|
||||
set ( CPACK_DEBIAN_PACKAGE_CONFLICTS "hsa-ext-rocr-dev" )
|
||||
|
||||
## RPM package specific variables
|
||||
set ( CPACK_RPM_PACKAGE_DEPENDS "hsakmt-roct" )
|
||||
|
||||
# Declare that this package will replace functionality provided by hsa-ext-rocr-dev package
|
||||
#set ( CPACK_DEBIAN_PACKAGE_BREAKS "hsa-ext-rocr-dev" ) # equivalent command not found
|
||||
set ( CPACK_RPM_PACKAGE_PROVIDES "hsa-ext-rocr-dev" )
|
||||
set ( CPACK_RPM_PACKAGE_OBSOLETES "hsa-ext-rocr-dev" )
|
||||
set ( CPACK_RPM_PACKAGE_CONFLICTS "hsa-ext-rocr-dev" )
|
||||
|
||||
set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post" )
|
||||
set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun" )
|
||||
|
||||
|
||||
@@ -68,9 +68,14 @@ class ExtensionEntryPoints {
|
||||
ExtensionEntryPoints();
|
||||
|
||||
bool LoadFinalizer(std::string library_name);
|
||||
bool LoadImage(std::string library_name);
|
||||
void Unload();
|
||||
|
||||
// Update Image Api table with handles to implementation
|
||||
bool LoadImage();
|
||||
|
||||
// Reset Api tables to point to null implementations
|
||||
void UnloadImage();
|
||||
|
||||
private:
|
||||
typedef void (*Load_t)(const ::HsaApiTable* table);
|
||||
typedef void (*Unload_t)();
|
||||
@@ -87,7 +92,7 @@ class ExtensionEntryPoints {
|
||||
void InitAmdExtTable();
|
||||
|
||||
// Update Amd Ext table for Api related to Images
|
||||
void UpdateAmdExtTable(void *func_ptr);
|
||||
void UpdateAmdExtTable(decltype(::hsa_amd_image_create)* func_ptr);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ExtensionEntryPoints);
|
||||
};
|
||||
|
||||
@@ -40,134 +40,18 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "image/inc/hsa_ext_image_impl.h"
|
||||
#include "core/inc/hsa_ext_interface.h"
|
||||
#include "core/inc/runtime.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "core/inc/runtime.h"
|
||||
// Implementations for missing / unsupported extensions
|
||||
template <class R, class... ARGS> static R hsa_ext_null(ARGS...) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
namespace core {
|
||||
// Implementations for missing / unsupported extensions
|
||||
template <class T0>
|
||||
static T0 hsa_ext_null() {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1>
|
||||
static T0 hsa_ext_null(T1) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2>
|
||||
static T0 hsa_ext_null(T1, T2) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3>
|
||||
static T0 hsa_ext_null(T1, T2, T3) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15, class T16>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15, T16) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15, class T16, class T17>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15, T16, T17) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15, class T16, class T17, class T18>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15, T16, T17, T18) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15, class T16, class T17, class T18,
|
||||
class T19>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15, T16, T17, T18, T19) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
|
||||
class T7, class T8, class T9, class T10, class T11, class T12,
|
||||
class T13, class T14, class T15, class T16, class T17, class T18,
|
||||
class T19, class T20>
|
||||
static T0 hsa_ext_null(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
T14, T15, T16, T17, T18, T19, T20) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
static T0 hsa_amd_null(T1, T2, T3, T4, T5, T6) {
|
||||
return HSA_STATUS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
ExtensionEntryPoints::ExtensionEntryPoints() {
|
||||
InitFinalizerExtTable();
|
||||
InitImageExtTable();
|
||||
@@ -223,21 +107,28 @@ void ExtensionEntryPoints::InitAmdExtTable() {
|
||||
// Update Amd Ext table for Api related to Images.
|
||||
// @note: Interface should be updated when Amd Ext table
|
||||
// begins hosting Api's from other extension libraries
|
||||
void ExtensionEntryPoints::UpdateAmdExtTable(void *func_ptr) {
|
||||
|
||||
void ExtensionEntryPoints::UpdateAmdExtTable(decltype(::hsa_amd_image_create)* func_ptr) {
|
||||
assert(hsa_api_table_.amd_ext_api.hsa_amd_image_create_fn ==
|
||||
(decltype(hsa_amd_image_create)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
assert(hsa_internal_api_table_.amd_ext_api.hsa_amd_image_create_fn ==
|
||||
(decltype(hsa_amd_image_create)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
hsa_api_table_.amd_ext_api.hsa_amd_image_create_fn =
|
||||
(decltype(hsa_amd_image_create)*)func_ptr;
|
||||
hsa_internal_api_table_.amd_ext_api.hsa_amd_image_create_fn =
|
||||
(decltype(hsa_amd_image_create)*)func_ptr;
|
||||
hsa_api_table_.amd_ext_api.hsa_amd_image_create_fn = func_ptr;
|
||||
hsa_internal_api_table_.amd_ext_api.hsa_amd_image_create_fn = func_ptr;
|
||||
}
|
||||
|
||||
void ExtensionEntryPoints::UnloadImage() {
|
||||
InitAmdExtTable();
|
||||
InitImageExtTable();
|
||||
core::hsa_internal_api_table_.Reset();
|
||||
rocr::image::ReleaseImageRsrcs();
|
||||
}
|
||||
|
||||
void ExtensionEntryPoints::Unload() {
|
||||
// Reset Image apis to hsa_ext_null function
|
||||
UnloadImage();
|
||||
|
||||
for (auto lib : libs_) {
|
||||
void* ptr = os::GetExportAddress(lib, "Unload");
|
||||
if (ptr) {
|
||||
@@ -259,138 +150,17 @@ void ExtensionEntryPoints::Unload() {
|
||||
core::hsa_internal_api_table_.Reset();
|
||||
}
|
||||
|
||||
bool ExtensionEntryPoints::LoadImage(std::string library_name) {
|
||||
os::LibHandle lib = os::LoadLib(library_name);
|
||||
if (lib == NULL) {
|
||||
return false;
|
||||
}
|
||||
libs_.push_back(lib);
|
||||
|
||||
void* ptr;
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_get_capability_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_get_capability_fn ==
|
||||
(decltype(::hsa_ext_image_get_capability)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_get_capability_fn =
|
||||
(decltype(::hsa_ext_image_get_capability)*)ptr;
|
||||
bool ExtensionEntryPoints::LoadImage() {
|
||||
// Consult user input on linking to Image implementation
|
||||
bool disable_image = core::Runtime::runtime_singleton_->flag().disable_image();
|
||||
if (disable_image) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_data_get_info_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_data_get_info_fn ==
|
||||
(decltype(::hsa_ext_image_data_get_info)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_data_get_info_fn =
|
||||
(decltype(::hsa_ext_image_data_get_info)*)ptr;
|
||||
}
|
||||
// Bind to Image implementation api's
|
||||
decltype(::hsa_amd_image_create)* func;
|
||||
rocr::image::LoadImage(&image_api, &func);
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_create_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_create_fn ==
|
||||
(decltype(::hsa_ext_image_create)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_create_fn = (decltype(::hsa_ext_image_create)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_import_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_import_fn ==
|
||||
(decltype(::hsa_ext_image_import)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_import_fn = (decltype(::hsa_ext_image_import)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_export_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_export_fn ==
|
||||
(decltype(::hsa_ext_image_export)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_export_fn = (decltype(::hsa_ext_image_export)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_copy_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_copy_fn ==
|
||||
(decltype(::hsa_ext_image_copy)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_copy_fn = (decltype(::hsa_ext_image_copy)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_clear_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_clear_fn ==
|
||||
(decltype(::hsa_ext_image_clear)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_clear_fn = (decltype(::hsa_ext_image_clear)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_image_destroy_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_image_destroy_fn ==
|
||||
(decltype(::hsa_ext_image_destroy)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_image_destroy_fn = (decltype(::hsa_ext_image_destroy)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_sampler_create_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_sampler_create_fn ==
|
||||
(decltype(::hsa_ext_sampler_create)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_sampler_create_fn = (decltype(::hsa_ext_sampler_create)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_ext_sampler_destroy_impl");
|
||||
if (ptr != NULL) {
|
||||
assert(image_api.hsa_ext_sampler_destroy_fn ==
|
||||
(decltype(::hsa_ext_sampler_destroy)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_ext_sampler_destroy_fn =
|
||||
(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 ==
|
||||
(decltype(::hsa_amd_image_get_info_max_dim)*)hsa_ext_null &&
|
||||
"Duplicate load of extension import.");
|
||||
image_api.hsa_amd_image_get_info_max_dim_fn =
|
||||
(decltype(::hsa_amd_image_get_info_max_dim)*)ptr;
|
||||
}
|
||||
|
||||
ptr = os::GetExportAddress(lib, "hsa_amd_image_create_impl");
|
||||
if (ptr != NULL) {
|
||||
UpdateAmdExtTable(ptr);
|
||||
}
|
||||
|
||||
// Initialize Version of Api Table
|
||||
image_api.version.major_id = HSA_IMAGE_API_TABLE_MAJOR_VERSION;
|
||||
image_api.version.minor_id = sizeof(ImageExtTable);
|
||||
@@ -400,11 +170,8 @@ bool ExtensionEntryPoints::LoadImage(std::string library_name) {
|
||||
hsa_internal_api_table_.CloneExts(&image_api,
|
||||
core::HsaApiTable::HSA_EXT_IMAGE_API_TABLE_ID);
|
||||
|
||||
ptr = os::GetExportAddress(lib, "Load");
|
||||
if (ptr != NULL) {
|
||||
((Load_t)ptr)(&core::hsa_internal_api_table_.hsa_api);
|
||||
}
|
||||
|
||||
// Update Amd Ext Api table Api that deals with Images
|
||||
UpdateAmdExtTable(func);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1349,13 +1349,9 @@ void Runtime::LoadExtensions() {
|
||||
#ifdef HSA_LARGE_MODEL
|
||||
static const std::string kFinalizerLib[] = {"hsa-ext-finalize64.dll",
|
||||
"libhsa-ext-finalize64.so.1"};
|
||||
static const std::string kImageLib[] = {"hsa-ext-image64.dll",
|
||||
"libhsa-ext-image64.so.1"};
|
||||
#else
|
||||
static const std::string kFinalizerLib[] = {"hsa-ext-finalize.dll",
|
||||
"libhsa-ext-finalize.so.1"};
|
||||
static const std::string kImageLib[] = {"hsa-ext-image.dll",
|
||||
"libhsa-ext-image.so.1"};
|
||||
#endif
|
||||
|
||||
// Update Hsa Api Table with handle of Finalizer extension Apis
|
||||
@@ -1366,7 +1362,7 @@ void Runtime::LoadExtensions() {
|
||||
core::HsaApiTable::HSA_EXT_FINALIZER_API_TABLE_ID);
|
||||
|
||||
// Update Hsa Api Table with handle of Image extension Apis
|
||||
extensions_.LoadImage(kImageLib[os_index(os::current_os)]);
|
||||
extensions_.LoadImage();
|
||||
hsa_api_table_.LinkExts(&extensions_.image_api,
|
||||
core::HsaApiTable::HSA_EXT_IMAGE_API_TABLE_ID);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,9 @@ class Flag {
|
||||
|
||||
var = os::GetEnvVar("HSA_NO_SCRATCH_THREAD_LIMITER");
|
||||
no_scratch_thread_limit_ = (var == "1") ? true : false;
|
||||
|
||||
var = os::GetEnvVar("HSA_DISABLE_IMAGE");
|
||||
disable_image_ = (var == "1") ? true : false;
|
||||
}
|
||||
|
||||
bool check_flat_scratch() const { return check_flat_scratch_; }
|
||||
@@ -153,6 +156,8 @@ class Flag {
|
||||
|
||||
std::string tools_lib_names() const { return tools_lib_names_; }
|
||||
|
||||
bool disable_image() const { return disable_image_; }
|
||||
|
||||
private:
|
||||
bool check_flat_scratch_;
|
||||
bool enable_vm_fault_message_;
|
||||
@@ -167,6 +172,7 @@ class Flag {
|
||||
bool fine_grain_pcie_;
|
||||
bool no_scratch_reclaim_;
|
||||
bool no_scratch_thread_limit_;
|
||||
bool disable_image_;
|
||||
|
||||
std::string enable_sdma_;
|
||||
|
||||
|
||||
@@ -326,6 +326,50 @@ static __forceinline std::string& rtrim(std::string& s) {
|
||||
|
||||
static __forceinline std::string& trim(std::string& s) { return ltrim(rtrim(s)); }
|
||||
|
||||
template <uint32_t lowBit, uint32_t highBit, typename T>
|
||||
static __forceinline uint32_t BitSelect(T p) {
|
||||
static_assert(sizeof(T) <= sizeof(uintptr_t), "Type out of range.");
|
||||
static_assert(highBit < sizeof(uintptr_t) * 8, "Bit index out of range.");
|
||||
|
||||
uintptr_t ptr = p;
|
||||
if (highBit != (sizeof(uintptr_t) * 8 - 1))
|
||||
return (uint32_t)((ptr & ((1ull << (highBit + 1)) - 1)) >> lowBit);
|
||||
else
|
||||
return (uint32_t)(ptr >> lowBit);
|
||||
}
|
||||
|
||||
inline uint32_t PtrLow16Shift8(const void* p) {
|
||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(p);
|
||||
return (uint32_t)((ptr & 0xFFFFULL) >> 8);
|
||||
}
|
||||
|
||||
inline uint32_t PtrHigh64Shift16(const void* p) {
|
||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(p);
|
||||
return (uint32_t)((ptr & 0xFFFFFFFFFFFF0000ULL) >> 16);
|
||||
}
|
||||
|
||||
inline uint32_t PtrLow40Shift8(const void* p) {
|
||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(p);
|
||||
return (uint32_t)((ptr & 0xFFFFFFFFFFULL) >> 8);
|
||||
}
|
||||
|
||||
inline uint32_t PtrHigh64Shift40(const void* p) {
|
||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(p);
|
||||
return (uint32_t)((ptr & 0xFFFFFF0000000000ULL) >> 40);
|
||||
}
|
||||
|
||||
inline uint32_t PtrLow32(const void* p) {
|
||||
return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(p));
|
||||
}
|
||||
|
||||
inline uint32_t PtrHigh32(const void* p) {
|
||||
uint32_t ptr = 0;
|
||||
#ifdef HSA_LARGE_MODEL
|
||||
ptr = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(p) >> 32);
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#include "atomic_helpers.h"
|
||||
|
||||
#endif // HSA_RUNTIME_CORE_UTIL_UTIIS_H_
|
||||
#endif // HSA_RUNTIME_CORE_UTIL_UTILS_H_
|
||||
|
||||
Archivo ejecutable
+182
@@ -0,0 +1,182 @@
|
||||
cmake_minimum_required ( VERSION 3.5.0 )
|
||||
|
||||
## Set ext runtime module name and project name.
|
||||
set ( IMAGE_NAME "hsa-ext-image" )
|
||||
set ( IMAGE_TARGET "${IMAGE_NAME}64" )
|
||||
set ( IMAGE_LIBRARY "lib${IMAGE_TARGET}" )
|
||||
project ( ${IMAGE_TARGET} )
|
||||
|
||||
## Build image as a shared or static library
|
||||
#if ( NOT DEFINED BUILD_SHARED_LIBS )
|
||||
# set ( BUILD_SHARED_LIBS "on" )
|
||||
#endif()
|
||||
#set ( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared library (.so) or not.")
|
||||
|
||||
# Optionally, build with ccache.
|
||||
set(ROCM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
|
||||
if (ROCM_CCACHE_BUILD)
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (CCACHE_PROGRAM)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
|
||||
else()
|
||||
message(WARNING "Unable to find ccache. Falling back to real compiler")
|
||||
endif() # if (CCACHE_PROGRAM)
|
||||
endif() # if (ROCM_CCACHE_BUILD)
|
||||
|
||||
## Include the cmake_modules utils.cmake
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules" )
|
||||
include ( utils )
|
||||
|
||||
## Compiler preproc definitions.
|
||||
add_definitions ( -D__linux__ )
|
||||
add_definitions ( -DUNIX_OS )
|
||||
add_definitions ( -DLINUX )
|
||||
add_definitions ( -D__AMD64__ )
|
||||
add_definitions ( -D__x86_64__ )
|
||||
add_definitions ( -DAMD_INTERNAL_BUILD )
|
||||
add_definitions ( -DLITTLEENDIAN_CPU=1 )
|
||||
add_definitions ( -D HSA_DEPRECATED= )
|
||||
add_definitions ( -D BRAHMA_BUILD=1 )
|
||||
|
||||
## Get the package version.
|
||||
#get_version( "1.1.9")
|
||||
#set(SO_MAJOR 1)
|
||||
#set(SO_MINOR 1)
|
||||
#if ( ${ROCM_PATCH_VERSION} )
|
||||
# set ( SO_PATCH ${ROCM_PATCH_VERSION})
|
||||
# set ( VERSION_PATCH ${ROCM_PATCH_VERSION})
|
||||
#else ()
|
||||
# set(SO_PATCH 9)
|
||||
#endif ()
|
||||
|
||||
#set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}" )
|
||||
#set( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${VERSION_JOB}-${VERSION_HASH}" )
|
||||
|
||||
## Find the hsakmt library and include files
|
||||
get_include_path( HSAKMT_INC_PATH "libhsakmt include path" NAMES "hsakmt.h" "libhsakmt/hsakmt.h" HINTS "${CMAKE_BINARY_DIR}/../../include" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../libhsakmt/include" PATHS "/opt/rocm/include")
|
||||
get_library_path( HSAKMT_LIB_PATH "libhsakmt library path" NAMES "libhsakmt.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../roct" PATHS "/opt/rocm/lib")
|
||||
include_directories( ${HSAKMT_INC_PATH} )
|
||||
link_directories( ${HSAKMT_LIB_PATH} )
|
||||
|
||||
## Find the hsa-runtime and include files
|
||||
#get_include_path( HSA_INC_PATH "ROCr include path" NAMES "inc/hsa.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime" "${CMAKE_BINARY_DIR}/../../include" PATHS "/opt/rocm/include")
|
||||
#get_library_path( HSA_LIB_PATH "ROCr library path" NAMES "libhsa-runtime64.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../hsa-core" "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/build" PATHS "/opt/rocm/lib")
|
||||
#include_directories( ${HSA_INC_PATH} )
|
||||
#link_directories( ${HSA_LIB_PATH} )
|
||||
|
||||
## Find self
|
||||
if( "${IMAGE_SOURCE_DIR}" STREQUAL "" )
|
||||
get_include_path( IMG_SOURCE_FILE null NAMES "image_runtime.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
get_filename_component( IMAGE_SOURCE_DIR "${IMG_SOURCE_FILE}" ABSOLUTE )
|
||||
unset( IMG_SOURCE_FILE CACHE )
|
||||
endif()
|
||||
set( IMAGE_SOURCE_DIR ${IMAGE_SOURCE_DIR} CACHE PATH "Image lib source dir" FORCE )
|
||||
|
||||
message( "Value of cmake_current_source_dir: ${CMAKE_CURRENT_SOURCE_DIR} ")
|
||||
get_filename_component( OPEN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE CACHE )
|
||||
message( "Value of open_source_dir: ${OPEN_SOURCE_DIR} ")
|
||||
set( OPEN_SOURCE_DIR ${OPEN_SOURCE_DIR} CACHE PATH "Open source root dir" FORCE )
|
||||
|
||||
## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
|
||||
|
||||
## ------------------------- Linux Compiler and Linker options -------------------------
|
||||
set ( CMAKE_CXX_FLAGS "-std=c++11 " )
|
||||
#set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -fPIC" )
|
||||
#set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
|
||||
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -fPIC" )
|
||||
|
||||
#if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
# set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
#elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
# set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
#endif ()
|
||||
|
||||
#if ( "${CMAKE_BUILD_TYPE}" STREQUAL Debug )
|
||||
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb" )
|
||||
#endif ()
|
||||
|
||||
#set ( DRVDEF "${IMAGE_SOURCE_DIR}/image.so.def" )
|
||||
|
||||
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,--version-script=${DRVDEF} -Wl,--enable-new-dtags" )
|
||||
|
||||
## Library path(s).
|
||||
include_directories(${IMAGE_SOURCE_DIR}/)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime/inc)
|
||||
include_directories(${OPEN_SOURCE_DIR}/hsa-runtime/core/inc)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/inc)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/core)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/r800)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/gfx9)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/gfx10)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/r800)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/gfx9)
|
||||
include_directories(${IMAGE_SOURCE_DIR}/addrlib/src/chip/gfx10)
|
||||
|
||||
set ( IMAGE_SRCS ${IMAGE_SOURCE_DIR}/addrlib/src/addrinterface.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/coord.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib1.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrlib2.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrobject.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/core/addrelemlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/ciaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/egbaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/r800/siaddrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/gfx9/gfx9addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/addrlib/src/gfx10/gfx10addrlib.cpp
|
||||
${IMAGE_SOURCE_DIR}/device_info.cpp
|
||||
${IMAGE_SOURCE_DIR}/hsa_ext_image.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_runtime.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_kv.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_ai.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_manager_nv.cpp
|
||||
${IMAGE_SOURCE_DIR}/image_lut_kv.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx7xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx8xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_object_gfx9xx.cpp
|
||||
${IMAGE_SOURCE_DIR}/opencl_blit_objects.cpp
|
||||
${IMAGE_SOURCE_DIR}/blit_kernel.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(${IMAGE_SOURCE_DIR}/blit_src ${CMAKE_CURRENT_BINARY_DIR}/image_blit)
|
||||
set_source_files_properties(${IMAGE_SOURCE_DIR}/opencl_blit_objects.cpp PROPERTIES GENERATED 1)
|
||||
|
||||
#add_library ( ${IMAGE_TARGET} SHARED ${IMAGE_SRCS} )
|
||||
add_library ( ${IMAGE_TARGET} STATIC ${IMAGE_SRCS} )
|
||||
add_dependencies( ${IMAGE_TARGET} opencl_blit_objects.cpp )
|
||||
|
||||
## Set the VERSION and SOVERSION values
|
||||
#set_property ( TARGET ${IMAGE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" )
|
||||
#set_property ( TARGET ${IMAGE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" )
|
||||
|
||||
## Add the core runtime in the link
|
||||
#target_link_libraries (
|
||||
# ${IMAGE_TARGET}
|
||||
# PRIVATE hsa-runtime64
|
||||
# PRIVATE hsakmt
|
||||
# c dl pthread rt
|
||||
#)
|
||||
|
||||
## If the build is Release, strip the target library
|
||||
#if ( "${CMAKE_BUILD_TYPE}" STREQUAL Release )
|
||||
# add_custom_command ( TARGET ${IMAGE_TARGET} POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE_NAME:${IMAGE_TARGET}> )
|
||||
#endif ()
|
||||
|
||||
## Create symlinks for legacy packaging and install
|
||||
#if ( ${BUILD_SHARED_LIBS} )
|
||||
# add_custom_target ( hsa_images_lib_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${IMAGE_LIBRARY}.so ${IMAGE_LIBRARY}-link.so )
|
||||
#endif()
|
||||
|
||||
## Set install information
|
||||
#if ( ${BUILD_SHARED_LIBS} )
|
||||
# install ( TARGETS ${IMAGE_TARGET} LIBRARY DESTINATION hsa/lib )
|
||||
# install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${IMAGE_LIBRARY}.so )
|
||||
#endif()
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include "inc/hsa.h"
|
||||
#include "inc/hsa_api_trace.h"
|
||||
#include "core/inc/hsa_table_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HSA_API_EXPORT Load(const ::HsaApiTable* table);
|
||||
void HSA_API_EXPORT Unload();
|
||||
|
||||
// Per library unload callback function. Set by the finalizer or image library
|
||||
// when needed.
|
||||
void (*UnloadCallback)() = NULL;
|
||||
|
||||
void Load(const ::HsaApiTable* table) {
|
||||
// Setup to bypass the runtime intercept layer.
|
||||
hsa_table_interface_init(table);
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
if (UnloadCallback != NULL) {
|
||||
UnloadCallback();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -16,8 +16,13 @@
|
||||
#undef HSA_ARGUMENT_ALIGN_BYTES
|
||||
#define HSA_ARGUMENT_ALIGN_BYTES 16
|
||||
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "core/inc/hsa_ext_amd_impl.h"
|
||||
#include "core/inc/hsa_table_interface.h"
|
||||
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
extern uint8_t blit_object_gfx7xx[14608];
|
||||
extern uint8_t blit_object_gfx8xx[15424];
|
||||
extern uint8_t blit_object_gfx9xx[15432];
|
||||
@@ -37,8 +42,6 @@ extern uint8_t ocl_blit_object_gfx1010[];
|
||||
extern uint8_t ocl_blit_object_gfx1011[];
|
||||
extern uint8_t ocl_blit_object_gfx1012[];
|
||||
|
||||
namespace amd {
|
||||
|
||||
// Arguments inserted by OCL compiler, all zero here.
|
||||
struct OCLHiddenArgs {
|
||||
uint64_t offset_x;
|
||||
@@ -52,20 +55,20 @@ struct OCLHiddenArgs {
|
||||
|
||||
static void* Allocate(hsa_agent_t agent, size_t size) {
|
||||
//use the host accessible kernarg pool
|
||||
hsa_amd_memory_pool_t pool = ext_image::ImageRuntime::instance()->kernarg_pool();
|
||||
hsa_amd_memory_pool_t pool = ImageRuntime::instance()->kernarg_pool();
|
||||
|
||||
void* ptr = NULL;
|
||||
|
||||
hsa_status_t status = hsa_amd_memory_pool_allocate(pool, size, 0, &ptr);
|
||||
hsa_status_t status = AMD::hsa_amd_memory_pool_allocate(pool, size, 0, &ptr);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) return NULL;
|
||||
|
||||
status = hsa_amd_agents_allow_access(1, &agent, NULL, ptr);
|
||||
status = AMD::hsa_amd_agents_allow_access(1, &agent, NULL, ptr);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
hsa_amd_memory_pool_free(ptr);
|
||||
AMD::hsa_amd_memory_pool_free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
return ptr;
|
||||
@@ -82,7 +85,7 @@ hsa_status_t BlitKernel::Cleanup() {
|
||||
|
||||
for (std::pair<const uint64_t, hsa_executable_t> pair :
|
||||
code_executable_map_) {
|
||||
hsa_executable_destroy(pair.second);
|
||||
HSA::hsa_executable_destroy(pair.second);
|
||||
}
|
||||
|
||||
code_executable_map_.clear();
|
||||
@@ -96,8 +99,7 @@ hsa_status_t BlitKernel::BuildBlitCode(
|
||||
hsa_agent_t agent, std::vector<BlitCodeInfo>& blit_code_catalog) {
|
||||
// Find existing kernels in the list that have compatible ISA.
|
||||
hsa_isa_t agent_isa = {0};
|
||||
hsa_status_t status =
|
||||
hsa_agent_get_info(agent, HSA_AGENT_INFO_ISA, &agent_isa);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(agent, HSA_AGENT_INFO_ISA, &agent_isa);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -108,7 +110,7 @@ hsa_status_t BlitKernel::BuildBlitCode(
|
||||
bool isa_compatible = false;
|
||||
hsa_isa_t code_isa = {pair.first};
|
||||
|
||||
status = hsa_isa_compatible(code_isa, agent_isa, &isa_compatible);
|
||||
status = HSA::hsa_isa_compatible(code_isa, agent_isa, &isa_compatible);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -123,7 +125,7 @@ hsa_status_t BlitKernel::BuildBlitCode(
|
||||
|
||||
// Get the target name
|
||||
char agent_name[64] = {0};
|
||||
status = hsa_agent_get_info(agent, HSA_AGENT_INFO_NAME, &agent_name);
|
||||
status = HSA::hsa_agent_get_info(agent, HSA_AGENT_INFO_NAME, &agent_name);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -142,8 +144,8 @@ hsa_status_t BlitKernel::BuildBlitCode(
|
||||
|
||||
// Create executable.
|
||||
hsa_executable_t executable = {0};
|
||||
status = hsa_executable_create(
|
||||
HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, "", &executable);
|
||||
status =
|
||||
HSA::hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, "", &executable);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -151,13 +153,13 @@ hsa_status_t BlitKernel::BuildBlitCode(
|
||||
code_executable_map_[agent_isa.handle] = executable;
|
||||
|
||||
// Load code object.
|
||||
status = hsa_executable_load_code_object(executable, agent, code_object, "");
|
||||
status = HSA::hsa_executable_load_code_object(executable, agent, code_object, "");
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// Freeze executable.
|
||||
status = hsa_executable_freeze(executable, "");
|
||||
status = HSA::hsa_executable_freeze(executable, "");
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -170,8 +172,7 @@ hsa_status_t BlitKernel::CopyBufferToImage(
|
||||
const void* src_memory, size_t src_row_pitch, size_t src_slice_pitch,
|
||||
const Image& dst_image, const hsa_ext_image_region_t& image_region) {
|
||||
if (dst_image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DB) {
|
||||
ImageManager* manager =
|
||||
ext_image::ImageRuntime::instance()->image_manager(dst_image.component);
|
||||
ImageManager* manager = ImageRuntime::instance()->image_manager(dst_image.component);
|
||||
|
||||
const uint32_t element_size =
|
||||
manager->GetImageProperty(dst_image.component, dst_image.desc.format,
|
||||
@@ -181,7 +182,7 @@ hsa_status_t BlitKernel::CopyBufferToImage(
|
||||
char* dst_memory = reinterpret_cast<char*>(dst_image.data) + dst_origin;
|
||||
const size_t size = image_region.range.x * element_size;
|
||||
|
||||
return hsa_memory_copy(dst_memory, src_memory, size);
|
||||
return HSA::hsa_memory_copy(dst_memory, src_memory, size);
|
||||
}
|
||||
|
||||
const Image* dst_image_view = NULL;
|
||||
@@ -230,8 +231,7 @@ hsa_status_t BlitKernel::CopyBufferToImage(
|
||||
args->pixelOrigin[1] = image_region.offset.y;
|
||||
args->pixelOrigin[2] = image_region.offset.z;
|
||||
|
||||
ImageManager* manager = ext_image::ImageRuntime::instance()->image_manager(
|
||||
dst_image_view->component);
|
||||
ImageManager* manager = ImageRuntime::instance()->image_manager(dst_image_view->component);
|
||||
|
||||
const uint32_t element_size =
|
||||
manager->GetImageProperty(dst_image_view->component,
|
||||
@@ -269,7 +269,7 @@ hsa_status_t BlitKernel::CopyBufferToImage(
|
||||
if (&dst_image != dst_image_view) {
|
||||
Image::Destroy(dst_image_view);
|
||||
}
|
||||
hsa_amd_memory_pool_free(args);
|
||||
AMD::hsa_amd_memory_pool_free(args);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -279,8 +279,7 @@ hsa_status_t BlitKernel::CopyImageToBuffer(
|
||||
const Image& src_image, void* dst_memory, size_t dst_row_pitch,
|
||||
size_t dst_slice_pitch, const hsa_ext_image_region_t& image_region) {
|
||||
if (src_image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DB) {
|
||||
ImageManager* manager =
|
||||
ext_image::ImageRuntime::instance()->image_manager(src_image.component);
|
||||
ImageManager* manager = ImageRuntime::instance()->image_manager(src_image.component);
|
||||
|
||||
const uint32_t element_size =
|
||||
manager->GetImageProperty(src_image.component, src_image.desc.format,
|
||||
@@ -291,7 +290,7 @@ hsa_status_t BlitKernel::CopyImageToBuffer(
|
||||
reinterpret_cast<const char*>(src_image.data) + src_origin;
|
||||
const size_t size = image_region.range.x * element_size;
|
||||
|
||||
return hsa_memory_copy(dst_memory, src_memory, size);
|
||||
return HSA::hsa_memory_copy(dst_memory, src_memory, size);
|
||||
}
|
||||
|
||||
const Image* src_image_view = NULL;
|
||||
@@ -340,8 +339,7 @@ hsa_status_t BlitKernel::CopyImageToBuffer(
|
||||
args->pixelOrigin[1] = image_region.offset.y;
|
||||
args->pixelOrigin[2] = image_region.offset.z;
|
||||
|
||||
ImageManager* manager = ext_image::ImageRuntime::instance()->image_manager(
|
||||
src_image_view->component);
|
||||
ImageManager* manager = ImageRuntime::instance()->image_manager(src_image_view->component);
|
||||
|
||||
const uint32_t element_size =
|
||||
manager->GetImageProperty(src_image_view->component,
|
||||
@@ -379,7 +377,7 @@ hsa_status_t BlitKernel::CopyImageToBuffer(
|
||||
if (&src_image != src_image_view) {
|
||||
Image::Destroy(src_image_view);
|
||||
}
|
||||
hsa_amd_memory_pool_free(args);
|
||||
AMD::hsa_amd_memory_pool_free(args);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -481,7 +479,7 @@ hsa_status_t BlitKernel::CopyImage(
|
||||
Image::Destroy(dst_image_view);
|
||||
}
|
||||
|
||||
hsa_amd_memory_pool_free(args);
|
||||
AMD::hsa_amd_memory_pool_free(args);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -531,7 +529,7 @@ hsa_status_t BlitKernel::FillImage(
|
||||
|
||||
hsa_status_t status = LaunchKernel(blit_queue, packet);
|
||||
|
||||
hsa_amd_memory_pool_free(args);
|
||||
AMD::hsa_amd_memory_pool_free(args);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -569,7 +567,8 @@ hsa_status_t BlitKernel::PopulateKernelCode(
|
||||
// Get symbol handle.
|
||||
hsa_executable_symbol_t kernel_symbol = {0};
|
||||
|
||||
hsa_status_t status = hsa_executable_get_symbol_by_name(executable, ocl_kernel_name_[i], &agent, &kernel_symbol);
|
||||
hsa_status_t status = HSA::hsa_executable_get_symbol_by_name(executable, ocl_kernel_name_[i],
|
||||
&agent, &kernel_symbol);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
blit_code_catalog.clear();
|
||||
return status;
|
||||
@@ -577,15 +576,14 @@ hsa_status_t BlitKernel::PopulateKernelCode(
|
||||
|
||||
// Get code handle.
|
||||
BlitCodeInfo blit_code = {0};
|
||||
status = hsa_executable_symbol_get_info(
|
||||
kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT,
|
||||
&blit_code.code_handle_);
|
||||
status = HSA::hsa_executable_symbol_get_info(
|
||||
kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, &blit_code.code_handle_);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
blit_code_catalog.clear();
|
||||
return status;
|
||||
}
|
||||
|
||||
status = hsa_executable_symbol_get_info(
|
||||
status = HSA::hsa_executable_symbol_get_info(
|
||||
kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE,
|
||||
&blit_code.group_segment_size_);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
@@ -593,7 +591,7 @@ hsa_status_t BlitKernel::PopulateKernelCode(
|
||||
return status;
|
||||
}
|
||||
|
||||
status = hsa_executable_symbol_get_info(
|
||||
status = HSA::hsa_executable_symbol_get_info(
|
||||
kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE,
|
||||
&blit_code.private_segment_size_);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
@@ -830,11 +828,11 @@ hsa_status_t BlitKernel::ConvertImage(const Image& original_image,
|
||||
static_cast<hsa_ext_image_channel_type_t>(converted_type),
|
||||
static_cast<hsa_ext_image_channel_order_t>(converted_order)};
|
||||
|
||||
amd::Image* new_image_handle = amd::Image::Create(original_image.component);
|
||||
Image* new_image_handle = Image::Create(original_image.component);
|
||||
*new_image_handle=original_image;
|
||||
new_image_handle->desc.geometry = converted_geometry;
|
||||
|
||||
hsa_status_t status = ext_image::ImageRuntime::instance()
|
||||
hsa_status_t status = ImageRuntime::instance()
|
||||
->image_manager(new_image_handle->component)
|
||||
->ModifyImageSrd(*new_image_handle, new_format);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
@@ -864,7 +862,7 @@ hsa_status_t BlitKernel::LaunchKernel(BlitQueue& blit_queue,
|
||||
|
||||
// Setup completion signal.
|
||||
hsa_signal_t kernel_signal = {0};
|
||||
hsa_status_t status = hsa_signal_create(1, 0, NULL, &kernel_signal);
|
||||
hsa_status_t status = HSA::hsa_signal_create(1, 0, NULL, &kernel_signal);
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
return status;
|
||||
}
|
||||
@@ -875,11 +873,11 @@ hsa_status_t BlitKernel::LaunchKernel(BlitQueue& blit_queue,
|
||||
const uint32_t bitmask = queue->size - 1;
|
||||
|
||||
// Reserve write index.
|
||||
uint64_t write_index = hsa_queue_add_write_index_acq_rel(queue, 1);
|
||||
uint64_t write_index = HSA::hsa_queue_add_write_index_scacq_screl(queue, 1);
|
||||
|
||||
while (true) {
|
||||
// Wait until we have room in the queue;
|
||||
const uint64_t read_index = hsa_queue_load_read_index_relaxed(queue);
|
||||
const uint64_t read_index = HSA::hsa_queue_load_read_index_relaxed(queue);
|
||||
if ((write_index - read_index) < queue->size) {
|
||||
break;
|
||||
}
|
||||
@@ -896,19 +894,19 @@ hsa_status_t BlitKernel::LaunchKernel(BlitQueue& blit_queue,
|
||||
queue_buffer[write_index & bitmask].header = kDispatchPacketHeader;
|
||||
|
||||
// Update doorbel register.
|
||||
hsa_signal_store_release(queue->doorbell_signal, write_index);
|
||||
HSA::hsa_signal_store_screlease(queue->doorbell_signal, write_index);
|
||||
|
||||
// Wait for the packet to finish.
|
||||
if (hsa_signal_wait_acquire(kernel_signal, HSA_SIGNAL_CONDITION_LT, 1,
|
||||
uint64_t(-1), HSA_WAIT_STATE_ACTIVE) != 0) {
|
||||
status = hsa_signal_destroy(kernel_signal);
|
||||
if (HSA::hsa_signal_wait_scacquire(kernel_signal, HSA_SIGNAL_CONDITION_LT, 1, uint64_t(-1),
|
||||
HSA_WAIT_STATE_ACTIVE) != 0) {
|
||||
status = HSA::hsa_signal_destroy(kernel_signal);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
// Signal wait returned unexpected value.
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
status = hsa_signal_destroy(kernel_signal);
|
||||
status = HSA::hsa_signal_destroy(kernel_signal);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
@@ -971,5 +969,7 @@ hsa_status_t BlitKernel::GetPatchedBlitObject(const char* agent_name,
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
} // namespace amd
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#undef HSA_ARGUMENT_ALIGN_BYTES
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include "inc/hsa.h"
|
||||
#include "resource.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
typedef struct BlitQueue {
|
||||
hsa_queue_t* queue_;
|
||||
volatile std::atomic<uint64_t> cached_index_;
|
||||
@@ -118,6 +120,8 @@ class BlitKernel {
|
||||
// Get the patched code object
|
||||
hsa_status_t GetPatchedBlitObject(const char* agent_name, uint8_t** code_object_handle);
|
||||
};
|
||||
} // namespace amd
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_BLIT_KERNEL_H
|
||||
|
||||
Las diferiencias del archivo han sido suprimidas porque una o mas lineas son muy largas
Las diferiencias del archivo han sido suprimidas porque una o mas lineas son muy largas
Las diferiencias del archivo han sido suprimidas porque una o mas lineas son muy largas
@@ -31,7 +31,7 @@ cmake_minimum_required(VERSION 3.5.0)
|
||||
#
|
||||
|
||||
## Include the cmake_modules utils.cmake
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../opensrc/hsa-runtime/cmake_modules" )
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake_modules" )
|
||||
include ( utils )
|
||||
|
||||
# Flag to abort before executing after default initialization of cache variables
|
||||
@@ -45,7 +45,6 @@ foreach(ITEM IN LISTS FOLDERS)
|
||||
list (APPEND LLVM_SEARCH_PATHS "${LLVM_SEARCH_ROOT}/${ITEM}/include/")
|
||||
endforeach()
|
||||
|
||||
|
||||
if (NOT DEFINED OPENCL_VER)
|
||||
set (OPENCL_VER "2.0")
|
||||
endif()
|
||||
|
||||
@@ -16,6 +16,9 @@ cat <<EOF
|
||||
// This file is automatically generated during build process, don't modify it
|
||||
//==============================================================================
|
||||
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
EOF
|
||||
|
||||
for file in ocl_blit_object*
|
||||
@@ -24,6 +27,12 @@ do
|
||||
echo -e '\n'
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
EOF
|
||||
|
||||
} > "$opencl_blit_file.tmp"
|
||||
|
||||
# Move the file atomically into place, so make doesn't get half a file
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
// year of creation of the work.
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "inc/hsa.h"
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "device_info.h"
|
||||
#include "addrlib/src/amdgpu_asic_addr.h"
|
||||
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
uint32_t MajorVerFromDevID(uint32_t dev_id) {
|
||||
return dev_id/100;
|
||||
}
|
||||
@@ -42,9 +44,8 @@ hsa_status_t GetGPUAsicID(hsa_agent_t agent, uint32_t *chip_id) {
|
||||
char asic_name[64];
|
||||
assert(chip_id != nullptr);
|
||||
|
||||
hsa_status_t status = hsa_agent_get_info(
|
||||
agent, static_cast<hsa_agent_info_t>(HSA_AGENT_INFO_NAME),
|
||||
&asic_name);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(
|
||||
agent, static_cast<hsa_agent_info_t>(HSA_AGENT_INFO_NAME), &asic_name);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
@@ -179,3 +180,6 @@ uint32_t DevIDToAddrLibFamily(uint32_t dev_id) {
|
||||
|
||||
assert(0); // We should have already returned
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -22,18 +22,16 @@
|
||||
#include "stdint.h"
|
||||
#include "inc/hsa.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
uint32_t MajorVerFromDevID(uint32_t dev_id);
|
||||
uint32_t MinorVerFromDevID(uint32_t dev_id);
|
||||
uint32_t StepFromDevID(uint32_t dev_id);
|
||||
uint32_t DevIDToAddrLibFamily(uint32_t dev_id);
|
||||
|
||||
hsa_status_t GetGPUAsicID(hsa_agent_t agent, uint32_t *chip_id);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
#endif // HSA_RUNTIME_CORE_INC_DEVICE_INFO_H_
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "inc/hsa.h"
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "inc/hsa_ext_image.h"
|
||||
#include "image_runtime.h"
|
||||
#include "image/inc/hsa_ext_image_impl.h"
|
||||
|
||||
#undef HSA_API
|
||||
#define HSA_API HSA_API_EXPORT
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
// Utilty routines
|
||||
//---------------------------------------------------------------------------//
|
||||
static void enforceDefaultPitch(hsa_agent_t agent, const hsa_ext_image_descriptor_t* image_descriptor, size_t& image_data_row_pitch, size_t& image_data_slice_pitch) {
|
||||
static void enforceDefaultPitch(hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
size_t& image_data_row_pitch, size_t& image_data_slice_pitch) {
|
||||
// Set default pitch
|
||||
if (image_data_row_pitch == 0) {
|
||||
auto manager = ext_image::ImageRuntime::instance()->image_manager(agent);
|
||||
auto manager = ImageRuntime::instance()->image_manager(agent);
|
||||
assert((manager != nullptr) && "Image manager should already exit.");
|
||||
image_data_row_pitch = image_descriptor->width *
|
||||
manager->GetImageProperty(agent, image_descriptor->format, image_descriptor->geometry)
|
||||
@@ -41,13 +41,11 @@ static void enforceDefaultPitch(hsa_agent_t agent, const hsa_ext_image_descripto
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
// Image APIs
|
||||
// APIs that implement Image functionality
|
||||
//---------------------------------------------------------------------------//
|
||||
extern "C" {
|
||||
|
||||
hsa_status_t HSA_API hsa_amd_image_get_info_max_dim_impl(hsa_agent_t agent,
|
||||
hsa_agent_info_t attribute,
|
||||
void* value) {
|
||||
|
||||
hsa_status_t hsa_amd_image_get_info_max_dim(hsa_agent_t agent, hsa_agent_info_t attribute,
|
||||
void* value) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -56,15 +54,13 @@ hsa_status_t HSA_API hsa_amd_image_get_info_max_dim_impl(hsa_agent_t agent,
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->GetImageInfoMaxDimension(
|
||||
agent, attribute, value);
|
||||
return ImageRuntime::instance()->GetImageInfoMaxDimension(agent, attribute, value);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_get_capability_impl(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
uint32_t* capability_mask) {
|
||||
hsa_status_t hsa_ext_image_get_capability(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
uint32_t* capability_mask) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -75,14 +71,14 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->GetImageCapability(
|
||||
agent, *image_format, image_geometry, *capability_mask);
|
||||
return ImageRuntime::instance()->GetImageCapability(agent, *image_format, image_geometry,
|
||||
*capability_mask);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API hsa_ext_image_data_get_info_impl(
|
||||
hsa_agent_t agent, const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_data_info_t* image_data_info) {
|
||||
hsa_status_t hsa_ext_image_data_get_info(hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_data_info_t* image_data_info) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -93,16 +89,14 @@ hsa_status_t HSA_API hsa_ext_image_data_get_info_impl(
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->GetImageSizeAndAlignment(
|
||||
return ImageRuntime::instance()->GetImageSizeAndAlignment(
|
||||
agent, *image_descriptor, HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE, 0, 0, *image_data_info);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_create_impl(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_t* image) {
|
||||
hsa_status_t hsa_ext_image_create(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_t* image) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -111,24 +105,22 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CreateImageHandle(
|
||||
agent, *image_descriptor, image_data, access_permission,
|
||||
HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE, 0, 0, *image);
|
||||
return ImageRuntime::instance()->CreateImageHandle(
|
||||
agent, *image_descriptor, image_data, access_permission, HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE, 0,
|
||||
0, *image);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_destroy_impl(hsa_agent_t agent, hsa_ext_image_t image) {
|
||||
hsa_status_t hsa_ext_image_destroy(hsa_agent_t agent, hsa_ext_image_t image) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->DestroyImageHandle(image);
|
||||
return ImageRuntime::instance()->DestroyImageHandle(image);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_copy_impl(hsa_agent_t agent, hsa_ext_image_t src_image,
|
||||
const hsa_dim3_t* src_offset, hsa_ext_image_t dst_image,
|
||||
const hsa_dim3_t* dst_offset, const hsa_dim3_t* range) {
|
||||
hsa_status_t hsa_ext_image_copy(hsa_agent_t agent, hsa_ext_image_t src_image,
|
||||
const hsa_dim3_t* src_offset, hsa_ext_image_t dst_image,
|
||||
const hsa_dim3_t* dst_offset, const hsa_dim3_t* range) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -138,15 +130,13 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CopyImage(
|
||||
src_image, dst_image, *src_offset, *dst_offset, *range);
|
||||
return ImageRuntime::instance()->CopyImage(src_image, dst_image, *src_offset, *dst_offset,
|
||||
*range);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_import_impl(hsa_agent_t agent, const void* src_memory,
|
||||
size_t src_row_pitch, size_t src_slice_pitch,
|
||||
hsa_ext_image_t dst_image,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
hsa_status_t hsa_ext_image_import(hsa_agent_t agent, const void* src_memory, size_t src_row_pitch,
|
||||
size_t src_slice_pitch, hsa_ext_image_t dst_image,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -155,15 +145,13 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CopyBufferToImage(
|
||||
src_memory, src_row_pitch, src_slice_pitch, dst_image, *image_region);
|
||||
return ImageRuntime::instance()->CopyBufferToImage(src_memory, src_row_pitch, src_slice_pitch,
|
||||
dst_image, *image_region);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_export_impl(hsa_agent_t agent, hsa_ext_image_t src_image,
|
||||
void* dst_memory, size_t dst_row_pitch,
|
||||
size_t dst_slice_pitch,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
hsa_status_t hsa_ext_image_export(hsa_agent_t agent, hsa_ext_image_t src_image, void* dst_memory,
|
||||
size_t dst_row_pitch, size_t dst_slice_pitch,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -172,14 +160,12 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CopyImageToBuffer(
|
||||
src_image, dst_memory, dst_row_pitch, dst_slice_pitch, *image_region);
|
||||
return ImageRuntime::instance()->CopyImageToBuffer(src_image, dst_memory, dst_row_pitch,
|
||||
dst_slice_pitch, *image_region);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_clear_impl(hsa_agent_t agent, hsa_ext_image_t image,
|
||||
const void* data,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
hsa_status_t hsa_ext_image_clear(hsa_agent_t agent, hsa_ext_image_t image, const void* data,
|
||||
const hsa_ext_image_region_t* image_region) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -188,13 +174,12 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->FillImage(image, data,
|
||||
*image_region);
|
||||
return ImageRuntime::instance()->FillImage(image, data, *image_region);
|
||||
};
|
||||
|
||||
hsa_status_t HSA_API hsa_ext_sampler_create_impl(
|
||||
hsa_agent_t agent, const hsa_ext_sampler_descriptor_t* sampler_descriptor,
|
||||
hsa_ext_sampler_t* sampler) {
|
||||
hsa_status_t hsa_ext_sampler_create(hsa_agent_t agent,
|
||||
const hsa_ext_sampler_descriptor_t* sampler_descriptor,
|
||||
hsa_ext_sampler_t* sampler) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -203,25 +188,22 @@ hsa_status_t HSA_API hsa_ext_sampler_create_impl(
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CreateSamplerHandle(
|
||||
agent, *sampler_descriptor, *sampler);
|
||||
return ImageRuntime::instance()->CreateSamplerHandle(agent, *sampler_descriptor, *sampler);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_sampler_destroy_impl(hsa_agent_t agent, hsa_ext_sampler_t sampler) {
|
||||
hsa_status_t hsa_ext_sampler_destroy(hsa_agent_t agent, hsa_ext_sampler_t sampler) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->DestroySamplerHandle(sampler);
|
||||
return ImageRuntime::instance()->DestroySamplerHandle(sampler);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_get_capability_with_layout_impl(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
hsa_ext_image_data_layout_t image_data_layout,
|
||||
uint32_t* capability_mask) {
|
||||
hsa_status_t hsa_ext_image_get_capability_with_layout(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
hsa_ext_image_data_layout_t image_data_layout,
|
||||
uint32_t* capability_mask) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -233,16 +215,14 @@ hsa_status_t HSA_API
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->GetImageCapability(
|
||||
agent, *image_format, image_geometry, *capability_mask);
|
||||
return ImageRuntime::instance()->GetImageCapability(agent, *image_format, image_geometry,
|
||||
*capability_mask);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API hsa_ext_image_data_get_info_with_layout_impl(
|
||||
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_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) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
@@ -257,20 +237,15 @@ hsa_status_t HSA_API hsa_ext_image_data_get_info_with_layout_impl(
|
||||
|
||||
enforceDefaultPitch(agent, image_descriptor, image_data_row_pitch, image_data_slice_pitch);
|
||||
|
||||
return ext_image::ImageRuntime::instance()->GetImageSizeAndAlignment(
|
||||
agent, *image_descriptor, image_data_layout, image_data_row_pitch,
|
||||
image_data_slice_pitch, *image_data_info);
|
||||
return ImageRuntime::instance()->GetImageSizeAndAlignment(
|
||||
agent, *image_descriptor, image_data_layout, image_data_row_pitch, image_data_slice_pitch,
|
||||
*image_data_info);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API
|
||||
hsa_ext_image_create_with_layout_impl(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) {
|
||||
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) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -282,19 +257,16 @@ hsa_status_t HSA_API
|
||||
|
||||
enforceDefaultPitch(agent, image_descriptor, image_data_row_pitch, image_data_slice_pitch);
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CreateImageHandle(
|
||||
return ImageRuntime::instance()->CreateImageHandle(
|
||||
agent, *image_descriptor, image_data, access_permission, image_data_layout,
|
||||
image_data_row_pitch, image_data_slice_pitch, *image);
|
||||
}
|
||||
|
||||
hsa_status_t HSA_API hsa_amd_image_create_impl(
|
||||
hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t *image_descriptor,
|
||||
const hsa_amd_image_descriptor_t *image_layout,
|
||||
const void *image_data,
|
||||
hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_t *image)
|
||||
{
|
||||
hsa_status_t hsa_amd_image_create(hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
const hsa_amd_image_descriptor_t* image_layout,
|
||||
const void* image_data, hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_t* image) {
|
||||
if (agent.handle == 0) {
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
@@ -303,8 +275,44 @@ hsa_status_t HSA_API hsa_amd_image_create_impl(
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->CreateImageHandleWithLayout(
|
||||
return ImageRuntime::instance()->CreateImageHandleWithLayout(
|
||||
agent, *image_descriptor, image_layout, image_data, access_permission, *image);
|
||||
}
|
||||
|
||||
void LoadImage(core::ImageExtTableInternal* image_api,
|
||||
decltype(::hsa_amd_image_create)** interface_api) {
|
||||
image_api->hsa_ext_image_get_capability_fn = hsa_ext_image_get_capability;
|
||||
|
||||
image_api->hsa_ext_image_data_get_info_fn = hsa_ext_image_data_get_info;
|
||||
|
||||
image_api->hsa_ext_image_create_fn = hsa_ext_image_create;
|
||||
|
||||
image_api->hsa_ext_image_import_fn = hsa_ext_image_import;
|
||||
|
||||
image_api->hsa_ext_image_export_fn = hsa_ext_image_export;
|
||||
|
||||
image_api->hsa_ext_image_copy_fn = hsa_ext_image_copy;
|
||||
|
||||
image_api->hsa_ext_image_clear_fn = hsa_ext_image_clear;
|
||||
|
||||
image_api->hsa_ext_image_destroy_fn = hsa_ext_image_destroy;
|
||||
|
||||
image_api->hsa_ext_sampler_create_fn = hsa_ext_sampler_create;
|
||||
|
||||
image_api->hsa_ext_sampler_destroy_fn = hsa_ext_sampler_destroy;
|
||||
|
||||
image_api->hsa_ext_image_get_capability_with_layout_fn = hsa_ext_image_get_capability_with_layout;
|
||||
|
||||
image_api->hsa_ext_image_data_get_info_with_layout_fn = hsa_ext_image_data_get_info_with_layout;
|
||||
|
||||
image_api->hsa_ext_image_create_with_layout_fn = hsa_ext_image_create_with_layout;
|
||||
|
||||
image_api->hsa_amd_image_get_info_max_dim_fn = hsa_amd_image_get_info_max_dim;
|
||||
|
||||
*interface_api = hsa_amd_image_create;
|
||||
}
|
||||
|
||||
void ReleaseImageRsrcs() { ImageRuntime::DestroySingleton(); }
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
global:
|
||||
hsa_ext_image_get_capability_impl;
|
||||
hsa_ext_image_data_get_info_impl;
|
||||
hsa_ext_image_create_impl;
|
||||
hsa_ext_image_import_impl;
|
||||
hsa_ext_image_export_impl;
|
||||
hsa_ext_image_copy_impl;
|
||||
hsa_ext_image_clear_impl;
|
||||
hsa_ext_image_destroy_impl;
|
||||
hsa_ext_sampler_create_impl;
|
||||
hsa_ext_sampler_destroy_impl;
|
||||
hsa_ext_image_get_capability_with_layout_impl;
|
||||
hsa_ext_image_data_get_info_with_layout_impl;
|
||||
hsa_ext_image_create_with_layout_impl;
|
||||
hsa_amd_image_get_info_max_dim_impl;
|
||||
hsa_amd_image_create_impl;
|
||||
Load;
|
||||
Unload;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
@@ -7,7 +7,9 @@
|
||||
#include "resource.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageLut {
|
||||
public:
|
||||
ImageLut() {}
|
||||
@@ -33,5 +35,6 @@ class ImageLut {
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageLut);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // AMD_HSA_EXT_IMAGE_IMAGE_LUT_H
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "image_lut_kv.h"
|
||||
#include "resource_kv.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
const uint32_t ImageLutKv::kGeometryLut_[GEOMETRY_COUNT] = {
|
||||
SQ_RSRC_IMG_1D, // HSA_EXT_IMAGE_GEOMETRY_1D
|
||||
SQ_RSRC_IMG_2D, // HSA_EXT_IMAGE_GEOMETRY_2D
|
||||
@@ -393,4 +395,5 @@ uint32_t ImageLutKv::GetPixelSize(uint8_t data_format, uint8_t data_type) const
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "image_lut.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageLutKv : public ImageLut {
|
||||
public:
|
||||
ImageLutKv() {}
|
||||
@@ -46,5 +48,6 @@ class ImageLutKv : public ImageLut {
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageLutKv);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // AMD_HSA_EXT_IMAGE_IMAGE_LUT_KV_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "inc/hsa_ext_image.h"
|
||||
#include "core/inc/hsa_ext_amd_impl.h"
|
||||
#include "image_manager.h"
|
||||
#include "image_runtime.h"
|
||||
|
||||
@@ -14,22 +15,23 @@
|
||||
__inline long int lrintf(float f) { return _mm_cvtss_si32(_mm_load_ss(&f)); }
|
||||
#endif
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
Image* Image::Create(hsa_agent_t agent) {
|
||||
hsa_amd_memory_pool_t pool = ext_image::ImageRuntime::instance()->kernarg_pool();
|
||||
hsa_amd_memory_pool_t pool = ImageRuntime::instance()->kernarg_pool();
|
||||
|
||||
Image* image = NULL;
|
||||
|
||||
hsa_status_t status =
|
||||
hsa_amd_memory_pool_allocate(pool, sizeof(Image), 0, reinterpret_cast<void**>(&image));
|
||||
AMD::hsa_amd_memory_pool_allocate(pool, sizeof(Image), 0, reinterpret_cast<void**>(&image));
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) return NULL;
|
||||
|
||||
new (image) Image();
|
||||
|
||||
status = hsa_amd_agents_allow_access(1, &agent, NULL, image);
|
||||
status = AMD::hsa_amd_agents_allow_access(1, &agent, NULL, image);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
Image::Destroy(image);
|
||||
@@ -43,24 +45,24 @@ void Image::Destroy(const Image* image) {
|
||||
assert(image != NULL);
|
||||
image->~Image();
|
||||
|
||||
hsa_status_t status = hsa_amd_memory_pool_free(const_cast<Image*>(image));
|
||||
hsa_status_t status = AMD::hsa_amd_memory_pool_free(const_cast<Image*>(image));
|
||||
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
Sampler* Sampler::Create(hsa_agent_t agent) {
|
||||
hsa_amd_memory_pool_t pool = ext_image::ImageRuntime::instance()->kernarg_pool();
|
||||
hsa_amd_memory_pool_t pool = ImageRuntime::instance()->kernarg_pool();
|
||||
|
||||
Sampler* sampler = NULL;
|
||||
|
||||
hsa_status_t status =
|
||||
hsa_amd_memory_pool_allocate(pool, sizeof(Sampler), 0, reinterpret_cast<void**>(&sampler));
|
||||
hsa_status_t status = AMD::hsa_amd_memory_pool_allocate(pool, sizeof(Sampler), 0,
|
||||
reinterpret_cast<void**>(&sampler));
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) return NULL;
|
||||
|
||||
new (sampler) Sampler();
|
||||
|
||||
status = hsa_amd_agents_allow_access(1, &agent, NULL, sampler);
|
||||
status = AMD::hsa_amd_agents_allow_access(1, &agent, NULL, sampler);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
Sampler::Destroy(sampler);
|
||||
@@ -74,7 +76,7 @@ void Sampler::Destroy(const Sampler* sampler) {
|
||||
assert(sampler != NULL);
|
||||
sampler->~Sampler();
|
||||
|
||||
hsa_status_t status = hsa_amd_memory_pool_free(const_cast<Sampler*>(sampler));
|
||||
hsa_status_t status = AMD::hsa_amd_memory_pool_free(const_cast<Sampler*>(sampler));
|
||||
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
}
|
||||
@@ -111,7 +113,7 @@ hsa_status_t ImageManager::CopyImageToBuffer(
|
||||
const Image& src_image, void* dst_memory, size_t dst_row_pitch,
|
||||
size_t dst_slice_pitch, const hsa_ext_image_region_t& image_region) {
|
||||
// Treat buffer as image since we don't tile our image anyway.
|
||||
amd::Image* dst_image = Image::Create(src_image.component);
|
||||
Image* dst_image = Image::Create(src_image.component);
|
||||
|
||||
dst_image->component = src_image.component;
|
||||
dst_image->desc = src_image.desc; // the width, height, depth is ignored.
|
||||
@@ -685,4 +687,5 @@ hsa_status_t ImageManager::FillImage(const Image& image, const void* pattern,
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include "resource.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
/// @brief Abstract class for creating AMD agent specific image / sampler
|
||||
/// resources and data transfer.
|
||||
class ImageManager {
|
||||
@@ -94,5 +96,6 @@ class ImageManager {
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageManager);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // AMD_HSA_EXT_IMAGE_IMAGE_MANAGER_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "hsakmt.h"
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "addrlib/src/core/addrlib.h"
|
||||
#include "image_runtime.h"
|
||||
#include "resource.h"
|
||||
@@ -15,7 +16,9 @@
|
||||
#include "util.h"
|
||||
#include "device_info.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
ImageManagerAi::ImageManagerAi() : ImageManagerKv() {}
|
||||
|
||||
ImageManagerAi::~ImageManagerAi() {}
|
||||
@@ -28,7 +31,7 @@ hsa_status_t ImageManagerAi::CalculateImageSizeAndAlignment(
|
||||
hsa_ext_image_data_info_t& image_info) const {
|
||||
ADDR2_COMPUTE_SURFACE_INFO_OUTPUT out = {0};
|
||||
hsa_profile_t profile;
|
||||
hsa_status_t status = hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
Image::TileMode tileMode = Image::TileMode::LINEAR;
|
||||
if (image_data_layout == HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE) {
|
||||
tileMode = (profile == HSA_PROFILE_BASE &&
|
||||
@@ -97,10 +100,10 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t
|
||||
sq_buf_rsrc_word3_u word3;
|
||||
|
||||
word0.val = 0;
|
||||
word0.f.base_address = ext_image::PtrLow32(image_data_addr);
|
||||
word0.f.base_address = PtrLow32(image_data_addr);
|
||||
|
||||
word1.val = image.srd[1];
|
||||
word1.f.base_address_hi = ext_image::PtrHigh32(image_data_addr);
|
||||
word1.f.base_address_hi = PtrHigh32(image_data_addr);
|
||||
word1.f.stride = image_prop.element_size;
|
||||
|
||||
word3.val = image.srd[3];
|
||||
@@ -120,8 +123,8 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t
|
||||
if(image_prop.element_size!=hwPixelSize)
|
||||
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
|
||||
|
||||
((SQ_IMG_RSRC_WORD0*)(&image.srd[0]))->bits.BASE_ADDRESS = ext_image::PtrLow40Shift8(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.BASE_ADDRESS_HI = ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD0*)(&image.srd[0]))->bits.BASE_ADDRESS = PtrLow40Shift8(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.BASE_ADDRESS_HI = PtrHigh64Shift40(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.DATA_FORMAT = image_prop.data_format;
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.NUM_FORMAT = image_prop.data_type;
|
||||
((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.DST_SEL_X = swizzle.x;
|
||||
@@ -137,9 +140,10 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t
|
||||
uintptr_t meta = uintptr_t(((SQ_IMG_RSRC_WORD5*)(&image.srd[5]))->bits.META_DATA_ADDRESS_HI) << 40;
|
||||
meta |= uintptr_t(((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS) << 8;
|
||||
meta += reinterpret_cast<uintptr_t>(image_data_addr);
|
||||
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS = ext_image::PtrLow40Shift8((void*)meta);
|
||||
((SQ_IMG_RSRC_WORD5*)(&image.srd[5]))->bits.META_DATA_ADDRESS_HI = ext_image::PtrHigh64Shift40((void*)meta);
|
||||
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS = PtrLow40Shift8((void*)meta);
|
||||
((SQ_IMG_RSRC_WORD5*)(&image.srd[5]))->bits.META_DATA_ADDRESS_HI =
|
||||
PtrHigh64Shift40((void*)meta);
|
||||
}
|
||||
//Looks like this is only used for CPU copies.
|
||||
image.row_pitch = 0;//desc->word4.bits.pitch+1*desc->word3.bits.element_size;
|
||||
@@ -240,10 +244,10 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image) const {
|
||||
sq_buf_rsrc_word3_u word3;
|
||||
|
||||
word0.val = 0;
|
||||
word0.f.base_address = ext_image::PtrLow32(image_data_addr);
|
||||
word0.f.base_address = PtrLow32(image_data_addr);
|
||||
|
||||
word1.val = 0;
|
||||
word1.f.base_address_hi = ext_image::PtrHigh32(image_data_addr);
|
||||
word1.f.base_address_hi = PtrHigh32(image_data_addr);
|
||||
word1.f.stride = image_prop.element_size;
|
||||
word1.f.swizzle_enable = false;
|
||||
word1.f.cache_swizzle = false;
|
||||
@@ -291,10 +295,10 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image) const {
|
||||
|
||||
const size_t row_pitch_size = out.pitch * image_prop.element_size;
|
||||
|
||||
word0.f.base_address = ext_image::PtrLow40Shift8(image_data_addr);
|
||||
word0.f.base_address = PtrLow40Shift8(image_data_addr);
|
||||
|
||||
word1.val = 0;
|
||||
word1.f.base_address_hi = ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
word1.f.base_address_hi = PtrHigh64Shift40(image_data_addr);
|
||||
word1.f.min_lod = 0;
|
||||
word1.f.data_format = image_prop.data_format;
|
||||
word1.f.num_format = image_prop.data_type;
|
||||
@@ -395,7 +399,7 @@ hsa_status_t ImageManagerAi::ModifyImageSrd(
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t ImageManagerAi::PopulateSamplerSrd(amd::Sampler& sampler) const {
|
||||
hsa_status_t ImageManagerAi::PopulateSamplerSrd(Sampler& sampler) const {
|
||||
const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc;
|
||||
|
||||
SQ_IMG_SAMP_WORD0 word0;
|
||||
@@ -545,4 +549,5 @@ uint32_t ImageManagerAi::GetAddrlibSurfaceInfoAi(
|
||||
return in.swizzleMode;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "addrlib/inc/addrinterface.h"
|
||||
#include "image_manager_kv.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageManagerAi : public ImageManagerKv {
|
||||
public:
|
||||
@@ -46,5 +47,7 @@ class ImageManagerAi : public ImageManagerKv {
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageManagerAi);
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_IMAGE_MANAGER_AI_H
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#include <climits>
|
||||
|
||||
#include "hsakmt.h"
|
||||
#include "inc/hsa.h"
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "core/inc/hsa_ext_amd_impl.h"
|
||||
#include "addrlib/inc/addrinterface.h"
|
||||
#include "addrlib/src/core/addrlib.h"
|
||||
#include "image_runtime.h"
|
||||
@@ -17,7 +18,9 @@
|
||||
#include "util.h"
|
||||
#include "device_info.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
ImageManagerKv::ImageManagerKv() : ImageManager() {}
|
||||
|
||||
ImageManagerKv::~ImageManagerKv() {}
|
||||
@@ -39,7 +42,8 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
|
||||
tileConfig.MacroTileConfig = &mtc[0];
|
||||
tileConfig.NumMacroTileConfigs = 40;
|
||||
uint32_t node_id = 0;
|
||||
status = hsa_agent_get_info(agent_, static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_DRIVER_NODE_ID), &node_id);
|
||||
status = HSA::hsa_agent_get_info(
|
||||
agent_, static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_DRIVER_NODE_ID), &node_id);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
HSAKMT_STATUS stat = hsaKmtGetTileConfig(node_id, &tileConfig);
|
||||
assert(stat == HSAKMT_STATUS_SUCCESS);
|
||||
@@ -96,7 +100,7 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
|
||||
// the change to the coherency mode happens before a call to
|
||||
// hsa_ext_image_create.
|
||||
hsa_amd_coherency_type_t coherency_type;
|
||||
status = hsa_amd_coherency_get_type(agent_, &coherency_type);
|
||||
status = AMD::hsa_amd_coherency_get_type(agent_, &coherency_type);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
mtype_ = (coherency_type == HSA_AMD_COHERENCY_TYPE_COHERENT) ? 3 : 1;
|
||||
|
||||
@@ -104,15 +108,14 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
|
||||
// hsa_ext_image_create.
|
||||
|
||||
hsa_region_t local_region = {0};
|
||||
status =
|
||||
hsa_agent_iterate_regions(agent_, GetLocalMemoryRegion, &local_region);
|
||||
status = HSA::hsa_agent_iterate_regions(agent_, GetLocalMemoryRegion, &local_region);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
local_memory_base_address_ = 0;
|
||||
if (local_region.handle != 0) {
|
||||
status = hsa_region_get_info(
|
||||
local_region, static_cast<hsa_region_info_t>(HSA_AMD_REGION_INFO_BASE),
|
||||
&local_memory_base_address_);
|
||||
status = HSA::hsa_region_get_info(local_region,
|
||||
static_cast<hsa_region_info_t>(HSA_AMD_REGION_INFO_BASE),
|
||||
&local_memory_base_address_);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -125,7 +128,7 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
|
||||
|
||||
void ImageManagerKv::Cleanup() {
|
||||
if (blit_queue_.queue_ != NULL) {
|
||||
hsa_queue_destroy(blit_queue_.queue_);
|
||||
HSA::hsa_queue_destroy(blit_queue_.queue_);
|
||||
}
|
||||
|
||||
if (addr_lib_ != NULL) {
|
||||
@@ -158,7 +161,7 @@ hsa_status_t ImageManagerKv::CalculateImageSizeAndAlignment(
|
||||
hsa_ext_image_data_info_t& image_info) const {
|
||||
ADDR_COMPUTE_SURFACE_INFO_OUTPUT out = {0};
|
||||
hsa_profile_t profile;
|
||||
hsa_status_t status = hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
Image::TileMode tileMode = Image::TileMode::LINEAR;
|
||||
if (image_data_layout == HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE) {
|
||||
tileMode = (profile == HSA_PROFILE_BASE &&
|
||||
@@ -240,8 +243,8 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image, const metadata_amd_t
|
||||
image.srd[6]=desc->word6.u32_all;
|
||||
image.srd[7]=desc->word7.u32_all;
|
||||
|
||||
((SQ_IMG_RSRC_WORD0*)(&image.srd[0]))->bits.base_address = ext_image::PtrLow40Shift8(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.base_address_hi = ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD0*)(&image.srd[0]))->bits.base_address = PtrLow40Shift8(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.base_address_hi = PtrHigh64Shift40(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.data_format = image_prop.data_format;
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.num_format = image_prop.data_type;
|
||||
((SQ_IMG_RSRC_WORD1*)(&image.srd[1]))->bits.mtype = mtype;
|
||||
@@ -250,7 +253,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image, const metadata_amd_t
|
||||
((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.dst_sel_y = swizzle.y;
|
||||
((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.dst_sel_z = swizzle.z;
|
||||
((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.dst_sel_w = swizzle.w;
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.meta_data_address += ext_image::PtrLow40Shift8(image_data_addr);
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.meta_data_address += PtrLow40Shift8(image_data_addr);
|
||||
|
||||
//Looks like this is only used for CPU copies.
|
||||
image.row_pitch = (desc->word4.bits.pitch+1)*image_prop.element_size;
|
||||
@@ -288,10 +291,10 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const {
|
||||
SQ_BUF_RSRC_WORD3 word3;
|
||||
|
||||
word0.u32_all = 0;
|
||||
word0.bits.base_address = ext_image::PtrLow32(image_data_addr);
|
||||
word0.bits.base_address = PtrLow32(image_data_addr);
|
||||
|
||||
word1.u32_all = 0;
|
||||
word1.bits.base_address_hi = ext_image::PtrHigh32(image_data_addr);
|
||||
word1.bits.base_address_hi = PtrHigh32(image_data_addr);
|
||||
word1.bits.stride = image_prop.element_size;
|
||||
word1.bits.swizzle_enable = false;
|
||||
word1.bits.cache_swizzle = false;
|
||||
@@ -341,10 +344,10 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const {
|
||||
|
||||
const size_t row_pitch_size = out.pitch * image_prop.element_size;
|
||||
|
||||
word0.bits.base_address = ext_image::PtrLow40Shift8(image_data_addr);
|
||||
word0.bits.base_address = PtrLow40Shift8(image_data_addr);
|
||||
|
||||
word1.u32_all = 0;
|
||||
word1.bits.base_address_hi = ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
word1.bits.base_address_hi = PtrHigh64Shift40(image_data_addr);
|
||||
word1.bits.min_lod = 0;
|
||||
word1.bits.data_format = image_prop.data_format;
|
||||
word1.bits.num_format = image_prop.data_type;
|
||||
@@ -364,10 +367,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const {
|
||||
word3.bits.dst_sel_z = swizzle.z;
|
||||
word3.bits.dst_sel_w = swizzle.w;
|
||||
word3.bits.tiling_index = out.tileIndex;
|
||||
word3.bits.pow2_pad = (ext_image::IsPowerOfTwo(row_pitch_size) &&
|
||||
ext_image::IsPowerOfTwo(image.desc.height))
|
||||
? 1
|
||||
: 0;
|
||||
word3.bits.pow2_pad = (IsPowerOfTwo(row_pitch_size) && IsPowerOfTwo(image.desc.height)) ? 1 : 0;
|
||||
word3.bits.type = image_lut_.MapGeometry(image.desc.geometry);
|
||||
word3.bits.atc = atc_access;
|
||||
|
||||
@@ -456,7 +456,7 @@ hsa_status_t ImageManagerKv::ModifyImageSrd(
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t ImageManagerKv::PopulateSamplerSrd(amd::Sampler& sampler) const {
|
||||
hsa_status_t ImageManagerKv::PopulateSamplerSrd(Sampler& sampler) const {
|
||||
const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc;
|
||||
|
||||
SQ_IMG_SAMP_WORD0 word0;
|
||||
@@ -525,9 +525,9 @@ hsa_status_t ImageManagerKv::CopyBufferToImage(
|
||||
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->blit_kernel().CopyBufferToImage(
|
||||
blit_queue_, blit_code_catalog_, src_memory, src_row_pitch,
|
||||
src_slice_pitch, dst_image, image_region);
|
||||
return ImageRuntime::instance()->blit_kernel().CopyBufferToImage(
|
||||
blit_queue_, blit_code_catalog_, src_memory, src_row_pitch, src_slice_pitch, dst_image,
|
||||
image_region);
|
||||
}
|
||||
|
||||
hsa_status_t ImageManagerKv::CopyImageToBuffer(
|
||||
@@ -537,9 +537,9 @@ hsa_status_t ImageManagerKv::CopyImageToBuffer(
|
||||
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
return ext_image::ImageRuntime::instance()->blit_kernel().CopyImageToBuffer(
|
||||
blit_queue_, blit_code_catalog_, src_image, dst_memory, dst_row_pitch,
|
||||
dst_slice_pitch, image_region);
|
||||
return ImageRuntime::instance()->blit_kernel().CopyImageToBuffer(
|
||||
blit_queue_, blit_code_catalog_, src_image, dst_memory, dst_row_pitch, dst_slice_pitch,
|
||||
image_region);
|
||||
}
|
||||
|
||||
hsa_status_t ImageManagerKv::CopyImage(const Image& dst_image,
|
||||
@@ -562,9 +562,9 @@ hsa_status_t ImageManagerKv::CopyImage(const Image& dst_image,
|
||||
BlitKernel::KernelOp copy_type = BlitKernel::KERNEL_OP_COPY_IMAGE_DEFAULT;
|
||||
|
||||
if ((src_order == dst_order) && (src_type == dst_type)) {
|
||||
return ext_image::ImageRuntime::instance()->blit_kernel().CopyImage(
|
||||
blit_queue_, blit_code_catalog_, dst_image, src_image, dst_origin,
|
||||
src_origin, size, copy_type);
|
||||
return ImageRuntime::instance()->blit_kernel().CopyImage(blit_queue_, blit_code_catalog_,
|
||||
dst_image, src_image, dst_origin,
|
||||
src_origin, size, copy_type);
|
||||
}
|
||||
|
||||
// Source and destination format must be the same, except for
|
||||
@@ -589,10 +589,9 @@ hsa_status_t ImageManagerKv::CopyImage(const Image& dst_image,
|
||||
uint32_t num_format_original = word1->bits.num_format;
|
||||
word1->bits.num_format = TYPE_UNORM;
|
||||
|
||||
hsa_status_t status =
|
||||
ext_image::ImageRuntime::instance()->blit_kernel().CopyImage(
|
||||
blit_queue_, blit_code_catalog_, dst_image, src_image, dst_origin,
|
||||
src_origin, size, copy_type);
|
||||
hsa_status_t status = ImageRuntime::instance()->blit_kernel().CopyImage(
|
||||
blit_queue_, blit_code_catalog_, dst_image, src_image, dst_origin, src_origin, size,
|
||||
copy_type);
|
||||
|
||||
// Revert to the original format after the copy operation is finished.
|
||||
word1->bits.num_format = num_format_original;
|
||||
@@ -655,9 +654,8 @@ hsa_status_t ImageManagerKv::FillImage(const Image& image, const void* pattern,
|
||||
break;
|
||||
}
|
||||
|
||||
hsa_status_t status =
|
||||
ext_image::ImageRuntime::instance()->blit_kernel().FillImage(
|
||||
blit_queue_, blit_code_catalog_, *image_view, new_pattern, region);
|
||||
hsa_status_t status = ImageRuntime::instance()->blit_kernel().FillImage(
|
||||
blit_queue_, blit_code_catalog_, *image_view, new_pattern, region);
|
||||
|
||||
// Revert back original configuration.
|
||||
if (word3_buff != NULL) {
|
||||
@@ -682,8 +680,7 @@ hsa_status_t ImageManagerKv::GetLocalMemoryRegion(hsa_region_t region,
|
||||
}
|
||||
|
||||
hsa_region_segment_t segment;
|
||||
hsa_status_t stat =
|
||||
hsa_region_get_info(region, HSA_REGION_INFO_SEGMENT, &segment);
|
||||
hsa_status_t stat = HSA::hsa_region_get_info(region, HSA_REGION_INFO_SEGMENT, &segment);
|
||||
if (stat != HSA_STATUS_SUCCESS) {
|
||||
return stat;
|
||||
}
|
||||
@@ -693,7 +690,7 @@ hsa_status_t ImageManagerKv::GetLocalMemoryRegion(hsa_region_t region,
|
||||
}
|
||||
|
||||
uint32_t base = 0;
|
||||
stat = hsa_region_get_info(region, HSA_REGION_INFO_GLOBAL_FLAGS, &base);
|
||||
stat = HSA::hsa_region_get_info(region, HSA_REGION_INFO_GLOBAL_FLAGS, &base);
|
||||
if (stat != HSA_STATUS_SUCCESS) {
|
||||
return stat;
|
||||
}
|
||||
@@ -926,12 +923,11 @@ BlitQueue& ImageManagerKv::BlitQueueInit() {
|
||||
blit_queue_.cached_index_ = 0;
|
||||
|
||||
uint32_t max_queue_size = 0;
|
||||
hsa_status_t status = hsa_agent_get_info(
|
||||
agent_, HSA_AGENT_INFO_QUEUE_MAX_SIZE, &max_queue_size);
|
||||
hsa_status_t status =
|
||||
HSA::hsa_agent_get_info(agent_, HSA_AGENT_INFO_QUEUE_MAX_SIZE, &max_queue_size);
|
||||
|
||||
status =
|
||||
hsa_queue_create(agent_, max_queue_size, HSA_QUEUE_TYPE_MULTI, NULL,
|
||||
NULL, UINT_MAX, UINT_MAX, &blit_queue_.queue_);
|
||||
status = HSA::hsa_queue_create(agent_, max_queue_size, HSA_QUEUE_TYPE_MULTI, NULL, NULL,
|
||||
UINT_MAX, UINT_MAX, &blit_queue_.queue_);
|
||||
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
blit_queue_.queue_ = NULL;
|
||||
@@ -939,12 +935,11 @@ BlitQueue& ImageManagerKv::BlitQueueInit() {
|
||||
}
|
||||
|
||||
// Get the kernel handles.
|
||||
status = ext_image::ImageRuntime::instance()->blit_kernel().BuildBlitCode(
|
||||
agent_, blit_code_catalog_);
|
||||
status = ImageRuntime::instance()->blit_kernel().BuildBlitCode(agent_, blit_code_catalog_);
|
||||
|
||||
if (HSA_STATUS_SUCCESS != status) {
|
||||
blit_code_catalog_.clear();
|
||||
hsa_queue_destroy(blit_queue_.queue_);
|
||||
HSA::hsa_queue_destroy(blit_queue_.queue_);
|
||||
blit_queue_.queue_ = NULL;
|
||||
return blit_queue_;
|
||||
}
|
||||
@@ -957,4 +952,5 @@ BlitQueue& ImageManagerKv::BlitQueueInit() {
|
||||
return blit_queue_;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include "image_lut_kv.h"
|
||||
#include "image_manager.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageManagerKv : public ImageManager {
|
||||
public:
|
||||
@@ -121,5 +122,7 @@ class ImageManagerKv : public ImageManager {
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageManagerKv);
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_IMAGE_MANAGER_KV_H
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <climits>
|
||||
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "addrlib/src/core/addrlib.h"
|
||||
#include "image_runtime.h"
|
||||
#include "resource.h"
|
||||
@@ -14,7 +15,8 @@
|
||||
#include "util.h"
|
||||
#include "device_info.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Workaround switch to combined format/type codes and missing gfx10
|
||||
@@ -143,8 +145,7 @@ hsa_status_t ImageManagerNv::CalculateImageSizeAndAlignment(
|
||||
hsa_ext_image_data_info_t& image_info) const {
|
||||
ADDR2_COMPUTE_SURFACE_INFO_OUTPUT out = {0};
|
||||
hsa_profile_t profile;
|
||||
hsa_status_t status = hsa_agent_get_info(component,
|
||||
HSA_AGENT_INFO_PROFILE, &profile);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
Image::TileMode tileMode = Image::TileMode::LINEAR;
|
||||
if (image_data_layout == HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE) {
|
||||
tileMode = (profile == HSA_PROFILE_BASE &&
|
||||
@@ -217,10 +218,10 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
|
||||
SQ_BUF_RSRC_WORD3 word3;
|
||||
|
||||
word0.val = 0;
|
||||
word0.f.BASE_ADDRESS = ext_image::PtrLow32(image_data_addr);
|
||||
word0.f.BASE_ADDRESS = PtrLow32(image_data_addr);
|
||||
|
||||
word1.val = image.srd[1];
|
||||
word1.f.BASE_ADDRESS_HI = ext_image::PtrHigh32(image_data_addr);
|
||||
word1.f.BASE_ADDRESS_HI = PtrHigh32(image_data_addr);
|
||||
word1.f.STRIDE = image_prop.element_size;
|
||||
|
||||
word3.val = image.srd[3];
|
||||
@@ -242,9 +243,9 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
|
||||
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
|
||||
}
|
||||
reinterpret_cast<SQ_IMG_RSRC_WORD0*>(&image.srd[0])->bits.BASE_ADDRESS =
|
||||
ext_image::PtrLow40Shift8(image_data_addr);
|
||||
reinterpret_cast<SQ_IMG_RSRC_WORD1*>(&image.srd[1])->bits.BASE_ADDRESS_HI
|
||||
= ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
PtrLow40Shift8(image_data_addr);
|
||||
reinterpret_cast<SQ_IMG_RSRC_WORD1*>(&image.srd[1])->bits.BASE_ADDRESS_HI =
|
||||
PtrHigh64Shift40(image_data_addr);
|
||||
reinterpret_cast<SQ_IMG_RSRC_WORD1*>(&image.srd[1])->bits.FORMAT = GetCombinedFormat(image_prop.data_format, image_prop.data_type);
|
||||
reinterpret_cast<SQ_IMG_RSRC_WORD3*>(&image.srd[3])->bits.DST_SEL_X =
|
||||
swizzle.x;
|
||||
@@ -264,9 +265,10 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
|
||||
uintptr_t meta = uintptr_t(((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS_HI) << 16;
|
||||
meta |= uintptr_t(((SQ_IMG_RSRC_WORD6*)(&image.srd[6]))->bits.META_DATA_ADDRESS) << 8;
|
||||
meta += reinterpret_cast<uintptr_t>(image_data_addr);
|
||||
|
||||
((SQ_IMG_RSRC_WORD6*)(&image.srd[6]))->bits.META_DATA_ADDRESS = ext_image::PtrLow16Shift8((void*)meta);
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS_HI = ext_image::PtrHigh64Shift16((void*)meta);
|
||||
|
||||
((SQ_IMG_RSRC_WORD6*)(&image.srd[6]))->bits.META_DATA_ADDRESS = PtrLow16Shift8((void*)meta);
|
||||
((SQ_IMG_RSRC_WORD7*)(&image.srd[7]))->bits.META_DATA_ADDRESS_HI =
|
||||
PtrHigh64Shift16((void*)meta);
|
||||
}
|
||||
// Looks like this is only used for CPU copies.
|
||||
image.row_pitch = 0;
|
||||
@@ -352,10 +354,10 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
|
||||
SQ_BUF_RSRC_WORD3 word3;
|
||||
|
||||
word0.val = 0;
|
||||
word0.f.BASE_ADDRESS = ext_image::PtrLow32(image_data_addr);
|
||||
word0.f.BASE_ADDRESS = PtrLow32(image_data_addr);
|
||||
|
||||
word1.val = 0;
|
||||
word1.f.BASE_ADDRESS_HI = ext_image::PtrHigh32(image_data_addr);
|
||||
word1.f.BASE_ADDRESS_HI = PtrHigh32(image_data_addr);
|
||||
word1.f.STRIDE = image_prop.element_size;
|
||||
word1.f.SWIZZLE_ENABLE = false;
|
||||
word1.f.CACHE_SWIZZLE = false;
|
||||
@@ -404,18 +406,18 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
|
||||
|
||||
const size_t row_pitch_size = out.pitch * image_prop.element_size;
|
||||
|
||||
word0.f.BASE_ADDRESS = ext_image::PtrLow40Shift8(image_data_addr);
|
||||
word0.f.BASE_ADDRESS = PtrLow40Shift8(image_data_addr);
|
||||
|
||||
word1.val = 0;
|
||||
word1.f.BASE_ADDRESS_HI = ext_image::PtrHigh64Shift40(image_data_addr);
|
||||
word1.f.BASE_ADDRESS_HI = PtrHigh64Shift40(image_data_addr);
|
||||
word1.f.MIN_LOD = 0;
|
||||
word1.f.FORMAT = GetCombinedFormat(image_prop.data_format, image_prop.data_type);
|
||||
// Only take the lowest 2 bits of (image.desc.width - 1)
|
||||
word1.f.WIDTH = ext_image::BitSelect<0, 1>(image.desc.width - 1);
|
||||
word1.f.WIDTH = BitSelect<0, 1>(image.desc.width - 1);
|
||||
|
||||
word2.val = 0;
|
||||
// Take the high 12 bits of (image.desc.width - 1)
|
||||
word2.f.WIDTH_HI = ext_image::BitSelect<2, 13>(image.desc.width - 1);
|
||||
word2.f.WIDTH_HI = BitSelect<2, 13>(image.desc.width - 1);
|
||||
word2.f.HEIGHT = image.desc.height ? image.desc.height - 1 : 0;
|
||||
word2.f.RESOURCE_LEVEL = 1;
|
||||
|
||||
@@ -507,7 +509,7 @@ hsa_status_t ImageManagerNv::ModifyImageSrd(
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t ImageManagerNv::PopulateSamplerSrd(amd::Sampler& sampler) const {
|
||||
hsa_status_t ImageManagerNv::PopulateSamplerSrd(Sampler& sampler) const {
|
||||
const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc;
|
||||
|
||||
SQ_IMG_SAMP_WORD0 word0;
|
||||
@@ -720,9 +722,8 @@ hsa_status_t ImageManagerNv::FillImage(const Image& image, const void* pattern,
|
||||
break;
|
||||
}
|
||||
|
||||
hsa_status_t status =
|
||||
ext_image::ImageRuntime::instance()->blit_kernel().FillImage(
|
||||
blit_queue_, blit_code_catalog_, *image_view, new_pattern, region);
|
||||
hsa_status_t status = ImageRuntime::instance()->blit_kernel().FillImage(
|
||||
blit_queue_, blit_code_catalog_, *image_view, new_pattern, region);
|
||||
|
||||
// Revert back original configuration.
|
||||
if (word3_buff != NULL) {
|
||||
@@ -740,4 +741,5 @@ hsa_status_t ImageManagerNv::FillImage(const Image& image, const void* pattern,
|
||||
return status;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "addrlib/inc/addrinterface.h"
|
||||
#include "image_manager_kv.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageManagerNv : public ImageManagerKv {
|
||||
public:
|
||||
@@ -48,6 +49,8 @@ class ImageManagerNv : public ImageManagerKv {
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageManagerNv);
|
||||
}; // namespace amd
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // EXT_IMAGE_IMAGE_MANAGER_NV_H_
|
||||
|
||||
@@ -5,16 +5,17 @@
|
||||
#include <climits>
|
||||
#include <mutex>
|
||||
|
||||
#include "core/inc/hsa_internal.h"
|
||||
#include "core/inc/hsa_ext_amd_impl.h"
|
||||
#include "resource.h"
|
||||
#include "image_manager_kv.h"
|
||||
#include "image_manager_ai.h"
|
||||
#include "image_manager_nv.h"
|
||||
#include "device_info.h"
|
||||
|
||||
// Per library unload callback function.
|
||||
extern "C" void (*UnloadCallback)();
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
namespace ext_image {
|
||||
std::atomic<ImageRuntime*> ImageRuntime::instance_(NULL);
|
||||
std::mutex ImageRuntime::instance_mutex_;
|
||||
|
||||
@@ -26,17 +27,16 @@ hsa_status_t FindKernelArgPool(hsa_amd_memory_pool_t pool, void* data) {
|
||||
uint32_t flag;
|
||||
size_t size;
|
||||
|
||||
err = hsa_amd_memory_pool_get_info(pool, HSA_AMD_MEMORY_POOL_INFO_SEGMENT,
|
||||
&segment);
|
||||
err = AMD::hsa_amd_memory_pool_get_info(pool, HSA_AMD_MEMORY_POOL_INFO_SEGMENT, &segment);
|
||||
assert(err == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (segment != HSA_AMD_SEGMENT_GLOBAL) return HSA_STATUS_SUCCESS;
|
||||
|
||||
err = hsa_amd_memory_pool_get_info(
|
||||
err = AMD::hsa_amd_memory_pool_get_info(
|
||||
pool, HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS, &flag);
|
||||
assert(err == HSA_STATUS_SUCCESS);
|
||||
|
||||
err = hsa_amd_memory_pool_get_info(pool, HSA_AMD_MEMORY_POOL_INFO_SIZE, &size);
|
||||
err = AMD::hsa_amd_memory_pool_get_info(pool, HSA_AMD_MEMORY_POOL_INFO_SIZE, &size);
|
||||
assert(err == HSA_STATUS_SUCCESS);
|
||||
|
||||
if (((HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT & flag) == 1) && (size != 0)) {
|
||||
@@ -53,7 +53,7 @@ hsa_status_t ImageRuntime::CreateImageManager(hsa_agent_t agent, void* data) {
|
||||
|
||||
hsa_device_type_t hsa_device_type;
|
||||
hsa_status_t hsa_error_code =
|
||||
hsa_agent_get_info(agent, HSA_AGENT_INFO_DEVICE, &hsa_device_type);
|
||||
HSA::hsa_agent_get_info(agent, HSA_AGENT_INFO_DEVICE, &hsa_device_type);
|
||||
if (hsa_error_code != HSA_STATUS_SUCCESS) {
|
||||
return hsa_error_code;
|
||||
}
|
||||
@@ -64,14 +64,14 @@ hsa_status_t ImageRuntime::CreateImageManager(hsa_agent_t agent, void* data) {
|
||||
hsa_error_code = GetGPUAsicID(agent, &chip_id);
|
||||
uint32_t major_ver = MajorVerFromDevID(chip_id);
|
||||
|
||||
amd::ImageManager* image_manager;
|
||||
ImageManager* image_manager;
|
||||
|
||||
if (major_ver >= 10) {
|
||||
image_manager = new amd::ImageManagerNv();
|
||||
image_manager = new ImageManagerNv();
|
||||
} else if (major_ver >= 9) {
|
||||
image_manager = new amd::ImageManagerAi();
|
||||
image_manager = new ImageManagerAi();
|
||||
} else {
|
||||
image_manager = new amd::ImageManagerKv();
|
||||
image_manager = new ImageManagerKv();
|
||||
}
|
||||
hsa_error_code = image_manager->Initialize(agent);
|
||||
|
||||
@@ -83,8 +83,7 @@ hsa_status_t ImageRuntime::CreateImageManager(hsa_agent_t agent, void* data) {
|
||||
runtime->image_managers_[agent.handle] = image_manager;
|
||||
} else if (hsa_device_type == HSA_DEVICE_TYPE_CPU) {
|
||||
uint32_t caches[4] = {0};
|
||||
hsa_error_code =
|
||||
hsa_agent_get_info(agent, HSA_AGENT_INFO_CACHE_SIZE, caches);
|
||||
hsa_error_code = HSA::hsa_agent_get_info(agent, HSA_AGENT_INFO_CACHE_SIZE, caches);
|
||||
|
||||
if (hsa_error_code != HSA_STATUS_SUCCESS) {
|
||||
return hsa_error_code;
|
||||
@@ -116,7 +115,7 @@ ImageRuntime* ImageRuntime::instance() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UnloadCallback = &ext_image::ImageRuntime::DestroySingleton;
|
||||
// UnloadCallback = &ext_image::ImageRuntime::DestroySingleton;
|
||||
}
|
||||
|
||||
return instance;
|
||||
@@ -131,7 +130,7 @@ ImageRuntime* ImageRuntime::CreateSingleton() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (HSA_STATUS_SUCCESS != hsa_iterate_agents(CreateImageManager, instance)) {
|
||||
if (HSA_STATUS_SUCCESS != HSA::hsa_iterate_agents(CreateImageManager, instance)) {
|
||||
instance->Cleanup();
|
||||
delete instance;
|
||||
return NULL;
|
||||
@@ -213,8 +212,7 @@ hsa_status_t ImageRuntime::GetImageInfoMaxDimension(hsa_agent_t component,
|
||||
uint32_t array_size = 0;
|
||||
|
||||
hsa_device_type_t device_type;
|
||||
hsa_status_t status =
|
||||
hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
@@ -245,14 +243,13 @@ hsa_status_t ImageRuntime::GetImageCapability(
|
||||
hsa_agent_t component, const hsa_ext_image_format_t& format,
|
||||
hsa_ext_image_geometry_t geometry, uint32_t& capability) {
|
||||
hsa_device_type_t device_type;
|
||||
hsa_status_t status =
|
||||
hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (device_type == HSA_DEVICE_TYPE_GPU) {
|
||||
amd::ImageManager* manager = image_manager(component);
|
||||
ImageManager* manager = image_manager(component);
|
||||
capability = manager->GetImageProperty(component, format, geometry).cap;
|
||||
} else {
|
||||
// Image is only supported on a GPU device.
|
||||
@@ -290,7 +287,7 @@ hsa_status_t ImageRuntime::GetImageSizeAndAlignment(
|
||||
uint32_t max_depth = 0;
|
||||
uint32_t max_array_size = 0;
|
||||
|
||||
amd::ImageManager* manager = image_manager(component);
|
||||
ImageManager* manager = image_manager(component);
|
||||
|
||||
// Validate the image dimension.
|
||||
manager->GetImageInfoMaxDimension(component, geometry, max_width, max_height,
|
||||
@@ -333,7 +330,7 @@ hsa_status_t ImageRuntime::CreateImageHandle(
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::Image* image = amd::Image::Create(component);
|
||||
Image* image = Image::Create(component);
|
||||
image->component = component;
|
||||
image->desc = image_descriptor;
|
||||
image->permission = access_permission;
|
||||
@@ -341,14 +338,15 @@ hsa_status_t ImageRuntime::CreateImageHandle(
|
||||
image->row_pitch = image_data_row_pitch;
|
||||
image->slice_pitch = image_data_slice_pitch;
|
||||
hsa_profile_t profile;
|
||||
status = hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_PROFILE, &profile);
|
||||
|
||||
if (image_data_layout == HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR) {
|
||||
image->tile_mode = amd::Image::TileMode::LINEAR;
|
||||
image->tile_mode = Image::TileMode::LINEAR;
|
||||
} else {
|
||||
amd::Image::TileMode tileMode = (profile == HSA_PROFILE_BASE &&
|
||||
image_descriptor.geometry != HSA_EXT_IMAGE_GEOMETRY_1DB)?
|
||||
amd::Image::TileMode::TILED : amd::Image::TileMode::LINEAR;
|
||||
Image::TileMode tileMode =
|
||||
(profile == HSA_PROFILE_BASE && image_descriptor.geometry != HSA_EXT_IMAGE_GEOMETRY_1DB)
|
||||
? Image::TileMode::TILED
|
||||
: Image::TileMode::LINEAR;
|
||||
image->tile_mode = tileMode;
|
||||
}
|
||||
|
||||
@@ -372,22 +370,22 @@ hsa_status_t ImageRuntime::CreateImageHandleWithLayout(
|
||||
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
|
||||
|
||||
uint32_t id;
|
||||
hsa_agent_get_info(component, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_CHIP_ID, &id);
|
||||
HSA::hsa_agent_get_info(component, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_CHIP_ID, &id);
|
||||
|
||||
if(image_layout->deviceID!=(0x1002<<16|id))
|
||||
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
|
||||
|
||||
const amd::metadata_amd_t* desc=reinterpret_cast<const amd::metadata_amd_t*>(image_layout);
|
||||
|
||||
amd::Image* image = amd::Image::Create(component);
|
||||
const metadata_amd_t* desc = reinterpret_cast<const metadata_amd_t*>(image_layout);
|
||||
|
||||
Image* image = Image::Create(component);
|
||||
image->component = component;
|
||||
image->desc = image_descriptor;
|
||||
image->permission = access_permission;
|
||||
image->data = const_cast<void*>(image_data);
|
||||
image->tile_mode=amd::Image::TILED;
|
||||
image->tile_mode = Image::TILED;
|
||||
hsa_status_t err=image_manager(component)->PopulateImageSrd(*image, desc);
|
||||
if(err!=HSA_STATUS_SUCCESS) {
|
||||
amd::Image::Destroy(image);
|
||||
Image::Destroy(image);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -397,13 +395,13 @@ hsa_status_t ImageRuntime::CreateImageHandleWithLayout(
|
||||
|
||||
hsa_status_t ImageRuntime::DestroyImageHandle(
|
||||
const hsa_ext_image_t& image_handle) {
|
||||
const amd::Image* image = amd::Image::Convert(image_handle.handle);
|
||||
const Image* image = Image::Convert(image_handle.handle);
|
||||
|
||||
if (image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::Image::Destroy(const_cast<amd::Image*>(image));
|
||||
Image::Destroy(const_cast<Image*>(image));
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -412,13 +410,13 @@ hsa_status_t ImageRuntime::CopyBufferToImage(
|
||||
const void* src_memory, size_t src_row_pitch, size_t src_slice_pitch,
|
||||
const hsa_ext_image_t& dst_image_handle,
|
||||
const hsa_ext_image_region_t& image_region) {
|
||||
const amd::Image* dst_image = amd::Image::Convert(dst_image_handle.handle);
|
||||
const Image* dst_image = Image::Convert(dst_image_handle.handle);
|
||||
|
||||
if (dst_image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::ImageManager* manager = image_manager(dst_image->component);
|
||||
ImageManager* manager = image_manager(dst_image->component);
|
||||
return manager->CopyBufferToImage(src_memory, src_row_pitch, src_slice_pitch,
|
||||
*dst_image, image_region);
|
||||
}
|
||||
@@ -427,13 +425,13 @@ hsa_status_t ImageRuntime::CopyImageToBuffer(
|
||||
const hsa_ext_image_t& src_image_handle, void* dst_memory,
|
||||
size_t dst_row_pitch, size_t dst_slice_pitch,
|
||||
const hsa_ext_image_region_t& image_region) {
|
||||
const amd::Image* src_image = amd::Image::Convert(src_image_handle.handle);
|
||||
const Image* src_image = Image::Convert(src_image_handle.handle);
|
||||
|
||||
if (src_image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::ImageManager* manager = image_manager(src_image->component);
|
||||
ImageManager* manager = image_manager(src_image->component);
|
||||
return manager->CopyImageToBuffer(*src_image, dst_memory, dst_row_pitch,
|
||||
dst_slice_pitch, image_region);
|
||||
}
|
||||
@@ -443,13 +441,13 @@ hsa_status_t ImageRuntime::CopyImage(const hsa_ext_image_t& src_image_handle,
|
||||
const hsa_dim3_t& src_origin,
|
||||
const hsa_dim3_t& dst_origin,
|
||||
const hsa_dim3_t size) {
|
||||
const amd::Image* src_image = amd::Image::Convert(src_image_handle.handle);
|
||||
const Image* src_image = Image::Convert(src_image_handle.handle);
|
||||
|
||||
if (src_image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
const amd::Image* dst_image = amd::Image::Convert(dst_image_handle.handle);
|
||||
const Image* dst_image = Image::Convert(dst_image_handle.handle);
|
||||
|
||||
if (dst_image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
@@ -459,7 +457,7 @@ hsa_status_t ImageRuntime::CopyImage(const hsa_ext_image_t& src_image_handle,
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::ImageManager* manager = image_manager(src_image->component);
|
||||
ImageManager* manager = image_manager(src_image->component);
|
||||
return manager->CopyImage(*dst_image, *src_image, dst_origin, src_origin,
|
||||
size);
|
||||
}
|
||||
@@ -467,13 +465,13 @@ hsa_status_t ImageRuntime::CopyImage(const hsa_ext_image_t& src_image_handle,
|
||||
hsa_status_t ImageRuntime::FillImage(
|
||||
const hsa_ext_image_t& image_handle, const void* pattern,
|
||||
const hsa_ext_image_region_t& image_region) {
|
||||
const amd::Image* image = amd::Image::Convert(image_handle.handle);
|
||||
const Image* image = Image::Convert(image_handle.handle);
|
||||
|
||||
if (image == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::ImageManager* manager = image_manager(image->component);
|
||||
ImageManager* manager = image_manager(image->component);
|
||||
return manager->FillImage(*image, pattern, image_region);
|
||||
}
|
||||
|
||||
@@ -484,8 +482,7 @@ hsa_status_t ImageRuntime::CreateSamplerHandle(
|
||||
sampler_handle.handle = 0;
|
||||
|
||||
hsa_device_type_t device_type;
|
||||
hsa_status_t status =
|
||||
hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
hsa_status_t status = HSA::hsa_agent_get_info(component, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
@@ -495,7 +492,7 @@ hsa_status_t ImageRuntime::CreateSamplerHandle(
|
||||
return HSA_STATUS_ERROR_INVALID_AGENT;
|
||||
}
|
||||
|
||||
amd::Sampler* sampler = amd::Sampler::Create(component);
|
||||
Sampler* sampler = Sampler::Create(component);
|
||||
if (sampler == NULL) {
|
||||
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -511,13 +508,13 @@ hsa_status_t ImageRuntime::CreateSamplerHandle(
|
||||
|
||||
hsa_status_t ImageRuntime::DestroySamplerHandle(
|
||||
hsa_ext_sampler_t& sampler_handle) {
|
||||
const amd::Sampler* sampler = amd::Sampler::Convert(sampler_handle.handle);
|
||||
const Sampler* sampler = Sampler::Convert(sampler_handle.handle);
|
||||
|
||||
if (sampler == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
amd::Sampler::Destroy(sampler);
|
||||
Sampler::Destroy(sampler);
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -528,7 +525,7 @@ ImageRuntime::ImageRuntime()
|
||||
ImageRuntime::~ImageRuntime() {}
|
||||
|
||||
void ImageRuntime::Cleanup() {
|
||||
std::map<uint64_t, amd::ImageManager*>::iterator it;
|
||||
std::map<uint64_t, ImageManager*>::iterator it;
|
||||
for (it = image_managers_.begin(); it != image_managers_.end(); ++it) {
|
||||
it->second->Cleanup();
|
||||
delete it->second;
|
||||
@@ -537,4 +534,5 @@ void ImageRuntime::Cleanup() {
|
||||
blit_kernel_.Cleanup();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
|
||||
#include "inc/hsa.h"
|
||||
|
||||
#undef HSA_API
|
||||
#define HSA_API
|
||||
|
||||
#include "inc/hsa_ext_image.h"
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "blit_kernel.h"
|
||||
#include "image_manager.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace ext_image {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
class ImageRuntime {
|
||||
public:
|
||||
/// @brief Getter for the ImageRuntime singleton object.
|
||||
@@ -98,13 +97,12 @@ class ImageRuntime {
|
||||
/// @brief Destroy the device sampler object referenced by the handle.
|
||||
hsa_status_t DestroySamplerHandle(hsa_ext_sampler_t& sampler);
|
||||
|
||||
amd::ImageManager* image_manager(hsa_agent_t agent) {
|
||||
std::map<uint64_t, amd::ImageManager*>::iterator it =
|
||||
image_managers_.find(agent.handle);
|
||||
ImageManager* image_manager(hsa_agent_t agent) {
|
||||
std::map<uint64_t, ImageManager*>::iterator it = image_managers_.find(agent.handle);
|
||||
return (it != image_managers_.end()) ? it->second : NULL;
|
||||
}
|
||||
|
||||
amd::BlitKernel& blit_kernel() { return blit_kernel_; }
|
||||
BlitKernel& blit_kernel() { return blit_kernel_; }
|
||||
|
||||
size_t cpu_l2_cache_size() const { return cpu_l2_cache_size_; }
|
||||
|
||||
@@ -131,10 +129,10 @@ class ImageRuntime {
|
||||
|
||||
/// @brief Contains mapping of agent and its corresponding ::ImageManager
|
||||
/// object.
|
||||
std::map<uint64_t, amd::ImageManager*> image_managers_;
|
||||
std::map<uint64_t, ImageManager*> image_managers_;
|
||||
|
||||
/// @brief Manages kernel for accessing images.
|
||||
amd::BlitKernel blit_kernel_;
|
||||
BlitKernel blit_kernel_;
|
||||
|
||||
size_t cpu_l2_cache_size_;
|
||||
|
||||
@@ -143,5 +141,6 @@ class ImageRuntime {
|
||||
DISALLOW_COPY_AND_ASSIGN(ImageRuntime);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_IMAGE_RUNTIME_H
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef HSA_RUNTIME_EXT_IMAGE_H
|
||||
#define HSA_RUNTIME_EXT_IMAGE_H
|
||||
|
||||
#include "inc/hsa.h"
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
#include "inc/hsa_ext_image.h"
|
||||
#include "core/inc/hsa_ext_interface.h"
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
// APIs that implement Image functionality
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
hsa_status_t hsa_amd_image_get_info_max_dim(hsa_agent_t agent, hsa_agent_info_t attribute,
|
||||
void* value);
|
||||
|
||||
hsa_status_t hsa_ext_image_get_capability(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
uint32_t* capability_mask);
|
||||
|
||||
hsa_status_t hsa_ext_image_data_get_info(hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_data_info_t* image_data_info);
|
||||
|
||||
hsa_status_t hsa_ext_image_create(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_t* image);
|
||||
|
||||
hsa_status_t hsa_ext_image_destroy(hsa_agent_t agent, hsa_ext_image_t image);
|
||||
|
||||
hsa_status_t hsa_ext_image_copy(hsa_agent_t agent, hsa_ext_image_t src_image,
|
||||
const hsa_dim3_t* src_offset, hsa_ext_image_t dst_image,
|
||||
const hsa_dim3_t* dst_offset, const hsa_dim3_t* range);
|
||||
|
||||
hsa_status_t hsa_ext_image_import(hsa_agent_t agent, const void* src_memory, size_t src_row_pitch,
|
||||
size_t src_slice_pitch, hsa_ext_image_t dst_image,
|
||||
const hsa_ext_image_region_t* image_region);
|
||||
|
||||
hsa_status_t hsa_ext_image_export(hsa_agent_t agent, hsa_ext_image_t src_image, void* dst_memory,
|
||||
size_t dst_row_pitch, size_t dst_slice_pitch,
|
||||
const hsa_ext_image_region_t* image_region);
|
||||
|
||||
hsa_status_t hsa_ext_image_clear(hsa_agent_t agent, hsa_ext_image_t image, const void* data,
|
||||
const hsa_ext_image_region_t* image_region);
|
||||
|
||||
hsa_status_t hsa_ext_sampler_create(hsa_agent_t agent,
|
||||
const hsa_ext_sampler_descriptor_t* sampler_descriptor,
|
||||
hsa_ext_sampler_t* sampler);
|
||||
|
||||
hsa_status_t hsa_ext_sampler_destroy(hsa_agent_t agent, hsa_ext_sampler_t sampler);
|
||||
|
||||
hsa_status_t hsa_ext_image_get_capability_with_layout(hsa_agent_t agent,
|
||||
hsa_ext_image_geometry_t image_geometry,
|
||||
const hsa_ext_image_format_t* image_format,
|
||||
hsa_ext_image_data_layout_t image_data_layout,
|
||||
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,
|
||||
size_t image_data_row_pitch, size_t image_data_slice_pitch,
|
||||
hsa_ext_image_data_info_t* 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);
|
||||
|
||||
hsa_status_t hsa_amd_image_create(hsa_agent_t agent,
|
||||
const hsa_ext_image_descriptor_t* image_descriptor,
|
||||
const hsa_amd_image_descriptor_t* image_layout,
|
||||
const void* image_data, hsa_access_permission_t access_permission,
|
||||
hsa_ext_image_t* image);
|
||||
|
||||
// Update Api table with func pointers that implement functionality
|
||||
void LoadImage(core::ImageExtTableInternal* image_api,
|
||||
decltype(::hsa_amd_image_create)** interface_api);
|
||||
|
||||
// Release resources acquired by Image implementation
|
||||
void ReleaseImageRsrcs();
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_H
|
||||
@@ -26,8 +26,8 @@
|
||||
(HSA_EXT_IMAGE_CAPABILITY_READ_ONLY | HSA_EXT_IMAGE_CAPABILITY_WRITE_ONLY | \
|
||||
HSA_EXT_IMAGE_CAPABILITY_READ_WRITE)
|
||||
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
typedef struct metadata_amd_s {
|
||||
uint32_t version; // Must be 1
|
||||
@@ -151,5 +151,6 @@ public:
|
||||
hsa_ext_sampler_descriptor_t desc;
|
||||
} Sampler;
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_RESOURCE_H
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
|
||||
#endif
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
union SQ_BUF_RSRC_WORD0 {
|
||||
struct {
|
||||
@@ -1116,5 +1117,6 @@ typedef struct metadata_amd_ai_s {
|
||||
uint32_t mip_offsets[0]; //Mip level offset bits [39:8] for each level (if any)
|
||||
} metadata_amd_ai_t;
|
||||
|
||||
} // namespace
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_RESOURCE_AI_H
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
|
||||
#endif
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
union SQ_BUF_RSRC_WORD0 {
|
||||
struct {
|
||||
#if defined(LITTLEENDIAN_CPU)
|
||||
@@ -459,5 +461,6 @@ typedef struct metadata_amd_ci_vi_s {
|
||||
uint32_t mip_offsets[0]; //Mip level offset bits [39:8] for each level (if any)
|
||||
} metadata_amd_ci_vi_t;
|
||||
|
||||
} // namespace
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_RESOURCE_KV_H
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_RESOURCE_KV_H
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
|
||||
#endif
|
||||
|
||||
namespace amd {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
/**********************************************************/
|
||||
/**********************************************************/
|
||||
@@ -830,5 +831,6 @@ typedef struct metadata_amd_nv_s {
|
||||
uint32_t mip_offsets[0];
|
||||
} metadata_amd_nv_t;
|
||||
|
||||
} // namespace amd
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
#endif // EXT_IMAGE_RESOURCE_NV_H_
|
||||
|
||||
@@ -1,40 +1,46 @@
|
||||
#ifndef HSA_RUNTIME_EXT_IMAGE_UTIL_H
|
||||
#define HSA_RUNTIME_EXT_IMAGE_UTIL_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
#include "stdlib.h"
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include "inc/hsa.h"
|
||||
|
||||
// A macro to disallow the copy and move constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
TypeName(TypeName&&); \
|
||||
void operator=(const TypeName&); \
|
||||
void operator=(TypeName&&);
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define ALIGNED_(x) __declspec(align(x))
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||
#endif // __GNUC__
|
||||
#define ALIGNED_(x) __attribute__((aligned(x)))
|
||||
#endif // __GNUC__
|
||||
#endif // _MSC_VER
|
||||
|
||||
#define MULTILINE(...) # __VA_ARGS__
|
||||
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include "mm_malloc.h"
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#include <x86intrin.h>
|
||||
#else
|
||||
#error \
|
||||
#error \
|
||||
"Processor not identified. " \
|
||||
"Need to provide a lightweight approximate clock interface (aka __rdtsc())."
|
||||
"Need to provide a lightweight approximate clock interface (aka __rdtsc())."
|
||||
#endif
|
||||
|
||||
namespace ext_image {
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
|
||||
#define __forceinline __inline__ __attribute__((always_inline))
|
||||
static __forceinline void __debugbreak() { __builtin_trap(); }
|
||||
#define __declspec(x) __attribute__((x))
|
||||
@@ -43,17 +49,94 @@ static __forceinline void __debugbreak() { __builtin_trap(); }
|
||||
#define __ALIGNED__(x) __attribute__((aligned(x)))
|
||||
|
||||
static __forceinline void* _aligned_malloc(size_t size, size_t alignment) {
|
||||
return _mm_malloc(size, alignment);
|
||||
#ifdef _ISOC11_SOURCE
|
||||
return aligned_alloc(alignment, size);
|
||||
#else
|
||||
void* mem = NULL;
|
||||
if (NULL != posix_memalign(&mem, alignment, size)) return NULL;
|
||||
return mem;
|
||||
#endif
|
||||
}
|
||||
static __forceinline void _aligned_free(void* ptr) { return _mm_free(ptr); }
|
||||
static __forceinline void _aligned_free(void* ptr) { return free(ptr); }
|
||||
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#include "intrin.h"
|
||||
#define __ALIGNED__(x) __declspec(align(x))
|
||||
namespace ext_image {
|
||||
|
||||
namespace rocr {
|
||||
namespace image {
|
||||
#else
|
||||
#error "Compiler and/or processor not identified."
|
||||
#endif
|
||||
|
||||
// A macro to disallow the copy and move constructor and operator= functions
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&) = delete; \
|
||||
TypeName(TypeName&&) = delete; \
|
||||
void operator=(const TypeName&) = delete; \
|
||||
void operator=(TypeName&&) = delete;
|
||||
|
||||
template <typename lambda> class ScopeGuard {
|
||||
public:
|
||||
explicit __forceinline ScopeGuard(const lambda& release) : release_(release), dismiss_(false) {}
|
||||
|
||||
ScopeGuard(ScopeGuard& rhs) { *this = rhs; }
|
||||
|
||||
__forceinline ~ScopeGuard() {
|
||||
if (!dismiss_) release_();
|
||||
}
|
||||
__forceinline ScopeGuard& operator=(ScopeGuard& rhs) {
|
||||
dismiss_ = rhs.dismiss_;
|
||||
release_ = rhs.release_;
|
||||
rhs.dismiss_ = true;
|
||||
}
|
||||
__forceinline void Dismiss() { dismiss_ = true; }
|
||||
|
||||
private:
|
||||
lambda release_;
|
||||
bool dismiss_;
|
||||
};
|
||||
|
||||
template <typename lambda> static __forceinline ScopeGuard<lambda> MakeScopeGuard(lambda rel) {
|
||||
return ScopeGuard<lambda>(rel);
|
||||
}
|
||||
|
||||
#define MAKE_SCOPE_GUARD_HELPER(lname, sname, ...) \
|
||||
auto lname = __VA_ARGS__; \
|
||||
ScopeGuard<decltype(lname)> sname(lname);
|
||||
#define MAKE_SCOPE_GUARD(...) \
|
||||
MAKE_SCOPE_GUARD_HELPER(PASTE(scopeGuardLambda, __COUNTER__), PASTE(scopeGuard, __COUNTER__), \
|
||||
__VA_ARGS__)
|
||||
#define MAKE_NAMED_SCOPE_GUARD(name, ...) \
|
||||
MAKE_SCOPE_GUARD_HELPER(PASTE(scopeGuardLambda, __COUNTER__), name, __VA_ARGS__)
|
||||
|
||||
/// @brief: Finds out the min one of two inputs, input must support ">"
|
||||
/// operator.
|
||||
/// @param: a(Input), a reference to type T.
|
||||
/// @param: b(Input), a reference to type T.
|
||||
/// @return: T.
|
||||
template <class T> static __forceinline T Min(const T& a, const T& b) { return (a > b) ? b : a; }
|
||||
|
||||
template <class T, class... Arg> static __forceinline T Min(const T& a, const T& b, Arg... args) {
|
||||
return Min(a, Min(b, args...));
|
||||
}
|
||||
|
||||
/// @brief: Find out the max one of two inputs, input must support ">" operator.
|
||||
/// @param: a(Input), a reference to type T.
|
||||
/// @param: b(Input), a reference to type T.
|
||||
/// @return: T.
|
||||
template <class T> static __forceinline T Max(const T& a, const T& b) { return (b > a) ? b : a; }
|
||||
|
||||
template <class T, class... Arg> static __forceinline T Max(const T& a, const T& b, Arg... args) {
|
||||
return Max(a, Max(b, args...));
|
||||
}
|
||||
|
||||
/// @brief: Free the memory space which is newed previously.
|
||||
/// @param: ptr(Input), a pointer to memory space. Can't be NULL.
|
||||
/// @return: void.
|
||||
struct DeleteObject {
|
||||
template <typename T> void operator()(const T* ptr) const { delete ptr; }
|
||||
};
|
||||
|
||||
/// @brief: Checks if a value is power of two, if it is, return true. Be careful
|
||||
/// when passing 0.
|
||||
/// @param: val(Input), the data to be checked.
|
||||
@@ -148,6 +231,24 @@ static __forceinline uint64_t NextPow2(uint64_t value) {
|
||||
return v + 1;
|
||||
}
|
||||
|
||||
static __forceinline bool strIsEmpty(const char* str) noexcept { return str[0] == '\0'; }
|
||||
|
||||
static __forceinline std::string& ltrim(std::string& s) {
|
||||
auto it = std::find_if(s.begin(), s.end(),
|
||||
[](char c) { return !std::isspace<char>(c, std::locale::classic()); });
|
||||
s.erase(s.begin(), it);
|
||||
return s;
|
||||
}
|
||||
|
||||
static __forceinline std::string& rtrim(std::string& s) {
|
||||
auto it = std::find_if(s.rbegin(), s.rend(),
|
||||
[](char c) { return !std::isspace<char>(c, std::locale::classic()); });
|
||||
s.erase(it.base(), s.end());
|
||||
return s;
|
||||
}
|
||||
|
||||
static __forceinline std::string& trim(std::string& s) { return ltrim(rtrim(s)); }
|
||||
|
||||
template<uint32_t lowBit, uint32_t highBit, typename T>
|
||||
static __forceinline uint32_t BitSelect(T p) {
|
||||
static_assert(sizeof(T) <= sizeof(uintptr_t), "Type out of range.");
|
||||
@@ -192,22 +293,7 @@ inline uint32_t PtrHigh32(const void* p) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic functor compatible with the STL algorithms that enables proper
|
||||
* destruction of a container of pointers. If (for instance), \c v is a vector
|
||||
* of pointers to objects of type T, then the destructors of the elements in
|
||||
* \c v are invoked when calling
|
||||
* \code{std::for_each(v.begin(), v.end(), DeleteObject())}
|
||||
*
|
||||
* The original code and further information about this function object can be
|
||||
* found in "Effective STL", 1st edition, item 7.
|
||||
*/
|
||||
struct DeleteObject {
|
||||
template<typename T>
|
||||
void operator()(const T *ptr) const {
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
} // namespace ext_image
|
||||
} // namespace image
|
||||
} // namespace rocr
|
||||
|
||||
#endif // HSA_RUNTIME_EXT_IMAGE_UTIL_H
|
||||
|
||||
Referencia en una nueva incidencia
Block a user