From 179b4c74f80a6155a7f5d439acee60bc10585c74 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 6 Aug 2021 08:27:32 +0200 Subject: [PATCH 08/11] 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. --- gnu/local.mk | 4 ++ ....10.0-add-rocclr-include-directories.patch | 14 +++++ .../rocm-opencl-runtime-4.3-noclinfo.patch | 28 +++++++++ .../rocm-opencl-runtime-4.3-nocltrace.patch | 25 ++++++++ .../rocm-opencl-runtime-4.3-noopencl.patch | 63 +++++++++++++++++++ gnu/packages/rocm.scm | 51 +++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch diff --git a/gnu/local.mk b/gnu/local.mk index db1f8e499d..6c73e02dd8 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1699,6 +1699,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 $ +- DESTINATION bin +- COMPONENT MAIN) ++#install(PROGRAMS $ ++# DESTINATION bin ++# COMPONENT MAIN) + install(PROGRAMS $ + 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 $ + # DESTINATION bin + # COMPONENT MAIN) +-install(PROGRAMS $ +- DESTINATION lib +- COMPONENT MAIN) + install(PROGRAMS $ + 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 $ + DESTINATION lib + COMPONENT MAIN) +-install(PROGRAMS $ +- DESTINATION lib +- COMPONENT MAIN) +-install(PROGRAMS $ +- 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 $ +- 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 3538208577..8cc0eff9e3 100644 --- a/gnu/packages/rocm.scm +++ b/gnu/packages/rocm.scm @@ -255,3 +255,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))) -- 2.31.1