unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Replace ATLAS with OpenBLAS (+lapack)
@ 2015-06-12  9:41 Ricardo Wurmus
  2015-06-14 22:04 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Wurmus @ 2015-06-12  9:41 UTC (permalink / raw
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

Hi Guix,

attached are three more patches to replace ATLAS with OpenBLAS in
python.scm.

I noticed that numpy also needs "lapack", because OpenBLAS is built with
"NO_LAPACK=1".  That's what the first patch is for.

This is also important for the second patch which makes python-scipy use
OpenBLAS and Lapack instead of ATLAS.

The final patch replaces "atlas" with "openblas" in the
python-scikit-learn package definition.

~~ Ricardo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-python-numpy-bootstrap-Add-lapack-to-inputs.patch --]
[-- Type: text/x-patch, Size: 1891 bytes --]

From aeb4f541486d5bb02d4002380e8f7be49967b10d Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Date: Fri, 12 Jun 2015 10:48:58 +0200
Subject: [PATCH 1/3] gnu: python-numpy-bootstrap: Add lapack to inputs.

* gnu/packages/python.scm (python-numpy-bootstrap)[inputs]: Add lapack to
  inputs, because OpenBLAS does not include lapack functions.
---
 gnu/packages/python.scm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 914c2dc..d753cd3 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -2283,7 +2283,8 @@ writing C extensions for Python as easy as Python itself.")
     (build-system python-build-system)
     (inputs
      `(("python-nose" ,python-nose)
-       ("openblas" ,openblas)))
+       ("openblas" ,openblas)
+       ("lapack" ,lapack)))
     (native-inputs
      `(("gfortran" ,gfortran-4.8)))
     (arguments
@@ -2293,11 +2294,21 @@ writing C extensions for Python as easy as Python itself.")
         (lambda* (#:key inputs #:allow-other-keys)
           (call-with-output-file "site.cfg"
             (lambda (port)
-              (format port "[openblas]
+              (format port
+                      "[openblas]
 libraries = openblas
 library_dirs = ~a/lib
 include_dirs = ~a/include
-" (assoc-ref inputs "openblas") (assoc-ref inputs "openblas"))))
+
+[lapack]
+lapack_libs = lapack
+library_dirs = ~a/lib
+include_dirs = ~a/include
+"
+                      (assoc-ref inputs "openblas")
+                      (assoc-ref inputs "openblas")
+                      (assoc-ref inputs "lapack")
+                      (assoc-ref inputs "lapack"))))
           ;; Use "gcc" executable, not "cc".
           (substitute* "numpy/distutils/system_info.py"
             (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
-- 
2.1.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-python-scipy-Build-with-OpenBLAS-and-lapack.patch --]
[-- Type: text/x-patch, Size: 2362 bytes --]

From a26127d8ecd9170d11350f7085c9e39aa4018b4a Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Date: Fri, 12 Jun 2015 11:30:51 +0200
Subject: [PATCH 2/3] gnu: python-scipy: Build with OpenBLAS and lapack.

* gnu/packages/python.scm (python-scipy)[inputs]: Remove "atlas", add "lapack"
  and "openblas".
* gnu/packages/python.scm (python-scipy)[arguments]: Replace phase
  "set-environment-variables" with "configure-openblas".
---
 gnu/packages/python.scm | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index d753cd3..832bb2d 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -2628,7 +2628,8 @@ toolkits.")
        ("python-pyparsing" ,python-pyparsing)
        ("python-nose" ,python-nose)
        ("python-sphinx" ,python-sphinx)
-       ("atlas" ,atlas)))
+       ("lapack" ,lapack)
+       ("openblas" ,openblas)))
     (native-inputs
      `(("gfortran" ,gfortran-4.8)
        ("texlive" ,texlive)
@@ -2637,18 +2638,23 @@ toolkits.")
     (arguments
      `(#:phases
        (alist-cons-before
-        'build 'set-environment-variables
+        'build 'configure-openblas
         (lambda* (#:key inputs #:allow-other-keys)
-          (let* ((atlas-threaded
-                  (string-append (assoc-ref inputs "atlas")
-                                 "/lib/libtatlas.so"))
-                 ;; On single core CPUs only the serial library is created.
-                 (atlas-lib
-                  (if (file-exists? atlas-threaded)
-                      atlas-threaded
-                      (string-append (assoc-ref inputs "atlas")
-                                     "/lib/libsatlas.so"))))
-            (setenv "ATLAS" atlas-lib)))
+          (call-with-output-file "site.cfg"
+            (lambda (port)
+              (format port
+                      "[blas]
+libraries = openblas
+library_dirs = ~a/lib
+include_dirs = ~a/include
+[atlas]
+library_dirs = ~a/lib
+atlas_libs = openblas
+"
+                      (assoc-ref inputs "openblas")
+                      (assoc-ref inputs "openblas")
+                      (assoc-ref inputs "openblas"))))
+          #t)
         (alist-cons-after
          'install 'install-doc
          (lambda* (#:key outputs #:allow-other-keys)
-- 
2.1.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-python-scikit-learn-Use-OpenBLAS-instead-of-ATLA.patch --]
[-- Type: text/x-patch, Size: 2863 bytes --]

From 79d29126037cd227b01b3a193bf016ec9e12b4fb Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Date: Fri, 12 Jun 2015 11:34:39 +0200
Subject: [PATCH 3/3] gnu: python-scikit-learn: Use OpenBLAS instead of ATLAS.

* gnu/packages/python.scm (python-scikit-learn)[inputs]: Replace "atlas" with
  "openblas".
---
 gnu/packages/python.scm | 43 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 832bb2d..5f9d487 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -2080,35 +2080,22 @@ sources.")
     (arguments
      `(#:phases
        (alist-cons-before
-        'build 'set-environment-variables
-        (lambda* (#:key inputs #:allow-other-keys)
-          (let* ((atlas-threaded
-                  (string-append (assoc-ref inputs "atlas")
-                                 "/lib/libtatlas.so"))
-                 ;; On single core CPUs only the serial library is created.
-                 (atlas-lib
-                  (if (file-exists? atlas-threaded)
-                      atlas-threaded
-                      (string-append (assoc-ref inputs "atlas")
-                                     "/lib/libsatlas.so"))))
-            (setenv "ATLAS" atlas-lib)))
-        (alist-cons-before
-         'check 'set-HOME
-         ;; some tests require access to "$HOME"
-         (lambda _ (setenv "HOME" "/tmp"))
-         ;; Tests can only be run after the library has been installed and not
-         ;; within the source directory.
-         (alist-cons-after
-          'install 'check
-          (lambda _
-            (with-directory-excursion "/tmp"
-              ;; With Python 3 one test of 3334 fails
-              ;; (sklearn.tests.test_common.test_transformers); see
-              ;; https://github.com/scikit-learn/scikit-learn/issues/3693
-              (system* "nosetests" "-v" "sklearn")))
-          (alist-delete 'check %standard-phases))))))
+        'check 'set-HOME
+        ;; some tests require access to "$HOME"
+        (lambda _ (setenv "HOME" "/tmp"))
+        ;; Tests can only be run after the library has been installed and not
+        ;; within the source directory.
+        (alist-cons-after
+         'install 'check
+         (lambda _
+           (with-directory-excursion "/tmp"
+             ;; With Python 3 one test of 3334 fails
+             ;; (sklearn.tests.test_common.test_transformers); see
+             ;; https://github.com/scikit-learn/scikit-learn/issues/3693
+             (system* "nosetests" "-v" "sklearn")))
+         (alist-delete 'check %standard-phases)))))
     (inputs
-     `(("atlas" ,atlas)
+     `(("openblas" ,openblas)
        ("python-nose" ,python-nose)))
     (propagated-inputs
      `(("python-numpy" ,python-numpy)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Replace ATLAS with OpenBLAS (+lapack)
  2015-06-12  9:41 [PATCH] Replace ATLAS with OpenBLAS (+lapack) Ricardo Wurmus
@ 2015-06-14 22:04 ` Ludovic Courtès
  2015-06-15  8:44   ` Ricardo Wurmus
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-06-14 22:04 UTC (permalink / raw
  To: Ricardo Wurmus; +Cc: Guix-devel

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> attached are three more patches to replace ATLAS with OpenBLAS in
> python.scm.

Good!

> From aeb4f541486d5bb02d4002380e8f7be49967b10d Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
> Date: Fri, 12 Jun 2015 10:48:58 +0200
> Subject: [PATCH 1/3] gnu: python-numpy-bootstrap: Add lapack to inputs.
>
> * gnu/packages/python.scm (python-numpy-bootstrap)[inputs]: Add lapack to
>   inputs, because OpenBLAS does not include lapack functions.

OK.

> From a26127d8ecd9170d11350f7085c9e39aa4018b4a Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
> Date: Fri, 12 Jun 2015 11:30:51 +0200
> Subject: [PATCH 2/3] gnu: python-scipy: Build with OpenBLAS and lapack.
>
> * gnu/packages/python.scm (python-scipy)[inputs]: Remove "atlas", add "lapack"
>   and "openblas".
> * gnu/packages/python.scm (python-scipy)[arguments]: Replace phase
>   "set-environment-variables" with "configure-openblas".

OK.

> From 79d29126037cd227b01b3a193bf016ec9e12b4fb Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
> Date: Fri, 12 Jun 2015 11:34:39 +0200
> Subject: [PATCH 3/3] gnu: python-scikit-learn: Use OpenBLAS instead of ATLAS.
>
> * gnu/packages/python.scm (python-scikit-learn)[inputs]: Replace "atlas" with
>   "openblas".

Please mention how the phases are modified in the commit log.

Otherwise OK.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Replace ATLAS with OpenBLAS (+lapack)
  2015-06-14 22:04 ` Ludovic Courtès
@ 2015-06-15  8:44   ` Ricardo Wurmus
  0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Wurmus @ 2015-06-15  8:44 UTC (permalink / raw
  To: Ludovic Courtès; +Cc: Guix-devel


Ludovic Courtès <ludo@gnu.org> writes:

> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:
>
>> attached are three more patches to replace ATLAS with OpenBLAS in
>> python.scm.

[...]

>> From 79d29126037cd227b01b3a193bf016ec9e12b4fb Mon Sep 17 00:00:00 2001
>> From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
>> Date: Fri, 12 Jun 2015 11:34:39 +0200
>> Subject: [PATCH 3/3] gnu: python-scikit-learn: Use OpenBLAS instead of ATLAS.
>>
>> * gnu/packages/python.scm (python-scikit-learn)[inputs]: Replace "atlas" with
>>   "openblas".
>
> Please mention how the phases are modified in the commit log.

I updated the commit log and pushed the three commits.  Thank you for
the review!

~~ Ricardo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-15  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-12  9:41 [PATCH] Replace ATLAS with OpenBLAS (+lapack) Ricardo Wurmus
2015-06-14 22:04 ` Ludovic Courtès
2015-06-15  8:44   ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).