From 64a711e3d0cbfba263bde4d4bfe672bfdfa895e5 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 09:11:47 -0500 Subject: [PATCH 01/35] Minor CMakeLists.txt cleanup: - Drop minimum cmake version required to 3.13.4 (this matches to other compiler projects) - Drop hipconfig.bin project - Introduce several variables so it is easier to track them - Cosmetic clean up --- amd/hipcc/CMakeLists.txt | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index c21f2472f623a2..017d56287a4e83 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -1,22 +1,36 @@ -cmake_minimum_required(VERSION 3.16.3) -project (hipcc.bin) +cmake_minimum_required(VERSION 3.13.4) + +project(hipcc VERSION "1.0.0" LANGUAGES C CXX) +set(hipcc_NAME "${PROJECT_NAME}") -# Specify the C++ standard set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) -set (LINK_LIBS libstdc++fs.so) -add_executable(hipcc.bin src/hipBin.cpp) -if (NOT WIN32) # C++17 does not require the std lib linking - target_link_libraries(hipcc.bin ${LINK_LIBS} ) # for hipcc.bin -endif() - -project (hipconfig.bin) -add_executable(hipconfig.bin src/hipBin.cpp) -if (NOT WIN32) # C++17 does not require the std lib linking - target_link_libraries(hipconfig.bin ${LINK_LIBS} ) # for hipconfig.bin -endif() +set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK + libstdc++fs.so) set(HIP_VERSION_MAJOR 4 PARENT_SCOPE) set(HIP_VERSION_MINOR 4 PARENT_SCOPE) set(HIP_VERSION_PATCH 4 PARENT_SCOPE) + +set(HIPCC_BIN + hipcc.bin) +set(HIPCC_SOURCES + src/hipBin.cpp) + +set(HIPCONFIG_BIN + hipconfig.bin) +set(HIPCONFIG_SOURCES + src/hipBin.cpp) + +add_executable(${HIPCC_BIN} ${HIPCC_SOURCES}) +if(NOT WIN32) + # C++17 does not require std lib linking. + target_link_libraries(${HIPCC_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK}) +endif() + +add_executable(${HIPCONFIG_BIN} ${HIPCONFIG_SOURCES}) +if(NOT WIN32) + # C++17 does not require std lib linking. + target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK}) +endif() From 51c74daffbf72a2a90206a3d6ccb8ef7099b7cae Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 09:19:49 -0500 Subject: [PATCH 02/35] Add .gitignore - Ignore merge files created by git - Ignore reject files created by patch - Ignore nested build directory --- amd/hipcc/.gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 amd/hipcc/.gitignore diff --git a/amd/hipcc/.gitignore b/amd/hipcc/.gitignore new file mode 100644 index 00000000000000..17f1f1fd43525d --- /dev/null +++ b/amd/hipcc/.gitignore @@ -0,0 +1,7 @@ +# Merge files created by git. +*.orig +# Reject files created by patch. +*.rej + +# Nested build directory. +/build* From 69dc2e6a25e6728eea04723aff4dbd62204c21ad Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 12:14:35 -0500 Subject: [PATCH 03/35] Add basic packaging --- amd/hipcc/CMakeLists.txt | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 017d56287a4e83..9272b923b90e58 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -3,6 +3,15 @@ cmake_minimum_required(VERSION 3.13.4) project(hipcc VERSION "1.0.0" LANGUAGES C CXX) set(hipcc_NAME "${PROJECT_NAME}") +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +find_package(ROCM) +if(ROCM_FOUND) + include(ROCMSetupVersion) + rocm_setup_version(VERSION "${hipcc_VERSION}") +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -34,3 +43,59 @@ if(NOT WIN32) # C++17 does not require std lib linking. target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK}) endif() + +set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators") +set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support ") +set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver") +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") +set(CPACK_PACKAGE_VERSION_MAJOR "${hipcc_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${hipcc_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${hipcc_VERSION_PATCH}") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") + +# Debian-specific packaging variables. +set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC") +if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) + set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) +else() + set(CPACK_DEBIAN_PACKAGE_RELEASE "local") +endif() + +# RPM-specific packaging variables. +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_PACKAGE_LICENSE "NCSA") +if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) + set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) +else() + set(CPACK_RPM_PACKAGE_RELEASE "local") +endif() +if(CPACK_RPM_PACKAGE_RELEASE) + set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) +endif() + +# ROCM versioning. +set(ROCM_VERSION_FOR_PACKAGE "") +if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) + set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION}) +elseif(DEFINED ENV{ROCM_VERSION}) + string(REGEX REPLACE "." "" ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_VERSION}) +else() + set(ROCM_VERSION_FOR_PACKAGE "99999") +endif() +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") + +install(FILES + "LICENSE.txt" + "README.md" + COMPONENT ${hipcc_NAME} + DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(TARGETS ${HIPCC_BIN} + COMPONENT ${hipcc_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS ${HIPCONFIG_BIN} + COMPONENT ${hipcc_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +include(CPack) From 3e7e027e10b5c510bda5d26d5b4cb7d32aa7e632 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 12:19:19 -0500 Subject: [PATCH 04/35] Wrap HIP_VERSION_{MAJOR, MINOR, PATCH} in HAS_PARENT_SCOPE --- amd/hipcc/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 9272b923b90e58..94776b8df11b0d 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -18,9 +18,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK libstdc++fs.so) -set(HIP_VERSION_MAJOR 4 PARENT_SCOPE) -set(HIP_VERSION_MINOR 4 PARENT_SCOPE) -set(HIP_VERSION_PATCH 4 PARENT_SCOPE) +get_directory_property(HAS_PARENT_SCOPE PARENT_DIRECTORY) +if(HAS_PARENT_SCOPE) + # FIXME(kzhuravl): Do we need these here? If yes, what is the default? + set(HIP_VERSION_MAJOR 4 PARENT_SCOPE) + set(HIP_VERSION_MINOR 4 PARENT_SCOPE) + set(HIP_VERSION_PATCH 4 PARENT_SCOPE) +else() + message(STATUS "Current scope has no parent") +endif() set(HIPCC_BIN hipcc.bin) From 6f5f4a84eb5fb1b4986a97e44af0e2792eeb5e41 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 12:21:37 -0500 Subject: [PATCH 05/35] Fix regex escape sequence --- amd/hipcc/src/hipBin_amd.h | 2 +- amd/hipcc/src/hipBin_nvidia.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index 6c906aa041c816..4e1aad7bedf4e9 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -726,7 +726,7 @@ void HipBinAmd::executeHipCCCmd(vector argv) { // Important to have all of '-Xlinker' in the set of unquoted characters. // Windows needs different quoting, ignore for now if (os != windows && escapeArg) { - regex reg("[^-a-zA-Z0-9_=+,.\/]"); + regex reg("[^-a-zA-Z0-9_=+,.\\/]"); arg = regex_replace(arg, reg, "\\$&"); } if (!swallowArg) diff --git a/amd/hipcc/src/hipBin_nvidia.h b/amd/hipcc/src/hipBin_nvidia.h index d9a7b38a1aaf73..d68a034cce56bf 100644 --- a/amd/hipcc/src/hipBin_nvidia.h +++ b/amd/hipcc/src/hipBin_nvidia.h @@ -538,7 +538,7 @@ void HipBinNvidia::executeHipCCCmd(vector argv) { } // Windows needs different quoting, ignore for now if (os != windows && escapeArg) { - regex reg("[^-a-zA-Z0-9_=+,.\/]"); + regex reg("[^-a-zA-Z0-9_=+,.\\/]"); arg = regex_replace(arg, reg, "\\$&"); } if (!swallowArg) From 0f2f8edc7f920acf4331f456cf959cf2c9514a9a Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 12:27:54 -0500 Subject: [PATCH 06/35] mktemp -> mkdtemp --- amd/hipcc/src/hipBin_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/src/hipBin_util.h b/amd/hipcc/src/hipBin_util.h index e7d607989aa0f1..6bc8a250c1cc36 100644 --- a/amd/hipcc/src/hipBin_util.h +++ b/amd/hipcc/src/hipBin_util.h @@ -187,7 +187,7 @@ string HipBinUtil::mktempFile(string name) { #if defined(_WIN32) || defined(_WIN64) fileName = _mktemp(&name[0]); #else - fileName = mktemp(&name[0]); + fileName = mkdtemp(&name[0]); #endif tmpFiles_.push_back(fileName); return fileName; From d2c6fc3d4e30a01902b7fdf301084f8be7c424fe Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 24 Jan 2023 12:37:50 -0500 Subject: [PATCH 07/35] Move and package hipcc and hipconfig scripts from HIPAMD to HIPCC --- amd/hipcc/CMakeLists.txt | 3 + amd/hipcc/bin/hipcc | 74 +++++ amd/hipcc/bin/hipcc.bat | 2 + amd/hipcc/bin/hipcc.pl | 645 ++++++++++++++++++++++++++++++++++++ amd/hipcc/bin/hipconfig | 66 ++++ amd/hipcc/bin/hipconfig.bat | 2 + amd/hipcc/bin/hipconfig.pl | 241 ++++++++++++++ 7 files changed, 1033 insertions(+) create mode 100755 amd/hipcc/bin/hipcc create mode 100755 amd/hipcc/bin/hipcc.bat create mode 100755 amd/hipcc/bin/hipcc.pl create mode 100755 amd/hipcc/bin/hipconfig create mode 100755 amd/hipcc/bin/hipconfig.bat create mode 100755 amd/hipcc/bin/hipconfig.pl diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 94776b8df11b0d..058673baf0834d 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -92,6 +92,9 @@ else() endif() set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin + DESTINATION . + USE_SOURCE_PERMISSIONS) install(FILES "LICENSE.txt" "README.md" diff --git a/amd/hipcc/bin/hipcc b/amd/hipcc/bin/hipcc new file mode 100755 index 00000000000000..dfb5a8f6b82410 --- /dev/null +++ b/amd/hipcc/bin/hipcc @@ -0,0 +1,74 @@ +#!/usr/bin/env perl +# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Need perl > 5.10 to use logic-defined or +use 5.006; use v5.10.1; + +use warnings; + +use File::Basename; +use File::Spec::Functions 'catfile'; + +# TODO: By default select perl script until change incorporated in HIP build script. +my $USE_PERL_SCRIPT = $ENV{'HIP_USE_PERL_SCRIPTS'}; +$USE_PERL_SCRIPT //= 1; # use defined-or assignment operator. Use env var, but if not defined default to 1. + +my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); +# escapes args with quotes SWDEV-341955 +foreach $arg (@ARGV) { + if ($isWindows) { + $arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\ ]/\\$&/g; + } +} + +my $SCRIPT_DIR=dirname(__FILE__); +if ($USE_PERL_SCRIPT) { + #Invoke hipcc.pl + my $HIPCC_PERL=catfile($SCRIPT_DIR, '/hipcc.pl'); + system($^X, $HIPCC_PERL, @ARGV); +} else { + $BIN_NAME="/hipcc.bin"; + if ($isWindows) { + $BIN_NAME="/hipcc.bin.exe"; + } + my $HIPCC_BIN=catfile($SCRIPT_DIR, $BIN_NAME); + if ( -e $HIPCC_BIN ) { + #Invoke hipcc.bin + system($HIPCC_BIN, @ARGV); + } else { + print "hipcc.bin not present; Install HIPCC binaries before proceeding"; + exit(-1); + } +} + +# Because of this wrapper we need to check +# the output of the system command for perl and bin +# else the failures are ignored and build fails silently +if ($? == -1) { + exit($?); +} +elsif ($? & 127) { + exit($?); +} +else { + $CMD_EXIT_CODE = $? >> 8; +} +exit($CMD_EXIT_CODE); diff --git a/amd/hipcc/bin/hipcc.bat b/amd/hipcc/bin/hipcc.bat new file mode 100755 index 00000000000000..beb67966cd5e24 --- /dev/null +++ b/amd/hipcc/bin/hipcc.bat @@ -0,0 +1,2 @@ +@set HIPCC="%~dp0hipcc" +@perl %HIPCC% %* diff --git a/amd/hipcc/bin/hipcc.pl b/amd/hipcc/bin/hipcc.pl new file mode 100755 index 00000000000000..6898cd0bba2996 --- /dev/null +++ b/amd/hipcc/bin/hipcc.pl @@ -0,0 +1,645 @@ +#!/usr/bin/env perl +# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Need perl > 5.10 to use logic-defined or +use 5.006; use v5.10.1; +use warnings; +use File::Basename; +use File::Temp qw/ :mktemp /; +use Cwd; +use Cwd 'abs_path'; + +# HIP compiler driver +# Will call clang or nvcc (depending on target) and pass the appropriate include and library options for +# the target compiler and HIP infrastructure. + +# Will pass-through options to the target compiler. The tools calling HIPCC must ensure the compiler +# options are appropriate for the target compiler. + +# Environment variable HIP_PLATFORM is to detect amd/nvidia path: +# HIP_PLATFORM='nvidia' or HIP_PLATFORM='amd'. +# If HIP_PLATFORM is not set hipcc will attempt auto-detect based on if nvcc is found. +# +# Other environment variable controls: +# HIP_PATH : Path to HIP directory, default is one dir level above location of this script. +# CUDA_PATH : Path to CUDA SDK (default /usr/local/cuda). Used on NVIDIA platforms only. +# HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only. +# HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to this +# script's abs_path). Used on AMD platforms only. + +if(scalar @ARGV == 0){ + print "No Arguments passed, exiting ...\n"; + exit(-1); +} + +# retrieve --rocm-path hipcc option from command line. +# We need to respect this over the env var ROCM_PATH for this compilation. +sub get_rocm_path_option { + my $rocm_path=""; + my @CLArgs = @ARGV; + foreach $arg (@CLArgs) { + if (index($arg,"--rocm-path=") != -1) { + ($rocm_path) = $arg=~ /=\s*(.*)\s*$/; + } + } + return $rocm_path; +} + +$verbose = $ENV{'HIPCC_VERBOSE'} // 0; +# Verbose: 0x1=commands, 0x2=paths, 0x4=hipcc args + +$HIPCC_COMPILE_FLAGS_APPEND=$ENV{'HIPCC_COMPILE_FLAGS_APPEND'}; +$HIPCC_LINK_FLAGS_APPEND=$ENV{'HIPCC_LINK_FLAGS_APPEND'}; + +# Known Features +@knownFeatures = ('sramecc-', 'sramecc+', 'xnack-', 'xnack+'); + +$HIP_LIB_PATH=$ENV{'HIP_LIB_PATH'}; +$DEVICE_LIB_PATH=$ENV{'DEVICE_LIB_PATH'}; +$HIP_CLANG_HCC_COMPAT_MODE=$ENV{'HIP_CLANG_HCC_COMPAT_MODE'}; # HCC compatibility mode +$HIP_COMPILE_CXX_AS_HIP=$ENV{'HIP_COMPILE_CXX_AS_HIP'} // "1"; + +#--- +# Temporary directories +my @tmpDirs = (); + +#--- +# Create a new temporary directory and return it +sub get_temp_dir { + my $tmpdir = mkdtemp("/tmp/hipccXXXXXXXX"); + push (@tmpDirs, $tmpdir); + return $tmpdir; +} + +#--- +# Delete all created temporary directories +sub delete_temp_dirs { + if (@tmpDirs) { + system ('rm -rf ' . join (' ', @tmpDirs)); + } + return 0; +} + +my $base_dir; +my $rocmPath; +BEGIN { + $base_dir = dirname(Cwd::realpath(__FILE__) ); + $rocmPath = get_rocm_path_option(); + if ($rocmPath ne '') { + # --rocm-path takes precedence over ENV{ROCM_PATH} + $ENV{ROCM_PATH}=$rocmPath; + } +} +use lib "$base_dir/"; + +use hipvars; +$isWindows = $hipvars::isWindows; +$HIP_RUNTIME = $hipvars::HIP_RUNTIME; +$HIP_PLATFORM = $hipvars::HIP_PLATFORM; +$HIP_COMPILER = $hipvars::HIP_COMPILER; +$HIP_CLANG_PATH = $hipvars::HIP_CLANG_PATH; +$CUDA_PATH = $hipvars::CUDA_PATH; +$HIP_PATH = $hipvars::HIP_PATH; +$ROCM_PATH = $hipvars::ROCM_PATH; +$HIP_VERSION = $hipvars::HIP_VERSION; +$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME; + +if ($HIP_PLATFORM eq "amd") { + # If using ROCclr runtime, need to find HIP_ROCCLR_HOME + if (!defined $DEVICE_LIB_PATH and -e "$HIP_ROCCLR_HOME/lib/bitcode") { + $DEVICE_LIB_PATH = "$HIP_ROCCLR_HOME/lib/bitcode"; + } + $HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include"; + if (!defined $HIP_LIB_PATH) { + $HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib"; + } + + if (!defined $DEVICE_LIB_PATH) { + if (-e "$ROCM_PATH/amdgcn/bitcode") { + $DEVICE_LIB_PATH = "$ROCM_PATH/amdgcn/bitcode"; + } + else { + # This path is to support an older build of the device library + # TODO: To be removed in the future. + $DEVICE_LIB_PATH = "$ROCM_PATH/lib"; + } + } +} + +if ($verbose & 0x2) { + print ("HIP_PATH=$HIP_PATH\n"); + print ("HIP_PLATFORM=$HIP_PLATFORM\n"); + print ("HIP_COMPILER=$HIP_COMPILER\n"); + print ("HIP_RUNTIME=$HIP_RUNTIME\n"); +} + +# set if user explicitly requests -stdlib=libc++. (else we default to libstdc++ for better interop with g++): +$setStdLib = 0; # TODO - set to 0 + +$default_amdgpu_target = 1; + +if ($HIP_PLATFORM eq "amd") { + $execExtension = ""; + if($isWindows) { + $execExtension = ".exe"; + } + $HIPCC="$HIP_CLANG_PATH/clang++" . $execExtension; + + # If $HIPCC clang++ is not compiled, use clang instead + if ( ! -e $HIPCC ) { + $HIPCC="$HIP_CLANG_PATH/clang" . $execExtension; + $HIPLDFLAGS = "--driver-mode=g++"; + } + # to avoid using dk linker or MSVC linker + if($isWindows) { + $HIPLDFLAGS .= " -fuse-ld=lld"; + $HIPLDFLAGS .= " --ld-path=$HIP_CLANG_PATH/lld-link.exe"; + + # escape possible spaces in path name + $HIPCC =~ s/\s/\\$&/g; + } + + # get Clang RT Builtin path + $HIP_CLANG_RT_LIB = `$HIPCC --print-runtime-dir`; + chomp($HIP_CLANG_RT_LIB); + + if (! defined $HIP_INCLUDE_PATH) { + $HIP_INCLUDE_PATH = "$HIP_PATH/include"; + } + if (! defined $HIP_LIB_PATH) { + $HIP_LIB_PATH = "$HIP_PATH/lib"; + } + if ($verbose & 0x2) { + print ("ROCM_PATH=$ROCM_PATH\n"); + if (defined $HIP_ROCCLR_HOME) { + print ("HIP_ROCCLR_HOME=$HIP_ROCCLR_HOME\n"); + } + print ("HIP_CLANG_PATH=$HIP_CLANG_PATH\n"); + print ("HIP_INCLUDE_PATH=$HIP_INCLUDE_PATH\n"); + print ("HIP_LIB_PATH=$HIP_LIB_PATH\n"); + print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n"); + print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n"); + } + + if ($HIP_CLANG_HCC_COMPAT_MODE) { + ## Allow __fp16 as function parameter and return type. + $HIPCXXFLAGS .= " -Xclang -fallow-half-arguments-and-returns -D__HIP_HCC_COMPAT_MODE__=1"; + } +} elsif ($HIP_PLATFORM eq "nvidia") { + $CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda'; + $HIP_INCLUDE_PATH = "$HIP_PATH/include"; + if ($verbose & 0x2) { + print ("CUDA_PATH=$CUDA_PATH\n"); + } + + $HIPCC="$CUDA_PATH/bin/nvcc"; + $HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets "; + $HIPCXXFLAGS .= " -isystem $CUDA_PATH/include"; + $HIPCFLAGS .= " -isystem $CUDA_PATH/include"; + + $HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L$CUDA_PATH/lib64"; +} else { + printf ("error: unknown HIP_PLATFORM = '$HIP_PLATFORM'"); + printf (" or HIP_COMPILER = '$HIP_COMPILER'"); + exit (-1); +} + +# Add paths to common HIP includes: +$HIPCXXFLAGS .= " -isystem \"$HIP_INCLUDE_PATH\"" ; +$HIPCFLAGS .= " -isystem \"$HIP_INCLUDE_PATH\"" ; + +my $compileOnly = 0; +my $needCXXFLAGS = 0; # need to add CXX flags to compile step +my $needCFLAGS = 0; # need to add C flags to compile step +my $needLDFLAGS = 1; # need to add LDFLAGS to compile step. +my $fileTypeFlag = 0; # to see if -x flag is mentioned +my $hasOMPTargets = 0; # If OMP targets is mentioned +my $hasC = 0; # options contain a c-style file +my $hasCXX = 0; # options contain a cpp-style file (NVCC must force recognition as GPU file) +my $hasCU = 0; # options contain a cu-style file (HCC must force recognition as GPU file) +my $hasHIP = 0; # options contain a hip-style file (HIP-Clang must pass offloading options) +my $printHipVersion = 0; # print HIP version +my $printCXXFlags = 0; # print HIPCXXFLAGS +my $printLDFlags = 0; # print HIPLDFLAGS +my $runCmd = 1; +my $buildDeps = 0; +my $hsacoVersion = 0; +my $funcSupp = 0; # enable function support +my $rdc = 0; # whether -fgpu-rdc is on + +my @options = (); +my @inputs = (); + +if ($verbose & 0x4) { + print "hipcc-args: ", join (" ", @ARGV), "\n"; +} + +# Handle code object generation +my $ISACMD=""; +if($HIP_PLATFORM eq "nvidia"){ + $ISACMD .= "$HIP_PATH/bin/hipcc -ptx "; + if($ARGV[0] eq "--genco"){ + foreach $isaarg (@ARGV[1..$#ARGV]){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + if ($verbose & 0x1) { + print "hipcc-cmd: ", $ISACMD, "\n"; + } + system($ISACMD) and die(); + exit(0); + } +} + +# TODO: convert toolArgs to an array rather than a string +my $toolArgs = ""; # arguments to pass to the clang or nvcc tool +my $optArg = ""; # -O args + +# TODO: hipcc uses --amdgpu-target for historical reasons. It should be replaced +# by clang option --offload-arch. +my @targetOpts = ('--offload-arch=', '--amdgpu-target='); + +my $targetsStr = ""; +my $skipOutputFile = 0; # file followed by -o should not contibute in picking compiler flags +my $prevArg = ""; # previous argument + +foreach $arg (@ARGV) +{ + # Save $arg, it can get changed in the loop. + $trimarg = $arg; + # TODO: figure out why this space removal is wanted. + # TODO: If someone has gone to the effort of quoting the spaces to the shell + # TODO: why are we removing it here? + $trimarg =~ s/^\s+|\s+$//g; # Remive whitespace + my $swallowArg = 0; + my $escapeArg = 1; + if ($arg eq '-c' or $arg eq '--genco' or $arg eq '-E') { + $compileOnly = 1; + $needLDFLAGS = 0; + } + + if ($skipOutputFile) { + # TODO: handle filename with shell metacharacters + $toolArgs .= " \"$arg\""; + $prevArg = $arg; + $skipOutputFile = 0; + next; + } + + if ($arg eq '-o') { + $needLDFLAGS = 1; + $skipOutputFile = 1; + } + + if(($trimarg eq '-stdlib=libc++') and ($setStdLib eq 0)) + { + $HIPCXXFLAGS .= " -stdlib=libc++"; + $setStdLib = 1; + } + + # Check target selection option: --offload-arch= and --amdgpu-target=... + foreach my $targetOpt (@targetOpts) { + if (substr($arg, 0, length($targetOpt)) eq $targetOpt) { + if ($targetOpt eq '--amdgpu-target=') { + print "Warning: The --amdgpu-target option has been deprecated and will be removed in the future. Use --offload-arch instead.\n"; + } + # If targets string is not empty, add a comma before adding new target option value. + $targetsStr .= ($targetsStr ? ',' : ''); + $targetsStr .= substr($arg, length($targetOpt)); + $default_amdgpu_target = 0; + # Collect the GPU arch options and pass them to clang later. + if ($HIP_PLATFORM eq "amd") { + $swallowArg = 1; + } + } + } + + if (($arg =~ /--genco/) and $HIP_PLATFORM eq 'amd' ) { + $arg = "--cuda-device-only"; + } + + if($trimarg eq '--version') { + $printHipVersion = 1; + } + if($trimarg eq '--short-version') { + $printHipVersion = 1; + $runCmd = 0; + } + if($trimarg eq '--cxxflags') { + $printCXXFlags = 1; + $runCmd = 0; + } + if($trimarg eq '--ldflags') { + $printLDFlags = 1; + $runCmd = 0; + } + if($trimarg eq '-M') { + $compileOnly = 1; + $buildDeps = 1; + } + if($trimarg eq '-use-staticlib') { + print "Warning: The -use-staticlib option has been deprecated and is no longer needed.\n" + } + if($trimarg eq '-use-sharedlib') { + print "Warning: The -use-sharedlib option has been deprecated and is no longer needed.\n" + } + if($arg =~ m/^-O/) + { + $optArg = $arg; + } + if($arg =~ '--amdhsa-code-object-version=') + { + print "Warning: The --amdhsa-code-object-version option has been deprecated and will be removed in the future. Use -mllvm -mcode-object-version instead.\n"; + $arg =~ s/--amdhsa-code-object-version=//; + $hsacoVersion = $arg; + $swallowArg = 1; + } + + # nvcc does not handle standard compiler options properly + # This can prevent hipcc being used as standard CXX/C Compiler + # To fix this we need to pass -Xcompiler for options + if (($arg eq '-fPIC' or $arg =~ '-Wl,') and $HIP_COMPILER eq 'nvcc') + { + $HIPCXXFLAGS .= " -Xcompiler ".$arg; + $swallowArg = 1; + } + + if ($arg eq '-x') { + $fileTypeFlag = 1; + } elsif (($arg eq 'c' and $prevArg eq '-x') or ($arg eq '-xc')) { + $fileTypeFlag = 1; + $hasC = 1; + $hasCXX = 0; + $hasHIP = 0; + } elsif (($arg eq 'c++' and $prevArg eq '-x') or ($arg eq '-xc++')) { + $fileTypeFlag = 1; + $hasC = 0; + $hasCXX = 1; + $hasHIP = 0; + } elsif (($arg eq 'hip' and $prevArg eq '-x') or ($arg eq '-xhip')) { + $fileTypeFlag = 1; + $hasC = 0; + $hasCXX = 0; + $hasHIP = 1; + } elsif ($arg =~ '-fopenmp-targets=') { + $hasOMPTargets = 1; + } elsif ($arg =~ m/^-/) { + # options start with - + if ($arg eq '-fgpu-rdc') { + $rdc = 1; + } elsif ($arg eq '-fno-gpu-rdc') { + $rdc = 0; + } + + # Process HIPCC options here: + if ($arg =~ m/^--hipcc/) { + $swallowArg = 1; + if ($arg eq "--hipcc-func-supp") { + print "Warning: The --hipcc-func-supp option has been deprecated and will be removed in the future.\n"; + $funcSupp = 1; + } elsif ($arg eq "--hipcc-no-func-supp") { + print "Warning: The --hipcc-no-func-supp option has been deprecated and will be removed in the future.\n"; + $funcSupp = 0; + } + } else { + push (@options, $arg); + } + #print "O: <$arg>\n"; + } elsif ($prevArg ne '-o') { + # input files and libraries + # Skip guessing if `-x {c|c++|hip}` is already specified. + + # Add proper file extension before each file type + # File Extension -> Flag + # .c -> -x c + # .cpp/.cxx/.cc/.cu/.cuh/.hip -> -x hip + if ($fileTypeFlag eq 0) { + if ($arg =~ /\.c$/) { + $hasC = 1; + $needCFLAGS = 1; + $toolArgs .= " -x c"; + } elsif (($arg =~ /\.cpp$/) or ($arg =~ /\.cxx$/) or ($arg =~ /\.cc$/) or ($arg =~ /\.C$/)) { + $needCXXFLAGS = 1; + if ($HIP_COMPILE_CXX_AS_HIP eq '0' or $HIP_PLATFORM ne "amd" or $hasOMPTargets eq 1) { + $hasCXX = 1; + } elsif ($HIP_PLATFORM eq "amd") { + $hasHIP = 1; + $toolArgs .= " -x hip"; + } + } elsif ((($arg =~ /\.cu$/ or $arg =~ /\.cuh$/) and $HIP_COMPILE_CXX_AS_HIP ne '0') or ($arg =~ /\.hip$/)) { + $needCXXFLAGS = 1; + if ($HIP_PLATFORM eq "amd") { + $hasHIP = 1; + $toolArgs .= " -x hip"; + } else { + $hasCU = 1; + } + } + } + if ($hasC) { + $needCFLAGS = 1; + } elsif ($hasCXX or $hasHIP) { + $needCXXFLAGS = 1; + } + push (@inputs, $arg); + #print "I: <$arg>\n"; + } + # Produce a version of $arg where characters significant to the shell are + # quoted. One could quote everything of course but don't bother for + # common characters such as alphanumerics. + # Do the quoting here because sometimes the $arg is changed in the loop + # Important to have all of '-Xlinker' in the set of unquoted characters. + if (not $isWindows and $escapeArg) { + $arg =~ s/[^-a-zA-Z0-9_=+,.\/]/\\$&/g; + } + if ($isWindows and $escapeArg) { + $arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\]/\\$&/g; + } + $toolArgs .= " $arg" unless $swallowArg; + $prevArg = $arg; +} + +if($HIP_PLATFORM eq "amd"){ + # No AMDGPU target specified at commandline. So look for HCC_AMDGPU_TARGET + if($default_amdgpu_target eq 1) { + if (defined $ENV{HCC_AMDGPU_TARGET}) { + $targetsStr = $ENV{HCC_AMDGPU_TARGET}; + } elsif (not $isWindows) { + # Else try using rocm_agent_enumerator + $ROCM_AGENT_ENUM = "${ROCM_PATH}/bin/rocm_agent_enumerator"; + $targetsStr = `${ROCM_AGENT_ENUM} -t GPU`; + $targetsStr =~ s/\n/,/g; + } + $default_amdgpu_target = 0; + } + + # Parse the targets collected in targetStr and set corresponding compiler options. + my @targets = split(',', $targetsStr); + $GPU_ARCH_OPT = " --offload-arch="; + + foreach my $val (@targets) { + # Ignore 'gfx000' target reported by rocm_agent_enumerator. + if ($val ne 'gfx000') { + my @procAndFeatures = split(':', $val); + $len = scalar @procAndFeatures; + my $procName; + if($len ge 1 and $len le 3) { # proc and features + $procName = $procAndFeatures[0]; + for my $i (1 .. $#procAndFeatures) { + if (grep($procAndFeatures[$i], @knownFeatures) eq 0) { + print "Warning: The Feature: $procAndFeatures[$i] is unknown. Correct compilation is not guaranteed.\n"; + } + } + } else { + $procName = $val; + } + $GPU_ARCH_ARG = $GPU_ARCH_OPT . $val; + $HIPLDARCHFLAGS .= $GPU_ARCH_ARG; + if ($HIP_PLATFORM eq 'amd' and $hasHIP) { + $HIPCXXFLAGS .= $GPU_ARCH_ARG; + } + } + } + if ($hsacoVersion > 0) { + if ($compileOnly eq 0) { + $HIPLDFLAGS .= " -mcode-object-version=$hsacoVersion"; + } else { + $HIPCXXFLAGS .= " -mcode-object-version=$hsacoVersion"; + } + } + + # rocm_agent_enumerator failed! Throw an error and die if linking is required + if ($default_amdgpu_target eq 1 and $compileOnly eq 0) { + print "No valid AMD GPU target was either specified or found. Please specify a valid target using --offload-arch=.\n" and die(); + } + + $ENV{HCC_EXTRA_LIBRARIES}="\n"; +} + +if ($hasCXX and $HIP_PLATFORM eq 'nvidia') { + $HIPCXXFLAGS .= " -x cu"; +} + +if ($buildDeps and $HIP_PLATFORM eq 'nvidia') { + $HIPCXXFLAGS .= " -M -D__CUDACC__"; + $HIPCFLAGS .= " -M -D__CUDACC__"; +} + +if ($buildDeps and $HIP_PLATFORM eq 'amd') { + $HIPCXXFLAGS .= " --cuda-host-only"; +} + +# hipcc currrently requires separate compilation of source files, ie it is not possible to pass +# CPP files combined with .O files +# Reason is that NVCC uses the file extension to determine whether to compile in CUDA mode or +# pass-through CPP mode. + +if ($HIP_PLATFORM eq "amd") { + # Set default optimization level to -O3 for hip-clang. + if ($optArg eq "") { + $HIPCXXFLAGS .= " -O3"; + $HIPCFLAGS .= " -O3"; + $HIPLDFLAGS .= " -O3"; + } + if (!$funcSupp and $optArg ne "-O0" and $hasHIP) { + $HIPCXXFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false"; + if ($needLDFLAGS and not $needCXXFLAGS) { + $HIPLDFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false"; + } + } + + if ($hasHIP) { + if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") { + $HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\""; + } + } + + if (!$compileOnly) { + $HIPLDFLAGS .= " --hip-link"; + if ($rdc) { + $HIPLDFLAGS .= $HIPLDARCHFLAGS; + } + if (not $isWindows) { + $HIPLDFLAGS .= " --rtlib=compiler-rt -unwindlib=libgcc"; + + } + } +} + +if ($HIPCC_COMPILE_FLAGS_APPEND) { + $HIPCXXFLAGS .= " $HIPCC_COMPILE_FLAGS_APPEND"; + $HIPCFLAGS .= " $HIPCC_COMPILE_FLAGS_APPEND"; +} +if ($HIPCC_LINK_FLAGS_APPEND) { + $HIPLDFLAGS .= " $HIPCC_LINK_FLAGS_APPEND"; +} + +# TODO: convert CMD to an array rather than a string +my $CMD="$HIPCC"; + +if ($needCFLAGS) { + $CMD .= " $HIPCFLAGS"; +} + +if ($needCXXFLAGS) { + $CMD .= " $HIPCXXFLAGS"; +} + +if ($needLDFLAGS and not $compileOnly) { + $CMD .= " $HIPLDFLAGS"; +} +$CMD .= " $toolArgs"; + +if ($verbose & 0x1) { + print "hipcc-cmd: ", $CMD, "\n"; +} + +if ($printHipVersion) { + if ($runCmd) { + print "HIP version: " + } + print $HIP_VERSION, "\n"; +} +if ($printCXXFlags) { + print $HIPCXXFLAGS; +} +if ($printLDFlags) { + print $HIPLDFLAGS; +} +if ($runCmd) { + system ("$CMD"); + if ($? == -1) { + print "failed to execute: $!\n"; + exit($?); + } + elsif ($? & 127) { + printf "child died with signal %d, %s coredump\n", + ($? & 127), ($? & 128) ? 'with' : 'without'; + exit($?); + } + else { + $CMD_EXIT_CODE = $? >> 8; + } + $? or delete_temp_dirs (); + exit($CMD_EXIT_CODE); +} + +# vim: ts=4:sw=4:expandtab:smartindent diff --git a/amd/hipcc/bin/hipconfig b/amd/hipcc/bin/hipconfig new file mode 100755 index 00000000000000..d50b10b94a9c82 --- /dev/null +++ b/amd/hipcc/bin/hipconfig @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Need perl > 5.10 to use logic-defined or +use 5.006; use v5.10.1; + +use warnings; + +use File::Basename; +use File::Spec::Functions 'catfile'; + +#TODO: By default select perl script until change incorporated in HIP build script +my $USE_PERL_SCRIPT = $ENV{'HIP_USE_PERL_SCRIPTS'}; +$USE_PERL_SCRIPT //= 1; # use defined-or assignment operator. Use env var, but if not defined default to 1. +my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); +my $SCRIPT_DIR=dirname(__FILE__); +if ($USE_PERL_SCRIPT) { + #Invoke hipconfig.pl + my $HIPCONFIG_PERL=catfile($SCRIPT_DIR, '/hipconfig.pl'); + system($^X, $HIPCONFIG_PERL, @ARGV); +} else { + $BIN_NAME="/hipconfig.bin"; + if ($isWindows) { + $BIN_NAME="/hipconfig.bin.exe"; + } + my $HIPCONFIG_BIN=catfile($SCRIPT_DIR, $BIN_NAME); + if ( -e $HIPCONFIG_BIN ) { + #Invoke hipconfig.bin + system($HIPCONFIG_BIN, @ARGV); + } else { + print "hipconfig.bin not present; Install HIPCC binaries before proceeding"; + exit(-1); + } +} + +# Because of this wrapper we need to check +# the output of the system command for perl and bin +# else the failures are ignored and build fails silently +if ($? == -1) { + exit($?); +} +elsif ($? & 127) { + exit($?); +} +else { + $CMD_EXIT_CODE = $? >> 8; +} +exit($CMD_EXIT_CODE); diff --git a/amd/hipcc/bin/hipconfig.bat b/amd/hipcc/bin/hipconfig.bat new file mode 100755 index 00000000000000..16e68a14b75ddb --- /dev/null +++ b/amd/hipcc/bin/hipconfig.bat @@ -0,0 +1,2 @@ +@set HIPCONFIG="%~dp0hipconfig" +@perl %HIPCONFIG% %* diff --git a/amd/hipcc/bin/hipconfig.pl b/amd/hipcc/bin/hipconfig.pl new file mode 100755 index 00000000000000..dd03ad67a8c548 --- /dev/null +++ b/amd/hipcc/bin/hipconfig.pl @@ -0,0 +1,241 @@ +#!/usr/bin/env perl +# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Need perl > 5.10 to use logic-defined or +use 5.006; use v5.10.1; +use warnings; +use Getopt::Long; +use Cwd; + +# Return name of HIP compiler - either 'clang' or 'nvcc' +# +use Getopt::Long; +use File::Basename; + +my $base_dir; +BEGIN { + $base_dir = dirname( Cwd::realpath(__FILE__) ); +} +use lib "$base_dir/"; +use hipvars; + +$isWindows = $hipvars::isWindows; +$HIP_RUNTIME = $hipvars::HIP_RUNTIME; +$HIP_PLATFORM = $hipvars::HIP_PLATFORM; +$HIP_COMPILER = $hipvars::HIP_COMPILER; +$HIP_CLANG_PATH = $hipvars::HIP_CLANG_PATH; +$CUDA_PATH = $hipvars::CUDA_PATH; +$HIP_PATH = $hipvars::HIP_PATH; +$ROCM_PATH = $hipvars::ROCM_PATH; +$HIP_VERSION = $hipvars::HIP_VERSION; + +Getopt::Long::Configure ( qw{bundling no_ignore_case}); +GetOptions( + "help|h" => \$p_help + ,"path|p" => \$p_path + ,"rocmpath|R" => \$p_rocmpath + ,"compiler|c" => \$p_compiler + ,"platform|P" => \$p_platform + ,"runtime|r" => \$p_runtime + ,"hipclangpath|l" => \$p_hipclangpath + ,"cpp_config|cxx_config|C" => \$p_cpp_config + ,"full|f|info" => \$p_full, + ,"version|v" => \$p_version, + ,"check" => \$p_check, + ,"newline|n" => \$p_newline +); + +if ($HIP_COMPILER eq "clang") { + $HIP_CLANG_VERSION = ""; + if($isWindows) { + $HIP_CLANG_VERSION = `\"$HIP_CLANG_PATH/clang++\" --version`; + } else { + $HIP_CLANG_VERSION = `$HIP_CLANG_PATH/clang++ --version`; + } + $HIP_CLANG_VERSION=~/.*clang version (\S+).*/; + $HIP_CLANG_VERSION=$1; + + $CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__="; + + $HIP_PATH_INCLUDE = $HIP_PATH."/include"; + $HIP_CLANG_INCLUDE = $HIP_CLANG_PATH."/../lib/clang/".$HIP_CLANG_VERSION; + if($isWindows) { + $CPP_CONFIG .= " -I\"$HIP_PATH_INCLUDE\" -I\"$HIP_CLANG_INCLUDE\""; + } else { + $CPP_CONFIG .= " -I$HIP_PATH_INCLUDE -I$HIP_CLANG_INCLUDE "; + } +} +if ($HIP_PLATFORM eq "nvidia") { + $CPP_CONFIG = " -D__HIP_PLATFORM_NVCC__= -D__HIP_PLATFORM_NVIDIA__= -I$HIP_PATH/include -I$CUDA_PATH/include"; +}; + +if ($p_help) { + print "usage: hipconfig [OPTIONS]\n"; + print " --path, -p : print HIP_PATH (use env var if set, else determine from hipconfig path)\n"; + print " --rocmpath, -R : print ROCM_PATH (use env var if set, else determine from hip path or /opt/rocm)\n"; + print " --cpp_config, -C : print C++ compiler options\n"; + print " --compiler, -c : print compiler (clang or nvcc)\n"; + print " --platform, -P : print platform (amd or nvidia)\n"; + print " --runtime, -r : print runtime (rocclr or cuda)\n"; + print " --hipclangpath, -l : print HIP_CLANG_PATH\n"; + print " --full, -f : print full config\n"; + print " --version, -v : print hip version\n"; + print " --check : check configuration\n"; + print " --newline, -n : print newline\n"; + print " --help, -h : print help message\n"; + exit(); +} + +if ($p_path) { + print "$HIP_PATH"; + $printed = 1; +} + +if ($p_rocmpath) { + print "$ROCM_PATH"; + $printed = 1; +} + +if ($p_cpp_config) { + print $CPP_CONFIG; + $printed = 1; +} + +if ($p_compiler) { + print $HIP_COMPILER; + $printed = 1; +} + +if ($p_platform) { + print $HIP_PLATFORM; + $printed = 1; +} + +if ($p_runtime) { + print $HIP_RUNTIME; + $printed = 1; +} + +if ($p_hipclangpath) { + if (defined $HIP_CLANG_PATH) { + print $HIP_CLANG_PATH; + } + $printed = 1; +} + +if ($p_version) { + print $HIP_VERSION; + $printed = 1; +} + +if (!$printed or $p_full) { + print "HIP version : ", $HIP_VERSION, "\n\n"; + print "== hipconfig\n"; + print "HIP_PATH : ", $HIP_PATH, "\n"; + print "ROCM_PATH : ", $ROCM_PATH, "\n"; + print "HIP_COMPILER : ", $HIP_COMPILER, "\n"; + print "HIP_PLATFORM : ", $HIP_PLATFORM, "\n"; + print "HIP_RUNTIME : ", $HIP_RUNTIME, "\n"; + print "CPP_CONFIG : ", $CPP_CONFIG, "\n"; + if ($HIP_PLATFORM eq "amd") + { + print "\n" ; + if ($HIP_COMPILER eq "clang") + { + print "== hip-clang\n"; + print ("HIP_CLANG_PATH : $HIP_CLANG_PATH\n"); + if ($isWindows) { + system("\"$HIP_CLANG_PATH/clang++\" --version"); + system("\"$HIP_CLANG_PATH/llc\" --version"); + printf("hip-clang-cxxflags : "); + $win_output = `perl \"$HIP_PATH/bin/hipcc\" --cxxflags`; + printf("$win_output \n"); + printf("hip-clang-ldflags : "); + $win_output = `perl \"$HIP_PATH/bin/hipcc\" --ldflags`; + printf("$win_output \n"); + } else { + system("$HIP_CLANG_PATH/clang++ --version"); + system("$HIP_CLANG_PATH/llc --version"); + print ("hip-clang-cxxflags : "); + system("$HIP_PATH/bin/hipcc --cxxflags"); + printf("\n"); + print ("hip-clang-ldflags : "); + system("$HIP_PATH/bin/hipcc --ldflags"); + printf("\n"); + } + } else { + print ("Unexpected HIP_COMPILER: $HIP_COMPILER\n"); + } + } + if ($HIP_PLATFORM eq "nvidia") { + print "\n" ; + print "== nvcc\n"; + print "CUDA_PATH : ", $CUDA_PATH, "\n"; + system("$CUDA_PATH/bin/nvcc --version"); + + } + print "\n" ; + + print "=== Environment Variables\n"; + if ($isWindows) { + print ("PATH=$ENV{PATH}\n"); + system("set | findstr //B //C:\"HIP\" //C:\"CUDA\" //C:\"LD_LIBRARY_PATH\""); + } else { + system("echo PATH=\$PATH"); + system("env | egrep '^HIP|^CUDA|^LD_LIBRARY_PATH'"); + } + + + print "\n" ; + if ($isWindows) { + print "== Windows Display Drivers\n"; + print "Hostname : "; system ("hostname"); + system ("wmic path win32_VideoController get AdapterCompatibility,InstalledDisplayDrivers,Name | findstr //B //C:\"Advanced Micro Devices\""); + } else { + print "== Linux Kernel\n"; + print "Hostname : "; system ("hostname"); + system ("uname -a"); + } + + if (-e "/usr/bin/lsb_release") { + system ("/usr/bin/lsb_release -a"); + } + + print "\n" ; + $printed = 1; +} + + +if ($p_check) { + print "\nCheck system installation:\n"; + + printf ("%-70s", "check hipconfig in PATH..."); + # Safer to use which hipconfig instead of invoking hipconfig + if (system ("which hipconfig > /dev/null 2>&1") != 0) { + print "FAIL\n"; + } else { + printf "good\n"; + } +} + +if ($p_newline) { + print "\n"; +} From 3efa9b1e5e15dc9c56d9108952cb6825b01ea4b0 Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 31 Jan 2023 06:06:36 +0000 Subject: [PATCH 08/35] SWDEV-379927 - ignore passing --rocm-path=xxxxx to nvcc nvidia platform --- amd/hipcc/src/hipBin_nvidia.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amd/hipcc/src/hipBin_nvidia.h b/amd/hipcc/src/hipBin_nvidia.h index d9a7b38a1aaf73..215be6fcca54e5 100644 --- a/amd/hipcc/src/hipBin_nvidia.h +++ b/amd/hipcc/src/hipBin_nvidia.h @@ -375,7 +375,9 @@ void HipBinNvidia::executeHipCCCmd(vector argv) { for (unsigned int i = 2; i < argv.size(); i++) { string isaarg = argv.at(i); ISACMD += " "; - ISACMD += isaarg; + if (!hipBinUtilPtr_->substringPresent(isaarg,"--rocm-path=")) { + ISACMD += isaarg; + } } if (verbose & 0x1) { cout<< "hipcc-cmd: " << ISACMD << "\n"; From 31543605f4a60fcb151327cb350be69f30304a26 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 31 Jan 2023 15:38:28 -0500 Subject: [PATCH 09/35] Add zip packaging --- amd/hipcc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 058673baf0834d..695281a07c4d47 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -50,7 +50,7 @@ if(NOT WIN32) target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK}) endif() -set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators") +set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators") set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support ") set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver") set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") From 78a5d49214db08fa90cf36d5f9f135b942ee5c15 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 7 Feb 2023 16:51:03 -0800 Subject: [PATCH 10/35] Added softlink for the files in bin folder The binary files will be installed in bin directory For backward compatibility, the hip/bin folder will have soft links to the actual files --- amd/hipcc/CMakeLists.txt | 7 +++++ amd/hipcc/hipcc-backward-compat.cmake | 42 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 amd/hipcc/hipcc-backward-compat.cmake diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 695281a07c4d47..9dabe12ce160af 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -106,5 +106,12 @@ install(TARGETS ${HIPCC_BIN} install(TARGETS ${HIPCONFIG_BIN} COMPONENT ${hipcc_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +# TODO: WIN32 check need to be removed if backward compatibility is required for WIN32 +option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON) +if(NOT WIN32) + if(HIPCC_BACKWARD_COMPATIBILITY) + include(hipcc-backward-compat.cmake) + endif() +endif() include(CPack) diff --git a/amd/hipcc/hipcc-backward-compat.cmake b/amd/hipcc/hipcc-backward-compat.cmake new file mode 100644 index 00000000000000..a38d26d320cc8a --- /dev/null +++ b/amd/hipcc/hipcc-backward-compat.cmake @@ -0,0 +1,42 @@ +# Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +cmake_minimum_required(VERSION 3.16.8) + +set(HIPCC_WRAPPER_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/wrapper_dir/bin) +set(HIPCC_SRC_BIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin) + +#function to create symlink to binaries +function(create_binary_symlink) + file(MAKE_DIRECTORY ${HIPCC_WRAPPER_BIN_DIR}) + #get all binaries + file(GLOB binary_files ${HIPCC_SRC_BIN_DIR}/*) + foreach(binary_file ${binary_files}) + get_filename_component(file_name ${binary_file} NAME) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../${CMAKE_INSTALL_BINDIR}/${file_name} ${HIPCC_WRAPPER_BIN_DIR}/${file_name}) + endforeach() +endfunction() + +# Create symlink to binaries +create_binary_symlink() +# TODO: Following has to modified if component based installation is required +install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip) From 2f3b708366dc75f92958410ab8ec210e0faa7b62 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Mon, 6 Feb 2023 13:21:06 -0500 Subject: [PATCH 11/35] SWDEV-355608 - deprecate/cleanup hipcc link flags - deprecate -use-staticlib, -use-sharedlib which no longer provide any functional values - use --hip-link instead of specifying the HIP runtime by name when linking - fix linker option bug in HIT test's cmake - update build options for unit tests requiring pthread or rt This is essentially a C++ port of this patch in Perl: https://github.com/ROCm-Developer-Tools/HIP/pull/3128 --- amd/hipcc/src/hipBin_amd.h | 73 +++++++++++++------------------------- 1 file changed, 24 insertions(+), 49 deletions(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index 6c906aa041c816..9090586b281b84 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -144,7 +144,6 @@ const string& HipBinAmd::getHipLdFlags() const { void HipBinAmd::initializeHipLdFlags() { - string hipLibPath; string hipLdFlags; const string& hipClangPath = getCompilerPath(); // If $HIPCC clang++ is not compiled, use clang instead @@ -152,12 +151,6 @@ void HipBinAmd::initializeHipLdFlags() { if (!fs::exists(hipCC)) { hipLdFlags = "--driver-mode=g++"; } - hipLibPath = getHipLibPath(); - hipLdFlags += " -L\"" + hipLibPath + "\""; - const OsType& os = getOSInfo(); - if (os == windows) { - hipLdFlags += " -lamdhip64"; - } hipLdFlags_ = hipLdFlags; } @@ -385,17 +378,13 @@ bool HipBinAmd::detectPlatform() { string HipBinAmd::getHipLibPath() const { string hipLibPath; const EnvVariables& env = getEnvVariables(); - if (env.hipLibPathEnv_.empty()) { - const string& rocclrHomePath = getRocclrHomePath(); - fs::path libPath = rocclrHomePath; - libPath /= "lib"; - hipLibPath = libPath.string(); + if (!env.hipLibPathEnv_.empty()) { + hipLibPath = env.hipLibPathEnv_; } - if (hipLibPath.empty()) { - const string& hipPath = getHipPath(); - fs::path libPath = hipPath; - libPath /= "lib"; - hipLibPath = libPath.string(); + else if (!env.hipPathEnv_.empty()) { + fs::path p = env.hipLibPathEnv_; + p /= "lib"; + hipLibPath = p.string(); } return hipLibPath; } @@ -500,8 +489,6 @@ void HipBinAmd::executeHipCCCmd(vector argv) { bool printLDFlags = 0; // print HIPLDFLAGS bool runCmd = 1; bool buildDeps = 0; - bool linkType = 1; - bool setLinkType = 0; string hsacoVersion; bool funcSupp = 0; // enable function support bool rdc = 0; // whether -fgpu-rdc is on @@ -616,14 +603,13 @@ void HipBinAmd::executeHipCCCmd(vector argv) { compileOnly = 1; buildDeps = 1; } - if ((trimarg == "-use-staticlib") && (setLinkType == 0)) { - linkType = 0; - setLinkType = 1; - swallowArg = 1; + if ((trimarg == "-use-staticlib")) { + std::cerr << "Warning: The -use-staticlib option has been deprecated and is no longer needed.\n"; + swallowArg = true; } - if ((trimarg == "-use-sharedlib") && (setLinkType == 0)) { - linkType = 1; - setLinkType = 1; + if ((trimarg == "-use-sharedlib")) { + std::cerr << "Warning: The -use-sharedlib option has been deprecated and is no longer needed.\n"; + swallowArg = true; } if (hipBinUtilPtr_->stringRegexMatch(arg, "^-O.*")) { optArg = arg; @@ -846,11 +832,6 @@ void HipBinAmd::executeHipCCCmd(vector argv) { if (buildDeps) { HIPCXXFLAGS += " --cuda-host-only"; } - // Add --hip-link only if it is compile only and -fgpu-rdc is on. - if (rdc && !compileOnly) { - HIPLDFLAGS += " --hip-link"; - HIPLDFLAGS += HIPLDARCHFLAGS; - } // hipcc currrently requires separate compilation of source files, // ie it is not possible to pass @@ -884,27 +865,21 @@ void HipBinAmd::executeHipCCCmd(vector argv) { HIPCXXFLAGS += hip_device_lib_str; } } - if (os != windows) { - HIPLDFLAGS += " -lgcc_s -lgcc -lpthread -lm -lrt"; - } - if (os != windows && !compileOnly) { - string hipClangVersion, toolArgTemp; - if (linkType == 0) { - toolArgTemp = " -L"+ hipLibPath + "-lamdhip64 -L" + - roccmPath+ "/lib -lhsa-runtime64 -ldl -lnuma " + toolArgs; - toolArgs = toolArgTemp; - } else { - toolArgTemp = toolArgs + " -Wl,-rpath=" + hipLibPath + ":" - + roccmPath+"/lib -lamdhip64 "; - toolArgs = toolArgTemp; + if (!compileOnly) { + string hip_path = getHipLibPath(); + if (!hip_path.empty()) { + HIPLDFLAGS += " -L" + hip_path; + } + HIPLDFLAGS += " --hip-link"; + if (rdc) { + HIPLDFLAGS += HIPLDARCHFLAGS; + } + if (!windows) { + HIPLDFLAGS += " --rtlib=compiler-rt -unwindlib=libgcc"; } - - hipClangVersion = getCompilerVersion(); - // To support __fp16 and _Float16, explicitly link with compiler-rt - toolArgs += " -L" + hipClangPath + "/../lib/clang/" + - hipClangVersion + "/lib/linux -lclang_rt.builtins-x86_64 "; } + if (!var.hipccCompileFlagsAppendEnv_.empty()) { HIPCXXFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " "; HIPCFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " "; From 3b1931971615d17fd69a84ab32923611a500ef90 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Mon, 20 Feb 2023 13:16:04 -0500 Subject: [PATCH 12/35] Misc. cleanups --- amd/hipcc/CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 9dabe12ce160af..d12e543b20a0c0 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -6,7 +6,7 @@ set(hipcc_NAME "${PROJECT_NAME}") include(CMakePackageConfigHelpers) include(GNUInstallDirs) -find_package(ROCM) +find_package(ROCM QUIET) if(ROCM_FOUND) include(ROCMSetupVersion) rocm_setup_version(VERSION "${hipcc_VERSION}") @@ -106,12 +106,14 @@ install(TARGETS ${HIPCC_BIN} install(TARGETS ${HIPCONFIG_BIN} COMPONENT ${hipcc_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -# TODO: WIN32 check need to be removed if backward compatibility is required for WIN32 + +# TODO: WIN32 check need to be removed if backward +# compatibility is required for WIN32. option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON) if(NOT WIN32) - if(HIPCC_BACKWARD_COMPATIBILITY) - include(hipcc-backward-compat.cmake) - endif() + if(HIPCC_BACKWARD_COMPATIBILITY) + include(hipcc-backward-compat.cmake) + endif() endif() include(CPack) From 41957ea96e6a33cc93adec76553549632e0a551c Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Mon, 20 Feb 2023 13:18:10 -0500 Subject: [PATCH 13/35] Make hipcc packages depend on perl --- amd/hipcc/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index d12e543b20a0c0..0b15b6097e18cf 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -62,6 +62,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") # Debian-specific packaging variables. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0)") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC") if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) @@ -72,6 +73,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") +set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From f9121fc59b10e4153919c0a57445fc6cc4140cd6 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Fri, 24 Feb 2023 14:45:04 -0500 Subject: [PATCH 14/35] Add missing hipvars.pm --- amd/hipcc/bin/hipvars.pm | 158 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 amd/hipcc/bin/hipvars.pm diff --git a/amd/hipcc/bin/hipvars.pm b/amd/hipcc/bin/hipvars.pm new file mode 100644 index 00000000000000..bea4ec71cef693 --- /dev/null +++ b/amd/hipcc/bin/hipvars.pm @@ -0,0 +1,158 @@ +#!/usr/bin/env perl +# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +package hipvars; +use warnings; +use Getopt::Long; +use Cwd; +use File::Basename; + +$HIP_BASE_VERSION_MAJOR = "5"; +$HIP_BASE_VERSION_MINOR = "5"; +$HIP_BASE_VERSION_PATCH = "0"; + +#--- +# Function to parse config file +sub parse_config_file { + my ($file, $config) = @_; + if (open (CONFIG, "$file")) { + while () { + my $config_line=$_; + chop ($config_line); + $config_line =~ s/^\s*//; + $config_line =~ s/\s*$//; + if (($config_line !~ /^#/) && ($config_line ne "")) { + my ($name, $value) = split (/=/, $config_line); + $$config{$name} = $value; + } + } + close(CONFIG); + } +} + +#--- +# Function to check if executable can be run +sub can_run { + my ($exe) = @_; + `$exe --version 2>&1`; + if ($? == 0) { + return 1; + } else { + return 0; + } +} + +$isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); + +# +# TODO: Fix rpath LDFLAGS settings +# +# Since this hipcc script gets installed at two uneven hierarchical levels, +# linked by symlink, the absolute path of this script should be used to +# derive HIP_PATH, as dirname $0 could be /opt/rocm/bin or /opt/rocm/hip/bin +# depending on how it gets invoked. +# ROCM_PATH which points to is determined based on whether +# we find bin/rocm_agent_enumerator in the parent of HIP_PATH or not. If it is found, +# ROCM_PATH is defined relative to HIP_PATH else it is hardcoded to /opt/rocm. +# +$HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../")); # use parent directory of hipcc +if (-e "$HIP_PATH/bin/rocm_agent_enumerator") { + $ROCM_PATH=$ENV{'ROCM_PATH'} // "$HIP_PATH"; # use HIP_PATH +}elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility + $ROCM_PATH=$ENV{'ROCM_PATH'} // dirname("$HIP_PATH"); # use parent directory of HIP_PATH +} else { + $ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm"; +} +$CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda'; + +# Windows has a different structure, all binaries are inside hip/bin +if ($isWindows) { + $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$HIP_PATH/bin"; +} else { + $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/llvm/bin"; +} +# HIP_ROCCLR_HOME is used by Windows builds +$HIP_ROCCLR_HOME=$ENV{'HIP_ROCCLR_HOME'}; + +if (defined $HIP_ROCCLR_HOME) { + $HIP_INFO_PATH= "$HIP_ROCCLR_HOME/lib/.hipInfo"; +} else { + $HIP_INFO_PATH= "$HIP_PATH/lib/.hipInfo"; # use actual file +} +#--- +#HIP_PLATFORM controls whether to use nvidia or amd platform: +$HIP_PLATFORM=$ENV{'HIP_PLATFORM'}; +# Read .hipInfo +my %hipInfo = (); +parse_config_file("$HIP_INFO_PATH", \%hipInfo); +# Prioritize Env first, otherwise use the hipInfo config file +$HIP_COMPILER = $ENV{'HIP_COMPILER'} // $hipInfo{'HIP_COMPILER'} // "clang"; +$HIP_RUNTIME = $ENV{'HIP_RUNTIME'} // $hipInfo{'HIP_RUNTIME'} // "rocclr"; + +# If using ROCclr runtime, need to find HIP_ROCCLR_HOME +if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "rocclr" and !defined $HIP_ROCCLR_HOME) { + my $hipvars_dir = dirname(Cwd::abs_path($0)); + if (-e "$hipvars_dir/../lib/bitcode") { + $HIP_ROCCLR_HOME = Cwd::abs_path($hipvars_dir . "/.."); #FILE_REORG Backward compatibility + } elsif (-e "$hipvars_dir/lib/bitcode") { + $HIP_ROCCLR_HOME = Cwd::abs_path($hipvars_dir); + } else { + $HIP_ROCCLR_HOME = $HIP_PATH; # use HIP_PATH + } +} + +if (not defined $HIP_PLATFORM) { + if (can_run("$HIP_CLANG_PATH/clang++") or can_run("clang++")) { + $HIP_PLATFORM = "amd"; + } elsif (can_run("$CUDA_PATH/bin/nvcc") or can_run("nvcc")) { + $HIP_PLATFORM = "nvidia"; + $HIP_COMPILER = "nvcc"; + $HIP_RUNTIME = "cuda"; + } else { + # Default to amd for now + $HIP_PLATFORM = "amd"; + } +} elsif ($HIP_PLATFORM eq "hcc") { + $HIP_PLATFORM = "amd"; + warn("Warning: HIP_PLATFORM=hcc is deprecated. Please use HIP_PLATFORM=amd. \n") +} elsif ($HIP_PLATFORM eq "nvcc") { + $HIP_PLATFORM = "nvidia"; + $HIP_COMPILER = "nvcc"; + $HIP_RUNTIME = "cuda"; + warn("Warning: HIP_PLATFORM=nvcc is deprecated. Please use HIP_PLATFORM=nvidia. \n") +} + +if ($HIP_COMPILER eq "clang") { + # Windows does not have clang at linux default path + if (defined $HIP_ROCCLR_HOME and (-e "$HIP_ROCCLR_HOME/bin/clang" or -e "$HIP_ROCCLR_HOME/bin/clang.exe")) { + $HIP_CLANG_PATH = "$HIP_ROCCLR_HOME/bin"; + } +} + +#--- +# Read .hipVersion +my %hipVersion = (); +parse_config_file("$hipvars::HIP_PATH/bin/.hipVersion", \%hipVersion); +$HIP_VERSION_MAJOR = $hipVersion{'HIP_VERSION_MAJOR'} // $HIP_BASE_VERSION_MAJOR; +$HIP_VERSION_MINOR = $hipVersion{'HIP_VERSION_MINOR'} // $HIP_BASE_VERSION_MINOR; +$HIP_VERSION_PATCH = $hipVersion{'HIP_VERSION_PATCH'} // $HIP_BASE_VERSION_PATCH; +$HIP_VERSION_GITHASH = $hipVersion{'HIP_VERSION_GITHASH'} // 0; +$HIP_VERSION="$HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH-$HIP_VERSION_GITHASH"; From 785c2258fc3404aaeb56328280ad818ce77630f9 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Thu, 23 Feb 2023 16:00:33 -0500 Subject: [PATCH 15/35] Copy bin to build Change-Id: I7986867e36308c82c7ce38168a24763535b36a09 --- amd/hipcc/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 0b15b6097e18cf..9c18a7889cba42 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -50,6 +50,9 @@ if(NOT WIN32) target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK}) endif() +# Copy scripts and batch files to build directory. +file(COPY ${CMAKE_SOURCE_DIR}/bin/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators") set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support ") set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver") From eab4ba13dded10de8a8b189436c8d6d9814c53e2 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 21 Mar 2023 10:32:20 -0400 Subject: [PATCH 16/35] Address review comments: - Remove HIP_VERSION_MAJOR/MINOR/PATCH - Make hipcc package depend on hip-dev, rocm-llvm --- amd/hipcc/CMakeLists.txt | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 9c18a7889cba42..6747f845475d15 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -18,16 +18,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK libstdc++fs.so) -get_directory_property(HAS_PARENT_SCOPE PARENT_DIRECTORY) -if(HAS_PARENT_SCOPE) - # FIXME(kzhuravl): Do we need these here? If yes, what is the default? - set(HIP_VERSION_MAJOR 4 PARENT_SCOPE) - set(HIP_VERSION_MINOR 4 PARENT_SCOPE) - set(HIP_VERSION_PATCH 4 PARENT_SCOPE) -else() - message(STATUS "Current scope has no parent") -endif() - set(HIPCC_BIN hipcc.bin) set(HIPCC_SOURCES @@ -65,7 +55,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") # Debian-specific packaging variables. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0)") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-dev, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0), rocm-llvm") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC") if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) @@ -76,7 +66,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") -set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-dev, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-llvm") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From dbcf5e74e84143b806427fd973d64cd2784611da Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 21 Mar 2023 10:36:04 -0400 Subject: [PATCH 17/35] Bring hipcc and hipconfig scripts in sync with HIP repo --- amd/hipcc/bin/hipcc | 2 +- amd/hipcc/bin/hipcc.bat | 0 amd/hipcc/bin/hipcc.pl | 52 +++++++++++++++++++++---------------- amd/hipcc/bin/hipconfig.bat | 0 4 files changed, 30 insertions(+), 24 deletions(-) mode change 100755 => 100644 amd/hipcc/bin/hipcc.bat mode change 100755 => 100644 amd/hipcc/bin/hipcc.pl mode change 100755 => 100644 amd/hipcc/bin/hipconfig.bat diff --git a/amd/hipcc/bin/hipcc b/amd/hipcc/bin/hipcc index dfb5a8f6b82410..4002631b5721c8 100755 --- a/amd/hipcc/bin/hipcc +++ b/amd/hipcc/bin/hipcc @@ -54,7 +54,7 @@ if ($USE_PERL_SCRIPT) { #Invoke hipcc.bin system($HIPCC_BIN, @ARGV); } else { - print "hipcc.bin not present; Install HIPCC binaries before proceeding"; + print "hipcc.bin not present; install HIPCC binaries before proceeding\n"; exit(-1); } } diff --git a/amd/hipcc/bin/hipcc.bat b/amd/hipcc/bin/hipcc.bat old mode 100755 new mode 100644 diff --git a/amd/hipcc/bin/hipcc.pl b/amd/hipcc/bin/hipcc.pl old mode 100755 new mode 100644 index 6898cd0bba2996..56dcda2d59870b --- a/amd/hipcc/bin/hipcc.pl +++ b/amd/hipcc/bin/hipcc.pl @@ -52,15 +52,21 @@ # retrieve --rocm-path hipcc option from command line. # We need to respect this over the env var ROCM_PATH for this compilation. -sub get_rocm_path_option { +sub get_path_options { my $rocm_path=""; + my $hip_path=""; my @CLArgs = @ARGV; foreach $arg (@CLArgs) { if (index($arg,"--rocm-path=") != -1) { ($rocm_path) = $arg=~ /=\s*(.*)\s*$/; + next; + } + if (index($arg,"--hip-path=") != -1) { + ($hip_path) = $arg=~ /=\s*(.*)\s*$/; + next; } } - return $rocm_path; + return ($rocm_path, $hip_path); } $verbose = $ENV{'HIPCC_VERBOSE'} // 0; @@ -99,13 +105,16 @@ sub delete_temp_dirs { } my $base_dir; -my $rocmPath; BEGIN { $base_dir = dirname(Cwd::realpath(__FILE__) ); - $rocmPath = get_rocm_path_option(); - if ($rocmPath ne '') { + my ($rocm_path, $hip_path) = get_path_options(); + if ($rocm_path ne '') { + # --rocm-path takes precedence over ENV{ROCM_PATH} + $ENV{ROCM_PATH}=$rocm_path; + } + if ($hip_path ne '') { # --rocm-path takes precedence over ENV{ROCM_PATH} - $ENV{ROCM_PATH}=$rocmPath; + $ENV{HIP_PATH}=$hip_path; } } use lib "$base_dir/"; @@ -123,25 +132,10 @@ BEGIN $HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME; if ($HIP_PLATFORM eq "amd") { - # If using ROCclr runtime, need to find HIP_ROCCLR_HOME - if (!defined $DEVICE_LIB_PATH and -e "$HIP_ROCCLR_HOME/lib/bitcode") { - $DEVICE_LIB_PATH = "$HIP_ROCCLR_HOME/lib/bitcode"; - } $HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include"; if (!defined $HIP_LIB_PATH) { $HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib"; } - - if (!defined $DEVICE_LIB_PATH) { - if (-e "$ROCM_PATH/amdgcn/bitcode") { - $DEVICE_LIB_PATH = "$ROCM_PATH/amdgcn/bitcode"; - } - else { - # This path is to support an older build of the device library - # TODO: To be removed in the future. - $DEVICE_LIB_PATH = "$ROCM_PATH/lib"; - } - } } if ($verbose & 0x2) { @@ -259,7 +253,12 @@ BEGIN if($ARGV[0] eq "--genco"){ foreach $isaarg (@ARGV[1..$#ARGV]){ $ISACMD .= " "; - $ISACMD .= $isaarg; + # ignore --rocm-path=xxxx on nvcc nvidia platform + if ($isaarg !~ /--rocm-path/) { + $ISACMD .= $isaarg; + } else { + print "Ignoring --rocm-path= on nvidia nvcc platform.\n"; + } } if ($verbose & 0x1) { print "hipcc-cmd: ", $ISACMD, "\n"; @@ -566,8 +565,15 @@ BEGIN } } + # If the HIP_PATH env var is defined, pass that path to Clang + if ($ENV{'HIP_PATH'}) { + my $hip_path_flag = " --hip-path=\"$HIP_PATH\""; + $HIPCXXFLAGS .= $hip_path_flag; + $HIPLDFLAGS .= $hip_path_flag; + } + if ($hasHIP) { - if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") { + if (defined $DEVICE_LIB_PATH) { $HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\""; } } diff --git a/amd/hipcc/bin/hipconfig.bat b/amd/hipcc/bin/hipconfig.bat old mode 100755 new mode 100644 From a7eac6a20f8b56a26ad86c7fd2190a655800701d Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Mon, 3 Apr 2023 15:14:17 -0400 Subject: [PATCH 18/35] Fix hip-dev package name for RPM dependencies --- amd/hipcc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 6747f845475d15..778e143e8bc89d 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -66,7 +66,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") -set(CPACK_RPM_PACKAGE_REQUIRES "hip-dev, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-llvm") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-llvm") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From 8ced3fe45242c2d466ddaa78a5cd6d7ac836625d Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Mon, 3 Apr 2023 15:28:55 -0400 Subject: [PATCH 19/35] Make hipcc packages depend on rocm-core --- amd/hipcc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 778e143e8bc89d..841b61b2498423 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -55,7 +55,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") # Debian-specific packaging variables. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-dev, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0), rocm-llvm") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-dev, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0), rocm-core, rocm-llvm") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC") if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) @@ -66,7 +66,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") -set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-llvm") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-core, rocm-llvm") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From 2ab667adc377e5ecd760746632c3beb3e7f5b3e2 Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Wed, 12 Apr 2023 11:45:16 -0600 Subject: [PATCH 20/35] add sphinx configs --- amd/hipcc/.github/dependabot.yml | 12 ++ amd/hipcc/.gitignore | 10 + amd/hipcc/.readthedocs.yaml | 14 ++ amd/hipcc/README.md | 17 +- amd/hipcc/docs/.sphinx/_toc.yml.in | 10 + amd/hipcc/docs/.sphinx/requirements.in | 1 + amd/hipcc/docs/.sphinx/requirements.txt | 268 ++++++++++++++++++++++++ amd/hipcc/docs/build.md | 12 ++ amd/hipcc/docs/conf.py | 13 ++ amd/hipcc/docs/env.md | 12 ++ amd/hipcc/docs/index.md | 5 + amd/hipcc/docs/test.md | 3 + amd/hipcc/docs/usage.md | 11 + 13 files changed, 385 insertions(+), 3 deletions(-) create mode 100644 amd/hipcc/.github/dependabot.yml create mode 100644 amd/hipcc/.readthedocs.yaml create mode 100644 amd/hipcc/docs/.sphinx/_toc.yml.in create mode 100644 amd/hipcc/docs/.sphinx/requirements.in create mode 100644 amd/hipcc/docs/.sphinx/requirements.txt create mode 100644 amd/hipcc/docs/build.md create mode 100644 amd/hipcc/docs/conf.py create mode 100644 amd/hipcc/docs/env.md create mode 100644 amd/hipcc/docs/index.md create mode 100644 amd/hipcc/docs/test.md create mode 100644 amd/hipcc/docs/usage.md diff --git a/amd/hipcc/.github/dependabot.yml b/amd/hipcc/.github/dependabot.yml new file mode 100644 index 00000000000000..ada22f1b56d111 --- /dev/null +++ b/amd/hipcc/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + open-pull-requests-limit: 10 + schedule: + interval: "daily" diff --git a/amd/hipcc/.gitignore b/amd/hipcc/.gitignore index 17f1f1fd43525d..3c2e3103578a16 100644 --- a/amd/hipcc/.gitignore +++ b/amd/hipcc/.gitignore @@ -5,3 +5,13 @@ # Nested build directory. /build* + +# documentation artifacts +build/ +_build/ +_images/ +_static/ +_templates/ +_toc.yml +docBin/ +_doxygen/ diff --git a/amd/hipcc/.readthedocs.yaml b/amd/hipcc/.readthedocs.yaml new file mode 100644 index 00000000000000..43a0890c96ead2 --- /dev/null +++ b/amd/hipcc/.readthedocs.yaml @@ -0,0 +1,14 @@ +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +sphinx: + configuration: docs/conf.py + +formats: [htmlzip] + +python: + version: "3.8" + install: + - requirements: docs/.sphinx/requirements.txt diff --git a/amd/hipcc/README.md b/amd/hipcc/README.md index 7f5a031c43bed5..a1d6a7441e9fe3 100644 --- a/amd/hipcc/README.md +++ b/amd/hipcc/README.md @@ -5,12 +5,11 @@ - [hipcc](#hipcc) + * [Documentation](#documentation) * [Environment Variables](#envVar) * [Usage](#hipcc-usage) * [Building](#building) * [Testing](#testing) - * [Linux](#linux) - * [Windows](#windows) @@ -20,6 +19,18 @@ `hipcc` will pass-through options to the target compiler. The tools calling hipcc must ensure the compiler options are appropriate for the target compiler. +## Documentation + +Run the steps below to build documentation locally. + +``` +cd docs + +pip3 install -r .sphinx/requirements.txt + +python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html +``` + ### Environment Variables The environment variable HIP_PLATFORM may be used to specify amd/nvidia: @@ -63,4 +74,4 @@ The hipcc and hipconfig executables are created in the current build folder. The ### hipcc: testing -Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned. \ No newline at end of file +Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned. diff --git a/amd/hipcc/docs/.sphinx/_toc.yml.in b/amd/hipcc/docs/.sphinx/_toc.yml.in new file mode 100644 index 00000000000000..0dbd7788147f51 --- /dev/null +++ b/amd/hipcc/docs/.sphinx/_toc.yml.in @@ -0,0 +1,10 @@ +# Anywhere {branch} is used, the branch name will be substituted. +# These comments will also be removed. +root: index +subtrees: + - numbered: False + entries: + - file: env + - file: usage + - file: build + - file: test diff --git a/amd/hipcc/docs/.sphinx/requirements.in b/amd/hipcc/docs/.sphinx/requirements.in new file mode 100644 index 00000000000000..6d6f5bde99a50a --- /dev/null +++ b/amd/hipcc/docs/.sphinx/requirements.in @@ -0,0 +1 @@ +rocm-docs-core==0.2.0 diff --git a/amd/hipcc/docs/.sphinx/requirements.txt b/amd/hipcc/docs/.sphinx/requirements.txt new file mode 100644 index 00000000000000..8ff899df3ff9f7 --- /dev/null +++ b/amd/hipcc/docs/.sphinx/requirements.txt @@ -0,0 +1,268 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile .sphinx/requirements.in +# +accessible-pygments==0.0.4 + # via pydata-sphinx-theme +alabaster==0.7.13 + # via sphinx +asttokens==2.2.1 + # via stack-data +attrs==22.2.0 + # via + # jsonschema + # jupyter-cache +babel==2.12.1 + # via + # pydata-sphinx-theme + # sphinx +backcall==0.2.0 + # via ipython +beautifulsoup4==4.12.2 + # via pydata-sphinx-theme +breathe==4.34.0 + # via rocm-docs-core +certifi==2022.12.7 + # via requests +cffi==1.15.1 + # via pynacl +charset-normalizer==3.1.0 + # via requests +click==8.1.3 + # via + # jupyter-cache + # sphinx-external-toc +comm==0.1.3 + # via ipykernel +debugpy==1.6.7 + # via ipykernel +decorator==5.1.1 + # via ipython +deprecated==1.2.13 + # via pygithub +docutils==0.16 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # rocm-docs-core + # sphinx +executing==1.2.0 + # via stack-data +fastjsonschema==2.16.3 + # via nbformat +gitdb==4.0.10 + # via gitpython +gitpython==3.1.31 + # via rocm-docs-core +greenlet==2.0.2 + # via sqlalchemy +idna==3.4 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==6.3.0 + # via + # jupyter-cache + # myst-nb +ipykernel==6.22.0 + # via myst-nb +ipython==8.12.0 + # via + # ipykernel + # myst-nb +jedi==0.18.2 + # via ipython +jinja2==3.1.2 + # via + # myst-parser + # sphinx +jsonschema==4.17.3 + # via nbformat +jupyter-cache==0.5.0 + # via myst-nb +jupyter-client==8.1.0 + # via + # ipykernel + # nbclient +jupyter-core==5.3.0 + # via + # ipykernel + # jupyter-client + # nbformat +linkify-it-py==1.0.3 + # via myst-parser +markdown-it-py==2.2.0 + # via + # mdit-py-plugins + # myst-parser +markupsafe==2.1.2 + # via jinja2 +matplotlib-inline==0.1.6 + # via + # ipykernel + # ipython +mdit-py-plugins==0.3.5 + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +myst-nb==0.17.1 + # via rocm-docs-core +myst-parser[linkify]==0.18.1 + # via + # myst-nb + # rocm-docs-core +nbclient==0.5.13 + # via + # jupyter-cache + # myst-nb +nbformat==5.8.0 + # via + # jupyter-cache + # myst-nb + # nbclient +nest-asyncio==1.5.6 + # via + # ipykernel + # nbclient +packaging==23.1 + # via + # ipykernel + # pydata-sphinx-theme + # sphinx +parso==0.8.3 + # via jedi +pexpect==4.8.0 + # via ipython +pickleshare==0.7.5 + # via ipython +platformdirs==3.2.0 + # via jupyter-core +prompt-toolkit==3.0.38 + # via ipython +psutil==5.9.4 + # via ipykernel +ptyprocess==0.7.0 + # via pexpect +pure-eval==0.2.2 + # via stack-data +pycparser==2.21 + # via cffi +pydata-sphinx-theme==0.13.3 + # via sphinx-book-theme +pygithub==1.57 + # via rocm-docs-core +pygments==2.15.0 + # via + # accessible-pygments + # ipython + # pydata-sphinx-theme + # sphinx +pyjwt==2.6.0 + # via pygithub +pynacl==1.5.0 + # via pygithub +pyrsistent==0.19.3 + # via jsonschema +python-dateutil==2.8.2 + # via jupyter-client +pyyaml==6.0 + # via + # jupyter-cache + # myst-nb + # myst-parser + # sphinx-external-toc +pyzmq==25.0.2 + # via + # ipykernel + # jupyter-client +requests==2.28.2 + # via + # pygithub + # sphinx +rocm-docs-core==0.2.0 + # via -r .sphinx/requirements.in +six==1.16.0 + # via + # asttokens + # python-dateutil +smmap==5.0.0 + # via gitdb +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.4 + # via beautifulsoup4 +sphinx==4.3.1 + # via + # breathe + # myst-nb + # myst-parser + # pydata-sphinx-theme + # rocm-docs-core + # sphinx-book-theme + # sphinx-copybutton + # sphinx-design + # sphinx-external-toc + # sphinx-notfound-page +sphinx-book-theme==1.0.0rc2 + # via rocm-docs-core +sphinx-copybutton==0.5.1 + # via rocm-docs-core +sphinx-design==0.3.0 + # via rocm-docs-core +sphinx-external-toc==0.3.1 + # via rocm-docs-core +sphinx-notfound-page==0.8.3 + # via rocm-docs-core +sphinxcontrib-applehelp==1.0.4 + # via sphinx +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==2.0.1 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via sphinx +sqlalchemy==1.4.47 + # via jupyter-cache +stack-data==0.6.2 + # via ipython +tabulate==0.9.0 + # via jupyter-cache +tornado==6.2 + # via + # ipykernel + # jupyter-client +traitlets==5.9.0 + # via + # comm + # ipykernel + # ipython + # jupyter-client + # jupyter-core + # matplotlib-inline + # nbclient + # nbformat +typing-extensions==4.5.0 + # via + # myst-nb + # myst-parser + # pydata-sphinx-theme +uc-micro-py==1.0.1 + # via linkify-it-py +urllib3==1.26.15 + # via requests +wcwidth==0.2.6 + # via prompt-toolkit +wrapt==1.15.0 + # via deprecated +zipp==3.15.0 + # via importlib-metadata + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/amd/hipcc/docs/build.md b/amd/hipcc/docs/build.md new file mode 100644 index 00000000000000..67a974dca8f00c --- /dev/null +++ b/amd/hipcc/docs/build.md @@ -0,0 +1,12 @@ +# Building + +```bash +mkdir build +cd build + +cmake .. + +make -j +``` + +The hipcc and hipconfig executables are created in the current build folder. These executables need to be copied to /opt/rocm/hip/bin folder location. Packaging and installing will be handled in future releases. diff --git a/amd/hipcc/docs/conf.py b/amd/hipcc/docs/conf.py new file mode 100644 index 00000000000000..bfd701171c1e54 --- /dev/null +++ b/amd/hipcc/docs/conf.py @@ -0,0 +1,13 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +from rocm_docs import ROCmDocs + +docs_core = ROCmDocs("HIPCC Documentation") +docs_core.setup() + +for sphinx_var in ROCmDocs.SPHINX_VARS: + globals()[sphinx_var] = getattr(docs_core, sphinx_var) diff --git a/amd/hipcc/docs/env.md b/amd/hipcc/docs/env.md new file mode 100644 index 00000000000000..09e260e3926e9d --- /dev/null +++ b/amd/hipcc/docs/env.md @@ -0,0 +1,12 @@ +# Environment Variables + +The environment variable HIP_PLATFORM may be used to specify amd/nvidia: +- HIP_PLATFORM='amd' or HIP_PLATFORM='nvidia'. +- If HIP_PLATFORM is not set, then hipcc will attempt to auto-detect based on if nvcc is found. + +Other environment variable controls: +- HIP_PATH : Path to HIP directory, default is one dir level above location of hipcc. +- CUDA_PATH : Path to CUDA SDK (default /usr/local/cuda). Used on NVIDIA platforms only. +- HSA_PATH : Path to HSA dir (defaults to ../../hsa relative to abs_path of hipcc). Used on AMD platforms only. +- HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only. +- HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to hipcc's abs_path). Used on AMD platforms only. diff --git a/amd/hipcc/docs/index.md b/amd/hipcc/docs/index.md new file mode 100644 index 00000000000000..0052142b6a2fb9 --- /dev/null +++ b/amd/hipcc/docs/index.md @@ -0,0 +1,5 @@ +# HIPCC + +`hipcc` is a compiler driver utility that will call clang or nvcc, depending on target, and pass the appropriate include and library options for the target compiler and HIP infrastructure. Historically, `hipcc` was provided as a script in the HIP repo ( https://github.com/ROCm-Developer-Tools/HIP/blob/main/bin/hipcc ). The `hipcc` provided in this project provides the same functionality, but is a binary rather than a script. At some point in the future, the hipcc script will be deprecated and ultimately removed from the HIP repo. + +`hipcc` will pass-through options to the target compiler. The tools calling hipcc must ensure the compiler options are appropriate for the target compiler. diff --git a/amd/hipcc/docs/test.md b/amd/hipcc/docs/test.md new file mode 100644 index 00000000000000..08e5b97d278d9b --- /dev/null +++ b/amd/hipcc/docs/test.md @@ -0,0 +1,3 @@ +# Testing + +Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned. diff --git a/amd/hipcc/docs/usage.md b/amd/hipcc/docs/usage.md new file mode 100644 index 00000000000000..f928af28fc3b8d --- /dev/null +++ b/amd/hipcc/docs/usage.md @@ -0,0 +1,11 @@ +# Usage + +The built executables can be used the same way as the hipcc/hipconfig perl scripts. +To use the newly built executables from the build folder use ./ in front of the executable name - +Example: +```shell +./hipconfig --help +./hipcc --help +./hipcc --version +./hipconfig --full +``` From a4180d927a2327eda6238ec3fb2c1741a7a50cee Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Wed, 12 Apr 2023 11:50:21 -0600 Subject: [PATCH 21/35] fix typo --- amd/hipcc/README.md | 2 +- amd/hipcc/docs/test.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/README.md b/amd/hipcc/README.md index a1d6a7441e9fe3..6212a9bc0d0241 100644 --- a/amd/hipcc/README.md +++ b/amd/hipcc/README.md @@ -74,4 +74,4 @@ The hipcc and hipconfig executables are created in the current build folder. The ### hipcc: testing -Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned. +Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Separate tests for hipcc/hipconfig is currently not planned. diff --git a/amd/hipcc/docs/test.md b/amd/hipcc/docs/test.md index 08e5b97d278d9b..ec376cce19046b 100644 --- a/amd/hipcc/docs/test.md +++ b/amd/hipcc/docs/test.md @@ -1,3 +1,3 @@ # Testing -Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned. +Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Separate tests for hipcc/hipconfig is currently not planned. From 7f780304ad548eaa262a3f3efcadb18dffb27c3c Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Thu, 13 Apr 2023 17:25:05 -0600 Subject: [PATCH 22/35] update documentation --- amd/hipcc/docs/env.md | 1 - amd/hipcc/docs/index.md | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/amd/hipcc/docs/env.md b/amd/hipcc/docs/env.md index 09e260e3926e9d..09e82e7ae541d7 100644 --- a/amd/hipcc/docs/env.md +++ b/amd/hipcc/docs/env.md @@ -7,6 +7,5 @@ The environment variable HIP_PLATFORM may be used to specify amd/nvidia: Other environment variable controls: - HIP_PATH : Path to HIP directory, default is one dir level above location of hipcc. - CUDA_PATH : Path to CUDA SDK (default /usr/local/cuda). Used on NVIDIA platforms only. -- HSA_PATH : Path to HSA dir (defaults to ../../hsa relative to abs_path of hipcc). Used on AMD platforms only. - HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only. - HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to hipcc's abs_path). Used on AMD platforms only. diff --git a/amd/hipcc/docs/index.md b/amd/hipcc/docs/index.md index 0052142b6a2fb9..b5ed99880414a7 100644 --- a/amd/hipcc/docs/index.md +++ b/amd/hipcc/docs/index.md @@ -1,5 +1,5 @@ # HIPCC -`hipcc` is a compiler driver utility that will call clang or nvcc, depending on target, and pass the appropriate include and library options for the target compiler and HIP infrastructure. Historically, `hipcc` was provided as a script in the HIP repo ( https://github.com/ROCm-Developer-Tools/HIP/blob/main/bin/hipcc ). The `hipcc` provided in this project provides the same functionality, but is a binary rather than a script. At some point in the future, the hipcc script will be deprecated and ultimately removed from the HIP repo. +`hipcc` is a compiler driver utility that will call clang or nvcc, depending on target, and pass the appropriate include and library options for the target compiler and HIP infrastructure. -`hipcc` will pass-through options to the target compiler. The tools calling hipcc must ensure the compiler options are appropriate for the target compiler. +There is both a Perl version, and a C++ executable version of the hipcc/hipconfig compiler driver utilities provided. Currently, by default the Perl version is used when 'hipcc' is called. To enable the C++ executable versions, set the environment variable `HIP_USE_PERL_SCRIPTS=0`. From 15d35cdd979410ad64f6bcb13f987543c8410536 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Mon, 17 Apr 2023 17:58:01 +0000 Subject: [PATCH 23/35] Update Jenkinsfile to account for HIP tests moving to hip-tests repository --- amd/hipcc/.jenkins/Jenkinsfile | 59 +++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/amd/hipcc/.jenkins/Jenkinsfile b/amd/hipcc/.jenkins/Jenkinsfile index a785c95a496169..a9f1e235ede679 100644 --- a/amd/hipcc/.jenkins/Jenkinsfile +++ b/amd/hipcc/.jenkins/Jenkinsfile @@ -19,6 +19,13 @@ def hipBuildTest(String backendLabel) { dir("${WORKSPACE}/hipamd") { git branch: 'develop', url: 'https://github.com/ROCm-Developer-Tools/hipamd' + env.HIPAMD_DIR = "${WORKSPACE}" + "/hipamd" + } + + // Clone hip-tests repository + dir("${WORKSPACE}/hip-tests") { + git branch: 'develop', + url: 'https://github.com/ROCm-Developer-Tools/hip-tests' } // Clone vdi and opencl for only amd backend server @@ -36,6 +43,25 @@ def hipBuildTest(String backendLabel) { } } + stage("BUILD HIP - ${backendLabel}") { + // Running the build on hipamd workspace + dir("${WORKSPACE}/hipamd") { + sh """#!/usr/bin/env bash + set -x + mkdir -p build + cd build + # Check if backend label contains string "amd" or backend host is a server with amd gpu + if [[ $backendLabel =~ amd ]]; then + cmake -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DAMD_OPENCL_PATH=\$OPENCL_DIR -DROCCLR_PATH=\$ROCclr_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + else + cmake -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + fi + make -j\$(nproc) + make install -j\$(nproc) + """ + } + } + stage("Build - HIPCC") { // Running the build on HIPCC workspace dir("${WORKSPACE}/HIPCC") { @@ -50,45 +76,42 @@ def hipBuildTest(String backendLabel) { } } - stage("Build - Catch2 framework") { - // Running the build on hipamd workspace - dir("${WORKSPACE}/hipamd") { + stage("BUILD HIP TESTS - ${backendLabel}") { + // Running the build on HIP TESTS workspace + dir("${WORKSPACE}/hip-tests") { + env.HIP_PATH = "${HIPAMD_DIR}" + "/build/install" sh """#!/usr/bin/env bash set -x + rm -rf build mkdir -p build cd build + echo "testing $HIP_PATH" # Check if backend label contains string "amd" or backend host is a server with amd gpu if [[ $backendLabel =~ amd ]]; then - cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=\$HIP_DIR -DAMD_OPENCL_PATH=\$OPENCL_DIR -DROCCLR_PATH=\$ROCclr_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + cmake -DHIP_PLATFORM=amd ../catch else export HIP_PLATFORM=nvidia - export HIP_COMPILER=nvcc - export HIP_RUNTIME=cuda - cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. - fi - make install -j\$(nproc) - if [[ $backendLabel =~ amd ]]; then - make build_tests -j\$(nproc) - else - HIP_COMPILER=nvcc HIP_PLATFORM=nvidia make build_tests -j\$(nproc) + cmake -DHIP_PLATFORM=nvidia ../catch fi + make -j\$(nproc) build_tests """ } } - stage('HIP Unit Tests - Catch2 framework') { - dir("${WORKSPACE}/hipamd/build") { + stage("TEST - ${backendLabel}") { + dir("${WORKSPACE}/hip-tests") { sh """#!/usr/bin/env bash set -x - # Check if backend label contains string "amd" or backend host is a server with amd gpu + cd build if [[ $backendLabel =~ amd ]]; then - LLVM_PATH=/opt/rocm/llvm ctest -E 'Unit_hiprtc_saxpy' + ctest else - make test + ctest -E 'Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior|Unit_hipMemcpy_Positive_Synchronization_Behavior|Unit_hipFreeNegativeHost' fi """ } } + } } From 771c46483fa9c3204afa095dffc5ff4b215ce1bd Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Thu, 20 Apr 2023 09:58:25 -0600 Subject: [PATCH 24/35] update dependabot config --- amd/hipcc/.github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/.github/dependabot.yml b/amd/hipcc/.github/dependabot.yml index ada22f1b56d111..9cdf2d670c3584 100644 --- a/amd/hipcc/.github/dependabot.yml +++ b/amd/hipcc/.github/dependabot.yml @@ -6,7 +6,7 @@ version: 2 updates: - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests + directory: "/docs/.sphinx" # Location of package manifests open-pull-requests-limit: 10 schedule: interval: "daily" From 66383365254b90a1dec2321c54780112ba40dfcd Mon Sep 17 00:00:00 2001 From: David Salinas Date: Mon, 24 Apr 2023 19:42:15 +0000 Subject: [PATCH 25/35] Update Jenkinsfile by adding CLR repository --- amd/hipcc/.jenkins/Jenkinsfile | 75 +++++++++++++++------------------- 1 file changed, 32 insertions(+), 43 deletions(-) diff --git a/amd/hipcc/.jenkins/Jenkinsfile b/amd/hipcc/.jenkins/Jenkinsfile index a9f1e235ede679..41707a6e4956bd 100644 --- a/amd/hipcc/.jenkins/Jenkinsfile +++ b/amd/hipcc/.jenkins/Jenkinsfile @@ -15,11 +15,12 @@ def hipBuildTest(String backendLabel) { env.HIP_DIR = "${WORKSPACE}" + "/hip" } - // Clone hipamd repository - dir("${WORKSPACE}/hipamd") { + // Clone clr repository + dir("${WORKSPACE}/clr") { git branch: 'develop', - url: 'https://github.com/ROCm-Developer-Tools/hipamd' - env.HIPAMD_DIR = "${WORKSPACE}" + "/hipamd" + credentialsId: 'branch-credentials', + url: 'https://github.com/ROCm-Developer-Tools/clr' + env.CLR_DIR = "${WORKSPACE}" + "/clr" } // Clone hip-tests repository @@ -27,34 +28,35 @@ def hipBuildTest(String backendLabel) { git branch: 'develop', url: 'https://github.com/ROCm-Developer-Tools/hip-tests' } + } - // Clone vdi and opencl for only amd backend server - if (backendLabel =~ /.*amd.*/) { - dir("${WORKSPACE}/ROCm-OpenCL-Runtime") { - git branch:'develop', - url: 'https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime' - env.OPENCL_DIR = "${WORKSPACE}" + "/ROCm-OpenCL-Runtime" - } - dir("${WORKSPACE}/ROCclr") { - git branch:'develop', - url: 'https://github.com/ROCm-Developer-Tools/ROCclr' - env.ROCclr_DIR = "${WORKSPACE}" + "/ROCclr" - } + stage("Build - HIPCC") { + // Running the build on HIPCC workspace + dir("${WORKSPACE}/HIPCC") { + sh """#!/usr/bin/env bash + set -x + rm -rf build + mkdir build + cd build/ + cmake .. + make + """ } } stage("BUILD HIP - ${backendLabel}") { - // Running the build on hipamd workspace - dir("${WORKSPACE}/hipamd") { + // Running the build on clr workspace + dir("${WORKSPACE}/clr") { sh """#!/usr/bin/env bash set -x + rm -rf build mkdir -p build cd build # Check if backend label contains string "amd" or backend host is a server with amd gpu if [[ $backendLabel =~ amd ]]; then - cmake -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DAMD_OPENCL_PATH=\$OPENCL_DIR -DROCCLR_PATH=\$ROCclr_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + cmake -DCLR_BUILD_HIP=ON -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. else - cmake -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + cmake -DCLR_BUILD_HIP=ON -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. fi make -j\$(nproc) make install -j\$(nproc) @@ -62,24 +64,10 @@ def hipBuildTest(String backendLabel) { } } - stage("Build - HIPCC") { - // Running the build on HIPCC workspace - dir("${WORKSPACE}/HIPCC") { - sh """#!/usr/bin/env bash - set -x - rm -rf build - mkdir build - cd build/ - cmake .. - make - """ - } - } - stage("BUILD HIP TESTS - ${backendLabel}") { // Running the build on HIP TESTS workspace dir("${WORKSPACE}/hip-tests") { - env.HIP_PATH = "${HIPAMD_DIR}" + "/build/install" + env.HIP_PATH = "${CLR_DIR}" + "/build/install" sh """#!/usr/bin/env bash set -x rm -rf build @@ -98,20 +86,21 @@ def hipBuildTest(String backendLabel) { } } - stage("TEST - ${backendLabel}") { - dir("${WORKSPACE}/hip-tests") { - sh """#!/usr/bin/env bash - set -x - cd build + timeout(time: 1, unit: 'HOURS') { + stage("TEST - ${backendLabel}") { + dir("${WORKSPACE}/hip-tests") { + sh """#!/usr/bin/env bash + set -x + cd build if [[ $backendLabel =~ amd ]]; then - ctest + ctest --overwrite BuildDirectory=. --output-junit hiptest_output_catch_amd.xml else - ctest -E 'Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior|Unit_hipMemcpy_Positive_Synchronization_Behavior|Unit_hipFreeNegativeHost' + ctest --overwrite BuildDirectory=. --output-junit hiptest_output_catch_nvidia.xml -E 'Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior|Unit_hipMemcpy_Positive_Synchronization_Behavior|Unit_hipFreeNegativeHost' fi """ + } } } - } } From 74078ba7842b3e7783268f77d75fa8ee03bc4e2a Mon Sep 17 00:00:00 2001 From: David Salinas Date: Fri, 5 May 2023 19:16:05 +0000 Subject: [PATCH 26/35] SWDEV-398680 - HIPCC missing permissions in Install target. --- amd/hipcc/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 841b61b2498423..4c3550527c5466 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -89,7 +89,8 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin DESTINATION . - USE_SOURCE_PERMISSIONS) + USE_SOURCE_PERMISSIONS + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(FILES "LICENSE.txt" "README.md" From 45d968a766725c2bec3f4c79fc858c75a86b13aa Mon Sep 17 00:00:00 2001 From: samjwu Date: Wed, 17 May 2023 10:53:41 -0600 Subject: [PATCH 27/35] Update documentation requirements --- amd/hipcc/docs/.sphinx/requirements.in | 2 +- amd/hipcc/docs/.sphinx/requirements.txt | 184 +++++------------------- 2 files changed, 35 insertions(+), 151 deletions(-) diff --git a/amd/hipcc/docs/.sphinx/requirements.in b/amd/hipcc/docs/.sphinx/requirements.in index 6d6f5bde99a50a..f2b692a9d732e6 100644 --- a/amd/hipcc/docs/.sphinx/requirements.in +++ b/amd/hipcc/docs/.sphinx/requirements.in @@ -1 +1 @@ -rocm-docs-core==0.2.0 +rocm-docs-core==0.10.3 diff --git a/amd/hipcc/docs/.sphinx/requirements.txt b/amd/hipcc/docs/.sphinx/requirements.txt index 8ff899df3ff9f7..acd74da70db1cd 100644 --- a/amd/hipcc/docs/.sphinx/requirements.txt +++ b/amd/hipcc/docs/.sphinx/requirements.txt @@ -1,97 +1,57 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile .sphinx/requirements.in +# pip-compile requirements.in # -accessible-pygments==0.0.4 +accessible-pygments==0.0.3 # via pydata-sphinx-theme alabaster==0.7.13 # via sphinx -asttokens==2.2.1 - # via stack-data -attrs==22.2.0 - # via - # jsonschema - # jupyter-cache babel==2.12.1 # via # pydata-sphinx-theme # sphinx -backcall==0.2.0 - # via ipython -beautifulsoup4==4.12.2 +beautifulsoup4==4.11.2 # via pydata-sphinx-theme breathe==4.34.0 # via rocm-docs-core certifi==2022.12.7 # via requests cffi==1.15.1 - # via pynacl + # via + # cryptography + # pynacl charset-normalizer==3.1.0 # via requests click==8.1.3 - # via - # jupyter-cache - # sphinx-external-toc -comm==0.1.3 - # via ipykernel -debugpy==1.6.7 - # via ipykernel -decorator==5.1.1 - # via ipython + # via sphinx-external-toc +cryptography==40.0.2 + # via pyjwt deprecated==1.2.13 # via pygithub -docutils==0.16 +docutils==0.19 # via # breathe # myst-parser # pydata-sphinx-theme - # rocm-docs-core # sphinx -executing==1.2.0 - # via stack-data -fastjsonschema==2.16.3 - # via nbformat gitdb==4.0.10 # via gitpython gitpython==3.1.31 # via rocm-docs-core -greenlet==2.0.2 - # via sqlalchemy idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.3.0 - # via - # jupyter-cache - # myst-nb -ipykernel==6.22.0 - # via myst-nb -ipython==8.12.0 - # via - # ipykernel - # myst-nb -jedi==0.18.2 - # via ipython +importlib-metadata==6.0.0 + # via sphinx +importlib-resources==5.12.0 + # via rocm-docs-core jinja2==3.1.2 # via # myst-parser # sphinx -jsonschema==4.17.3 - # via nbformat -jupyter-cache==0.5.0 - # via myst-nb -jupyter-client==8.1.0 - # via - # ipykernel - # nbclient -jupyter-core==5.3.0 - # via - # ipykernel - # jupyter-client - # nbformat linkify-it-py==1.0.3 # via myst-parser markdown-it-py==2.2.0 @@ -100,104 +60,54 @@ markdown-it-py==2.2.0 # myst-parser markupsafe==2.1.2 # via jinja2 -matplotlib-inline==0.1.6 - # via - # ipykernel - # ipython mdit-py-plugins==0.3.5 # via myst-parser mdurl==0.1.2 # via markdown-it-py -myst-nb==0.17.1 +myst-parser[linkify]==1.0.0 # via rocm-docs-core -myst-parser[linkify]==0.18.1 - # via - # myst-nb - # rocm-docs-core -nbclient==0.5.13 - # via - # jupyter-cache - # myst-nb -nbformat==5.8.0 +packaging==23.0 # via - # jupyter-cache - # myst-nb - # nbclient -nest-asyncio==1.5.6 - # via - # ipykernel - # nbclient -packaging==23.1 - # via - # ipykernel # pydata-sphinx-theme # sphinx -parso==0.8.3 - # via jedi -pexpect==4.8.0 - # via ipython -pickleshare==0.7.5 - # via ipython -platformdirs==3.2.0 - # via jupyter-core -prompt-toolkit==3.0.38 - # via ipython -psutil==5.9.4 - # via ipykernel -ptyprocess==0.7.0 - # via pexpect -pure-eval==0.2.2 - # via stack-data pycparser==2.21 # via cffi pydata-sphinx-theme==0.13.3 - # via sphinx-book-theme -pygithub==1.57 + # via + # rocm-docs-core + # sphinx-book-theme +pygithub==1.58.1 # via rocm-docs-core -pygments==2.15.0 +pygments==2.14.0 # via # accessible-pygments - # ipython # pydata-sphinx-theme # sphinx -pyjwt==2.6.0 +pyjwt[crypto]==2.6.0 # via pygithub pynacl==1.5.0 # via pygithub -pyrsistent==0.19.3 - # via jsonschema -python-dateutil==2.8.2 - # via jupyter-client +pytz==2023.3 + # via babel pyyaml==6.0 # via - # jupyter-cache - # myst-nb # myst-parser # sphinx-external-toc -pyzmq==25.0.2 - # via - # ipykernel - # jupyter-client requests==2.28.2 # via # pygithub # sphinx -rocm-docs-core==0.2.0 - # via -r .sphinx/requirements.in -six==1.16.0 - # via - # asttokens - # python-dateutil +rocm-docs-core==0.10.3 + # via -r requirements.in smmap==5.0.0 # via gitdb snowballstemmer==2.2.0 # via sphinx soupsieve==2.4 # via beautifulsoup4 -sphinx==4.3.1 +sphinx==5.3.0 # via # breathe - # myst-nb # myst-parser # pydata-sphinx-theme # rocm-docs-core @@ -206,11 +116,11 @@ sphinx==4.3.1 # sphinx-design # sphinx-external-toc # sphinx-notfound-page -sphinx-book-theme==1.0.0rc2 +sphinx-book-theme==1.0.1 # via rocm-docs-core sphinx-copybutton==0.5.1 # via rocm-docs-core -sphinx-design==0.3.0 +sphinx-design==0.4.1 # via rocm-docs-core sphinx-external-toc==0.3.1 # via rocm-docs-core @@ -228,41 +138,15 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -sqlalchemy==1.4.47 - # via jupyter-cache -stack-data==0.6.2 - # via ipython -tabulate==0.9.0 - # via jupyter-cache -tornado==6.2 - # via - # ipykernel - # jupyter-client -traitlets==5.9.0 - # via - # comm - # ipykernel - # ipython - # jupyter-client - # jupyter-core - # matplotlib-inline - # nbclient - # nbformat typing-extensions==4.5.0 - # via - # myst-nb - # myst-parser - # pydata-sphinx-theme + # via pydata-sphinx-theme uc-micro-py==1.0.1 # via linkify-it-py urllib3==1.26.15 # via requests -wcwidth==0.2.6 - # via prompt-toolkit wrapt==1.15.0 # via deprecated zipp==3.15.0 - # via importlib-metadata - -# The following packages are considered to be unsafe in a requirements file: -# setuptools + # via + # importlib-metadata + # importlib-resources From 68125e8cb2ef6d29261c78e5739397a9c1d48d5d Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Fri, 19 May 2023 14:17:39 -0400 Subject: [PATCH 28/35] Fix package license policy --- amd/hipcc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 4c3550527c5466..f0a0880d94d90b 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -65,7 +65,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") -set(CPACK_RPM_PACKAGE_LICENSE "NCSA") +set(CPACK_RPM_PACKAGE_LICENSE "MIT") set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-core, rocm-llvm") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) From dd9b3cb0d8f3aa0c95a17ccce22728d28e642952 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Wed, 24 May 2023 19:54:23 +0000 Subject: [PATCH 29/35] Set exe permissions correctly Change-Id: I15c38b9e217a761cc377f1c8f1f7227a48e1800a --- amd/hipcc/bin/hipcc.bat | 0 amd/hipcc/bin/hipcc.pl | 0 amd/hipcc/bin/hipconfig.bat | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 amd/hipcc/bin/hipcc.bat mode change 100644 => 100755 amd/hipcc/bin/hipcc.pl mode change 100644 => 100755 amd/hipcc/bin/hipconfig.bat diff --git a/amd/hipcc/bin/hipcc.bat b/amd/hipcc/bin/hipcc.bat old mode 100644 new mode 100755 diff --git a/amd/hipcc/bin/hipcc.pl b/amd/hipcc/bin/hipcc.pl old mode 100644 new mode 100755 diff --git a/amd/hipcc/bin/hipconfig.bat b/amd/hipcc/bin/hipconfig.bat old mode 100644 new mode 100755 From 9b2ef375969cdf6862a65391425aa883e60b180a Mon Sep 17 00:00:00 2001 From: David Salinas Date: Wed, 24 May 2023 19:58:36 +0000 Subject: [PATCH 30/35] Correct required packages Change-Id: I919311fa0ea28934a10d91f2399d2772bae13ef6 --- amd/hipcc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 4c3550527c5466..a76611065a7528 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -55,7 +55,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") # Debian-specific packaging variables. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-dev, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, liburi-encode-perl, perl (>= 5.0), rocm-core, rocm-llvm") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), libfile-basedir-perl, hip-dev, rocm-core, rocm-llvm") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC") if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) @@ -66,7 +66,7 @@ endif() # RPM-specific packaging variables. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") -set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-core, rocm-llvm") +set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-BaseDir, hip-devel, rocm-core, rocm-llvm") if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From 59ea8ec46acf68aff738c601318c5221f6b6f7e7 Mon Sep 17 00:00:00 2001 From: AravindanC Date: Wed, 24 May 2023 20:48:23 -0700 Subject: [PATCH 31/35] SWDEV-401335 - Disable Auto provides for CPACK RPM --- amd/hipcc/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 4c3550527c5466..967618993f2260 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -67,6 +67,7 @@ endif() set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "NCSA") set(CPACK_RPM_PACKAGE_REQUIRES "hip-devel, perl >= 5.0, perl-File-BaseDir, perl-File-Listing, perl-File-Which, perl-URI-Encode, rocm-core, rocm-llvm") +set(CPACK_RPM_PACKAGE_AUTOPROV 0) if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From 56d84515d93d765f52b4ea9c2df746ab5d9c4f01 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Wed, 24 May 2023 20:04:53 +0000 Subject: [PATCH 32/35] Exclude .bat files from Linux packaging Change-Id: Ia366d69ea53a99b514fd237181fcbe19114a348d --- amd/hipcc/CMakeLists.txt | 15 ++++++++++++++- amd/hipcc/hipcc-backward-compat.cmake | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index a76611065a7528..62afb07a5776dd 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -87,18 +87,31 @@ else() endif() set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") +# Exclude Windows specific BAT scripts from install/packaging for Linux. +if (NOT WIN32) + set(exclusion_pattern "*.bat") +else () + set(exclusion_pattern "") +endif() + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin DESTINATION . USE_SOURCE_PERMISSIONS - DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + FILES_MATCHING + PATTERN "*" + PATTERN ${exclusion_pattern} EXCLUDE ) + install(FILES "LICENSE.txt" "README.md" COMPONENT ${hipcc_NAME} DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install(TARGETS ${HIPCC_BIN} COMPONENT ${hipcc_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS ${HIPCONFIG_BIN} COMPONENT ${hipcc_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/amd/hipcc/hipcc-backward-compat.cmake b/amd/hipcc/hipcc-backward-compat.cmake index a38d26d320cc8a..d426d8be112c6d 100644 --- a/amd/hipcc/hipcc-backward-compat.cmake +++ b/amd/hipcc/hipcc-backward-compat.cmake @@ -39,4 +39,7 @@ endfunction() # Create symlink to binaries create_binary_symlink() # TODO: Following has to modified if component based installation is required -install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip) +install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip + FILES_MATCHING + PATTERN "*" + PATTERN ${exclusion_pattern} EXCLUDE ) From 1e8b07a6e28b6adb9f4cf9f022707c8472685859 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 6 Jun 2023 21:19:16 +0000 Subject: [PATCH 33/35] SWDEV-401335 - Disable Auto requires for CPACK Change-Id: I0cc39826a292d935cf9a6b70df15cb759c1d5a68 --- amd/hipcc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/CMakeLists.txt b/amd/hipcc/CMakeLists.txt index 70610400dc945d..52da4f0dcff5b2 100644 --- a/amd/hipcc/CMakeLists.txt +++ b/amd/hipcc/CMakeLists.txt @@ -67,7 +67,7 @@ endif() set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_LICENSE "MIT") set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-BaseDir, hip-devel, rocm-core, rocm-llvm") -set(CPACK_RPM_PACKAGE_AUTOPROV 0) +set(CPACK_RPM_PACKAGE_AUTOREQROV 0) if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) else() From bb3b65248dfd15a09b858e493924ed62ec4c2d42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 06:05:51 +0000 Subject: [PATCH 34/35] Bump rocm-docs-core from 0.10.3 to 0.13.4 in /docs/.sphinx Bumps [rocm-docs-core](https://github.com/RadeonOpenCompute/rocm-docs-core) from 0.10.3 to 0.13.4. - [Release notes](https://github.com/RadeonOpenCompute/rocm-docs-core/releases) - [Changelog](https://github.com/RadeonOpenCompute/rocm-docs-core/blob/develop/CHANGELOG.md) - [Commits](https://github.com/RadeonOpenCompute/rocm-docs-core/compare/v0.10.3...v0.13.4) --- updated-dependencies: - dependency-name: rocm-docs-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- amd/hipcc/docs/.sphinx/requirements.in | 2 +- amd/hipcc/docs/.sphinx/requirements.txt | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/amd/hipcc/docs/.sphinx/requirements.in b/amd/hipcc/docs/.sphinx/requirements.in index f2b692a9d732e6..7f2c40a8e05d29 100644 --- a/amd/hipcc/docs/.sphinx/requirements.in +++ b/amd/hipcc/docs/.sphinx/requirements.in @@ -1 +1 @@ -rocm-docs-core==0.10.3 +rocm-docs-core==0.13.4 diff --git a/amd/hipcc/docs/.sphinx/requirements.txt b/amd/hipcc/docs/.sphinx/requirements.txt index acd74da70db1cd..4b247b75c10cf5 100644 --- a/amd/hipcc/docs/.sphinx/requirements.txt +++ b/amd/hipcc/docs/.sphinx/requirements.txt @@ -36,6 +36,8 @@ docutils==0.19 # myst-parser # pydata-sphinx-theme # sphinx +fastjsonschema==2.17.1 + # via rocm-docs-core gitdb==4.0.10 # via gitpython gitpython==3.1.31 @@ -44,10 +46,6 @@ idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.0.0 - # via sphinx -importlib-resources==5.12.0 - # via rocm-docs-core jinja2==3.1.2 # via # myst-parser @@ -87,17 +85,16 @@ pyjwt[crypto]==2.6.0 # via pygithub pynacl==1.5.0 # via pygithub -pytz==2023.3 - # via babel pyyaml==6.0 # via # myst-parser + # rocm-docs-core # sphinx-external-toc requests==2.28.2 # via # pygithub # sphinx -rocm-docs-core==0.10.3 +rocm-docs-core==0.13.4 # via -r requirements.in smmap==5.0.0 # via gitdb @@ -146,7 +143,3 @@ urllib3==1.26.15 # via requests wrapt==1.15.0 # via deprecated -zipp==3.15.0 - # via - # importlib-metadata - # importlib-resources From f3e88e2638b649a94a8475c9ca6d09ef8469df46 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Wed, 7 Jun 2023 20:03:24 +0000 Subject: [PATCH 35/35] add HIPCC_BIN_DIR to cmake for CLR build Change-Id: I0b96f1234341eb974b8794b51c82cab38739fe52 --- amd/hipcc/.jenkins/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/hipcc/.jenkins/Jenkinsfile b/amd/hipcc/.jenkins/Jenkinsfile index 41707a6e4956bd..d4fe13c5732787 100644 --- a/amd/hipcc/.jenkins/Jenkinsfile +++ b/amd/hipcc/.jenkins/Jenkinsfile @@ -54,9 +54,9 @@ def hipBuildTest(String backendLabel) { cd build # Check if backend label contains string "amd" or backend host is a server with amd gpu if [[ $backendLabel =~ amd ]]; then - cmake -DCLR_BUILD_HIP=ON -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + cmake -DHIPCC_BIN_DIR=\$HIPCC_DIR/bin -DCLR_BUILD_HIP=ON -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. else - cmake -DCLR_BUILD_HIP=ON -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + cmake -DHIPCC_BIN_DIR=\$HIPCC_DIR/bin -DCLR_BUILD_HIP=ON -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. fi make -j\$(nproc) make install -j\$(nproc)