diff --git a/hipamd/CMakeLists.txt b/hipamd/CMakeLists.txt index 76393736e2..aa835ed2ca 100755 --- a/hipamd/CMakeLists.txt +++ b/hipamd/CMakeLists.txt @@ -49,6 +49,7 @@ option(BUILD_HIPIFY_CLANG "Enable building the CUDA->HIP converter" OFF) option(__HIP_ENABLE_PCH "Enable/Disable pre-compiled hip headers" ON) option(__HIP_USE_CMPXCHG_FOR_FP_ATOMICS "Enable/Disable FP Atomics version" OFF) option(HIP_OFFICIAL_BUILD "Enable/Disable for mainline/staging builds" OFF) +option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" ON) set(HIPCC_BIN_DIR "" CACHE STRING "HIPCC and HIPCONFIG binary directories") if(__HIP_ENABLE_PCH) @@ -246,7 +247,7 @@ message (STATUS "ROCM Installation path(ROCM_PATH): ${ROCM_PATH}") # Determine HIP install path if (UNIX) - set(HIP_DEFAULT_INSTALL_PREFIX "${ROCM_PATH}/hip") + set(HIP_DEFAULT_INSTALL_PREFIX "${ROCM_PATH}") endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX ${HIP_DEFAULT_INSTALL_PREFIX} CACHE PATH "Installation path for HIP" FORCE) @@ -256,9 +257,23 @@ if(DEV_LOG_ENABLE MATCHES "yes") add_definitions(-DDEV_LOG_ENABLE) endif() -# Set default install path as "${ROCM_PATH}/hip", can override the path from cmake build. +# Set default install path as "${ROCM_PATH}", can override the path from cmake build. set(CPACK_INSTALL_PREFIX ${HIP_DEFAULT_INSTALL_PREFIX} CACHE PATH "Package Installation path for HIP") +if(NOT WIN32) +#TODO Once the build script(prototype) changes are merged +# The string replace statements should be removed + if(FILE_REORG_BACKWARD_COMPATIBILITY) + if(CPACK_INSTALL_PREFIX) + string(REPLACE "/hip" "" CPACK_INSTALL_PREFIX ${CPACK_INSTALL_PREFIX}) + endif() + + if(CMAKE_INSTALL_PREFIX) + string(REPLACE "/hip" "" CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + endif() + endif()#End of File reorg check +endif()#end of OS check + if(IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}) message(STATUS "HIP will be installed in: " ${CMAKE_INSTALL_PREFIX}) else() @@ -268,7 +283,7 @@ endif() # set the installation path for the installer package set(CPACK_SET_DESTDIR ON CACHE BOOL "Installer package will install hip to CMAKE_INSTALL_PREFIX instead of CPACK_PACKAGING_INSTALL_PREFIX") if (NOT CPACK_SET_DESTDIR) - set(CPACK_PACKAGING_INSTALL_PREFIX "${ROCM_PATH}/hip" CACHE PATH "Default installation path of hcc installer package") + set(CPACK_PACKAGING_INSTALL_PREFIX "${ROCM_PATH}" CACHE PATH "Default installation path of hcc installer package") endif (NOT CPACK_SET_DESTDIR) ############################# @@ -348,17 +363,25 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0) endif() else() # Exclude .bat files on Linux. + #Hip bin files moved to /opt/rocm/bin and the file permission need to set properly install(DIRECTORY ${HIP_COMMON_BIN_DIR} DESTINATION . USE_SOURCE_PERMISSIONS + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE PATTERN *.bat EXCLUDE) endif() - # The following two lines will be removed after upstream updation - install(CODE "MESSAGE(\"Removing ${CMAKE_INSTALL_PREFIX}/include\")") - install(CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/include)") + if(WIN32) #not required for flat folder structure + # The following two lines will be removed after upstream updation + install(CODE "MESSAGE(\"Removing ${CMAKE_INSTALL_PREFIX}/include\")") + install(CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/include)") + endif() install(DIRECTORY include DESTINATION .) install(DIRECTORY ${HIP_COMMON_INCLUDE_DIR}/hip/ DESTINATION include/hip/) - install(DIRECTORY ${HIP_COMMON_DIR}/cmake DESTINATION .) + if(WIN32) + install(DIRECTORY ${HIP_COMMON_DIR}/cmake DESTINATION .) + else() + install(DIRECTORY ${HIP_COMMON_DIR}/cmake/ DESTINATION CONFIG_PACKAGE_INSTALL_DIR) + endif() endif() # Install generated headers @@ -455,4 +478,9 @@ if(HIP_HIPCC_EXECUTABLE) endif() endif() -# vim: ts=4:sw=4:expandtab:smartindent +#File reorg Backward compatibility function +if(NOT WIN32) + if(FILE_REORG_BACKWARD_COMPATIBILITY) + include(hip-backward-compat.cmake) + endif() +endif() diff --git a/hipamd/hip-backward-compat.cmake b/hipamd/hip-backward-compat.cmake new file mode 100644 index 0000000000..988d3c232a --- /dev/null +++ b/hipamd/hip-backward-compat.cmake @@ -0,0 +1,254 @@ +# 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(HIP_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(HIP_WRAPPER_DIR ${HIP_BUILD_DIR}/wrapper_dir) +set(HIP_WRAPPER_INC_DIR ${HIP_WRAPPER_DIR}/include/hip) +set(HIP_WRAPPER_BIN_DIR ${HIP_WRAPPER_DIR}/bin) +set(HIP_WRAPPER_LIB_DIR ${HIP_WRAPPER_DIR}/lib) +set(HIP_WRAPPER_CMAKE_DIR ${HIP_WRAPPER_DIR}/cmake) +set(HIP_WRAPPER_FINDHIP_DIR ${HIP_WRAPPER_DIR}/FindHIP) +set(HIP_SRC_INC_DIR ${HIP_SRC_PATH}/include/hip) +set(HIP_SRC_BIN_DIR ${HIP_SRC_PATH}/bin) + +#Function to generate header template file +function(create_header_template) + file(WRITE ${HIP_WRAPPER_DIR}/header.hpp.in "/* + 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. + */\n\n#ifndef @include_guard@\n#define @include_guard@ \n\n#pragma message(\"This file is deprecated. Use file from include path /opt/rocm-ver/include/ and prefix with hip\")\n@include_statements@ \n\n#endif") +endfunction() + +#use header template file and generate wrapper header files +function(generate_wrapper_header) +#create respecitve folder in /opt/rocm/hip + file(MAKE_DIRECTORY ${HIP_WRAPPER_INC_DIR}/amd_detail) + file(MAKE_DIRECTORY ${HIP_WRAPPER_INC_DIR}/nvidia_detail) + + #find all header files from include/hip + file(GLOB include_files ${HIP_BUILD_DIR}/include/hip/*.h) + #Convert the list of files into #includes + foreach(header_file ${include_files}) + # set include guard + get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) + string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) + set(include_guard "${include_guard}HIP_WRAPPER_INCLUDE_HIP_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) + set(include_statements "${include_statements}#include \"../../../include/hip/${file_name}\"\n") + + configure_file(${HIP_WRAPPER_DIR}/header.hpp.in ${HIP_WRAPPER_INC_DIR}/${file_name}) + unset(include_guard) + unset(include_statements) + endforeach() + + #find all header files from include/hip/amd_detail + file(GLOB include_files ${HIP_SRC_INC_DIR}/amd_detail/*) + #Convert the list of files into #includes + foreach(header_file ${include_files}) + # set include guard + get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) + string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) + set(include_guard "${include_guard}HIP_WRAPPER_INCLUDE_HIP_AMD_DETAIL_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) + set(include_statements "${include_statements}#include \"../../../../include/hip/amd_detail/${file_name}\"\n") + + configure_file(${HIP_WRAPPER_DIR}/header.hpp.in ${HIP_WRAPPER_INC_DIR}/amd_detail/${file_name}) + unset(include_guard) + unset(include_statements) + endforeach() + + #find all header files from include/hip/nvidia_detail + file(GLOB include_files ${HIP_SRC_INC_DIR}/nvidia_detail/*) + #Convert the list of files into #includes + foreach(header_file ${include_files}) + # set include guard + get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) + string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) + set(include_guard "${include_guard}HIP_WRAPPER_INCLUDE_HIP_NVIDIA_DETAIL_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) + set(include_statements "${include_statements}#include \"../../../../include/hip/nvidia_detail/${file_name}\"\n") + + configure_file(${HIP_WRAPPER_DIR}/header.hpp.in ${HIP_WRAPPER_INC_DIR}/nvidia_detail/${file_name}) + unset(include_guard) + unset(include_statements) + endforeach() + +endfunction() + +#function to create symlink to binaries +function(create_binary_symlink) + file(MAKE_DIRECTORY ${HIP_WRAPPER_BIN_DIR}) + #get all binaries + file(GLOB binary_files ${HIP_SRC_BIN_DIR}/*) + #Add .hipVersion to binary list + set(binary_files "${binary_files}" ".hipVersion") + 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 + ../../bin/${file_name} ${HIP_WRAPPER_BIN_DIR}/${file_name}) + endforeach() + + unset(binary_files) + file(GLOB binary_files ${HIP_BUILD_DIR}/bin/*) + foreach(binary_file ${binary_files}) + get_filename_component(file_name ${binary_file} NAME) + if(WIN32) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../bin/${file_name} ${HIP_WRAPPER_BIN_DIR}/${file_name}) + + else() + if( NOT ${file_name} MATCHES ".bat$") + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../bin/${file_name} ${HIP_WRAPPER_BIN_DIR}/${file_name}) + endif()#end of bat file check + endif()#end of OS check + endforeach() +endfunction() + +#function to create symlink to libraries +function(create_library_symlink) + file(MAKE_DIRECTORY ${HIP_WRAPPER_LIB_DIR}) + if(BUILD_SHARED_LIBS) + set(LIB_AMDHIP "libamdhip64.so") + set(MAJ_VERSION "${HIP_LIB_VERSION_MAJOR}") + set(SO_VERSION "${HIP_LIB_VERSION_STRING}") + set(library_files "${LIB_AMDHIP}" "${LIB_AMDHIP}.${MAJ_VERSION}" "${LIB_AMDHIP}.${SO_VERSION}") + + if(__HIP_ENABLE_RTC) + set(LIB_HIPRTC "libhiprtc-builtins.so") + set(library_files "${library_files}" "${LIB_HIPRTC}" "${LIB_HIPRTC}.${MAJ_VERSION}" "${LIB_HIPRTC}.${SO_VERSION}" ) + endif() + + else() + set(library_files "libamdhip64.a") + endif() + + foreach(file_name ${library_files}) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../lib/${file_name} ${HIP_WRAPPER_LIB_DIR}/${file_name}) + endforeach() +endfunction() + +function(create_cmake_symlink) + file(MAKE_DIRECTORY ${HIP_WRAPPER_CMAKE_DIR}/hip) + #create symlink to all config files + file(GLOB config_files ${HIP_BUILD_DIR}/hip-config*) + foreach(config_name ${config_files}) + get_filename_component(file_name ${config_name} NAME) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../../../lib/cmake/hip/${file_name} ${HIP_WRAPPER_CMAKE_DIR}/hip/${file_name}) + endforeach() + #create symlink to hip-lang + unset(config_files) + file(MAKE_DIRECTORY ${HIP_WRAPPER_CMAKE_DIR}/hip-lang) + file(GLOB config_files ${HIP_BUILD_DIR}/src/hip-lang-config*) + foreach(config_name ${config_files}) + get_filename_component(file_name ${config_name} NAME) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../../../lib/cmake/hip-lang/${file_name} ${HIP_WRAPPER_CMAKE_DIR}/hip-lang/${file_name}) + endforeach() + + unset(config_files) + file(MAKE_DIRECTORY ${HIP_WRAPPER_FINDHIP_DIR}/FindHIP) + file(GLOB config_files ${HIP_BUILD_DIR}/cmake/FindHIP/*.cmake) + #create symlink to FindHIP + foreach(config_name ${config_files}) + get_filename_component(file_name ${config_name} NAME) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../../lib/cmake/hip/FindHIP/${file_name} ${HIP_WRAPPER_FINDHIP_DIR}/FindHIP/${file_name}) + endforeach() + + unset(config_files) + file(GLOB config_files ${HIP_BUILD_DIR}/cmake/*.cmake) + foreach(config_name ${config_files}) + get_filename_component(file_name ${config_name} NAME) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ../../lib/cmake/hip/${file_name} ${HIP_WRAPPER_FINDHIP_DIR}/${file_name}) + endforeach() + +endfunction() + +#Creater a template for header file +create_header_template() +#Use template header file and generater wrapper header files +generate_wrapper_header() +install(DIRECTORY ${HIP_WRAPPER_INC_DIR} DESTINATION hip/include COMPONENT dev) +# Create symlink to binaries +create_binary_symlink() +install(DIRECTORY ${HIP_WRAPPER_BIN_DIR} DESTINATION hip COMPONENT dev) + +option(BUILD_SHARED_LIBS "Build the shared library" ON) +# Create symlink to library files +create_library_symlink() +if(HIP_PLATFORM STREQUAL "amd" ) + if(BUILD_SHARED_LIBS) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libamdhip64.so DESTINATION hip/lib COMPONENT binary) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libamdhip64.so.${HIP_LIB_VERSION_MAJOR} DESTINATION hip/lib COMPONENT binary) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libamdhip64.so.${HIP_LIB_VERSION_STRING} DESTINATION hip/lib COMPONENT binary) + if(__HIP_ENABLE_RTC) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libhiprtc-builtins.so DESTINATION hip/lib COMPONENT binary) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libhiprtc-builtins.so.${HIP_LIB_VERSION_MAJOR} DESTINATION hip/lib COMPONENT binary) + install(FILES ${HIP_WRAPPER_LIB_DIR}/libhiprtc-builtins.so.${HIP_LIB_VERSION_STRING} DESTINATION hip/lib COMPONENT binary) + endif() + else() + install(FILES ${HIP_WRAPPER_LIB_DIR}/libamdhip64.a DESTINATION hip/lib COMPONENT binary) + endif()#End BUILD_SHARED_LIBS +endif()#End HIP_PLATFORM AMD +#create symlink to cmake files +create_cmake_symlink() +install(DIRECTORY ${HIP_WRAPPER_CMAKE_DIR} DESTINATION hip/lib COMPONENT binary) +install(DIRECTORY ${HIP_WRAPPER_FINDHIP_DIR}/ DESTINATION hip/cmake COMPONENT dev) diff --git a/hipamd/hip-config.cmake.in b/hipamd/hip-config.cmake.in index b860de3895..9ad8a5e5d9 100755 --- a/hipamd/hip-config.cmake.in +++ b/hipamd/hip-config.cmake.in @@ -191,6 +191,8 @@ if(NOT WIN32) #if HSA is not under ROCm then provide CMAKE_PREFIX_PATH= find_path(HSA_HEADER hsa/hsa.h PATHS + "${_IMPORT_PREFIX}/include" + #FILE_REORG_BACKWARD_COMPATIBILITY ${_IMPORT_PREFIX}/../include is for Backward compatibility "${_IMPORT_PREFIX}/../include" ${ROCM_PATH}/include ) @@ -216,8 +218,8 @@ if(HIP_RUNTIME MATCHES "rocclr") if(NOT WIN32) set_target_properties(hip::device PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include" - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" ) endif() endif() diff --git a/hipamd/packaging/CMakeLists.txt b/hipamd/packaging/CMakeLists.txt index 9fe824cf0b..d52d7d86ac 100644 --- a/hipamd/packaging/CMakeLists.txt +++ b/hipamd/packaging/CMakeLists.txt @@ -73,7 +73,9 @@ if(WIN32) USE_SOURCE_PERMISSIONS) else() install(DIRECTORY ${HIP_COMMON_DIR}/bin DESTINATION . COMPONENT dev - USE_SOURCE_PERMISSIONS PATTERN *.bat EXCLUDE) + USE_SOURCE_PERMISSIONS + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + PATTERN *.bat EXCLUDE) endif() if (NOT ${HIPCC_BIN_DIR} STREQUAL "") @@ -82,7 +84,8 @@ if (NOT ${HIPCC_BIN_DIR} STREQUAL "") endif() install(DIRECTORY ${hip_SOURCE_DIR}/bin DESTINATION . COMPONENT dev - USE_SOURCE_PERMISSIONS) + USE_SOURCE_PERMISSIONS + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(DIRECTORY ${HIP_COMMON_DIR}/include DESTINATION . COMPONENT dev) install(DIRECTORY ${hip_SOURCE_DIR}/include/hip/amd_detail DESTINATION include/hip COMPONENT dev) @@ -93,7 +96,7 @@ install(FILES ${CMAKE_BINARY_DIR}/include/hip/amd_detail/hip_prof_str.h install(FILES ${CMAKE_BINARY_DIR}/include/hip/hip_version.h DESTINATION include/hip COMPONENT dev) install(FILES ${CMAKE_BINARY_DIR}/.hipVersion DESTINATION bin COMPONENT dev) -install(DIRECTORY ${HIP_COMMON_DIR}/cmake DESTINATION . COMPONENT dev) +install(DIRECTORY ${HIP_COMMON_DIR}/cmake/ DESTINATION lib/cmake/hip COMPONENT dev) #End dev files install #Begin doc files install @@ -102,12 +105,12 @@ if(DOXYGEN_EXE) add_custom_target(build_doxygen ALL COMMAND HIP_PATH=${HIP_COMMON_DIR} doxygen ${HIP_COMMON_DIR}/docs/doxygen-input/doxy.cfg) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/RuntimeAPI/html - DESTINATION docs/RuntimeAPI COMPONENT doc) + DESTINATION share/doc/hip/RuntimeAPI COMPONENT doc) endif() #End doc files install #Begin samples files install -install(DIRECTORY ${HIP_COMMON_DIR}/samples DESTINATION . COMPONENT samples) +install(DIRECTORY ${HIP_COMMON_DIR}/samples DESTINATION share/hip COMPONENT samples) #End samples files install #Begin test files install @@ -156,18 +159,21 @@ set(CPACK_DEBIAN_BINARY_PACKAGE_NAME "hip-runtime-amd") set(CPACK_RPM_BINARY_PACKAGE_NAME "hip-runtime-amd") set(CPACK_COMPONENT_BINARY_DESCRIPTION "HIP:Heterogenous-computing Interface for Portability [RUNTIME - AMD]") - -configure_file(hip-runtime-amd.postinst ${CMAKE_CURRENT_BINARY_DIR}/binary/postinst @ONLY) -configure_file(hip-runtime-amd.prerm ${CMAKE_CURRENT_BINARY_DIR}/binary/prerm @ONLY) - -set(CPACK_DEBIAN_BINARY_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/binary/postinst;${CMAKE_CURRENT_BINARY_DIR}/binary/prerm") +if(FILE_REORG_BACKWARD_COMPATIBILITY) +#This is used for softlinking hip-target files + configure_file(hip-runtime-amd.postinst ${CMAKE_CURRENT_BINARY_DIR}/binary/postinst @ONLY) + configure_file(hip-runtime-amd.prerm ${CMAKE_CURRENT_BINARY_DIR}/binary/prerm @ONLY) + set(CPACK_DEBIAN_BINARY_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/binary/postinst;${CMAKE_CURRENT_BINARY_DIR}/binary/prerm") +endif() set(CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS "hsa-rocr-dev (>= 1.3), rocminfo, comgr (>= 2.0), rocm-llvm, libc6, rocm-core") set(CPACK_DEBIAN_BINARY_PACKAGE_PROVIDES "hip-rocclr (= ${CPACK_PACKAGE_VERSION})") set(CPACK_DEBIAN_BINARY_PACKAGE_REPLACES "hip-rocclr (= ${CPACK_PACKAGE_VERSION})") set(CPACK_RPM_BINARY_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_RPM_BINARY_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/binary/postinst") -set(CPACK_RPM_BINARY_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/binary/prerm") +if(FILE_REORG_BACKWARD_COMPATIBILITY) + set(CPACK_RPM_BINARY_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/binary/postinst") + set(CPACK_RPM_BINARY_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/binary/prerm") +endif() string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) set(CPACK_RPM_BINARY_PACKAGE_REQUIRES "hsa-rocr-dev >= 1.3, rocminfo, comgr >= 2.0, rocm-llvm, rocm-core") set(CPACK_RPM_BINARY_PACKAGE_PROVIDES "hip-rocclr = ${HIP_BASE_VERSION}") @@ -249,16 +255,10 @@ set(CPACK_DEBIAN_RUNTIME-NVIDIA_PACKAGE_NAME "hip-runtime-nvidia") set(CPACK_RPM_RUNTIME-NVIDIA_PACKAGE_NAME "hip-runtime-nvidia") set(CPACK_COMPONENT_RUNTIME-NVIDIA_DESCRIPTION "HIP: Heterogenous-computing Interface for Portability [RUNTIME-NVIDIA]") -configure_file(hip-runtime-nvidia.postinst ${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/postinst @ONLY) -configure_file(hip-runtime-nvidia.prerm ${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/prerm @ONLY) -set(CPACK_DEBIAN_RUNTIME-NVIDIA_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/postinst;${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/prerm") - set(CPACK_DEBIAN_RUNTIME-NVIDIA_PACKAGE_DEPENDS "cuda (>= 7.5), rocm-core") set(CPACK_DEBIAN_RUNTIME-NVIDIA_PACKAGE_PROVIDES "hip-nvcc") set(CPACK_DEBIAN_RUNTIME-NVIDIA_PACKAGE_REPLACES "hip-nvcc") -set(CPACK_RPM_RUNTIME-NVIDIA_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/postinst") -set(CPACK_RPM_RUNTIME-NVIDIA_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/runtime-nvidia/prerm") set(CPACK_RPM_RUNTIME-NVIDIA_PACKAGE_PROVIDES "hip-nvcc") set(CPACK_RPM_RUNTIME-NVIDIA_PACKAGE_OBSOLETES "hip-nvcc") set(CPACK_RPM_RUNTIME-NVIDIA_PACKAGE_REQUIRES "cuda >= 7.5, rocm-core") diff --git a/hipamd/packaging/hip-devel.postinst b/hipamd/packaging/hip-devel.postinst index f52f33cd12..d2af3bd1e0 100755 --- a/hipamd/packaging/hip-devel.postinst +++ b/hipamd/packaging/hip-devel.postinst @@ -19,31 +19,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ROCMDIR=@ROCM_PATH@ -HIPDIR=$ROCMDIR/hip - -# Soft-link to bin files -HIPBINFILES=$HIPDIR/bin/* -ROCMBINDIR=$ROCMDIR/bin -mkdir -p $ROCMBINDIR +HIPINCDIR=$ROCMDIR/include/hip CURRENTDIR=`pwd` -cd $ROCMBINDIR -for f in $HIPBINFILES -do - ln -r -s -f $f $(basename $f) -done - ln -r -s -f $HIPDIR/bin/.hipVersion .hipVersion -cd $CURRENTDIR - -# Soft-link to headers -HIPINCDIR=$HIPDIR/include/hip -ROCMINCDIR=$ROCMDIR/include -mkdir -p $ROCMINCDIR -cd $ROCMINCDIR - ln -r -s -f $HIPINCDIR hip -cd $CURRENTDIR - # The following will be removed after upstream updation cd $HIPINCDIR - ln -r -s -f amd_detail hcc_detail - ln -r -s -f nvidia_detail nvcc_detail +ln -r -s -f amd_detail hcc_detail +ln -r -s -f nvidia_detail nvcc_detail cd $CURRENTDIR + +#FILE_REORG_BACKWARD_COMPATIBILITY +HIPINCDIR=$ROCMDIR/hip/include/hip +if [ -d $HIPINCDIR ]; then + # The following will be removed after upstream updation + cd $HIPINCDIR + ln -r -s -f amd_detail hcc_detail + ln -r -s -f nvidia_detail nvcc_detail + cd $CURRENTDIR +fi diff --git a/hipamd/packaging/hip-devel.prerm b/hipamd/packaging/hip-devel.prerm index e1db4fbd5e..92be883252 100755 --- a/hipamd/packaging/hip-devel.prerm +++ b/hipamd/packaging/hip-devel.prerm @@ -19,35 +19,23 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ROCMDIR=@ROCM_PATH@ -HIPDIR=$ROCMDIR/hip -([ ! -d $ROCMDIR ] || [ ! -d $HIPDIR ]) && exit 0 - -# Remove soft-link to bin files -HIPBINDIR=$HIPDIR/bin -ROCMBINDIR=$ROCMDIR/bin -([ ! -d $ROCMBINDIR ] || [ ! -d $HIPBINDIR ]) && exit 0 -HIPBINFILES=$HIPBINDIR/* CURRENTDIR=`pwd` -cd $ROCMBINDIR -for f in $HIPBINFILES; do - [ -e $f ] || continue - rm $(basename $f) -done -rm .hipVersion -cd $CURRENTDIR -rmdir --ignore-fail-on-non-empty $ROCMBINDIR -# Remove soft-link to headers -HIPINCDIR=$HIPDIR/include -cd $HIPINCDIR/hip +HIPINCDIR=$ROCMDIR/include/hip +([ ! -d $HIPINCDIR ]) && exit 0 +cd $HIPINCDIR rm hcc_detail rm nvcc_detail cd $CURRENTDIR -ROCMINCDIR=$ROCMDIR/include -([ ! -d $ROCMINCDIR ] || [ ! -d $HIPINCDIR ]) && exit 0 -cd $ROCMINCDIR -rm hip +#FILE_REORG_BACKWARD_COMPATIBILITY + #backward copatibility code , to be removed later +HIPDIR=$ROCMDIR/hip +HIPINCDIR=$ROCMDIR/hip/include/hip +([ ! -d $HIPINCDIR ]) && exit 0 +cd $HIPINCDIR +rm -f hcc_detail +rm -f nvcc_detail cd $CURRENTDIR -rmdir --ignore-fail-on-non-empty $ROCMINCDIR - +([ ! -d $HIPDIR ]) && exit 0 +rmdir --ignore-fail-on-non-empty $HIPDIR diff --git a/hipamd/packaging/hip-runtime-amd.postinst b/hipamd/packaging/hip-runtime-amd.postinst index a40954d989..563ae2f160 100755 --- a/hipamd/packaging/hip-runtime-amd.postinst +++ b/hipamd/packaging/hip-runtime-amd.postinst @@ -20,25 +20,25 @@ # THE SOFTWARE. ROCMDIR=@ROCM_PATH@ -ROCMLIBDIR=$ROCMDIR/lib -HIPDIR=$ROCMDIR/hip -HIPLIBDIR=$ROCMDIR/hip/lib +ROCMCMAKEDIR=$ROCMDIR/lib/cmake +HIPCMAKEDIR=$ROCMDIR/hip/lib/cmake CURRENTDIR=`pwd` -# Soft-link to library files -HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v "cmake\|[-/$]") -mkdir -p $ROCMLIBDIR -mkdir -p $ROCMLIBDIR/cmake +mkdir -p $HIPCMAKEDIR/hip +mkdir -p $HIPCMAKEDIR/hip-lang -cd $ROCMLIBDIR -for f in $HIPLIBFILES +HIPTARGETFILES=$(ls -A $ROCMCMAKEDIR/hip | grep "^hip-targets") +cd $HIPCMAKEDIR/hip +for f in $HIPTARGETFILES do - ln -s -r -f $HIPLIBDIR/$f $(basename $f) + ln -s -r -f $ROCMCMAKEDIR/hip/$f $(basename $f) done cd $CURRENTDIR -# Make the hip cmake directory link. -cd $ROCMLIBDIR/cmake -ln -s -r -f $HIPLIBDIR/cmake/hip hip -ln -s -r -f $HIPLIBDIR/cmake/hip-lang hip-lang +HIPLANGTARGETFILES=$(ls -A $ROCMCMAKEDIR/hip-lang | grep "^hip-lang-targets") +cd $HIPCMAKEDIR/hip-lang +for f in $HIPLANGTARGETFILES +do + ln -s -r -f $ROCMCMAKEDIR/hip-lang/$f $(basename $f) +done cd $CURRENTDIR diff --git a/hipamd/packaging/hip-runtime-amd.prerm b/hipamd/packaging/hip-runtime-amd.prerm index 69b7758a6c..5af8d5cec7 100755 --- a/hipamd/packaging/hip-runtime-amd.prerm +++ b/hipamd/packaging/hip-runtime-amd.prerm @@ -20,28 +20,33 @@ # THE SOFTWARE. ROCMDIR=@ROCM_PATH@ -ROCMLIBDIR=$ROCMDIR/lib HIPDIR=$ROCMDIR/hip -HIPLIBDIR=$ROCMDIR/hip/lib -([ ! -d $ROCMDIR ] || [ ! -d $HIPDIR ]) && exit 0 -([ ! -d $ROCMLIBDIR ] || [ ! -d $HIPLIBDIR ]) && exit 0 +HIPCMAKEDIR=$ROCMDIR/hip/lib/cmake/hip +HIPLANGCMAKEDIR=$ROCMDIR/hip/lib/cmake/hip-lang CURRENTDIR=`pwd` -# Remove soft-links to libraries -HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v [-/$]) +([ ! -d $ROCMDIR ] || [ ! -d $HIPDIR ]) && exit 0 -cd $ROCMLIBDIR -for f in $HIPLIBFILES; do +([ ! -d $HIPCMAKEDIR ] ) && exit 0 +# Remove soft-links to hip-target +HIPTARGETFILES=$(ls -A $HIPCMAKEDIR | grep "^hip-targets") + +cd $HIPCMAKEDIR +for f in $HIPTARGETFILES; do [ -e $f ] || continue rm $(basename $f) done cd $CURRENTDIR +([ ! -d $HIPLANGCMAKEDIR ] ) && exit 0 +# Remove soft-links to hip-lang-target +HIPLANGTARGETFILES=$(ls -A $HIPLANGCMAKEDIR | grep "^hip-lang-targets") + +cd $HIPLANGCMAKEDIR +for f in $HIPLANGTARGETFILES; do + [ -e $f ] || continue + rm $(basename $f) +done -cd $ROCMLIBDIR/cmake -unlink hip -unlink hip-lang cd $CURRENTDIR -cd $ROCMLIBDIR -rmdir --ignore-fail-on-non-empty cmake -cd $CURRENTDIR -rmdir --ignore-fail-on-non-empty $ROCMLIBDIR +rmdir --ignore-fail-on-non-empty $HIPCMAKEDIR +rmdir --ignore-fail-on-non-empty $HIPLANGCMAKEDIR