Subject: Re: [PATCH] gnu: metis: Use 64-bit floating pointer numbers on 64-bit architectures.

From: Paul Garlick <[email-masked]>
Date: Thu, 18 Mar 2021 18:41:53 +0000

Hi Ludo,

I think it is a good idea to allow for different variants, even on 64-
bit architectures.

In one direction there is a performance advantage using 32-bit floats. 
In the other direction accuracy improves using the 64-bit data type.

There is a similar situation with the scotch library.  The scotch32
package variant is preferable, even on 64-bit systems, except for the
case of very large models.

Best regards,

Paul.

On Thu, 2021-03-18 at 16:02 +0100, Ludovic Courtès wrote:
> From: Ludovic Courtès <[email-masked]>
> 
> * gnu/packages/maths.scm (metis)[arguments]: Add #:modules and #:phases.
> ---
>  gnu/packages/maths.scm | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> Hi!
> 
> Metis defaults to 32-bit floating point numbers.  However, on 64-bit
> platforms, users probably expect 64-bit floating point numbers, hence
> this patch.
> 
> We could make it configurable through different variants or via package
> parameters when they’re available, but I wonder about the usefulness of
> a variant that uses 32-bit floats on 64-bit architectures.  Can we keep
> just this one variant?
> 
> Thanks,
> Ludo’.
> 
> diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
> index 565f109f47..4cd9112be9 100644
> --- a/gnu/packages/maths.scm
> +++ b/gnu/packages/maths.scm
> @@ -12,7 +12,7 @@
>  ;;; Copyright © 2015 Fabian Harfert <[email-masked]>
>  ;;; Copyright © 2016 Roel Janssen <[email-masked]>
>  ;;; Copyright © 2016, 2018, 2020 Kei Kebreau <[email-masked]>
> -;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <[email-masked]>
> +;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <[email-masked]>
>  ;;; Copyright © 2016 Leo Famulari <[email-masked]>
>  ;;; Copyright © 2016, 2017 Thomas Danckaert <[email-masked]>
>  ;;; Copyright © 2017, 2018, 2019, 2020 Paul Garlick <[email-masked]>
> @@ -3312,7 +3312,26 @@ YACC = bison -pscotchyy -y -b y
>       `(#:tests? #f                      ;no tests
>         #:configure-flags `("-DSHARED=ON"
>                             ,(string-append "-DGKLIB_PATH=" (getcwd)
> -                                           "/metis-" ,version "/GKlib"))))
> +                                           "/metis-" ,version "/GKlib"))
> +
> +       #:modules ((system base target)
> +                  (guix build cmake-build-system)
> +                  (guix build utils))
> +       #:phases (modify-phases %standard-phases
> +                  (add-after 'unpack 'set-real-type-width
> +                    (lambda* (#:key build target #:allow-other-keys)
> +                      ;; Enable 64-bit floating point numbers on 64-bit
> +                      ;; architectures.  Leave the default 32-bit width on
> +                      ;; other architectures.
> +                      (let ((word-size
> +                             (with-target (or target build %host-type)
> +                               (lambda ()
> +                                 (target-word-size)))))
> +                        (when (= 8 word-size)
> +                          (display "setting REALTYPEWIDTH to 64...\n")
> +                          (substitute* "include/metis.h"
> +                            (("define REALTYPEWIDTH.*$")
> +                             "define REALTYPEWIDTH 64\n")))))))))
>      (home-page "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview")
>      (synopsis "Graph partitioning and fill-reducing matrix ordering library")
>      (description
>