* [PATCH] gnu: Add libpetsc
@ 2014-04-30 19:13 Eric Bavier
2014-04-30 21:29 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-04-30 19:13 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 19 bytes --]
Comments welcome.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-libpetsc.patch --]
[-- Type: text/x-diff, Size: 6407 bytes --]
From 73b22ecbc690a2acde4a5cd8a7f6f9b1f220bfe1 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
Date: Wed, 30 Apr 2014 14:01:43 -0500
Subject: [PATCH] gnu: Add libpetsc
* gnu/packages/maths.scm (libpetsc): New variable.
(libpetsc-complex): New variable.
* gnu/packages/patches/petsc-fix-threadcomm.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
---
gnu-system.am | 1 +
gnu/packages/maths.scm | 92 +++++++++++++++++++++++++
gnu/packages/patches/petsc-fix-threadcomm.patch | 12 ++++
3 files changed, 105 insertions(+)
create mode 100644 gnu/packages/patches/petsc-fix-threadcomm.patch
diff --git a/gnu-system.am b/gnu-system.am
index c18db0d..0bf3eec 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -323,6 +323,7 @@ dist_patch_DATA = \
gnu/packages/patches/patchelf-page-size.patch \
gnu/packages/patches/patchutils-xfail-gendiff-tests.patch \
gnu/packages/patches/perl-no-sys-dirs.patch \
+ gnu/packages/patches/petsc-fix-threadcomm.patch \
gnu/packages/patches/plotutils-libpng-jmpbuf.patch \
gnu/packages/patches/procps-make-3.82.patch \
gnu/packages/patches/python-fix-tests.patch \
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 1bbd236..dea2eee 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -366,3 +366,95 @@ post-processing. The specification of any input to these modules is done
either interactively using the graphical user interface or in ASCII text files
using Gmsh's own scripting language.")
(license license:gpl2+)))
+
+(define-public libpetsc
+ (package
+ (name "libpetsc")
+ (version "3.4.4")
+ (source
+ (origin
+ (method url-fetch)
+ ;; The *-lite-* tarball does not contain the *large* documentation
+ (uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
+ "petsc-lite-" version ".tar.gz"))
+ (sha256
+ (base32 "0v5dg6dhdjpi5ianvd4mm6hsvxzv1bsxwnh9f9myag0a0d9xk9iv"))
+ (patches
+ (list (search-patch "petsc-fix-threadcomm.patch")))))
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("cmake" ,cmake)
+ ("python" ,python-2)
+ ("perl" ,perl)))
+ (inputs
+ `(("gfortran" ,gfortran-4.8)
+ ("lapack" ,lapack)
+ ;; leaving out hdf5 and fftw, as petsc expects them to be built with mpi
+ ;; leaving out opengl, as configuration seems to only be for mac
+ ))
+ (arguments
+ `(#:test-target "test"
+ #:parallel-build? #f
+ #:configure-flags
+ `("--with-mpi=0"
+ "--with-openmp=1")
+ #:phases
+ (alist-replace
+ 'configure
+ ;; PETSc's configure script is actually a python script, so we can't
+ ;; run it with bash.
+ (lambda* (#:key outputs (configure-flags '())
+ #:allow-other-keys)
+ (let* ((prefix (assoc-ref outputs "out"))
+ (flags `(,(string-append "--prefix=" prefix)
+ ,@configure-flags)))
+ (format #t "build directory: ~s~%" (getcwd))
+ (format #t "configure flags: ~s~%" flags)
+ (zero? (apply system* "./configure" flags))))
+ (alist-cons-after
+ 'install 'clean-local-references
+ ;; Try to keep installed files from leaking build directory paths.
+ ;; Fortran modules will have references to the build directory
+ ;; because cmake passes absolute path names to the compiler.
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (fortran (assoc-ref inputs "gfortran")))
+ (substitute* (map (lambda (file)
+ (string-append out "/" file))
+ '("conf/petscvariables"
+ "conf/PETScConfig.cmake"
+ "include/petscconf.h"
+ "include/petscmachineinfo.h"))
+ (((getcwd)) out))
+ ;; Make compiler references point to the store
+ (substitute* (string-append out "/conf/petscvariables")
+ (("= g(cc|\\+\\+|fortran)" _ suffix)
+ (string-append "= " fortran "/bin/g" suffix)))
+ ;; PETSc installs some build logs, which aren't necessary.
+ (for-each (lambda (file)
+ (delete-file (string-append out "/" file)))
+ '("conf/configure.log"
+ "conf/make.log"
+ "conf/test.log"
+ "conf/RDict.db"
+ ;; Once installed, should uninstall with Guix
+ "conf/uninstall.py"))))
+ %standard-phases))))
+ (home-page "http://www.mcs.anl.gov/petsc")
+ (synopsis "Library to solve ODEs and algebraic equations")
+ (description "PETSc, pronounced PET-see (the S is silent), is a suite of
+data structures and routines for the scalable (parallel) solution of
+scientific applications modeled by partial differential equations.")
+ (license (license:bsd-style
+ "http://www.mcs.anl.gov/petsc/documentation/copyright.html"))))
+
+(define-public libpetsc-complex
+ (package (inherit libpetsc)
+ (name "libpetsc-complex")
+ (arguments
+ (substitute-keyword-arguments (package-arguments libpetsc)
+ ((#:configure-flags cf)
+ `(cons "--with-scalar-type=complex" ,cf))))
+ (description
+ (string-append (package-description libpetsc)
+ " Complex scalar type version."))))
diff --git a/gnu/packages/patches/petsc-fix-threadcomm.patch b/gnu/packages/patches/petsc-fix-threadcomm.patch
new file mode 100644
index 0000000..7ef1876
--- /dev/null
+++ b/gnu/packages/patches/petsc-fix-threadcomm.patch
@@ -0,0 +1,12 @@
+--- a/src/sys/threadcomm/impls/openmp/tcopenmp.c 2014-03-13 21:47:22.000000000 -0500
++++ b/src/sys/threadcomm/impls/openmp/tcopenmp.c 2014-04-02 14:44:57.185170151 -0500
+@@ -1,6 +1,9 @@
+ #define PETSC_DESIRE_FEATURE_TEST_MACROS
+ #include <../src/sys/threadcomm/impls/openmp/tcopenmpimpl.h>
+ #include <omp.h>
++#if defined(PETSC_HAVE_SCHED_CPU_SET_T)
++#include <sched.h>
++#endif
+
+ PetscErrorCode PetscThreadCommGetRank_OpenMP(PetscInt *trank)
+ {
--
1.8.4
[-- Attachment #3: Type: text/plain, Size: 12 bytes --]
--
`~Eric
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gnu: Add libpetsc
2014-04-30 19:13 [PATCH] gnu: Add libpetsc Eric Bavier
@ 2014-04-30 21:29 ` Ludovic Courtès
2014-05-01 16:26 ` Eric Bavier
2014-05-01 20:52 ` Eric Bavier
0 siblings, 2 replies; 6+ messages in thread
From: Ludovic Courtès @ 2014-04-30 21:29 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
Eric Bavier <ericbavier@gmail.com> skribis:
> From 73b22ecbc690a2acde4a5cd8a7f6f9b1f220bfe1 Mon Sep 17 00:00:00 2001
> From: Eric Bavier <bavier@member.fsf.org>
> Date: Wed, 30 Apr 2014 14:01:43 -0500
> Subject: [PATCH] gnu: Add libpetsc
>
> * gnu/packages/maths.scm (libpetsc): New variable.
> (libpetsc-complex): New variable.
> * gnu/packages/patches/petsc-fix-threadcomm.patch: New patch.
> * gnu-system.am (dist_patch_DATA): Add it.
[...]
> +(define-public libpetsc
> + (package
> + (name "libpetsc")
I think this should be “petsc”, as it’s the upstream name and commonly
used AFAIK. WDYT?
[...]
> + ;; Try to keep installed files from leaking build directory paths.
> + ;; Fortran modules will have references to the build directory
> + ;; because cmake passes absolute path names to the compiler.
Rather “directory names” and “absolute file names” (info "(standards)
GNU Manuals").
(This CMake story is terrible, BTW.)
> +(define-public libpetsc-complex
> + (package (inherit libpetsc)
> + (name "libpetsc-complex")
Likewise, “petsc-complex”?
> +++ b/gnu/packages/patches/petsc-fix-threadcomm.patch
Please add a comment at the beginning of the patch saying what it does
and whether it’s available upstream.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gnu: Add libpetsc
2014-04-30 21:29 ` Ludovic Courtès
@ 2014-05-01 16:26 ` Eric Bavier
2014-05-01 18:20 ` Andreas Enge
2014-05-01 20:52 ` Eric Bavier
1 sibling, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-05-01 16:26 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
ludo@gnu.org (Ludovic Courtès) writes:
>> +(define-public libpetsc
>> + (package
>> + (name "libpetsc")
>
> I think this should be “petsc”, as it’s the upstream name and commonly
> used AFAIK. WDYT?
I was originally thinking "petsc" but then discovered that the package
name on many other distributions is "libpetsc". I would personally
prefer "petsc".
>> + ;; Try to keep installed files from leaking build directory paths.
>> + ;; Fortran modules will have references to the build directory
>> + ;; because cmake passes absolute path names to the compiler.
>
> Rather “directory names” and “absolute file names” (info "(standards)
> GNU Manuals").
I'll fix that.
> (This CMake story is terrible, BTW.)
I think PETSc has an alternative build system. I'll check whether using
that one would improve anything.
>> +(define-public libpetsc-complex
>> + (package (inherit libpetsc)
>> + (name "libpetsc-complex")
>
> Likewise, “petsc-complex”?
Yes.
>> +++ b/gnu/packages/patches/petsc-fix-threadcomm.patch
>
> Please add a comment at the beginning of the patch saying what it does
> and whether it’s available upstream.
Will do.
--
`~Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gnu: Add libpetsc
2014-05-01 16:26 ` Eric Bavier
@ 2014-05-01 18:20 ` Andreas Enge
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Enge @ 2014-05-01 18:20 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
On Thu, May 01, 2014 at 11:26:48AM -0500, Eric Bavier wrote:
> I was originally thinking "petsc" but then discovered that the package
> name on many other distributions is "libpetsc". I would personally
> prefer "petsc".
Our general rule is to use the upstream name (less need to think!), while
I think other distributions often add "lib" for packages that do not contain
executables.
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gnu: Add libpetsc
2014-04-30 21:29 ` Ludovic Courtès
2014-05-01 16:26 ` Eric Bavier
@ 2014-05-01 20:52 ` Eric Bavier
2014-05-02 6:53 ` Ludovic Courtès
1 sibling, 1 reply; 6+ messages in thread
From: Eric Bavier @ 2014-05-01 20:52 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Pushed.
ludo@gnu.org (Ludovic Courtès) writes:
> (This CMake story is terrible, BTW.)
I removed CMake from the package inputs. PETSc then uses an alternative
build system, which is much slower because it doesn't support build
parallelism, but it doesn't put absolute file names into the fortran
modules.
>> +++ b/gnu/packages/patches/petsc-fix-threadcomm.patch
>
> Please add a comment at the beginning of the patch saying what it does
> and whether it’s available upstream.
I submitted the patch to the developers.
--
`~Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gnu: Add libpetsc
2014-05-01 20:52 ` Eric Bavier
@ 2014-05-02 6:53 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2014-05-02 6:53 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
Eric Bavier <ericbavier@gmail.com> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> (This CMake story is terrible, BTW.)
>
> I removed CMake from the package inputs. PETSc then uses an alternative
> build system, which is much slower because it doesn't support build
> parallelism, but it doesn't put absolute file names into the fortran
> modules.
Ah, good, thanks for looking into.
>>> +++ b/gnu/packages/patches/petsc-fix-threadcomm.patch
>>
>> Please add a comment at the beginning of the patch saying what it does
>> and whether it’s available upstream.
>
> I submitted the patch to the developers.
Cool, thanks.
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-02 6:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 19:13 [PATCH] gnu: Add libpetsc Eric Bavier
2014-04-30 21:29 ` Ludovic Courtès
2014-05-01 16:26 ` Eric Bavier
2014-05-01 18:20 ` Andreas Enge
2014-05-01 20:52 ` Eric Bavier
2014-05-02 6:53 ` Ludovic Courtès
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).