commit:     3a3bb43e54a6ea93fecdf9486e68fa748718a1c7
Author:     Patrick Lauer <patrick <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  3 06:30:45 2023 +0000
Commit:     罗百科 <patrick <AT> gentoo <DOT> org>
CommitDate: Sun Sep  3 06:31:23 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3a3bb43e

dev-util/rocminfo: add 5.5.1

Signed-off-by: Patrick Lauer <patrick <AT> gentoo.org>

 dev-util/rocminfo/Manifest                         |   1 +
 .../rocminfo-5.5.1-detect-builtin-amdgpu.patch     | 105 +++++++++++++++++++++
 dev-util/rocminfo/rocminfo-5.5.1.ebuild            |  38 ++++++++
 3 files changed, 144 insertions(+)

diff --git a/dev-util/rocminfo/Manifest b/dev-util/rocminfo/Manifest
index 2d12d0105a99..ca11bdb959f9 100644
--- a/dev-util/rocminfo/Manifest
+++ b/dev-util/rocminfo/Manifest
@@ -1,3 +1,4 @@
 DIST rocminfo-5.1.3.tar.gz 16772 BLAKE2B 
1b35661f9e6cd8cd5180ef3e4fd3dd8e7d6b282947d25c81b0b8bd347a5bee11cf87d950bbd8adcbd7a8a3053c41622b8e99fc0b56f4a14bdf4acf20992becc7
 SHA512 
998d499b0ae9a22bde30b2c26e31587a78b5ed63a19649d5b203eb47a044f17d1d4d3e951ec094d5be1ca3ba37efa4b19f5b53047727158170fa90c13a8c7563
 DIST rocminfo-5.3.3.tar.gz 16829 BLAKE2B 
341908048b9726a22ab5e81317916166d4ba114c5060fd8b7b455e0f4df3857b16a735cfccce2d013cd6632680e29b2e0c9ef91461d46b7e94dc71b0751aa42e
 SHA512 
336a408eb49eb8d40b506f58d62de3fd406d00b0de169bc3f6176c76f1f50366347d212de8783b5c48ae1b6660d307b276ba6b3bac8d8286f5e93cfe739c4dae
 DIST rocminfo-5.4.3.tar.gz 16832 BLAKE2B 
2344b6bd3ffecdfa657559e4d4d8c09de862ebcda287fd67db9864d19aab0a928b071bc43ddd4a24a31037c61500b1bb9697d11b3031c860c5bac77392c664ef
 SHA512 
80221c91f56cd04ba8dcbddd53bb47cb57bb97b74102890a7a43203e9a2fd572762025feb65676774f774a9a5f0d0a1293fc4508fc82d21b6b4042ad92210096
+DIST rocminfo-5.5.1.tar.gz 17020 BLAKE2B 
42fdbd32b7092306dc4442910ae922b616c859439511e2acfb17dee32557d77a9731aeb1d7ce25d32ae76f9cafd1e56476ac522545efe516d238d9285fa7b4a3
 SHA512 
5710979ee885bf35d40b7d07b157226ea4bb84bd14a2c57bdf8c93ca483685a8ce39d01f15b828d015968102457e9a94335a5273524d98eca76d0f8ceed2e8c1

diff --git a/dev-util/rocminfo/files/rocminfo-5.5.1-detect-builtin-amdgpu.patch 
b/dev-util/rocminfo/files/rocminfo-5.5.1-detect-builtin-amdgpu.patch
new file mode 100644
index 000000000000..dd1aefe4df4f
--- /dev/null
+++ b/dev-util/rocminfo/files/rocminfo-5.5.1-detect-builtin-amdgpu.patch
@@ -0,0 +1,105 @@
+From 3a4d533a1e2a179ad873c480dc4a42ea23681263 Mon Sep 17 00:00:00 2001
+From: Mike Li <[email protected]>
+Date: Wed, 17 Aug 2022 11:44:09 -0400
+Subject: [PATCH 1/2] Check permission and handle PermissionError exception
+
+Signed-off-by: Mike Li <[email protected]>
+Change-Id: If7cb8464d0b761e4be45c85eb7147ceed609da61
+---
+ rocm_agent_enumerator | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/rocm_agent_enumerator b/rocm_agent_enumerator
+index 6264a5f..ceb9e11 100755
+--- a/rocm_agent_enumerator
++++ b/rocm_agent_enumerator
+@@ -195,10 +195,15 @@ def readFromKFD():
+       node_path = os.path.join(topology_dir, node)
+       if os.path.isdir(node_path):
+         prop_path = node_path + '/properties'
+-        if os.path.isfile(prop_path):
++        if os.path.isfile(prop_path) and os.access(prop_path, os.R_OK):
+           target_search_term = re.compile("gfx_target_version.+")
+           with open(prop_path) as f:
+-            line = f.readline()
++            try:
++              line = f.readline()
++            except PermissionError:
++              # We may have a subsystem (e.g. scheduler) limiting device 
visibility which
++              # could cause a permission error.
++              line = ''
+             while line != '' :
+               search_result = target_search_term.search(line)
+               if search_result is not None:
+
+From 94b4b3f0a66eb70912177ca7076b4267f8b5449b Mon Sep 17 00:00:00 2001
+From: Johannes Dieterich <[email protected]>
+Date: Mon, 21 Nov 2022 18:09:55 +0000
+Subject: [PATCH 2/2] Fix rocminfo when run within docker environments
+
+Currently, rocminfo will fail when executed inside a docker container
+due to being unable to lsmod inside docker. This has impacts on
+rocprofiler use.
+
+Fix this behavior by querying initstate of the amdgpu module from
+/sys/module/amdgpu instead. If initstate is marked "live" everything if
+fine - error out with either "not loaded" (initstate file does not
+exist) or "not live" (initstate file does not contain "live" string).
+
+Change-Id: I6f2e9655942fd4cf840fd3f56b7d69e893fa84d7
+---
+ rocminfo.cc | 30 ++++++++++++++++++++++++------
+ 1 file changed, 24 insertions(+), 6 deletions(-)
+
+diff --git a/rocminfo.cc b/rocminfo.cc
+index 0842d57..8ed9111 100755
+--- a/rocminfo.cc
++++ b/rocminfo.cc
+@@ -51,6 +51,7 @@
+ #include <unistd.h>
+ #include <pwd.h>
+ 
++#include <fstream>
+ #include <vector>
+ #include <string>
+ #include <sstream>
+@@ -1039,16 +1040,33 @@ AcquireAndDisplayAgentInfo(hsa_agent_t agent, void* 
data) {
+ 
+ int CheckInitialState(void) {
+   // Check kernel module for ROCk is loaded
+-  FILE *fd = popen("lsmod | grep amdgpu", "r");
+-  char buf[16];
+-  if (fread (buf, 1, sizeof (buf), fd) == 0) {
++
++  std::ifstream amdgpu_initstate("/sys/module/amdgpu/initstate");
++  if (amdgpu_initstate){
++    std::stringstream buffer;
++    buffer << amdgpu_initstate.rdbuf();
++    amdgpu_initstate.close();
++
++    std::string line;
++    bool is_live = false;
++    while (std::getline(buffer, line)){
++      if (line.find( "live" ) != std::string::npos){
++        is_live = true;
++        break;
++      }
++    }
++    if (is_live){
++      printf("%sROCk module is loaded%s\n", COL_WHT, COL_RESET);
++    } else {
++      printf("%sROCk module is NOT live, possibly no GPU devices%s\n",
++                                                          COL_RED, COL_RESET);
++      return -1;
++    }
++  } else {
+     printf("%sROCk module is NOT loaded, possibly no GPU devices%s\n",
+                                                           COL_RED, COL_RESET);
+     return -1;
+-  } else {
+-    printf("%sROCk module is loaded%s\n", COL_WHT, COL_RESET);
+   }
+-  pclose(fd);
+ 
+   // Check if user belongs to the group for /dev/kfd (e.g. "video" or
+   // "render")

diff --git a/dev-util/rocminfo/rocminfo-5.5.1.ebuild 
b/dev-util/rocminfo/rocminfo-5.5.1.ebuild
new file mode 100644
index 000000000000..296b859a1fd3
--- /dev/null
+++ b/dev-util/rocminfo/rocminfo-5.5.1.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake
+
+if [[ ${PV} == *9999 ]] ; then
+       EGIT_REPO_URI="https://github.com/RadeonOpenCompute/rocminfo/";
+       inherit git-r3
+else
+       
SRC_URI="https://github.com/RadeonOpenCompute/rocminfo/archive/rocm-${PV}.tar.gz
 -> ${P}.tar.gz"
+       KEYWORDS="~amd64"
+       S="${WORKDIR}/rocminfo-rocm-${PV}"
+fi
+
+DESCRIPTION="ROCm Application for Reporting System Info"
+HOMEPAGE="https://github.com/RadeonOpenCompute/rocminfo";
+LICENSE="UoI-NCSA"
+SLOT="0/$(ver_cut 1-2)"
+
+RDEPEND=">=dev-libs/rocr-runtime-${PV}"
+DEPEND="${RDEPEND}"
+
+#PATCHES=(
+#      "${FILESDIR}/${PN}-5.5.1-detect-builtin-amdgpu.patch"
+#)
+
+src_prepare() {
+       sed -e "/CPACK_RESOURCE_FILE_LICENSE/d" -i CMakeLists.txt || die
+       sed -e "/num_change_since_prev_pkg(/cset(NUM_COMMITS 0)" -i 
cmake_modules/utils.cmake || die # Fix QA issue on "git not found"
+       cmake_src_prepare
+}
+
+src_configure() {
+       local mycmakeargs=( -DROCRTST_BLD_TYPE=Release )
+       cmake_src_configure
+}

Reply via email to