Skip to content

Commit fdd643a

Browse files
authored
Merge pull request #142 from RadeonOpenCompute/rocm-5.2.x
ROCm 5.2.0 updates
2 parents 7f0e08c + dbc2f40 commit fdd643a

File tree

15 files changed

+114
-108
lines changed

15 files changed

+114
-108
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The University of Illinois/NCSA
22
Open Source License (NCSA)
33

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

66
Developed by:
77

src/CMakeLists.txt

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ project( ${CORE_RUNTIME_TARGET} )
5959
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
6060
include ( utils )
6161
include ( hsa_common )
62+
# Set default libdir to be "lib" for ROCm, distros will override this anyway:
63+
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory")
6264
include ( GNUInstallDirs )
6365

6466
## Expose static library option
@@ -117,7 +119,7 @@ endif()
117119
target_include_directories( ${CORE_RUNTIME_TARGET}
118120
PUBLIC
119121
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
120-
$<INSTALL_INTERFACE:include/hsa>
122+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/hsa>
121123
PRIVATE
122124
${CMAKE_CURRENT_SOURCE_DIR}
123125
${CMAKE_CURRENT_SOURCE_DIR}/libamdhsacode )
@@ -191,10 +193,10 @@ set ( SRCS core/util/lnx/os_linux.cpp
191193

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

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

199201
## Optional image module defintions.
200202
if(${IMAGE_SUPPORT})
@@ -203,8 +205,6 @@ if(${IMAGE_SUPPORT})
203205
HSA_IMAGE_SUPPORT
204206
UNIX_OS
205207
LINUX
206-
__AMD64__
207-
__x86_64__
208208
AMD_INTERNAL_BUILD
209209
BRAHMA_BUILD=1 )
210210

@@ -275,7 +275,7 @@ if( NOT ${BUILD_SHARED_LIBS} )
275275

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

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

289289
## Create symlinks for legacy packaging and install
290-
add_custom_target ( hsa_include_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../../include/hsa hsa_include_link )
290+
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 )
291291
if ( ${BUILD_SHARED_LIBS} )
292-
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 )
293-
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} )
292+
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 )
293+
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} )
294294
endif()
295295

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

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

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

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

319317
## Configure and install package config file
320318
# Record our usage data for clients find_package calls.
321-
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
322319
install ( EXPORT ${CORE_RUNTIME_NAME}Targets
323320
FILE ${CORE_RUNTIME_NAME}Targets.cmake
324321
NAMESPACE ${CORE_RUNTIME_NAME}::
325-
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
322+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
326323
COMPONENT dev)
327324

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

339-
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_LIBDIR}
340336
configure_package_config_file(${CORE_RUNTIME_NAME}-config.cmake.in
341337
${CORE_RUNTIME_NAME}-config.cmake
342-
INSTALL_DESTINATION lib/cmake/${CORE_RUNTIME_NAME} )
338+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME} )
343339

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

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

352347
# Install build files needed only when using a static build.
353348
if( NOT ${BUILD_SHARED_LIBS} )
354349
# libelf find package module
355350
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindLibElf.cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/COPYING-CMAKE-SCRIPTS
356-
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
351+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
357352
COMPONENT dev)
358353
# Linker script (defines function aliases)
359354
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LNKSCR}
360-
DESTINATION lib/cmake/${CORE_RUNTIME_NAME}
355+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_RUNTIME_NAME}
361356
COMPONENT dev)
362357
endif()
363358

src/DEBIAN/Binary/prerm.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ rm_ldconfig() {
5353
}
5454

5555
case "$1" in
56-
( remove )
56+
( remove | upgrade)
5757
rm_ldconfig
5858
;;
5959
( * )

src/RPM/Binary/postun.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
################################################################################
4242

4343
# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build
44-
if [ $1 -eq 0 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
44+
if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
45+
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
4546
rm -f /etc/ld.so.conf.d/hsa-rocr.conf
4647
ldconfig
4748
fi

src/core/inc/amd_loader_context.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
namespace rocr {
4949
namespace amd {
5050

51-
class LoaderContext final: public amd::hsa::loader::Context {
52-
public:
53-
LoaderContext(): amd::hsa::loader::Context() {}
51+
class LoaderContext final : public rocr::amd::hsa::loader::Context {
52+
public:
53+
LoaderContext() : rocr::amd::hsa::loader::Context() {}
5454

5555
~LoaderContext() {}
5656

src/core/runtime/amd_aql_queue.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,9 +866,17 @@ bool AqlQueue::DynamicScratchHandler(hsa_signal_value_t error_code, void* arg) {
866866
const uint64_t rounds = groups / cu_count;
867867
const uint64_t asymmetricGroups = rounds * asymmetryPerRound;
868868
const uint64_t symmetricGroups = groups - asymmetricGroups;
869-
const uint64_t maxGroupsPerEngine =
869+
uint64_t maxGroupsPerEngine =
870870
((symmetricGroups + engines - 1) / engines) + (asymmetryPerRound ? rounds : 0);
871871

872+
// For gfx10+ devices we must attempt to assign the smaller of 256 lanes or 16 groups to each
873+
// engine.
874+
if (queue->agent_->isa()->GetMajorVersion() >= 10 && maxGroupsPerEngine < 16 &&
875+
lanes_per_group * maxGroupsPerEngine < 256) {
876+
uint64_t groups_per_interleave = (256 + lanes_per_group - 1) / lanes_per_group;
877+
maxGroupsPerEngine = Min(groups_per_interleave, 16ul);
878+
}
879+
872880
// Populate all engines at max group occupancy, then clip down to device limits.
873881
groups = maxGroupsPerEngine * engines;
874882
scratch.wanted_slots = groups * waves_per_group;
@@ -1042,6 +1050,13 @@ bool AqlQueue::ExceptionHandler(hsa_signal_value_t error_code, void* arg) {
10421050
// Undefined or unexpected code
10431051
assert((errorCode != HSA_STATUS_ERROR) && "Undefined or unexpected queue error code");
10441052

1053+
// Suppress VM fault reporting. This is more useful when reported through the system error
1054+
// handler.
1055+
if (errorCode == HSA_STATUS_ERROR_MEMORY_FAULT) {
1056+
debug_print("Queue error - HSA_STATUS_ERROR_MEMORY_FAULT\n");
1057+
return false;
1058+
}
1059+
10451060
queue->Suspend();
10461061
if (queue->errors_callback_ != nullptr) {
10471062
queue->errors_callback_(errorCode, queue->public_handle(), queue->errors_data_);

src/core/runtime/amd_gpu_agent.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
10151015
case HSA_AMD_AGENT_INFO_SVM_DIRECT_HOST_ACCESS:
10161016
assert(regions_.size() != 0 && "No device local memory found!");
10171017
*((bool*)value) = properties_.Capability.ui32.CoherentHostAccess == 1;
1018+
break;
10181019
case HSA_AMD_AGENT_INFO_COOPERATIVE_COMPUTE_UNIT_COUNT:
10191020
if (core::Runtime::runtime_singleton_->flag().coop_cu_count() &&
10201021
(isa_->GetMajorVersion() == 9) && (isa_->GetMinorVersion() == 0) &&

0 commit comments

Comments
 (0)