Skip to content

Commit

Permalink
ROCm 5.2.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
skeelyamd committed Jun 28, 2022
1 parent 7f0e08c commit dbc2f40
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 108 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The University of Illinois/NCSA
Open Source License (NCSA)

Copyright (c) 2014-2017, Advanced Micro Devices, Inc. All rights reserved.
Copyright (c) 2014-2022, Advanced Micro Devices, Inc. All rights reserved.

Developed by:

Expand Down
39 changes: 17 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ project( ${CORE_RUNTIME_TARGET} )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
include ( utils )
include ( hsa_common )
# Set default libdir to be "lib" for ROCm, distros will override this anyway:
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory")
include ( GNUInstallDirs )

## Expose static library option
Expand Down Expand Up @@ -117,7 +119,7 @@ endif()
target_include_directories( ${CORE_RUNTIME_TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<INSTALL_INTERFACE:include/hsa>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/hsa>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/libamdhsacode )
Expand Down Expand Up @@ -191,10 +193,10 @@ set ( SRCS core/util/lnx/os_linux.cpp

target_sources( ${CORE_RUNTIME_TARGET} PRIVATE ${SRCS} )

if ( NOT DEFINED IMAGE_SUPPORT )
if ( NOT DEFINED IMAGE_SUPPORT AND CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|x86_64|amd64|AMD64" )
set ( IMAGE_SUPPORT ON )
endif()
set ( IMAGE_SUPPORT ${IMAGE_SUPPORT} CACHE BOOL "Build with image support (default: ON)." )
set ( IMAGE_SUPPORT ${IMAGE_SUPPORT} CACHE BOOL "Build with image support (default: ON for x86, OFF elsewise)." )

## Optional image module defintions.
if(${IMAGE_SUPPORT})
Expand All @@ -203,8 +205,6 @@ if(${IMAGE_SUPPORT})
HSA_IMAGE_SUPPORT
UNIX_OS
LINUX
__AMD64__
__x86_64__
AMD_INTERNAL_BUILD
BRAHMA_BUILD=1 )

Expand Down Expand Up @@ -275,7 +275,7 @@ if( NOT ${BUILD_SHARED_LIBS} )

## Bind to source build target interface but not its link requirements.
target_include_directories( ${CORE_RUNTIME_NAME} INTERFACE $<TARGET_PROPERTY:${CORE_RUNTIME_NAME}::${CORE_RUNTIME_TARGET},INTERFACE_INCLUDE_DIRECTORIES> )
target_link_libraries ( ${CORE_RUNTIME_NAME} INTERFACE -Wl,$<INSTALL_PREFIX>/lib/cmake/${CORE_RUNTIME_NAME}/${LNKSCR}
target_link_libraries ( ${CORE_RUNTIME_NAME} INTERFACE -Wl,$<INSTALL_PREFIX>/${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}/${LNKSCR}
-Wl,--whole-archive $<TARGET_FILE:${CORE_RUNTIME_NAME}::${CORE_RUNTIME_TARGET}> -Wl,--no-whole-archive)
add_dependencies( ${CORE_RUNTIME_NAME} ${CORE_RUNTIME_TARGET} )

Expand All @@ -287,25 +287,23 @@ if( NOT ${BUILD_SHARED_LIBS} )
endif()

## Create symlinks for legacy packaging and install
add_custom_target ( hsa_include_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../include/hsa hsa_include_link )
add_custom_target ( hsa_include_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../${CMAKE_INSTALL_INCLUDEDIR}/hsa hsa_include_link )
if ( ${BUILD_SHARED_LIBS} )
add_custom_target ( hsa_lib_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../lib/${CORE_RUNTIME_LIBRARY}.so ${CORE_RUNTIME_LIBRARY}-link.so )
add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../lib/${CORE_RUNTIME_LIBRARY}.so.${VERSION_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${VERSION_MAJOR} )
add_custom_target ( hsa_lib_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../${CMAKE_INSTALL_LIBDIR}/${CORE_RUNTIME_LIBRARY}.so ${CORE_RUNTIME_LIBRARY}-link.so )
add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../${CMAKE_INSTALL_LIBDIR}/${CORE_RUNTIME_LIBRARY}.so.${VERSION_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${VERSION_MAJOR} )
endif()

## Set install information
# Installs binaries and exports the library usage data to ${HSAKMT_TARGET}Targets
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
install ( TARGETS ${CORE_RUNTIME_TARGET} EXPORT ${CORE_RUNTIME_NAME}Targets
ARCHIVE DESTINATION lib COMPONENT binary
LIBRARY DESTINATION lib COMPONENT binary )
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT binary
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT binary )

# Install license
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT binary )

# Install public headers
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_INCLUDEDIR}
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa COMPONENT dev )
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hsa COMPONENT dev )

# Legacy symlink - not packaged (CPack is bugged until ~3.18, see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4637)
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION hsa/include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
Expand All @@ -318,11 +316,10 @@ endif ()

## Configure and install package config file
# Record our usage data for clients find_package calls.
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
install ( EXPORT ${CORE_RUNTIME_NAME}Targets
FILE ${CORE_RUNTIME_NAME}Targets.cmake
NAMESPACE ${CORE_RUNTIME_NAME}::
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
COMPONENT dev)

# Adds the target alias hsa-runtime64::hsa-runtime64 to the local cmake cache.
Expand All @@ -336,28 +333,26 @@ add_library( ${CORE_RUNTIME_NAME}::${CORE_RUNTIME_NAME} ALIAS ${CORE_RUNTIME_NAM
# Create cmake configuration files
include(CMakePackageConfigHelpers)

# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
configure_package_config_file(${CORE_RUNTIME_NAME}-config.cmake.in
${CORE_RUNTIME_NAME}-config.cmake
INSTALL_DESTINATION lib/cmake/${CORE_RUNTIME_NAME} )
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME} )

write_basic_package_version_file(${CORE_RUNTIME_NAME}-config-version.cmake
VERSION ${SO_VERSION_STRING} COMPATIBILITY AnyNewerVersion )

# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_NAME}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_NAME}-config-version.cmake
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
COMPONENT dev)

# Install build files needed only when using a static build.
if( NOT ${BUILD_SHARED_LIBS} )
# libelf find package module
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindLibElf.cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/COPYING-CMAKE-SCRIPTS
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
COMPONENT dev)
# Linker script (defines function aliases)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LNKSCR}
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
COMPONENT dev)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/DEBIAN/Binary/prerm.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rm_ldconfig() {
}

case "$1" in
( remove )
( remove | upgrade)
rm_ldconfig
;;
( * )
Expand Down
3 changes: 2 additions & 1 deletion src/RPM/Binary/postun.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
################################################################################

# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build
if [ $1 -eq 0 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
rm -f /etc/ld.so.conf.d/hsa-rocr.conf
ldconfig
fi
6 changes: 3 additions & 3 deletions src/core/inc/amd_loader_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
namespace rocr {
namespace amd {

class LoaderContext final: public amd::hsa::loader::Context {
public:
LoaderContext(): amd::hsa::loader::Context() {}
class LoaderContext final : public rocr::amd::hsa::loader::Context {
public:
LoaderContext() : rocr::amd::hsa::loader::Context() {}

~LoaderContext() {}

Expand Down
17 changes: 16 additions & 1 deletion src/core/runtime/amd_aql_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,17 @@ bool AqlQueue::DynamicScratchHandler(hsa_signal_value_t error_code, void* arg) {
const uint64_t rounds = groups / cu_count;
const uint64_t asymmetricGroups = rounds * asymmetryPerRound;
const uint64_t symmetricGroups = groups - asymmetricGroups;
const uint64_t maxGroupsPerEngine =
uint64_t maxGroupsPerEngine =
((symmetricGroups + engines - 1) / engines) + (asymmetryPerRound ? rounds : 0);

// For gfx10+ devices we must attempt to assign the smaller of 256 lanes or 16 groups to each
// engine.
if (queue->agent_->isa()->GetMajorVersion() >= 10 && maxGroupsPerEngine < 16 &&
lanes_per_group * maxGroupsPerEngine < 256) {
uint64_t groups_per_interleave = (256 + lanes_per_group - 1) / lanes_per_group;
maxGroupsPerEngine = Min(groups_per_interleave, 16ul);
}

// Populate all engines at max group occupancy, then clip down to device limits.
groups = maxGroupsPerEngine * engines;
scratch.wanted_slots = groups * waves_per_group;
Expand Down Expand Up @@ -1042,6 +1050,13 @@ bool AqlQueue::ExceptionHandler(hsa_signal_value_t error_code, void* arg) {
// Undefined or unexpected code
assert((errorCode != HSA_STATUS_ERROR) && "Undefined or unexpected queue error code");

// Suppress VM fault reporting. This is more useful when reported through the system error
// handler.
if (errorCode == HSA_STATUS_ERROR_MEMORY_FAULT) {
debug_print("Queue error - HSA_STATUS_ERROR_MEMORY_FAULT\n");
return false;
}

queue->Suspend();
if (queue->errors_callback_ != nullptr) {
queue->errors_callback_(errorCode, queue->public_handle(), queue->errors_data_);
Expand Down
1 change: 1 addition & 0 deletions src/core/runtime/amd_gpu_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_SVM_DIRECT_HOST_ACCESS:
assert(regions_.size() != 0 && "No device local memory found!");
*((bool*)value) = properties_.Capability.ui32.CoherentHostAccess == 1;
break;
case HSA_AMD_AGENT_INFO_COOPERATIVE_COMPUTE_UNIT_COUNT:
if (core::Runtime::runtime_singleton_->flag().coop_cu_count() &&
(isa_->GetMajorVersion() == 9) && (isa_->GetMinorVersion() == 0) &&
Expand Down
Loading

0 comments on commit dbc2f40

Please sign in to comment.