summary refs log tree commit diff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2021-08-06 08:27:32 +0200
committerLars-Dominik Braun <lars@6xq.net>2021-08-08 16:47:56 +0200
commitc0f10a5dd4be70a990223b707be1067f6982c4ae (patch)
treebc148f8a37719b502345bf2307e2f1ceffff7428
parent7221722dd53e466846ba6467373f7a71b28091e9 (diff)
downloadguix-c0f10a5dd4be70a990223b707be1067f6982c4ae.tar.gz
gnu: Add rocm-opencl-runtime.
* gnu/packages/rocm.scm (rocm-opencl-runtime): New variable.
* gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch,
gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
-rw-r--r--gnu/local.mk4
-rw-r--r--gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch14
-rw-r--r--gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch28
-rw-r--r--gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch25
-rw-r--r--gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch63
-rw-r--r--gnu/packages/rocm.scm51
6 files changed, 185 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index d545db39dd..3f09b167b1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1702,6 +1702,10 @@ 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-add-rocclr-include-directories.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-sanitize-system-libxml.patch	\
   %D%/packages/patches/rust-1.19-mrustc.patch			\
   %D%/packages/patches/rust-1.25-accept-more-detailed-gdb-lines.patch \
diff --git a/gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch b/gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch
new file mode 100644
index 0000000000..d81bb0747f
--- /dev/null
+++ b/gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000000..5709e0d19a
--- /dev/null
+++ b/gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch
@@ -0,0 +1,28 @@
+Do not build and install clinfo.
+
+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
+ 
+ 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 ------------------------------------------------------------###
+ 
+ # 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)
diff --git a/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch b/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch
new file mode 100644
index 0000000000..e0328d7734
--- /dev/null
+++ b/gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch
@@ -0,0 +1,25 @@
+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
new file mode 100644
index 0000000000..ed20f02503
--- /dev/null
+++ b/gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch
@@ -0,0 +1,63 @@
+Do not build and install libOpenCL.
+
+--- b/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -70,7 +70,7 @@
+     ${ROCclr_DIR}
+     ${LIBROCclr_STATIC_DIR})
+ 
+-add_subdirectory(khronos/icd)
++#add_subdirectory(khronos/icd)
+ add_subdirectory(amdocl)
+ #add_subdirectory(tools/clinfo)
+ add_subdirectory(tools/cltrace)
+@@ -93,9 +93,6 @@
+     OUTPUT_VARIABLE OPENCL_VERSION_GITDATE
+     OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 
+-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
+-        COMPONENT DEV
+-        USE_SOURCE_PERMISSIONS
+-        PATTERN cl_d3d10.h EXCLUDE
+-        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
+--- 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 @@
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
+-    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+-    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+-    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
++#install (TARGETS OpenCL
++#    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
++#    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
++#    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 631d8336c0..07e395c9f0 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -253,3 +253,54 @@ applications to launch compute kernels to available HSA ROCm kernel agents.")
 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")
+    (version %rocm-version)
+    (source (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"))
+              (patches
+               (search-patches
+                "rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.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"))))
+    (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)))))))))
+    (inputs
+     `(("mesa" ,mesa)
+       ("rocm-comgr" ,rocm-comgr)
+       ("rocr-runtime" ,rocr-runtime)
+       ("rocclr" ,rocclr)
+       ("ocl-icd" ,ocl-icd)
+       ("glew" ,glew)))
+    (native-inputs `())
+    (home-page "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime")
+    (synopsis "ROCm OpenCL Runtime")
+    (description "OpenCL 2.0 compatible language runtime, supporting offline
+and in-process/in-memory compilation.")
+    (license license:ncsa)))