[PATCH 0/2] gnu: Update rocm to 5.1.3.

DoneSubmitted by John Kehayias.
Details
3 participants
  • John Kehayias
  • Lars-Dominik Braun
  • Ludovic Courtès
Owner
unassigned
Severity
normal
J
J
John Kehayias wrote on 13 Jun 19:23 +0200
(name . Guix-patches)(address . guix-patches@gnu.org)
ForlI9pwyimRYtR94XmPipgXx6bzs-Y1jQCExNj9rQaTxBedIjgvrK4nW2nEzO2YbLkDH79uRpzxmlC128hf7Tcy3Jnf7U6SNUAjRg36Xwk=@protonmail.com
Hi Guixers,

Incoming are two patches to update the rocm packages (AMD's OpenCL stuff) to the latest version. With this I can use OpenCL in Darktable with my current gen GPU (note: I'm not on linux-libre, which likely impacts what cards can be used).

I tested that everything builds and darktable-cltest reports successful output, as well as rocminfo. E.g. running

./pre-inst-env guix shell rocm-opencl-runtime rocm-device-libs opencl-icd-loader darktable -- darktable-cltest

A few quick notes on these patches. Most of this was discussed on IRC recently, but for the record:

1. llvm-for-rocm: The first patch updates this to use llvm-14, which is what the current rocm version is based on.

2. rocm: All of the packages are updated in one commit as they share a version number and there some interdependencies.

3. rocclr: This is no longer meant as a standalone package: cmake will output a warning and there is no install to be done. It is meant to be included in packages that use it. I've made a plain origin for the rocclr source that is needed (see rocm-opencl-runtime that uses it) and renamed the old version to rocclr-4 since that will still build/install in case it is of use.

This is the commit that changed the build behavior, active since v4.5 at least: https://github.com/ROCm-Developer-Tools/ROCclr/commit/df1449608e92c9e42b4ce5799e6eb51934ae7d4a

4. Relatedly, both Arch and Gentoo build rocclr before building rocm-opencl-runtime, but this doesn't seem to do anything. Unfortunately the rocm readmes are unclear/not up to date on exactly what is needed. From my testing, just setting a configure flag to point to the rocclr source is all that is needed.

The Arch and Gentoo recipes are here:



We can do the same thing by adding in this phase for rocm-opencl-runtime. I did not see any change in the final output and everything (with Darktable) seemed fine without it. It will take a little longer to build as it does build rocclr explicitly. Anyway, in case it is of use to anyone, here is the code

(add-before 'configure 'configure-rocclr
(lambda* (#:key inputs #:allow-other-keys)
(invoke "cmake" (string-append "-DAMD_OPENCL_PATH="
#$(package-source this-package))
"-B build-rocclr" "-S" #$rocclr-src)
(invoke "make" "-C" "build-rocclr")))

Okay, that's it! Overall is mostly updating hashes and some patches, other than the rocclr notes above. I hope I got the (long) commit message correct on the second patch. The changes work well for me locally.

Thanks!
John
J
J
John Kehayias wrote on 13 Jun 19:25 +0200
[PATCH 1/2] gnu: Update llvm-for-rocm to 5.1.3.
(name . 55948@debbugs.gnu.org)(address . 55948@debbugs.gnu.org)
ZPzTkbGFoM3QlIk5ZlQkjzhPZX9kfyzWSxSPt7LFVmkqWxIm0phcnzans3rIZLUC4myOvDqkJ51zFiT1akRqwpco6AABdwzg6omPLgSX6GE=@protonmail.com
Empty Message
From a4e57b69b4de183952a85cdb0d86c3d952b9d990 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Sun, 12 Jun 2022 17:03:40 -0400
Subject: [PATCH 1/2] gnu: Update llvm-for-rocm: Update to 5.1.3.

* gnu/packages/llvm.scm (llvm-for-rocm): Update to 5.1.3, now based on llvm-14.
[source]{patches}: Remove unneeded patches (add_Object and add_libraries) and add new one (linkdl).
* gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch,
gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch: Delete files.
* gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch: New file.
* gnu/local.mk (dist_patch_DATA): Update to match current patches.
---
gnu/local.mk | 3 +--
gnu/packages/llvm.scm | 14 ++++++------
.../llvm-roc-3.0.0-add_libraries.patch | 22 -------------------
.../patches/llvm-roc-4.2.0-add_Object.patch | 13 -----------
.../patches/llvm-roc-5.0.0-linkdl.patch | 15 +++++++++++++
5 files changed, 23 insertions(+), 44 deletions(-)
delete mode 100644 gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
delete mode 100644 gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
create mode 100644 gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch

Toggle diff (133 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 03e180cc85..ddf843ab3a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1451,9 +1451,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch	\
   %D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch	\
   %D%/packages/patches/llvm-9-fix-scev-miscompilation.patch	\
-  %D%/packages/patches/llvm-roc-3.0.0-add_libraries.patch \
   %D%/packages/patches/llvm-roc-4.0.0-remove-isystem-usr-include.patch \
-  %D%/packages/patches/llvm-roc-4.2.0-add_Object.patch \
+  %D%/packages/patches/llvm-roc-5.0.0-linkdl.patch \
   %D%/packages/patches/lm-sensors-hwmon-attrs.patch		\
   %D%/packages/patches/lrcalc-includes.patch    		\
   %D%/packages/patches/lsh-fix-x11-forwarding.patch		\
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 8bc9e8904c..98c4e0122d 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Greg Hogan <code@greghogan.com>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1109,10 +1110,10 @@ (define-public clang-toolchain clang-toolchain-13)
 
 (define-public llvm-for-rocm
   (package
-    ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine.
-    (inherit llvm-12)
+    ;; Based on LLVM 14 as of v5.0.0
+    (inherit llvm-14)
     (name "llvm-for-rocm")
-    (version "4.3.0")                         ;this must match '%rocm-version'
+    (version "5.1.3")                         ;this must match '%rocm-version'
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -1121,10 +1122,9 @@ (define-public llvm-for-rocm
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0p75nr1qpmy6crymdax5hm40wkimman4lnglz4x5cnbiqindya7s"))
+                "0j6ydfkwrxwskgnhxc3cmry42n5faqbnwf2747qgf7lz5id8h8g5"))
               (patches
-               (search-patches "llvm-roc-4.2.0-add_Object.patch"
-                               "llvm-roc-3.0.0-add_libraries.patch"
+               (search-patches "llvm-roc-5.0.0-linkdl.patch"
                                "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
     (arguments
      (substitute-keyword-arguments (package-arguments llvm-12)
@@ -1141,7 +1141,7 @@ (define-public llvm-for-rocm
            "-DBUILD_SHARED_LIBS:BOOL=TRUE"
            "-DLLVM_VERSION_SUFFIX="))))
     (properties `((hidden? . #t)
-                  ,@(package-properties llvm-12)))))
+                  ,@(package-properties llvm-14)))))
 
 
 
diff --git a/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch b/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
deleted file mode 100644
index f6bc639f33..0000000000
--- a/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files
-
-diff -Naur a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
---- a/clang/lib/Basic/CMakeLists.txt	2019-12-28 07:42:49.119055933 +0100
-+++ b/clang/lib/Basic/CMakeLists.txt	2019-12-28 07:42:13.265056070 +0100
-@@ -2,6 +2,7 @@
-   Core
-   MC
-   Support
-+  Option
-   )
- 
- find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
-diff -Naur a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
---- a/clang/lib/Driver/CMakeLists.txt	2019-12-28 07:41:39.521056199 +0100
-+++ b/clang/lib/Driver/CMakeLists.txt	2019-12-28 07:40:23.998056487 +0100
-@@ -79,4 +79,5 @@
-   LINK_LIBS
-   clangBasic
-   ${system_libs}
-+  pthread
-   )
diff --git a/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch b/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
deleted file mode 100644
index f1762a558b..0000000000
--- a/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files
-
-diff --color -uprN orig/lib/Target/AMDGPU/Disassembler/CMakeLists.txt llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
---- a/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt	2021-06-14 11:57:54.222796911 +0800
-+++ b/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt	2021-06-14 11:58:35.206796875 +0800
-@@ -11,6 +11,7 @@ add_llvm_component_library(LLVMAMDGPUDis
-   MC
-   MCDisassembler
-   Support
-+  Object
- 
-   ADD_TO_COMPONENT
-   AMDGPU
diff --git a/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch b/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch
new file mode 100644
index 0000000000..d6ed3aef93
--- /dev/null
+++ b/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch
@@ -0,0 +1,15 @@
+Taken from the Gentoo patch:
+https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files/llvm-roc-5.0.0-linkdl.patch
+
+LLVMOffloadArch should link libdl to fix undefined symbol 'dlsym' when linking
+
+--- a/llvm/lib/OffloadArch/offload-arch/CMakeLists.txt
++++ b/llvm/lib/OffloadArch/offload-arch/CMakeLists.txt
+@@ -3,6 +3,7 @@ add_llvm_tool(offload-arch
+   ${CMAKE_CURRENT_SOURCE_DIR}/offload-arch.cpp
+   DEPENDS generated-table LLVMOffloadArch
+ )
++target_link_libraries(LLVMOffloadArch PRIVATE ${CMAKE_DL_LIBS})
+ target_link_libraries(offload-arch PRIVATE LLVMOffloadArch)
+ 
+ if(CMAKE_HOST_UNIX)
-- 
2.36.1
J
J
John Kehayias wrote on 13 Jun 19:26 +0200
[PATCH 2/2] gnu: rocm: Update to 5.1.3.
(name . 55948@debbugs.gnu.org)(address . 55948@debbugs.gnu.org)
0Lex6E3kVY8eDx6QwUBXpTCvDjY_V_gBBkbFE253mPSFzaVeI27X0EKOlk3FyF_Qa9n3e1L5cjvt9no0LvuQmjArS2_79dE22nDUbhxxWiU=@protonmail.com
Empty Message
From ea4977f27d1758d7affb3e954edd6c77f4851981 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Mon, 13 Jun 2022 11:36:23 -0400
Subject: [PATCH 2/2] gnu: rocm: Update to 5.1.3.

All packages updated at the same time as they have a shared version. rocclr is
no longer a stand-alone package, so the previous version is kept as rocclr-4
and the current version is just the source, rocclr-src, needed by rocm-opencl-runtime.

* gnu/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch: Delete files.
* gnu/local.mk (dist_patch_DATA): Remove them.
* gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch: Update patches.
* gnu/packages/rocm.scm (rocm-cmake, rocm-device-libs, rocm-comgr,
roct-thunk-interface, rocr-runtime, rocm-opencl-runtime, rocminfo,
rocm-bandwidth-test): Update to 5.1.3.
(roct-thunk-interface)[inputs]: Add libdrm.
[native-inputs]: Add gcc:lib and pkg-config.
(rocclr-src): New variable.
(rocclr-4): New variable (previous version of the package).
(rocm-opencl-runtime)[source]: Remove obsolete patches.
[arguments]: Rewrite with gexps. Add needed #:configure-flags.
[inputs]: Remove rocclr, add numactl.
---
gnu/local.mk | 2 -
.../rocm-comgr-3.1.0-dependencies.patch | 11 ++-
.../rocm-opencl-runtime-3.10.0-includes.patch | 14 ---
.../rocm-opencl-runtime-4.3-noclinfo.patch | 29 +++---
.../rocm-opencl-runtime-4.3-nocltrace.patch | 25 -----
.../rocm-opencl-runtime-4.3-noopencl.patch | 65 +++++++------
gnu/packages/rocm.scm | 95 +++++++++++--------
7 files changed, 115 insertions(+), 126 deletions(-)
delete mode 100644 gnu/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch
delete mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch

Toggle diff (180 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index ddf843ab3a..c8a24e3ef3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1758,9 +1758,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/rnp-disable-ruby-rnp-tests.patch		\
   %D%/packages/patches/rnp-unbundle-googletest.patch		\
   %D%/packages/patches/rocm-comgr-3.1.0-dependencies.patch \
-  %D%/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch \
   %D%/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch \
-  %D%/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch \
   %D%/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch \
   %D%/packages/patches/ruby-mustache-1.1.1-fix-race-condition-tests.patch \
   %D%/packages/patches/ruby-sanitize-system-libxml.patch	\
diff --git a/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch b/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
index c91d273f92..fc2c74718a 100644
--- a/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
+++ b/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
@@ -11,11 +11,11 @@ Without these additional required dependencies, linking fails with errors such a
  CMakeLists.txt | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
 
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 1794a07..c7b852a 100644
+diff --git a/lib/comgr/CMakeLists.txt b/lib/comgr/CMakeLists.txt
+index 8b5ca2f..a7d226f 100644
 --- a/lib/comgr/CMakeLists.txt
 +++ b/lib/comgr/CMakeLists.txt
-@@ -207,7 +207,11 @@ install(FILES
+@@ -294,7 +294,11 @@ install(FILES
    DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
  
  set(CLANG_LIBS
@@ -28,7 +28,7 @@ index 1794a07..c7b852a 100644
  
  set(LLD_LIBS
    lldELF
-@@ -218,8 +222,20 @@ if (LLVM_LINK_LLVM_DYLIB)
+@@ -305,8 +309,21 @@ if (LLVM_LINK_LLVM_DYLIB)
  else()
    llvm_map_components_to_libnames(LLVM_LIBS
      ${LLVM_TARGETS_TO_BUILD}
@@ -46,7 +46,8 @@ index 1794a07..c7b852a 100644
 +    IRReader
 +    CodeGen
 +    Linker
++    Demangle
 +    BinaryFormat)
  endif()
  
- target_link_libraries(amd_comgr
+ target_link_options(amd_comgr
diff --git a/gnu/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch b/gnu/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch
deleted file mode 100644
index d81bb0747f..0000000000
--- a/gnu/packages/patches/rocm-opencl-runtime-3.10.0-includes.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-Add missing include dirs for ROCclr.
-
---- a/amdocl/CMakeLists.txt	2020-12-05 22:05:55.838529158 +0100
-+++ b/amdocl/CMakeLists.txt	2020-12-05 22:07:35.677524507 +0100
-@@ -23,6 +23,9 @@
- include_directories(${CMAKE_CURRENT_LIST_DIR}/../khronos)
- include_directories(${CMAKE_CURRENT_LIST_DIR}/../khronos/headers)
- include_directories(${CMAKE_CURRENT_LIST_DIR}/../khronos/headers/opencl2.2)
-+include_directories(${ROCclr_DIR}/../../../include)
-+include_directories(${ROCclr_DIR}/../../../include/compiler/lib/include/)
-+include_directories(${ROCclr_DIR}/../../../include/elf/)
- 
- if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
-    (CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang"))
diff --git a/gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch b/gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch
index 5709e0d19a..97376fd421 100644
--- a/gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch
+++ b/gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch
@@ -4,25 +4,26 @@ diff --git a/CMakeLists.txt.orig b/CMakeLists.txt
 index 76847d3..3f62bfe 100644
 --- a/CMakeLists.txt.orig
 +++ b/CMakeLists.txt
-@@ -72,7 +72,7 @@ find_package(ROCclr REQUIRED CONFIG
+@@ -15,9 +15,9 @@ option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorganization backward co
  
- add_subdirectory(khronos/icd)
+ 
+ set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/khronos/headers/opencl2.2" CACHE PATH "")
+ #add_subdirectory(khronos/icd)
  add_subdirectory(amdocl)
 -add_subdirectory(tools/clinfo)
 +#add_subdirectory(tools/clinfo)
  add_subdirectory(tools/cltrace)
  if(BUILD_TESTS)
    add_subdirectory(tests/ocltst)
-@@ -108,9 +108,9 @@ endif()
- ###--- Packaging ------------------------------------------------------------###
+diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt
+index 48353eb..cd1e7c1 100644
+--- a/packaging/CMakeLists.txt
++++ b/packaging/CMakeLists.txt
+@@ -5,6 +5,6 @@ set(CPACK_COMPONENTS_ALL binary dev icd)
+ set(CPACK_DEB_COMPONENT_INSTALL ON)
+ set(CPACK_RPM_COMPONENT_INSTALL ON)
  
- # MAIN package
--install(PROGRAMS $<TARGET_FILE:clinfo>
--        DESTINATION bin
--        COMPONENT MAIN)
-+#install(PROGRAMS $<TARGET_FILE:clinfo>
-+#        DESTINATION bin
-+#        COMPONENT MAIN)
- install(PROGRAMS $<TARGET_FILE:cltrace>
-         DESTINATION lib
-         COMPONENT MAIN)
+-install(TARGETS clinfo DESTINATION bin COMPONENT binary)
++#install(TARGETS clinfo DESTINATION bin COMPONENT binary)
+ install(TARGETS amdocl DESTINATION lib COMPONENT binary)
+ install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.txt DESTINATION share/doc/${CMAKE_PROJECT_NAME} COMPONENT binary)
diff --git a/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch b/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch
deleted file mode 100644
index e0328d7734..0000000000
--- a/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-Do not build and install cltrace.
-
-diff --git a/CMakeLists.txt.orig b/CMakeLists.txt
-index c449db4..9cff673 100644
---- a/CMakeLists.txt.orig
-+++ b/CMakeLists.txt
-@@ -73,7 +73,7 @@ find_package(ROCclr REQUIRED CONFIG
- #add_subdirectory(khronos/icd)
- add_subdirectory(amdocl)
- #add_subdirectory(tools/clinfo)
--add_subdirectory(tools/cltrace)
-+#add_subdirectory(tools/cltrace)
- if(BUILD_TESTS)
-   add_subdirectory(tests/ocltst)
- endif()
-@@ -108,9 +108,6 @@ endif()
- #install(PROGRAMS $<TARGET_FILE:clinfo>
- #        DESTINATION bin
- #        COMPONENT MAIN)
--install(PROGRAMS $<TARGET_FILE:cltrace>
--        DESTINATION lib
--        COMPONENT MAIN)
- install(PROGRAMS $<TARGET_FILE:amdocl64>
-         DESTINATION lib
-         COMPONENT MAIN)
diff --git a/gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch b/gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch
index ed20f02503..9f80d7da9d 100644
--- a/gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch
+++ b/gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch
@@ -2,36 +2,21 @@ Do not build and install libOpenCL.
 
 --- b/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -70,7 +70,7 @@
-     ${ROCclr_DIR}
-     ${LIBROCclr_STATIC_DIR})
+@@ -15,9 +15,9 @@ option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorganization backward co
  
+ 
+ set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/khronos/headers/opencl2.2" CACHE PATH "")
 -add_subdirectory(khronos/icd)
 +#add_subdirectory(khronos/icd)
  add_subdirectory(amdocl)
- #add_subdirectory(tools/clinfo)
+ add_subdirectory(tools/clinfo)
  add_subdirectory(tools/cltrace)
-@@ -93,9 +93,6 @@
-     OUTPUT_VARIABLE OPENCL_VERSION_GITDATE
-     OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(BUILD_TESTS)
+   add_subdirectory(tests/ocltst)
+@@ -25,16 +25,6 @@ endif()
+ 
+ ###--- Packaging ------------------------------------------------------------###
  
--get_target_property(OPENCL_LIB_VERSION_MAJOR OpenCL SOVERSION)
--get_target_property(OPENCL_LIB_VERSION_STRING OpenCL VERSION)
--
- find_package(ROCM QUIET CONFIG PATHS /opt/rocm)
-
- if(ROCM_FOUND)
-@@ -117,25 +114,6 @@
- install(PROGRAMS $<TARGET_FILE:amdocl64>
- DESTINATION lib
- COMPONENT MAIN)
--install(PROGRAMS $<TARGET_FILE:OpenCL>
-- DESTINATION lib
-- COMPONENT MAIN)
--install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
-- DESTINATION lib
-- COMPONENT MAIN)
--
-# DEV package
-install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2/CL"
- DESTINATION include
@@ -41,15 +26,26 @@ Do not build and install libOpenCL.
- PATTERN cl_d3d11.h EXCLUDE
- PATTERN cl_dx9_media_sharing.h EXCLUDE
- PATTERN cl_egl.h EXCLUDE)
--install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
-- DESTINATION lib
-- COMPONENT DEV)
-
+-
#############################
# Packaging steps
+ #############################
+@@ -53,8 +43,8 @@ if (DEFINED ROCM_PATCH_VERSION)
+ set(OPENCL_AMD_ICD_FILE "amdocl64_${ROCM_PATCH_VERSION}.icd")
+ endif()
+
+-get_target_property(OPENCL_LIB_VERSION_MAJOR OpenCL SOVERSION)
+-get_target_property(OPENCL_LIB_VERSION_STRING OpenCL VERSION)
++#get_target_property(OPENCL_LIB_VERSION_MAJOR OpenCL SOVERSION)
++#get_target_property(OPENCL_LIB_VERSION_STRING OpenCL VERSION)
+
+ #Set Package Version
+ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
+diff --git a/khronos/icd/CMakeLists.txt b/khronos/icd/CMakeLists.txt
+index 4bafa86..987dd6f 100644
--- a/khronos/icd/CMakeLists.txt 2020-06-07 16:05:32.425022904 +0200
+++ b/khronos/icd/CMakeLists.txt 2020-06-07 16:06:03.273022786 +0200
-@@ -132,7 +132,7 @@
+@@ -132,7 +132,7 @@ if (BUILD_TESTING)
add_subdirectory (test)
endif()
@@ -61,3 +57,14 @@ Do not build and install libOpenCL.
+# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt
+index 48353eb..cd1e7c1 100644
+--- a/packaging/CMakeLists.txt
++++ b/packaging/CMakeLists.txt
+@@ -17,5 +17,5 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/khronos/headers/opencl2.2/CL
+ PATTERN cl_dx9_media_sharing.h EXCLUDE
+ PATTERN cl_egl.h EXCLUDE )
+
+-install(TARGETS OpenCL DESTINATION lib COMPONENT icd )
++#install(TARGETS OpenCL DESTINATION lib COMPONENT icd )
+ install(FILES ${CMAKE_SOURCE_DIR}/khronos/icd/LICENSE DESTINATION share/doc/rocm-ocl-icd COMPONENT icd)
Toggle diff (202 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 2ccc6d3251..6c1a83cc88 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This program is free software; you can redistribute it and/or modify it
 ;;; under the terms of the GNU General Public License as published by
@@ -18,21 +19,25 @@ (define-module (gnu packages rocm)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
   #:use-module (gnu packages elf)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages opencl)
+  #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages version-control)
-  #:use-module (gnu packages vim))
+  #:use-module (gnu packages vim)
+  #:use-module (gnu packages xdisorg))
 
 ;; The components are tightly integrated and can only be upgraded as a unit. If
 ;; you want to upgrade ROCm, bump this version number and update hashes below.
-(define %rocm-version "4.3.0")
+(define %rocm-version "5.1.3")
 
 (define-public rocm-cmake
   (package
@@ -46,7 +51,7 @@ (define-public rocm-cmake
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0sic2zxmzl2pb2865vvq55mbpcr8pby8v19pjdlm08pypqw5h6h6"))))
+                "1bn3l04qnc1ls9abs15s1sgsrwmkfk0g8jgdjqshrcr3ab8ffcpf"))))
     (build-system cmake-build-system)
     (arguments `(#:tests? #f)) ; Tests try to use git commit
     (native-inputs (list git))
@@ -68,7 +73,7 @@ (define-public rocm-device-libs
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "1f8xsylfajpxqjk6ayjnrry53y8b0a6lh9d72pd41nffxfyzvw3w"))))
+                "07vkrxxc49i72r0lcl6dap0qcw1bignsw920rj4h1mac3bwa8q4j"))))
     (build-system cmake-build-system)
     (arguments
      `(#:configure-flags
@@ -93,7 +98,7 @@ (define-public rocm-comgr
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0bakbm7shr0l67lph44b5cnc9psd6rivg1mp79qizaawkn380x60"))
+                "1achb3216cbm7x2d05xj7j7ivn24y11q2d2p5whw3v4ykgfqql6f"))
               (patches
                (search-patches "rocm-comgr-3.1.0-dependencies.patch"))))
     (build-system cmake-build-system)
@@ -125,10 +130,11 @@ (define-public roct-thunk-interface
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0ffqhrrscmcydfqf61dk58d7nnxk6n2k68jhqfj7a4hvhlphb74f"))))
+                "0k5bchq1jhgraqrhj9q47b45n33wnd2ipwrrj39q51jzxmyyzxj2"))))
     (build-system cmake-build-system)
     (arguments `(#:tests? #f)) ; Not sure how to run tests.
-    (inputs (list numactl))
+    (inputs (list libdrm numactl))
+    (native-inputs (list `(,gcc "lib") pkg-config))
     (home-page "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface")
     (synopsis "Radeon Open Compute Thunk Interface")
     (description "User-mode API interfaces used to interact with the ROCk
@@ -147,7 +153,7 @@ (define-public rocr-runtime
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0jqfqf5ymwlbpac065bhigmkgsk7mbyimdgvca7ymn38wpf80ka7"))))
+                "1j1cy64w13plgsy20mir4xm6x4xnwkyil3g03xnda6ynhd7bkhv7"))))
     (build-system cmake-build-system)
     (arguments
      `(#:configure-flags
@@ -174,10 +180,23 @@ (define-public rocr-runtime
 applications to launch compute kernels to available HSA ROCm kernel agents.")
     (license license:ncsa)))
 
-(define-public rocclr
+;; This is the source only for ROCclr as from v4.5 it should only be built as
+;; part of a client.  A warning is output if attempting to build stand-alone
+;; and there is no install.  The previous version is kept as rocclr-4.
+(define rocclr-src
+  (origin
+    (method git-fetch)
+    (uri (git-reference
+          (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
+          (commit (string-append "rocm-" %rocm-version))))
+    (sha256
+     (base32
+      "0x1frzpz9j1s516vscbdm9g5cqirvv5w7wmq2kyljcygnci7yqar"))))
+
+(define-public rocclr-4
   (package
-    (name "rocclr")
-    (version %rocm-version)
+    (name "rocclr-4")
+    (version "4.3.0")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -232,39 +251,41 @@ (define-public rocm-opencl-runtime
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))
+                "1rirvc8h0ahicw1vw4js4jq5gw25x47gmg3gczmyz97c72wvgfiv"))
               (patches
                (search-patches
-                "rocm-opencl-runtime-3.10.0-includes.patch"
                 ;; Do not install libOpenCL, which ocl-icd provides.
                 "rocm-opencl-runtime-4.3-noopencl.patch"
                 ;; Guix includes a program clinfo already.
-                "rocm-opencl-runtime-4.3-noclinfo.patch"
-                ;; cltrace linking fails, remove it.
-                "rocm-opencl-runtime-4.3-nocltrace.patch"))))
+                "rocm-opencl-runtime-4.3-noclinfo.patch"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:tests? #f ; Not sure how to run them.
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'install 'create-icd
-           ;; Manually install ICD, which simply consists of dumping
-           ;; the path of the .so into the correct file.
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (vendors (string-append out "/etc/OpenCL/vendors"))
-                    (sopath (string-append out "/lib/libamdocl64.so")))
-               (mkdir-p vendors)
-               (with-output-to-file (string-append vendors "/amdocl64.icd")
-                 (lambda _ (display sopath)))))))))
+     (list
+      #:tests? #f ; Not sure how to run them.
+      #:configure-flags
+      #~(list
+         (string-append "-DAMD_OPENCL_PATH=" #$(package-source this-package))
+         ;; The ROCclr source is needed to build the runtime.
+         (string-append "-DROCCLR_PATH=" #$rocclr-src)
+         (string-append "-DROCM_PATH=" #$output))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'create-icd
+            ;; Manually install ICD, which simply consists of dumping
+            ;; the path of the .so into the correct file.
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((vendors (string-append #$output "/etc/OpenCL/vendors"))
+                     (sopath (string-append #$output "/lib/libamdocl64.so")))
+                (mkdir-p vendors)
+                (with-output-to-file (string-append vendors "/amdocl64.icd")
+                  (lambda _ (display sopath)))))))))
     (inputs
-     (list mesa
-           rocm-comgr
-           rocr-runtime
-           rocclr
+     (list glew
+           mesa
+           numactl
            opencl-icd-loader
-           glew))
-    (native-inputs `())
+           rocm-comgr
+           rocr-runtime))
     (synopsis "ROCm OpenCL Runtime")
     (description "OpenCL 2.0 compatible language runtime, supporting offline
 and in-process/in-memory compilation.")
@@ -282,7 +303,7 @@ (define-public rocminfo
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0pcm308vwkjrwnrk507iya20mkil8j0vx699w9jk2gas4n4jvkcz"))))
+                "0hdfbvn55h5lk5s8vqlmri5r94vlas8v8yjxwd9d70igslk0kr67"))))
     (build-system cmake-build-system)
     (arguments
      `(#:tests? #f ; No tests.
@@ -314,7 +335,7 @@ (define-public rocm-bandwidth-test
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0a14kwkjpiyljgzxblh031qibn6xgbxp6m12zdy1pmwb2c44jjmm"))))
+                "0rnn2ms68mvzpcp31dk304sfqnv352i7vb48k7rw3qjahhrjm48c"))))
     (build-system cmake-build-system)
     (arguments `(#:tests? #f)) ; No tests.
     (inputs (list rocr-runtime))
-- 
2.36.1
L
L
Ludovic Courtès wrote on 16 Jun 13:35 +0200
Re: bug#55948: [PATCH 0/2] gnu: Update rocm to 5.1.3.
(name . John Kehayias)(address . john.kehayias@protonmail.com)(address . 55948-done@debbugs.gnu.org)
87sfo4lu22.fsf@gnu.org
Hello John,

Pushed!

67c30ff8ad gnu: rocm: Update to 5.1.3.
25809f5a40 gnu: Update llvm-for-rocm: Update to 5.1.3.

John Kehayias <john.kehayias@protonmail.com> skribis:

Toggle quote (2 lines)
> Okay, that's it! Overall is mostly updating hashes and some patches, other than the rocclr notes above. I hope I got the (long) commit message correct on the second patch. The changes work well for me locally.

Thanks for the explanations, it’s great to know the context and things
you addressed.

Ludo’.
Closed
L
L
Lars-Dominik Braun wrote on 16 Jun 14:04 +0200
YqscOHyKZ/XpL8ZS@noor.fritz.box
Hi Ludo,

Toggle quote (1 lines)
> Pushed!
aw, I’m too late. I was going to propose the attached changes.

Lars
Toggle diff (77 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 7b197bb67b..f5d3eac588 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1127,14 +1127,9 @@ (define-public llvm-for-rocm
                (search-patches "llvm-roc-5.0.0-linkdl.patch"
                                "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
     (arguments
-     (substitute-keyword-arguments (package-arguments llvm-12)
-       ((#:phases phases '%standard-phases)
-        `(modify-phases ,phases
-           (add-after 'unpack 'chdir
-             (lambda _
-               (chdir "llvm")))))
+     (substitute-keyword-arguments (package-arguments llvm-14)
        ((#:configure-flags flags)
-        ''("-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
+        #~(list"-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
            "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
            "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
            "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 6c1a83cc88..b85b39d783 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -193,51 +193,6 @@ (define rocclr-src
      (base32
       "0x1frzpz9j1s516vscbdm9g5cqirvv5w7wmq2kyljcygnci7yqar"))))
 
-(define-public rocclr-4
-  (package
-    (name "rocclr-4")
-    (version "4.3.0")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
-                    (commit (string-append "rocm-" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "1pm1y020zriz7zmi95w0rcpka0jrsc7wwh81sssnysi8wxk3nnfy"))))
-    (build-system cmake-build-system)
-    (arguments
-     `(#:tests? #f ; No tests.
-       #:configure-flags
-       `(,(string-append
-           "-DOPENCL_DIR="
-           (assoc-ref %build-inputs "rocm-opencl-runtime-src")))))
-    (inputs
-     `(("mesa" ,mesa)
-       ("rocm-comgr" ,rocm-comgr)
-       ("llvm" ,llvm-for-rocm)
-       ("rocm-device-libs" ,rocm-device-libs)
-       ("rocr-runtime" ,rocr-runtime)
-       ("rocm-cmake" ,rocm-cmake)
-       ;; rocclr depends on a few headers provided by rocm-opencl-runtime.
-       ("rocm-opencl-runtime-src"
-        ,(origin
-           (method git-fetch)
-           (uri (git-reference
-                 (url "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git")
-                 (commit (string-append "rocm-" version))))
-           (file-name (git-file-name name version))
-           (sha256
-            (base32
-             "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))))))
-    (home-page "https://github.com/ROCm-Developer-Tools/ROCclr")
-    (synopsis "Radeon Open Compute Common Language Runtime")
-    (description "ROCclr is a virtual device interface that compute runtimes
-interact with to different backends such as ROCr or PAL.  This abstraction
-allows runtimes to work on Windows as well as on Linux without much effort.")
-    (license license:ncsa)))
-
 (define-public rocm-opencl-runtime
   (package
     (name "rocm-opencl-runtime")
L
L
Ludovic Courtès wrote on 16 Jun 14:17 +0200
(name . Lars-Dominik Braun)(address . lars@6xq.net)
87fsk4ls4e.fsf@gnu.org
Hi,

Lars-Dominik Braun <lars@6xq.net> skribis:

Toggle quote (3 lines)
>> Pushed!
> aw, I’m too late. I was going to propose the attached changes.

Oh sorry; it’s never too late though.

Toggle quote (22 lines)
> diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
> index 7b197bb67b..f5d3eac588 100644
> --- a/gnu/packages/llvm.scm
> +++ b/gnu/packages/llvm.scm
> @@ -1127,14 +1127,9 @@ (define-public llvm-for-rocm
> (search-patches "llvm-roc-5.0.0-linkdl.patch"
> "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
> (arguments
> - (substitute-keyword-arguments (package-arguments llvm-12)
> - ((#:phases phases '%standard-phases)
> - `(modify-phases ,phases
> - (add-after 'unpack 'chdir
> - (lambda _
> - (chdir "llvm")))))
> + (substitute-keyword-arguments (package-arguments llvm-14)
> ((#:configure-flags flags)
> - ''("-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
> + #~(list"-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
> "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
> "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
> "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"

John, WDYT?

Toggle quote (5 lines)
> -(define-public rocclr-4
> - (package
> - (name "rocclr-4")
> - (version "4.3.0")

Fine with me; John?

Lars, feel free to push these if John agrees.

Ludo’.
J
J
John Kehayias wrote on 16 Jun 17:43 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)
p7UDsBfkXQB0KbipxDmXapQM1kxe1QIiAeJoUzBDMns-Zb0pBYJxKth92VCHEiwzTorjfPPrVwMK6f0553bGgxpci2_AwWF16OmBoDH6M2E=@protonmail.com
Hi Ludo’ and Lars,

Thanks for the review and assistance (Lars and I discussed this on IRC a few days ago).

------- Original Message -------
On Thursday, June 16th, 2022 at 8:17 AM, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (26 lines)
> > diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
> > index 7b197bb67b..f5d3eac588 100644
> > --- a/gnu/packages/llvm.scm
> > +++ b/gnu/packages/llvm.scm
> > @@ -1127,14 +1127,9 @@ (define-public llvm-for-rocm
> > (search-patches "llvm-roc-5.0.0-linkdl.patch"
> > "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
> > (arguments
> > - (substitute-keyword-arguments (package-arguments llvm-12)
> > - ((#:phases phases '%standard-phases)
> > - `(modify-phases ,phases
> > - (add-after 'unpack 'chdir
> > - (lambda _
> > - (chdir "llvm")))))
> > + (substitute-keyword-arguments (package-arguments llvm-14)
> > ((#:configure-flags flags)
> > - ''("-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
> > + #~(list"-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
> > "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
> > "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
> > "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
>
>
> John, WDYT?
>

Fine with me! (I'm assuming Lars had built this version locally as this just seems like a clean up and better inheritance structure.)

Toggle quote (8 lines)
> > -(define-public rocclr-4
> > - (package
> > - (name "rocclr-4")
> > - (version "4.3.0")
>
> Fine with me; John?
>

Likewise! For some context, Lars and I had discussed on IRC about ROCm dropping support in later v4 (and now v5) for hardware he uses. Unfortunately, figuring out what is supported or works in this space is very difficult as they cater to more workstation setups. We have time machine and guix past at least, though maybe we can keep older versions explicitly. Since Lars might be one of the few (only?) that uses the older ROCm, I left it to him. rocclr v4 is probably not useful on its own, so I'm fine with dropping it.

Toggle quote (4 lines)
> Lars, feel free to push these if John agrees.
>
> Ludo’.

By the way, I forgot I had to make a kernel change to use this, see https://issues.guix.gnu.org/55111Let me try again with these patches having landed and report back on that issue directly at #55111.

Thanks everyone!
John
L
L
Lars-Dominik Braun wrote on 28 Jun 13:22 +0200
(name . John Kehayias)(address . john.kehayias@protonmail.com)
YrrkaLKFrBXQMG61@noor.fritz.box
Hi,

thanks for having a look. Pushed as:

453b0670a6 gnu: llvm-for-rocm: Inherit from llvm-14
b7c99f2b88 gnu: rocclr-4: Remove package.

Cheers,
Lars
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 55948@debbugs.gnu.org