Subject: [PATCH 5/6] gnu: Add clinfo.

From: Fis Trivial <[email-masked]>
Date: Sat, 12 May 2018 19:51:41 +0000

* gnu/packages/opencl.scm (clinfo): New variable.
---
 gnu/packages/opencl.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/opencl.scm b/gnu/packages/opencl.scm
index a84eeac01..5346d23ac 100644
--- a/gnu/packages/opencl.scm
+++ b/gnu/packages/opencl.scm
@@ -163,6 +163,58 @@ Loader as provided by this project.  This free ICD Loader can load any (free or
 non free) ICD")
     (license license:bsd-2)))
 
+(define-public clinfo
+  (package
+    (name "clinfo")
+    (version "2.2.18.04.06")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/Oblomov/clinfo/archive/"
+                    version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0v7cy01irwdgns6lzaprkmm0502pp5a24zhhffydxz1sgfjj2w7p"))))
+    (build-system gnu-build-system)
+    (native-inputs `(("opencl-headers" ,opencl-headers)))
+    (inputs
+     `(("ocl-icd" ,ocl-icd)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (let ((cores (number->string (parallel-job-count))))
+               (setenv "CC" "gcc")
+               (invoke "make" "-j" cores))))
+         (delete 'install)
+         (add-after 'build 'make-install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (invoke "make" "install" (string-append
+                                       "PREFIX="
+                                       (assoc-ref outputs "out")))))
+         ;; OpenCL vendors are registered in $GUIX_PROFILE/etc/OpenCL/vendors/
+         ;; So we wrap clinfo to find those files. Otherwise, clinfo will try
+         ;; to find them in /etc/OpenCL/vendors
+         (add-after 'make-install 'wrap
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bin (string-append out "/bin/clinfo")))
+               (wrap-program bin
+                 `("OPENCL_VENDOR_PATH" ":" prefix
+                   ("$GUIX_PROFILE$GUIX_ENVIRONMENT/etc/OpenCL/vendors")))))))
+       ;; Cannot be run in store environment.
+       #:tests? #f))
+    (home-page "https://github.com/Oblomov/clinfo")
+    (synopsis "Print all known information about all available OpenCL platforms
+and devices")
+    (description "clinfo is a simple command-line application that enumerates
+all possible (known) properties of the OpenCL platform and devices available on
+the system.")
+    (license license:cc0)))
+
 (define-public beignet
   (package
     (name "beignet")
-- 
2.14.3