summary refs log tree commit diff
path: root/gnu/packages
diff options
context:
space:
mode:
authorDavid Elsing <david.elsing@posteo.net>2022-10-13 21:04:11 +0000
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2022-10-15 12:01:33 +0200
commitc1529021917b28905349d888eb89b461c9ad0fcc (patch)
treeee1841182d6bd2e44263f9b16924e7359d9d7292 /gnu/packages
parentafd853977a4872748960cd9a74e608509c856c45 (diff)
downloadguix-c1529021917b28905349d888eb89b461c9ad0fcc.tar.gz
gnu: Add pocketfft-cpp.
* gnu/packages/patches/pocketfft-cpp-prefer-preprocessor-if.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/cpp.scm (pocketfft-cpp): New variable.

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/cpp.scm28
-rw-r--r--gnu/packages/patches/pocketfft-cpp-prefer-preprocessor-if.patch109
2 files changed, 137 insertions, 0 deletions
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index e8c3b29312..b5adcd8bcc 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -2008,3 +2008,31 @@ CRC32C algorithm, which is specified in RFC 3720, section 12.1.")
 floating point numbers from strings.  It implements the C++ from_chars
 functions for the float and double types.")
     (license (list license:asl2.0 license:expat)))) ; dual licensed
+
+(define-public pocketfft-cpp
+  (let ((commit "daa8bb18327bc5c7d22c69428c25cf5dc64167d3")
+        (revision "0"))
+    (package
+      (name "pocketfft-cpp")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/mreineck/pocketfft")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1dbkkqkmkxgmz1qjpsqzic5ig3qw1pqndbb3dvjc7xq5f2rdzyq1"))
+                (patches (search-patches
+                          "pocketfft-cpp-prefer-preprocessor-if.patch"))))
+      (build-system copy-build-system)
+      (arguments
+       (list
+        #:install-plan #~'(("pocketfft_hdronly.h" "include/"))))
+      (home-page "https://github.com/mreineck/pocketfft")
+      (synopsis "C++11 header-only Fast Fourier Transform library")
+      (description "This package provides a single-header C++11 library for
+computing Fast Fourier transformations.  It supports multidimensional arrays,
+different floating point sizes and complex transformations.")
+      (license license:bsd-3))))
diff --git a/gnu/packages/patches/pocketfft-cpp-prefer-preprocessor-if.patch b/gnu/packages/patches/pocketfft-cpp-prefer-preprocessor-if.patch
new file mode 100644
index 0000000000..028bdf2f89
--- /dev/null
+++ b/gnu/packages/patches/pocketfft-cpp-prefer-preprocessor-if.patch
@@ -0,0 +1,109 @@
+This patch replaces #ifndef POCKETFFT_NO_VECTORS by #if POCKETFFT_NO_VECTORS.
+It also makes it the default, as SIMD instructions are not that well-suited
+for substitutes.
+
+diff --git a/pocketfft_hdronly.h b/pocketfft_hdronly.h
+index d75ada6..b2d0a23 100644
+--- a/pocketfft_hdronly.h
++++ b/pocketfft_hdronly.h
+@@ -39,6 +39,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #ifndef POCKETFFT_HDRONLY_H
+ #define POCKETFFT_HDRONLY_H
+ 
++#ifndef POCKETFFT_NO_VECTORS
++#define POCKETFFT_NO_VECTORS 1
++#endif
++
+ #ifndef __cplusplus
+ #error This file is C++ and requires a C++ compiler.
+ #endif
+@@ -106,29 +110,29 @@ constexpr bool FORWARD  = true,
+                BACKWARD = false;
+ 
+ // only enable vector support for gcc>=5.0 and clang>=5.0
+-#ifndef POCKETFFT_NO_VECTORS
+-#define POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
++#define POCKETFFT_NO_VECTORS 1
+ #if defined(__INTEL_COMPILER)
+ // do nothing. This is necessary because this compiler also sets __GNUC__.
+ #elif defined(__clang__)
+ // AppleClang has their own version numbering
+ #ifdef __apple_build_version__
+ #  if (__clang_major__ > 9) || (__clang_major__ == 9 && __clang_minor__ >= 1)
+-#     undef POCKETFFT_NO_VECTORS
++#define POCKETFFT_NO_VECTORS 0
+ #  endif
+ #elif __clang_major__ >= 5
+-#  undef POCKETFFT_NO_VECTORS
++#define POCKETFFT_NO_VECTORS 0
+ #endif
+ #elif defined(__GNUC__)
+ #if __GNUC__>=5
+-#undef POCKETFFT_NO_VECTORS
++#define POCKETFFT_NO_VECTORS 0
+ #endif
+ #endif
+ #endif
+ 
+ template<typename T> struct VLEN { static constexpr size_t val=1; };
+ 
+-#ifndef POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
+ #if (defined(__AVX512F__))
+ template<> struct VLEN<float> { static constexpr size_t val=16; };
+ template<> struct VLEN<double> { static constexpr size_t val=8; };
+@@ -145,7 +149,7 @@ template<> struct VLEN<double> { static constexpr size_t val=2; };
+ template<> struct VLEN<float> { static constexpr size_t val=4; };
+ template<> struct VLEN<double> { static constexpr size_t val=2; };
+ #else
+-#define POCKETFFT_NO_VECTORS
++#define POCKETFFT_NO_VECTORS 1
+ #endif
+ #endif
+ 
+@@ -180,7 +184,7 @@ template<typename T> class arr
+     T *p;
+     size_t sz;
+ 
+-#if defined(POCKETFFT_NO_VECTORS)
++#if POCKETFFT_NO_VECTORS
+     static T *ralloc(size_t num)
+       {
+       if (num==0) return nullptr;
+@@ -3026,7 +3030,7 @@ class rev_iter
+ template<typename T> struct VTYPE {};
+ template <typename T> using vtype_t = typename VTYPE<T>::type;
+ 
+-#ifndef POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
+ template<> struct VTYPE<float>
+   {
+   using type = float __attribute__ ((vector_size (VLEN<float>::val*sizeof(float))));
+@@ -3139,7 +3143,7 @@ POCKETFFT_NOINLINE void general_nd(const cndarr<T> &in, ndarr<T> &out,
+         auto storage = alloc_tmp<T0>(in.shape(), len, sizeof(T));
+         const auto &tin(iax==0? in : out);
+         multi_iter<vlen> it(tin, out, axes[iax]);
+-#ifndef POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
+         if (vlen>1)
+           while (it.remaining()>=vlen)
+             {
+@@ -3245,7 +3249,7 @@ template<typename T> POCKETFFT_NOINLINE void general_r2c(
+     constexpr auto vlen = VLEN<T>::val;
+     auto storage = alloc_tmp<T>(in.shape(), len, sizeof(T));
+     multi_iter<vlen> it(in, out, axis);
+-#ifndef POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
+     if (vlen>1)
+       while (it.remaining()>=vlen)
+         {
+@@ -3300,7 +3304,7 @@ template<typename T> POCKETFFT_NOINLINE void general_c2r(
+       constexpr auto vlen = VLEN<T>::val;
+       auto storage = alloc_tmp<T>(out.shape(), len, sizeof(T));
+       multi_iter<vlen> it(in, out, axis);
+-#ifndef POCKETFFT_NO_VECTORS
++#if !(POCKETFFT_NO_VECTORS)
+       if (vlen>1)
+         while (it.remaining()>=vlen)
+           {