77 lines
2.4 KiB
Ruby
77 lines
2.4 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"
|
|
|
|
bottle do
|
|
cellar :any
|
|
rebuild 1
|
|
sha256 "8df061c7222cc121bda7fa99383762de7a4e4f5f7b722ed324e5db3aeccf7c87" => :mojave
|
|
sha256 "61cae18adcd0140264dd31818f3986b58b3399201ec3fc9bbc18666a815c1af9" => :high_sierra
|
|
sha256 "30dd2e1659c5288859e19204aa2afeb61a514cb12fc9e75a849b7c944ced314b" => :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",
|
|
]
|
|
simd_args = ["--enable-sse2"]
|
|
|
|
# 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
|