about summary refs log tree commit diff
path: root/guix.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix.scm')
-rw-r--r--guix.scm101
1 files changed, 97 insertions, 4 deletions
diff --git a/guix.scm b/guix.scm
index 299332e..23b7583 100644
--- a/guix.scm
+++ b/guix.scm
@@ -7,10 +7,15 @@
 ;;
 ;;   guix shell -C -D -F -v 3 -L . pangemma-shell-git  # pangemma-shell-git
 ;;
-;;   see premake5.lua header for examples.
+;; optimized for arch:
+;;
+;;   guix shell --tune=native -C -D -F -v 3 -L . pangemma-shell-git  # pangemma-shell-git
+;;
+;; see premake5.lua header for examples.
 ;;
 ;;   guix shell -C -D -F -v 3 -L . gemma-git           # for specific packages
 ;;
+;; To optimize use guix --tune=march-type (e.g. --tune=native)
 
 (define-module (guix)
   #:use-module ((guix licenses) #:prefix license:)
@@ -18,13 +23,17 @@
   #:use-module (guix packages)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix utils)
+
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages base)
   #:use-module (gnu packages build-tools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages gdb)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages guile-xyz)
@@ -45,6 +54,90 @@
 (define %pangemma-version
     (read-string (open-pipe "cat VERSION|tr -d $'\n'" OPEN_READ)))
 
+(define-public openblas-pangemma
+;; we are fixating on an older openblas, for now
+  (package
+    (name "openblas-pangemma")
+    (version "0.3.21")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/xianyi/OpenBLAS")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0yx1axiki12y0xz0d5s76vvl7ds36k0npv1sww08k2qslhz1g9qp"))))
+    (build-system gnu-build-system)
+    (properties `((tunable? . #t)))
+    (arguments
+     (list
+      #:tests? #f ;; skip tests
+      #:test-target "test"
+      ;; No default baseline is supplied for powerpc-linux.
+      #:substitutable? (not (target-ppc32?))
+      #:make-flags
+      #~(list (string-append "PREFIX=" #$output)
+              (string-append "CFLAGS=-O3 -g -Wno-incompatible-pointer-types -Wno-error=implicit-function-declaration")
+              "SHELL=bash"
+              "MAKE_NB_JOBS=0"          ;use jobserver for submakes
+
+              ;; This is the maximum number of threads OpenBLAS will ever use (that
+              ;; is, if $OPENBLAS_NUM_THREADS is greater than that, then NUM_THREADS
+              ;; is used.)  If we don't set it, the makefile sets it to the number
+              ;; of cores of the build machine, which is obviously wrong.
+              "NUM_THREADS=128"
+
+              ;; DYNAMIC_ARCH is only supported on some architectures.
+              ;; DYNAMIC_ARCH combined with TARGET=GENERIC provides a library
+              ;; which uses the optimizations for the detected CPU.  This can
+              ;; be overridden at runtime with the environment variable
+              ;; OPENBLAS_CORETYPE=<type>, where "type" is a supported CPU
+              ;; type.  On other architectures we target only the baseline CPU
+              ;; supported by Guix.
+              #$@(cond
+                    ((or (target-x86-64?)
+                         (target-x86-32?)
+                         (target-ppc64le?)
+                         (target-aarch64?))
+                     ;; Dynamic older enables a few extra CPU architectures
+                     ;; on x86_64 that were released before 2010.
+                     '("DYNAMIC_ARCH=1" "DYNAMIC_OLDER=1" "TARGET=GENERIC"))
+                    ;; On some of these architectures the CPU type can't be detected.
+                    ;; We list the oldest CPU core we want to have support for.
+                    ;; On MIPS we force the "SICORTEX" TARGET, as for the other
+                    ;; two available MIPS targets special extended instructions
+                    ;; for Loongson cores are used.
+                    ((target-mips64el?)
+                     '("TARGET=SICORTEX"))
+                    ((target-arm32?)
+                     '("TARGET=ARMV7"))
+                    ((target-riscv64?)
+                     '("TARGET=RISCV64_GENERIC"))
+                    (else '())))
+      ;; no configure script
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure)
+          (add-before 'build 'set-extralib
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Get libgfortran found when building in utest.
+              (setenv "FEXTRALIB"
+                      (string-append
+                       "-L"
+                       (dirname
+                        (search-input-file inputs "/lib/libgfortran.so")))))))))
+    (inputs
+     (list `(,gfortran "lib")))
+    (native-inputs
+     (list cunit gfortran perl))
+    (home-page "https://www.openblas.net/")
+    (synopsis "Optimized BLAS library based on GotoBLAS")
+    (description
+     "OpenBLAS is a BLAS library forked from the GotoBLAS2-1.13 BSD version.")
+    (license license:bsd-3)))
+
 (define-public pangemma-base-git
   "Pangemma base build package"
   (package
@@ -54,7 +147,7 @@
     (build-system gnu-build-system)
     (inputs
      (list gsl
-           openblas
+           openblas-pangemma
            guile-3.0
            `(,guile-3.0 "debug")
            ;; `(,guile-3.0 "dev")
@@ -102,7 +195,7 @@ genome-wide association studies (GWAS).")
     (build-system gnu-build-system)
     (propagated-inputs
      (modify-inputs (package-inputs pangemma-base-git)
-                    (append which binutils coreutils gcc-toolchain premake5 gnu-make gdb ;; for the shell
+                    (append which binutils coreutils gcc-toolchain premake5 gnu-make gdb gperftools ;; for the shell
                  )))
     (arguments
      `(#:phases (modify-phases %standard-phases
@@ -126,7 +219,7 @@ genome-wide association studies (GWAS).")
      (list catch2
            gdb
            gsl
-           openblas
+           openblas-pangemma
            zlib))
        ;; ("gsl-static" ,gsl-static)
        ;; ("zlib:static" ,zlib "static")