summary refs log tree commit diff
path: root/gnu/packages/maths.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-12-03 23:29:39 +0100
committerLudovic Courtès <ludo@gnu.org>2022-01-01 15:23:53 +0100
commit6b704123709d29cdd7e2892b630edc3c7afc1566 (patch)
treef59e82894d3099bd6440650e0f874a4a5908d241 /gnu/packages/maths.scm
parent24667081ad49f327932308f9cc06d93a9be0c80a (diff)
downloadguix-6b704123709d29cdd7e2892b630edc3c7afc1566.tar.gz
gnu: Add ceres-solver-benchmarks.
* gnu/packages/maths.scm (ceres-solver-benchmarks): New variable.
Diffstat (limited to 'gnu/packages/maths.scm')
-rw-r--r--gnu/packages/maths.scm43
1 files changed, 43 insertions, 0 deletions
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index ba9b6cb415..efc64a7c48 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -2480,6 +2480,49 @@ can solve two kinds of problems:
     ;; Mark as tunable to take advantage of SIMD code in Eigen.
     (properties `((tunable? . #t)))))
 
+(define-public ceres-solver-benchmarks
+  (package
+    (inherit ceres)
+    (name "ceres-solver-benchmarks")
+    (arguments
+     '(#:modules ((ice-9 popen)
+                  (ice-9 rdelim)
+                  (guix build utils)
+                  (guix build cmake-build-system))
+
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure)
+                  (replace 'build
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (bin (string-append out "/bin")))
+                        (define flags
+                          (string-tokenize
+                           (read-line (open-pipe* OPEN_READ
+                                                  "pkg-config" "eigen3"
+                                                  "--cflags"))))
+
+                        (define (compile-file file)
+                          (let ((source (string-append file ".cc")))
+                            (format #t "building '~a'...~%" file)
+                            (apply invoke "c++" "-fopenmp" "-O2" "-g" "-DNDEBUG"
+                                   source "-lceres" "-lbenchmark" "-lglog"
+                                   "-pthread"
+                                   "-o" (string-append bin "/" file)
+                                   "-I" ".." flags)))
+
+                        (mkdir-p bin)
+                        (with-directory-excursion "internal/ceres"
+                          (for-each compile-file
+                                    '("small_blas_gemm_benchmark"
+                                      "small_blas_gemv_benchmark"
+                                      "autodiff_cost_function_benchmark"))))))
+                  (delete 'check)
+                  (delete 'install))))
+    (inputs (modify-inputs (package-inputs ceres)
+              (prepend googlebenchmark ceres)))
+    (synopsis "Benchmarks of the Ceres optimization problem solver")))
+
 ;; For a fully featured Octave, users are strongly recommended also to install
 ;; the following packages: less, ghostscript, gnuplot.
 (define-public octave-cli