From 9277b7b0496d0877caa74e2ac2cdc611e813fecb Mon Sep 17 00:00:00 2001 From: Icarus Sparry Date: Thu, 8 Jul 2021 20:06:46 +0000 Subject: [PATCH 01/18] Add dependency on rocm-core The intention is to make all rocm-packages depend on a tiny rocm-core package so that all of rocm can be removed by removing rocm-core. Obviously it is less than ideal that you install by using some variant of "apt install rocm" and remove everything by "apt remove rocm-core", but this is easy to document. The alternative "apt autoremove rocm" may remove unrelated packages. Signed-off-by: Icarus Sparry Change-Id: I95cf65550a33b8852ad3da15bbb5c1ac4a88bf46 --- packaging/hip-base.txt | 11 +++++++++-- packaging/hip-doc.txt | 16 ++++++++++++++-- packaging/hip-nvcc.txt | 10 ++++++++-- packaging/hip-rocclr.txt | 10 ++++++++-- packaging/hip-samples.txt | 10 ++++++++-- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/packaging/hip-base.txt b/packaging/hip-base.txt index 0a0ebe47..cf4466a8 100644 --- a/packaging/hip-base.txt +++ b/packaging/hip-base.txt @@ -58,7 +58,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), liburi-encode-perl, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, libc6, file") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), liburi-encode-perl, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, libc6, file, rocm-core") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-base") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_base") @@ -69,10 +69,17 @@ set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") -set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-Which, perl-File-Listing, perl-File-BaseDir, perl-URI-Encode, file") +set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-Which, perl-File-Listing, perl-File-BaseDir, perl-URI-Encode, file, rocm-core") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_base") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_base") set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") +# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake +set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") +if(NOT ROCM_DEP_ROCMCORE) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() + include(CPack) diff --git a/packaging/hip-doc.txt b/packaging/hip-doc.txt index da59c55f..8b16b081 100644 --- a/packaging/hip-doc.txt +++ b/packaging/hip-doc.txt @@ -55,7 +55,7 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), rocm-core") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-doc") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_doc") @@ -65,9 +65,21 @@ set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, rocm-core") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_doc") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_doc") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") + +# Remove depenency on rocm-core if not wanted. Add a -DROCM_DEP_ROCMCORE=ON +# to the cmake invocation. Do it this way so we can have the same code +# in all the packages, and don't need to worry if we need commas or not +# because there are other dependencies. Code is slightly fragile as we are +# using regular expressions to edit strings. +set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") +if(NOT ROCM_DEP_ROCMCORE) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() + include(CPack) diff --git a/packaging/hip-nvcc.txt b/packaging/hip-nvcc.txt index 9b0f150d..7fc51a37 100644 --- a/packaging/hip-nvcc.txt +++ b/packaging/hip-nvcc.txt @@ -42,7 +42,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), cuda (>= 7.5)") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), cuda (>= 7.5), rocm-core") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-nvcc") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_nvcc") @@ -54,9 +54,15 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, cuda >= 7.5") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, cuda >= 7.5, rocm-core") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_nvcc") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_nvcc") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") +# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake +set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") +if(NOT ROCM_DEP_ROCMCORE) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() include(CPack) diff --git a/packaging/hip-rocclr.txt b/packaging/hip-rocclr.txt index 5250c45f..de4858f9 100644 --- a/packaging/hip-rocclr.txt +++ b/packaging/hip-rocclr.txt @@ -77,7 +77,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hsa-rocr-dev (>= 1.3), rocminfo, hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), comgr (>= 2.0), llvm-amdgpu, libc6") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hsa-rocr-dev (>= 1.3), rocminfo, hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), comgr (>= 2.0), llvm-amdgpu, libc6, rocm-core") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-hcc (= ${CPACK_PACKAGE_VERSION})") set(CPACK_BINARY_RPM "ON") @@ -88,8 +88,14 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hsa-rocr-dev >= 1.3, rocminfo, hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, comgr >= 2.0, llvm-amdgpu") +set(CPACK_RPM_PACKAGE_REQUIRES "hsa-rocr-dev >= 1.3, rocminfo, hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, comgr >= 2.0, llvm-amdgpu, rocm-core") set(CPACK_RPM_PACKAGE_PROVIDES "hip-hcc = ${HIP_BASE_VERSION}") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") +# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake +set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") +if(NOT ROCM_DEP_ROCMCORE) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() include(CPack) diff --git a/packaging/hip-samples.txt b/packaging/hip-samples.txt index f6dde380..b4b7211c 100644 --- a/packaging/hip-samples.txt +++ b/packaging/hip-samples.txt @@ -43,7 +43,7 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), rocm-core") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-samples") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_samples") @@ -53,9 +53,15 @@ set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, rocm-core") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_samples") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_samples") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") +# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake +set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") +if(NOT ROCM_DEP_ROCMCORE) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() include(CPack) From 26a09b0c1f22138b98ecf840c9aa72b2f058aaaa Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 24 Aug 2021 04:22:54 -0700 Subject: [PATCH 02/18] Revert "Add dependency on rocm-core" This reverts commit 9277b7b0496d0877caa74e2ac2cdc611e813fecb. Change-Id: Ibe61bb4bd54bab82e9de52be60cf55561c4fc5aa --- packaging/hip-base.txt | 11 ++--------- packaging/hip-doc.txt | 16 ++-------------- packaging/hip-nvcc.txt | 10 ++-------- packaging/hip-rocclr.txt | 10 ++-------- packaging/hip-samples.txt | 10 ++-------- 5 files changed, 10 insertions(+), 47 deletions(-) diff --git a/packaging/hip-base.txt b/packaging/hip-base.txt index cf4466a8..0a0ebe47 100644 --- a/packaging/hip-base.txt +++ b/packaging/hip-base.txt @@ -58,7 +58,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), liburi-encode-perl, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, libc6, file, rocm-core") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), liburi-encode-perl, libfile-basedir-perl, libfile-copy-recursive-perl, libfile-listing-perl, libfile-which-perl, libc6, file") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-base") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_base") @@ -69,17 +69,10 @@ set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") -set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-Which, perl-File-Listing, perl-File-BaseDir, perl-URI-Encode, file, rocm-core") +set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-Which, perl-File-Listing, perl-File-BaseDir, perl-URI-Encode, file") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_base") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_base") set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") -# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake -set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -endif() - include(CPack) diff --git a/packaging/hip-doc.txt b/packaging/hip-doc.txt index 8b16b081..da59c55f 100644 --- a/packaging/hip-doc.txt +++ b/packaging/hip-doc.txt @@ -55,7 +55,7 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), rocm-core") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-doc") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_doc") @@ -65,21 +65,9 @@ set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, rocm-core") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_doc") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_doc") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") - -# Remove depenency on rocm-core if not wanted. Add a -DROCM_DEP_ROCMCORE=ON -# to the cmake invocation. Do it this way so we can have the same code -# in all the packages, and don't need to worry if we need commas or not -# because there are other dependencies. Code is slightly fragile as we are -# using regular expressions to edit strings. -set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -endif() - include(CPack) diff --git a/packaging/hip-nvcc.txt b/packaging/hip-nvcc.txt index 7fc51a37..9b0f150d 100644 --- a/packaging/hip-nvcc.txt +++ b/packaging/hip-nvcc.txt @@ -42,7 +42,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), cuda (>= 7.5), rocm-core") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), cuda (>= 7.5)") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-nvcc") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_nvcc") @@ -54,15 +54,9 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, cuda >= 7.5, rocm-core") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, cuda >= 7.5") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_nvcc") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_nvcc") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") -# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake -set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -endif() include(CPack) diff --git a/packaging/hip-rocclr.txt b/packaging/hip-rocclr.txt index de4858f9..5250c45f 100644 --- a/packaging/hip-rocclr.txt +++ b/packaging/hip-rocclr.txt @@ -77,7 +77,7 @@ set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hsa-rocr-dev (>= 1.3), rocminfo, hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), comgr (>= 2.0), llvm-amdgpu, libc6, rocm-core") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hsa-rocr-dev (>= 1.3), rocminfo, hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), comgr (>= 2.0), llvm-amdgpu, libc6") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-hcc (= ${CPACK_PACKAGE_VERSION})") set(CPACK_BINARY_RPM "ON") @@ -88,14 +88,8 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hsa-rocr-dev >= 1.3, rocminfo, hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, comgr >= 2.0, llvm-amdgpu, rocm-core") +set(CPACK_RPM_PACKAGE_REQUIRES "hsa-rocr-dev >= 1.3, rocminfo, hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, comgr >= 2.0, llvm-amdgpu") set(CPACK_RPM_PACKAGE_PROVIDES "hip-hcc = ${HIP_BASE_VERSION}") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") -# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake -set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -endif() include(CPack) diff --git a/packaging/hip-samples.txt b/packaging/hip-samples.txt index b4b7211c..f6dde380 100644 --- a/packaging/hip-samples.txt +++ b/packaging/hip-samples.txt @@ -43,7 +43,7 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), rocm-core") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})") set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-samples") set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_samples") @@ -53,15 +53,9 @@ set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, rocm-core") +set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}") set(CPACK_RPM_PACKAGE_OBSOLETES "hip_samples") set(CPACK_RPM_PACKAGE_CONFLICTS "hip_samples") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") -# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake -set(ROCM_DEP_ROCMCORE "@ROCM_DEP_ROCMCORE@") -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -endif() include(CPack) From ea92cc111635e317ad77e34ec0097545d1f87f27 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 27 Jan 2022 06:09:48 +0000 Subject: [PATCH 03/18] SWDEV-1 - Switch to new patch version Change-Id: I859f856a16e1ddc91bbe2b86339b2a3e6836488f --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71678c47..f3f3215f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,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_ENABLE_RTC "Enable/Disable pre-processed hiprtc shared lib" 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(HIP_OFFICIAL_BUILD "Enable/Disable for mainline/staging builds" ON) if(__HIP_ENABLE_PCH) set(_pchStatus 1) From 879c4e491fa27dd950b1fb6252871d6cfcc62cb6 Mon Sep 17 00:00:00 2001 From: Rakesh Roy Date: Fri, 20 Jan 2023 22:39:43 +0530 Subject: [PATCH 04/18] SWDEV-380109, SWDEV-375004 - Fix rocprim test failure - For !__HIPCC_RTC__ case, operator<<(std::ostream& os, const hip_bfloat16& bf16) calls itself in endless recursion - Convert hip_bfloat16 to float to fix this Change-Id: I252a656817550caf43c587cebf461474f12b8c0c (cherry picked from commit 26e8996ce868dd060e65ed60621dd2c9e358e17a) --- include/hip/amd_detail/amd_hip_bfloat16.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/hip/amd_detail/amd_hip_bfloat16.h b/include/hip/amd_detail/amd_hip_bfloat16.h index 8c7f7839..deb3bfb7 100644 --- a/include/hip/amd_detail/amd_hip_bfloat16.h +++ b/include/hip/amd_detail/amd_hip_bfloat16.h @@ -32,10 +32,8 @@ #include "host_defines.h" #if defined(__HIPCC_RTC__) #define __HOST_DEVICE__ __device__ - #define HIP_OSTREAM __hip_internal::ostream #else #define __HOST_DEVICE__ __host__ __device__ - #define HIP_OSTREAM std::ostream #endif #if __cplusplus < 201103L || !defined(__HIPCC__) @@ -181,12 +179,12 @@ static_assert(__hip_internal::is_trivial{}, static_assert(sizeof(hip_bfloat16) == sizeof(hip_bfloat16_public) && offsetof(hip_bfloat16, data) == offsetof(hip_bfloat16_public, data), "internal hip_bfloat16 does not match public hip_bfloat16"); -#endif -inline HIP_OSTREAM& operator<<(HIP_OSTREAM& os, const hip_bfloat16& bf16) +inline std::ostream& operator<<(std::ostream& os, const hip_bfloat16& bf16) { - return os << bf16; + return os << float(bf16); } +#endif inline __HOST_DEVICE__ hip_bfloat16 operator+(hip_bfloat16 a) { From 80d81cbc4938aa0740e7da37486dc9485705c79f Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Tue, 31 Jan 2023 13:22:22 +0000 Subject: [PATCH 05/18] SWDEV-380412, SWDEV-379395 - Use getQueue as it handles null stream and flags can be combination. Change-Id: If37854a9fc0fc57acb30e652953a7f283831cad8 (cherry picked from commit f5393b99a91df99967e6761bcb3c07c02be9573c) --- src/hip_module.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hip_module.cpp b/src/hip_module.cpp index f3ae2611..ae5d2660 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -516,7 +516,8 @@ hipError_t ihipModuleLaunchCooperativeKernelMultiDevice(hipFunctionLaunchParams* return hipErrorInvalidValue; } - if ((flags < 0) || (flags > hipCooperativeLaunchMultiDeviceNoPostSync)) { + if (flags > (hipCooperativeLaunchMultiDeviceNoPostSync + + hipCooperativeLaunchMultiDeviceNoPreSync)) { return hipErrorInvalidValue; } @@ -730,7 +731,7 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL return hipErrorInvalidValue; } - amd::HostQueue* queue = reinterpret_cast(launch.stream)->asHostQueue(); + amd::HostQueue* queue = hip::getQueue(launch.stream); hipFunction_t func = nullptr; // The order of devices in the launch may not match the order in the global array for (size_t dev = 0; dev < g_devices.size(); ++dev) { From 25a1d4ee84ac37f3afffe4ddbdb6073fdcfd59bc Mon Sep 17 00:00:00 2001 From: pghafari Date: Mon, 23 Jan 2023 18:06:18 -0500 Subject: [PATCH 06/18] SWDEV-381514 - adding scopelock for hipDeviceReset Change-Id: I3dd95a40d6abff721a4774f26e99d1162bafdfa1 (cherry picked from commit d589b47bcd131a28b0b17331717a20f882076639) --- src/hip_device.cpp | 15 +++++++++------ src/hip_internal.hpp | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hip_device.cpp b/src/hip_device.cpp index fedd62e5..a3d059ac 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -107,13 +107,16 @@ void Device::RemoveStreamFromPools(Stream* stream) { // ================================================================================================ void Device::Reset() { - auto it = mem_pools_.begin(); - while (it != mem_pools_.end()) { - auto current = it++; - (*current)->ReleaseAllMemory(); - delete *current; + { + amd::ScopedLock lock(lock_); + auto it = mem_pools_.begin(); + while (it != mem_pools_.end()) { + auto current = it++; + (*current)->ReleaseAllMemory(); + delete *current; + } + mem_pools_.clear(); } - mem_pools_.clear(); flags_ = hipDeviceScheduleSpin; hip::Stream::destroyAllStreams(deviceId_); amd::MemObjMap::Purge(devices()[0]); diff --git a/src/hip_internal.hpp b/src/hip_internal.hpp index 99bdf00d..9c4d3e47 100644 --- a/src/hip_internal.hpp +++ b/src/hip_internal.hpp @@ -382,7 +382,7 @@ namespace hip { /// HIP Device class class Device { - amd::Monitor lock_{"Device lock"}; + amd::Monitor lock_{"Device lock", true}; /// ROCclr context amd::Context* context_; /// Device's ID From 6d2c2d40c44d708db9739b633a0df5959b427b8f Mon Sep 17 00:00:00 2001 From: Anusha GodavarthySurya Date: Thu, 1 Dec 2022 13:22:06 +0000 Subject: [PATCH 07/18] SWDEV-380024 - Fix performance drop in TF-RCCL models Change-Id: Ie04219daacc29654d0f47e1c15ed5cd78d88d8c8 --- src/hip_event.cpp | 16 ++++++++-------- src/hip_event.hpp | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/hip_event.cpp b/src/hip_event.cpp index f556cabe..afe8621c 100644 --- a/src/hip_event.cpp +++ b/src/hip_event.cpp @@ -30,21 +30,21 @@ namespace hip { static amd::Monitor eventSetLock{"Guards global event set"}; static std::unordered_set eventSet; -bool Event::ready() { +bool Event::ready(eventType type) { if (event_->status() != CL_COMPLETE) { event_->notifyCmdQueue(); } // Check HW status of the ROCcrl event. Note: not all ROCclr modes support HW status - bool ready = g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_); + bool ready = CheckHwEvent(type); if (!ready) { ready = (event_->status() == CL_COMPLETE); } return ready; } -bool EventDD::ready() { +bool EventDD::ready(eventType type) { // Check HW status of the ROCcrl event. Note: not all ROCclr modes support HW status - bool ready = g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_); + bool ready = CheckHwEvent(type); // FIXME: Remove status check entirely if (!ready) { ready = (event_->status() == CL_COMPLETE); @@ -60,7 +60,7 @@ hipError_t Event::query() { return hipSuccess; } - return ready() ? hipSuccess : hipErrorNotReady; + return ready(Query) ? hipSuccess : hipErrorNotReady; } hipError_t Event::synchronize() { @@ -108,7 +108,7 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { return hipErrorInvalidHandle; } - if (!ready()) { + if (!ready(ElapsedTime)) { return hipErrorNotReady; } @@ -124,7 +124,7 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { return hipErrorInvalidHandle; } - if (!ready() || !eStop.ready()) { + if (!ready(ElapsedTime) || !eStop.ready(ElapsedTime)) { return hipErrorNotReady; } @@ -199,7 +199,7 @@ hipError_t Event::streamWait(hipStream_t stream, uint flags) { amd::HostQueue* queue = hip::getQueue(stream); // Access to event_ object must be lock protected amd::ScopedLock lock(lock_); - if ((event_ == nullptr) || (event_->command().queue() == queue) || ready()) { + if ((event_ == nullptr) || (event_->command().queue() == queue) || ready(StreamWait)) { return hipSuccess; } if (!event_->notifyCmdQueue()) { diff --git a/src/hip_event.hpp b/src/hip_event.hpp index e08ea33f..b3cd9d53 100644 --- a/src/hip_event.hpp +++ b/src/hip_event.hpp @@ -89,6 +89,7 @@ class EventMarker : public amd::Marker { } }; +enum eventType { Query, StreamWait, ElapsedTime }; class Event { /// event recorded on stream where capture is active bool onCapture_; @@ -96,6 +97,16 @@ class Event { hipStream_t captureStream_ = nullptr; /// Previous captured nodes before event record std::vector nodesPrevToRecorded_; + protected: + bool CheckHwEvent(eventType type) { + bool ready; + if (type == Query) { + ready = g_devices[deviceId()]->devices()[0]->IsHwEventReadyForcedWait(*event_); + } else { + ready = g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_); + } + return ready; + } public: Event(unsigned int flags) : flags(flags), lock_("hipEvent_t", true), @@ -170,7 +181,7 @@ class Event { return hipErrorInvalidConfiguration; } virtual bool awaitEventCompletion(); - virtual bool ready(); + virtual bool ready(eventType type); virtual int64_t time(bool getStartTs) const; protected: @@ -190,7 +201,7 @@ class EventDD : public Event { virtual ~EventDD() {} virtual bool awaitEventCompletion(); - virtual bool ready(); + virtual bool ready(eventType type); virtual int64_t time(bool getStartTs) const; }; From 263b9ab14818b7be59e87dbf7b15c47474b4aafd Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 13 Feb 2023 11:10:05 +0000 Subject: [PATCH 08/18] SWDEV-379941 - hipDeviceSetSharedMemConfig returns hipSuccess Change-Id: Ia587863d0b43376db976170f7506cc6ac00c90b8 --- src/hip_device_runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hip_device_runtime.cpp b/src/hip_device_runtime.cpp index def9bcb0..80210b5d 100644 --- a/src/hip_device_runtime.cpp +++ b/src/hip_device_runtime.cpp @@ -506,7 +506,7 @@ hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig config ) { // No way to set cache config yet. - HIP_RETURN(hipErrorNotSupported); + HIP_RETURN(hipSuccess); } hipError_t hipDeviceSynchronize ( void ) { From 9db82b8334e2896943b7790a2046689c2d4ee414 Mon Sep 17 00:00:00 2001 From: sdashmiz Date: Fri, 17 Feb 2023 14:21:59 -0500 Subject: [PATCH 09/18] SWDEV-379388 - remove check for stream capture ongoing for now Signed-off-by: sdashmiz Change-Id: I68771102ba4dff6157bca34a4135cb245f023d08 --- src/hip_event.cpp | 3 --- src/hip_stream.cpp | 6 ------ 2 files changed, 9 deletions(-) diff --git a/src/hip_event.cpp b/src/hip_event.cpp index afe8621c..cf301572 100644 --- a/src/hip_event.cpp +++ b/src/hip_event.cpp @@ -404,9 +404,6 @@ hipError_t hipEventSynchronize(hipEvent_t event) { HIP_RETURN(hipErrorInvalidHandle); } - if (hip::Stream::StreamCaptureOngoing() == true) { - HIP_RETURN(hipErrorStreamCaptureUnsupported); - } hip::Event* e = reinterpret_cast(event); HIP_RETURN(e->synchronize()); } diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index 3d1e9168..71d9630e 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -534,12 +534,6 @@ hipError_t hipStreamWaitEvent_common(hipStream_t stream, hipEvent_t event, unsig return hipErrorContextIsDestroyed; } - if (stream != nullptr) { - // If still capturing return error - if (hip::Stream::StreamCaptureOngoing() == true) { - HIP_RETURN(hipErrorStreamCaptureIsolation); - } - } hip::Event* e = reinterpret_cast(event); return e->streamWait(stream, flags); } From d32bf634c62bc76b6206079d1bb14e45322dbfea Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Tue, 21 Feb 2023 12:50:02 +0000 Subject: [PATCH 10/18] SWDEV-319526 - SE ID size incresed. Change-Id: Ia7df94d172102b321f12c8caa821e3a7e4447a21 (cherry picked from commit dfa0846fdcff4fafac0126c7eb43ba99e788e42c) --- include/hip/amd_detail/amd_device_functions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hip/amd_detail/amd_device_functions.h b/include/hip/amd_detail/amd_device_functions.h index ce421c63..1a4900db 100644 --- a/include/hip/amd_detail/amd_device_functions.h +++ b/include/hip/amd_detail/amd_device_functions.h @@ -922,7 +922,7 @@ int __syncthreads_or(int predicate) PIPE_ID 7:6 Pipeline from which the wave was dispatched. CU_ID 11:8 Compute Unit the wave is assigned to. SH_ID 12 Shader Array (within an SE) the wave is assigned to. - SE_ID 14:13 Shader Engine the wave is assigned to. + SE_ID 15:13 Shader Engine the wave is assigned to. TG_ID 19:16 Thread-group ID VM_ID 23:20 Virtual Memory ID QUEUE_ID 26:24 Queue from which this wave was dispatched. @@ -935,7 +935,7 @@ int __syncthreads_or(int predicate) #define HW_ID_CU_ID_SIZE 4 #define HW_ID_CU_ID_OFFSET 8 -#define HW_ID_SE_ID_SIZE 2 +#define HW_ID_SE_ID_SIZE 3 #define HW_ID_SE_ID_OFFSET 13 /* From bb2b6bb8075a8134abd23f0f6924fbf19c3cd0d6 Mon Sep 17 00:00:00 2001 From: Sourabh Betigeri Date: Fri, 10 Mar 2023 23:19:57 +0000 Subject: [PATCH 11/18] SWDEV-387810 - SWDEV-388582 - Fixes to verify if current stream matches the capture stream. - invalid to synchronize or query the execution status of a capturing stream but non-capturing streams can. Change-Id: Ifa641e807216d3b7c3e8c2fb1be2f7a50bd641df --- src/hip_device_runtime.cpp | 3 ++- src/hip_graph.cpp | 2 +- src/hip_internal.hpp | 3 ++- src/hip_stream.cpp | 20 +++++++++++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/hip_device_runtime.cpp b/src/hip_device_runtime.cpp index 80210b5d..86639e26 100644 --- a/src/hip_device_runtime.cpp +++ b/src/hip_device_runtime.cpp @@ -518,7 +518,8 @@ hipError_t hipDeviceSynchronize ( void ) { HIP_RETURN(hipErrorOutOfMemory); } - if (hip::Stream::StreamCaptureOngoing() == true) { + if (hip::Stream::StreamCaptureOngoing(reinterpret_cast( + hip::getCurrentDevice()->GetNullStream())) == true) { HIP_RETURN(hipErrorStreamCaptureUnsupported); } diff --git a/src/hip_graph.cpp b/src/hip_graph.cpp index 4b5d9e15..5d11dab0 100644 --- a/src/hip_graph.cpp +++ b/src/hip_graph.cpp @@ -29,7 +29,7 @@ std::vector g_captureStreams; amd::Monitor g_captureStreamsLock{"StreamCaptureGlobalList"}; -static amd::Monitor g_streamSetLock{"StreamCaptureset"}; +amd::Monitor g_streamSetLock{"StreamCaptureset"}; std::unordered_set g_allCapturingStreams; inline hipError_t ihipGraphAddNode(hipGraphNode_t graphNode, hipGraph_t graph, diff --git a/src/hip_internal.hpp b/src/hip_internal.hpp index 9c4d3e47..03808800 100644 --- a/src/hip_internal.hpp +++ b/src/hip_internal.hpp @@ -299,7 +299,7 @@ namespace hip { static void destroyAllStreams(int deviceId); /// Check Stream Capture status to make sure it is done - static bool StreamCaptureOngoing(void); + static bool StreamCaptureOngoing(hipStream_t hStream); /// Returns capture status of the current stream hipStreamCaptureStatus GetCaptureStatus() const { return captureStatus_; } @@ -569,5 +569,6 @@ constexpr bool kMarkerDisableFlush = true; //!< Avoids command batch flush in extern std::vector g_captureStreams; extern amd::Monitor g_captureStreamsLock; +extern amd::Monitor g_streamSetLock; extern std::unordered_set g_allCapturingStreams; #endif // HIP_SRC_HIP_INTERNAL_H diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index 71d9630e..f20f3998 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -211,8 +211,18 @@ void Stream::destroyAllStreams(int deviceId) { } } -bool Stream::StreamCaptureOngoing(void) { - return (g_allCapturingStreams.empty() == true) ? false : true; +bool Stream::StreamCaptureOngoing(hipStream_t hStream) { + hip::Stream* s = reinterpret_cast(hStream); + // If any local thread has an ongoing or concurrent capture sequence initiated + // with hipStreamCaptureModeGlobal, it is prohibited from unsafe calls + if (s != nullptr && s->GetCaptureMode() == hipStreamCaptureModeGlobal) { + amd::ScopedLock lock(g_captureStreamsLock); + return (g_captureStreams.empty() == true) ? false : true; + } + else { + amd::ScopedLock lock(g_streamSetLock); + return (g_allCapturingStreams.find(s) == g_allCapturingStreams.end() ? false : true); + } } };// hip namespace @@ -448,7 +458,7 @@ hipError_t hipStreamSynchronize_common(hipStream_t stream) { } if (stream != nullptr) { // If still capturing return error - if (hip::Stream::StreamCaptureOngoing() == true) { + if (hip::Stream::StreamCaptureOngoing(stream) == true) { HIP_RETURN(hipErrorStreamCaptureUnsupported); } } @@ -558,7 +568,7 @@ hipError_t hipStreamQuery_common(hipStream_t stream) { } if (stream != nullptr) { // If still capturing return error - if (hip::Stream::StreamCaptureOngoing() == true) { + if (hip::Stream::StreamCaptureOngoing(stream) == true) { HIP_RETURN(hipErrorStreamCaptureUnsupported); } } @@ -689,7 +699,7 @@ hipError_t hipLaunchHostFunc_spt(hipStream_t stream, hipHostFn_t fn, void* userD // ================================================================================================ hipError_t hipLaunchHostFunc(hipStream_t stream, hipHostFn_t fn, void* userData) { HIP_INIT_API(hipLaunchHostFunc, stream, fn, userData); - if (stream == nullptr) { + if (stream == nullptr && (hip::Stream::StreamCaptureOngoing(stream) == true)) { HIP_RETURN(hipErrorStreamCaptureImplicit); } HIP_RETURN(hipLaunchHostFunc_common(stream, fn, userData)); From c1741e9b671a58080b7150e11d9130e6a2f22dcb Mon Sep 17 00:00:00 2001 From: German Date: Mon, 27 Mar 2023 14:46:54 -0400 Subject: [PATCH 12/18] SWDEV-382359 - Workaround a non-uniform launch in MIOpen Change-Id: Idee06494a67e641301890863b376d9ef5965837d --- src/hip_module.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hip_module.cpp b/src/hip_module.cpp index ae5d2660..345f65bc 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -368,6 +368,12 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, if (status != hipSuccess) { return status; } + + // Make sure the app doesn't launch a workgroup bigger than the global size + if (globalWorkSizeX < blockDimX) blockDimX = globalWorkSizeX; + if (globalWorkSizeY < blockDimY) blockDimY = globalWorkSizeY; + if (globalWorkSizeZ < blockDimZ) blockDimZ = globalWorkSizeZ; + amd::Command* command = nullptr; amd::HostQueue* queue = hip::getQueue(hStream); status = ihipLaunchKernelCommand(command, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, From 8326bbbad02b8a03f85ab294af4542bfcc9d965c Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Wed, 29 Mar 2023 12:56:44 +0000 Subject: [PATCH 13/18] SWDEV-393361 - Extern monitor to avoid copy in multithreading. Defining monitor in header cause copy and hence it's moved to cpp. Change-Id: Ie79dd3db2ed55b3d44651146ac7e08b777277780 --- src/hip_context.cpp | 2 +- src/hip_internal.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hip_context.cpp b/src/hip_context.cpp index 824e6959..9f6fd930 100644 --- a/src/hip_context.cpp +++ b/src/hip_context.cpp @@ -26,7 +26,7 @@ #include "utils/versions.hpp" std::vector g_devices; - +amd::Monitor g_hipInitlock{"hipInit lock"}; namespace hip { thread_local TlsAggregator tls; Device* host_device = nullptr; diff --git a/src/hip_internal.hpp b/src/hip_internal.hpp index 03808800..b0b8f0c4 100644 --- a/src/hip_internal.hpp +++ b/src/hip_internal.hpp @@ -71,7 +71,7 @@ typedef struct ihipIpcEventHandle_st { const char* ihipGetErrorName(hipError_t hip_error); -static amd::Monitor g_hipInitlock{"hipInit lock"}; +extern amd::Monitor g_hipInitlock; #define HIP_INIT(noReturn) {\ amd::ScopedLock lock(g_hipInitlock); \ if (!amd::Runtime::initialized()) { \ From fc3e4cea7a069a27c0324f469b1384035325033b Mon Sep 17 00:00:00 2001 From: Sourabh Betigeri Date: Thu, 13 Apr 2023 22:59:59 +0000 Subject: [PATCH 14/18] SWDEV-392367 - Fixes hipMemGetAddressRange returning device buffer size as 0 Change-Id: I6b5640b544390b2dfc53fad271acc7f30240e274 --- src/hip_memory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index f3fcf68f..46316ed2 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -702,7 +702,8 @@ hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDevice // Since we are using SVM buffer DevicePtr and HostPtr is the same void* ptr = dptr; - amd::Memory* svmMem = getMemoryObjectWithOffset(ptr); + size_t offset = 0; + amd::Memory* svmMem = getMemoryObject(ptr, offset); if (svmMem == nullptr) { HIP_RETURN(hipErrorNotFound); } From 98466aaafef70600c60f4964fe771ef0c0539ccc Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 24 Apr 2023 09:58:54 +0000 Subject: [PATCH 15/18] SWDEV-379572 - hipDeviceSetCacheConfig returns hipSuccess Change-Id: Ided66d565f8cdb7fde52b4b3c0ad5adb9661b999 --- src/hip_device_runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hip_device_runtime.cpp b/src/hip_device_runtime.cpp index 86639e26..1a73ecd8 100644 --- a/src/hip_device_runtime.cpp +++ b/src/hip_device_runtime.cpp @@ -474,7 +474,7 @@ hipError_t hipDeviceSetCacheConfig ( hipFuncCache_t cacheConfig ) { // No way to set cache config yet. - HIP_RETURN(hipErrorNotSupported); + HIP_RETURN(hipSuccess); } hipError_t hipDeviceSetLimit ( hipLimit_t limit, size_t value ) { From 9671ea8432d8c959ffc7e3d9e7170be2bfe7aa54 Mon Sep 17 00:00:00 2001 From: Ajay Date: Wed, 22 Mar 2023 16:45:42 +0000 Subject: [PATCH 16/18] SWDEV-398541/SWDEV-390170 - guard deprecated runtime apis on CUDA 12.0 Change-Id: I4ab967c276dfa98f75d508b9484e8d1324b4e4a7 --- include/hip/nvidia_detail/nvidia_hip_runtime_api.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h index 0c492b7c..758fbc2c 100644 --- a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h +++ b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h @@ -39,6 +39,7 @@ THE SOFTWARE. #define CUDA_11030 11030 #define CUDA_11040 11040 #define CUDA_11060 11060 +#define CUDA_12000 12000 #ifdef __cplusplus extern "C" { @@ -2773,6 +2774,7 @@ inline static hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t return hipCUDAErrorTohipError(cudaFuncSetCacheConfig(func, cacheConfig)); } +#if CUDA_VERSION < CUDA_12000 __HIP_DEPRECATED inline static hipError_t hipBindTexture(size_t* offset, struct textureReference* tex, const void* devPtr, @@ -2786,6 +2788,8 @@ __HIP_DEPRECATED inline static hipError_t hipBindTexture2D( const hipChannelFormatDesc* desc, size_t width, size_t height, size_t pitch) { return hipCUDAErrorTohipError(cudaBindTexture2D(offset, tex, devPtr, desc, width, height, pitch)); } +#endif // CUDA_VERSION < CUDA_12000 + inline static hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f) { @@ -2818,10 +2822,12 @@ inline static hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDe return hipCUDAErrorTohipError(cudaGetTextureObjectResourceDesc( pResDesc, textureObject)); } +#if CUDA_VERSION < CUDA_12000 __HIP_DEPRECATED inline static hipError_t hipGetTextureAlignmentOffset( size_t* offset, const struct textureReference* texref) { return hipCUDAErrorTohipError(cudaGetTextureAlignmentOffset(offset,texref)); } +#endif inline static hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array) { @@ -3067,6 +3073,7 @@ inline static hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags( blockSize, dynamicSMemSize, flags)); } +#if CUDA_VERSION < CUDA_12000 template inline static hipError_t hipBindTexture(size_t* offset, const struct texture& tex, const void* devPtr, size_t size = UINT_MAX) { @@ -3109,6 +3116,7 @@ __HIP_DEPRECATED inline static hipError_t hipBindTextureToArray( struct texture& tex, hipArray_const_t array) { return hipCUDAErrorTohipError(cudaBindTextureToArray(tex, array)); } +#endif // CUDA_VERSION < CUDA_12000 template inline static hipChannelFormatDesc hipCreateChannelDesc() { From 1362d832cc03589dba10824149c5b9b6281b2017 Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 5 May 2023 00:08:27 +0000 Subject: [PATCH 17/18] SWDEV-398541/SWDEV-394488 - cudaStreamGetCaptureInfo_v2 is undefined in CUDA 12.0 hipStreamPerThrdCompilerOptn.cc test fails to build with cudaStreamGetCaptureInfo_v2 in CUDA 12.0. fix was to change runtime API cudaStreamGetCaptureInfo_v2 to Driver cuStreamGetCaptureInfo_v2 Change-Id: I23428f7088b49862fa58d3821a8a039970d491b5 --- include/hip/nvidia_detail/nvidia_hip_runtime_api.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h index 758fbc2c..2e5cebe5 100644 --- a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h +++ b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h @@ -3478,8 +3478,10 @@ inline static hipError_t hipStreamGetCaptureInfo_v2( hipStream_t stream, hipStreamCaptureStatus* captureStatus_out, unsigned long long* id_out __dparm(0), hipGraph_t* graph_out __dparm(0), const hipGraphNode_t** dependencies_out __dparm(0), size_t* numDependencies_out __dparm(0)) { - return hipCUDAErrorTohipError(cudaStreamGetCaptureInfo_v2( - stream, captureStatus_out, id_out, graph_out, dependencies_out, numDependencies_out)); + return hipCUResultTohipError(cuStreamGetCaptureInfo_v2( + stream, reinterpret_cast(captureStatus_out), + reinterpret_cast(id_out), graph_out, + dependencies_out, numDependencies_out)); } #endif From eaf00c0b70cdf41388ab919771757d009bc62996 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 5 May 2023 00:51:15 +0000 Subject: [PATCH 18/18] SWDEV-398296/SWDEV-393199 - Added new include file for opengl interop mappings for nvidia Change-Id: I1932d8fd924b7c7b8141084fef44659fa0a5305a --- .../hip/nvidia_detail/nvidia_hip_gl_interop.h | 44 +++++++++++++++++++ .../nvidia_detail/nvidia_hip_runtime_api.h | 19 -------- 2 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 include/hip/nvidia_detail/nvidia_hip_gl_interop.h diff --git a/include/hip/nvidia_detail/nvidia_hip_gl_interop.h b/include/hip/nvidia_detail/nvidia_hip_gl_interop.h new file mode 100644 index 00000000..ce2b2f3e --- /dev/null +++ b/include/hip/nvidia_detail/nvidia_hip_gl_interop.h @@ -0,0 +1,44 @@ +/* +Copyright (c) 2023 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. +*/ +#ifndef HIP_INCLUDE_NVIDIA_HIP_GL_INTEROP_H +#define HIP_INCLUDE_NVIDIA_HIP_GL_INTEROP_H + +#include + +typedef enum cudaGLDeviceList hipGLDeviceList; +#define hipGLDeviceListAll cudaGLDeviceListAll +#define hipGLDeviceListCurrentFrame cudaGLDeviceListCurrentFrame +#define hipGLDeviceListNextFrame cudaGLDeviceListNextFrame + +inline static hipError_t hipGLGetDevices(unsigned int* pHipDeviceCount, int* pHipDevices, unsigned int hipDeviceCount, + hipGLDeviceList deviceList) { + return hipCUDAErrorTohipError(cudaGLGetDevices(pHipDeviceCount, pHipDevices, hipDeviceCount, deviceList)); +} + +inline static hipError_t hipGraphicsGLRegisterBuffer(hipGraphicsResource** resource, GLuint buffer, unsigned int flags) { + return hipCUDAErrorTohipError(cudaGraphicsGLRegisterBuffer(resource, buffer, flags)); +} + +inline static hipError_t hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint image, GLenum target, unsigned int flags) { + return hipCUDAErrorTohipError(cudaGraphicsGLRegisterImage(resource, image, target, flags)); +} +#endif diff --git a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h index 2e5cebe5..f2ffc7f0 100644 --- a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h +++ b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h @@ -27,7 +27,6 @@ THE SOFTWARE. #include #include #include -#include #include @@ -1303,11 +1302,6 @@ typedef cudaExternalSemaphore_t hipExternalSemaphore_t; typedef struct cudaExternalSemaphoreSignalParams hipExternalSemaphoreSignalParams; typedef struct cudaExternalSemaphoreWaitParams hipExternalSemaphoreWaitParams; -typedef enum cudaGLDeviceList hipGLDeviceList; -#define hipGLDeviceListAll cudaGLDeviceListAll -#define hipGLDeviceListCurrentFrame cudaGLDeviceListCurrentFrame -#define hipGLDeviceListNextFrame cudaGLDeviceListNextFrame - typedef struct cudaGraphicsResource hipGraphicsResource; typedef cudaGraphicsResource_t hipGraphicsResource_t; @@ -2896,19 +2890,6 @@ inline static hipError_t hipDestroyExternalMemory(hipExternalMemory_t extMem) { return hipCUDAErrorTohipError(cudaDestroyExternalMemory(extMem)); } -inline static hipError_t hipGLGetDevices(unsigned int* pHipDeviceCount, int* pHipDevices, unsigned int hipDeviceCount, - hipGLDeviceList deviceList) { - return hipCUDAErrorTohipError(cudaGLGetDevices(pHipDeviceCount, pHipDevices, hipDeviceCount, deviceList)); -} - -inline static hipError_t hipGraphicsGLRegisterBuffer(hipGraphicsResource** resource, GLuint buffer, unsigned int flags) { - return hipCUDAErrorTohipError(cudaGraphicsGLRegisterBuffer(resource, buffer, flags)); -} - -inline static hipError_t hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint image, GLenum target, unsigned int flags) { - return hipCUDAErrorTohipError(cudaGraphicsGLRegisterImage(resource, image, target, flags)); -} - inline static hipError_t hipGraphicsMapResources(int count, hipGraphicsResource_t* resources, hipStream_t stream __dparm(0)) { return hipCUDAErrorTohipError(cudaGraphicsMapResources(count, resources, stream)); }