guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 10/14] gnu: Add MUMPS.


From: ericbavier
Subject: [PATCH 10/14] gnu: Add MUMPS.
Date: Sat, 27 Jun 2015 22:45:47 -0500

From: Eric Bavier <address@hidden>

* gnu/packages/maths.scm (mumps, mumps-metis, mumps-openmpi)
  (mumps-metis-openmpi): New variables.
* gnu/packages/patches/mumps-build-parallelism.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
---
 gnu-system.am                                      |   1 +
 gnu/packages/maths.scm                             | 165 +++++++++++++++++++++
 gnu/packages/patches/mumps-build-parallelism.patch |  13 ++
 3 files changed, 179 insertions(+)
 create mode 100644 gnu/packages/patches/mumps-build-parallelism.patch

diff --git a/gnu-system.am b/gnu-system.am
index 0c9a2eb..af2c0eb 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -518,6 +518,7 @@ dist_patch_DATA =                                           
\
   gnu/packages/patches/mpc123-initialize-ao.patch              \
   gnu/packages/patches/mplayer2-theora-fix.patch               \
   gnu/packages/patches/module-init-tools-moduledir.patch       \
+  gnu/packages/patches/mumps-build-parallelism.patch           \
   gnu/packages/patches/mupdf-buildsystem-fix.patch             \
   gnu/packages/patches/mutt-CVE-2014-9116.patch                        \
   gnu/packages/patches/net-tools-bitrot.patch                  \
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index bc13fd5..369457d 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -32,6 +32,7 @@
   #:use-module (guix download)
   #:use-module (guix svn-download)
   #:use-module (guix utils)
+  #:use-module (guix build utils)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages algebra)
@@ -628,6 +629,170 @@ scientific applications modeled by partial differential 
equations.")
            ,@(delete "--with-mpi=0" ,cf)))))
     (synopsis "Library to solve PDEs (with complex scalars and MPI support)")))
 
+(define-public mumps
+  (package
+    (name "mumps")
+    (version "5.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://mumps.enseeiht.fr/MUMPS_";
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "0690yp73sqk8zn2jnrzdr5swnjdyd7j0774s4xamjjwcxarw87hr"))
+       (patches (list (search-patch "mumps-build-parallelism.patch")))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("fortran" ,gfortran)
+       ;; These are required for linking against mumps, but we let the user
+       ;; declare the dependency.
+       ("blas" ,openblas)
+       ("metis" ,metis)
+       ("scotch" ,scotch)))
+    (arguments
+     `(#:modules ((ice-9 match)
+                  (guix build gnu-build-system)
+                  (guix build utils))
+       #:phases
+       (modify-phases %standard-phases
+         (replace
+          'configure
+          (lambda* (#:key inputs #:allow-other-keys)
+            (call-with-output-file "Makefile.inc"
+              (lambda (port)
+                (format port "
+PLAT         =
+LIBEXT       = .a
+OUTC         = -o
+OUTF         = -o
+RM           = rm -f~:[
+CC           = gcc
+FC           = gfortran
+FL           = gfortran
+INCSEQ       = -I$(topdir)/libseq
+LIBSEQ       = -L$(topdir)/libseq -lmpiseq
+LIBSEQNEEDED = libseqneeded~;
+CC           = mpicc
+FC           = mpifort
+FL           = mpifort~]
+AR           = ar vr # rules require trailing space, ugh...
+RANLIB       = ranlib
+LIBBLAS      = -L~a address@hidden
+SCALAP       = -L~a -lscalapack~]
+LIBOTHERS    = -pthread
+CDEFS        = -DAdd_
+PIC          = -fPIC
+OPTF         = -O2 -DALLOW_NON_INIT $(PIC)
+OPTL         = -O2 $(PIC)
+OPTC         = -O2 $(PIC)
+INCS         = $(INCSEQ)
+LIBS         = $(SCALAP) $(LIBSEQ)
+LPORDDIR     = $(topdir)/PORD/lib
+IPORD        = -I$(topdir)/PORD/include
+LPORD        = -L$(LPORDDIR) -lpord
+ORDERINGSF   = address@hidden
+METISDIR     = ~a
+IMETIS       = -I$(METISDIR)/include
+LMETIS       = -L$(METISDIR)/lib -lmetis
+ORDERINGSF  += address@hidden:{
+SCOTCHDIR    = ~a
+ISCOTCH      = -I$(SCOTCHDIR)/include
+LSCOTCH      = -L$(SCOTCHDIR)/lib ~a-lesmumps -lscotch -lscotcherr
+ORDERINGSF  += ~a~}~]
+ORDERINGSC   = $(ORDERINGSF)
+LORDERINGS   = $(LPORD) $(LMETIS) $(LSCOTCH)
+IORDERINGSF  = $(ISCOTCH)
+IORDERINGSC  = $(IPORD) $(IMETIS) $(ISCOTCH)"
+                        (assoc-ref inputs "mpi")
+                        (assoc-ref inputs "blas")
+                        (assoc-ref inputs "scalapack")
+                        (assoc-ref inputs "metis")
+                        (match (list (assoc-ref inputs "pt-scotch")
+                                     (assoc-ref inputs "scotch"))
+                          ((#f #f)
+                           #f)
+                          ((#f scotch)
+                           `((,scotch "" "-Dscotch")))
+                          ((ptscotch _)
+                           `((,ptscotch
+                              "-lptesmumps -lptscotch -lptscotcherr "
+                              "-Dptscotch")))))))))
+         (replace
+          'build
+          ;; By default only the d-precision library is built.  Make with "all"
+          ;; target so that all precision libraries and examples are built.
+          (lambda _
+            (zero? (system* "make" "all"
+                            (format #f "-j~a" (current-processor-count))))))
+         (replace
+          'check
+          (lambda* (#:key (exec-prefix '()) #:allow-other-keys)
+            (with-directory-excursion "examples"
+              (use-modules (srfi srfi-1))
+              (every
+               (lambda (prec type)
+                 (use-modules (ice-9 popen))
+                 (let ((tester (apply open-pipe*
+                                      `(,OPEN_WRITE
+                                        ,@exec-prefix
+                                        ,(string-append "./" prec
+                                                        "simpletest"))))
+                       (input  (open-input-file
+                                (string-append "input_simpletest_" type))))
+                   (begin
+                     (dump-port input tester)
+                     (close-port input)
+                     (zero? (close-pipe tester)))))
+               '("s" "d" "c" "z")
+               '("real" "real" "cmplx" "cmplx")))))
+         (replace
+          'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out")))
+              (copy-recursively "lib" (string-append out "/lib"))
+              (copy-recursively "include" (string-append out "/include"))
+              (when (file-exists? "libseq/libmpiseq.a")
+                (copy-file "libseq/libmpiseq.a"
+                           (string-append out "/lib/libmpiseq.a")))))))))
+    (home-page "http://mumps.enseeiht.fr";)
+    (synopsis "Multifrontal sparse direct solver")
+    (description
+     "MUMPS (MUltifrontal Massively Parallel sparse direct Solver) solves a
+sparse system of linear equations A x = b using Guassian elimination.")
+    (license license:public-domain)))
+
+(define-public mumps-metis
+  (package (inherit mumps)
+    (name "mumps-metis")
+    (inputs
+     (alist-delete "scotch" (package-inputs mumps)))))
+
+(define-public mumps-openmpi
+  (package (inherit mumps)
+    (name "mumps-openmpi")
+    (inputs
+     `(("mpi" ,openmpi)
+       ("scalapack" ,scalapack)
+       ("pt-scotch" ,pt-scotch)
+       ,@(alist-delete "scotch" (package-inputs mumps))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mumps)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace
+            'check
+            (lambda _
+              ((assoc-ref ,phases 'check)
+               #:exec-prefix '("mpirun" "-n" "2"))))))))
+    (synopsis "Multifrontal sparse direct solver (with MPI)")))
+
+(define-public mumps-metis-openmpi
+  (package (inherit mumps-openmpi)
+    (name "mumps-metis-openmpi")
+    (inputs
+     (alist-delete "pt-scotch" (package-inputs mumps-openmpi)))))
+
 (define-public superlu
   (package
     (name "superlu")
diff --git a/gnu/packages/patches/mumps-build-parallelism.patch 
b/gnu/packages/patches/mumps-build-parallelism.patch
new file mode 100644
index 0000000..26dd330
--- /dev/null
+++ b/gnu/packages/patches/mumps-build-parallelism.patch
@@ -0,0 +1,13 @@
+Building sublibraries in parallel can lead to race conditions on the libseq
+and lipord targets.
+
+--- MUMPS_5.0.0/Makefile.orig  2015-06-15 10:08:54.523146562 -0500
++++ MUMPS_5.0.0/Makefile       2015-06-15 10:19:44.074367512 -0500
+@@ -11,6 +11,7 @@
+       sexamples dexamples cexamples zexamples \
+       mumps_lib requiredobj libseqneeded clean
+ 
++.NOTPARALLEL:
+ alllib:               c z s d
+ all:          cexamples zexamples sexamples dexamples
+ 
-- 
2.2.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]