81 lines
2.6 KiB
Ruby
81 lines
2.6 KiB
Ruby
class Fftw < Formula
|
|
desc "C routines to compute the Discrete Fourier Transform"
|
|
homepage "http://www.fftw.org"
|
|
url "http://fftw.org/fftw-3.3.8.tar.gz"
|
|
sha256 "6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
rebuild 2
|
|
sha256 "759b2cd17b53caa4071279657cc79c93943f9b652eeb7334432178ac4921c670" => :mojave
|
|
sha256 "0c9d6d53d26aea1c85a58ea3e3802f7af53d236e4f2360cc742113468afe7357" => :high_sierra
|
|
sha256 "2c2e3dd55528741188da3027927d5ad4568338bfa7d2d1d38e3c7ce14d13fdf2" => :sierra
|
|
end
|
|
|
|
depends_on "gcc"
|
|
depends_on "open-mpi"
|
|
|
|
fails_with :clang
|
|
|
|
def install
|
|
args = [
|
|
"--enable-shared",
|
|
"--disable-debug",
|
|
"--prefix=#{prefix}",
|
|
"--enable-threads",
|
|
"--disable-dependency-tracking",
|
|
"--enable-mpi",
|
|
"--enable-openmp",
|
|
]
|
|
|
|
# FFTW supports runtime detection of CPU capabilities, so it is safe to
|
|
# use with --enable-avx and the code will still run on all CPUs
|
|
simd_args = ["--enable-sse2", "--enable-avx"]
|
|
|
|
# single precision
|
|
# enable-sse2, enable-avx and enable-avx2 work for both single and double precision
|
|
system "./configure", "--enable-single", *(args + simd_args)
|
|
system "make", "install"
|
|
|
|
# clean up so we can compile the double precision variant
|
|
system "make", "clean"
|
|
|
|
# double precision
|
|
# enable-sse2, enable-avx and enable-avx2 work for both single and double precision
|
|
system "./configure", *(args + simd_args)
|
|
system "make", "install"
|
|
|
|
# clean up so we can compile the long-double precision variant
|
|
system "make", "clean"
|
|
|
|
# long-double precision
|
|
# no SIMD optimization available
|
|
system "./configure", "--enable-long-double", *args
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
# Adapted from the sample usage provided in the documentation:
|
|
# http://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html
|
|
(testpath/"fftw.c").write <<~EOS
|
|
#include <fftw3.h>
|
|
int main(int argc, char* *argv)
|
|
{
|
|
fftw_complex *in, *out;
|
|
fftw_plan p;
|
|
long N = 1;
|
|
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
|
|
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
|
|
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
|
|
fftw_execute(p); /* repeat as needed */
|
|
fftw_destroy_plan(p);
|
|
fftw_free(in); fftw_free(out);
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
system ENV.cc, "-o", "fftw", "fftw.c", "-L#{lib}", "-lfftw3", *ENV.cflags.to_s.split
|
|
system "./fftw"
|
|
end
|
|
end
|