62 lines
2.1 KiB
Ruby
62 lines
2.1 KiB
Ruby
class Openblas < Formula
|
|
desc "Optimized BLAS library"
|
|
homepage "https://www.openblas.net/"
|
|
url "https://github.com/xianyi/OpenBLAS/archive/v0.3.2.tar.gz"
|
|
sha256 "e8ba64f6b103c511ae13736100347deb7121ba9b41ba82052b1a018a65c0cb15"
|
|
head "https://github.com/xianyi/OpenBLAS.git", :branch => "develop"
|
|
|
|
bottle do
|
|
sha256 "7c3f1b1fd82948e900794c02579de24e4d2a5415054e48c273272e7f514692c4" => :mojave
|
|
sha256 "f62d8e5426d7b7ccef5c6c144fe8089211f39b2900c1c73964bda1685eeb2084" => :high_sierra
|
|
sha256 "77d319be444902da83b151863d5ed4525ff9945a438340e15e58bde98a422990" => :sierra
|
|
sha256 "573b8bfe7a0717ecc2d00bcc6e8986ba888ef729976e915752ba685bf43c00d2" => :el_capitan
|
|
end
|
|
|
|
keg_only :provided_by_macos,
|
|
"macOS provides BLAS and LAPACK in the Accelerate framework"
|
|
|
|
option "with-openmp", "Enable parallel computations with OpenMP"
|
|
|
|
depends_on "gcc" # for gfortran
|
|
|
|
fails_with :clang if build.with? "openmp"
|
|
|
|
def install
|
|
ENV["DYNAMIC_ARCH"] = "1" if build.bottle?
|
|
ENV["USE_OPENMP"] = "1" if build.with? "openmp"
|
|
|
|
# Must call in two steps
|
|
system "make", "CC=#{ENV.cc}", "FC=gfortran", "libs", "netlib", "shared"
|
|
system "make", "PREFIX=#{prefix}", "install"
|
|
|
|
lib.install_symlink "libopenblas.dylib" => "libblas.dylib"
|
|
lib.install_symlink "libopenblas.dylib" => "liblapack.dylib"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include "cblas.h"
|
|
|
|
int main(void) {
|
|
int i;
|
|
double A[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
|
|
double B[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
|
|
double C[9] = {.5, .5, .5, .5, .5, .5, .5, .5, .5};
|
|
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,
|
|
3, 3, 2, 1, A, 3, B, 3, 2, C, 3);
|
|
for (i = 0; i < 9; i++)
|
|
printf("%lf ", C[i]);
|
|
printf("\\n");
|
|
if (fabs(C[0]-11) > 1.e-5) abort();
|
|
if (fabs(C[4]-21) > 1.e-5) abort();
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lopenblas",
|
|
"-o", "test"
|
|
system "./test"
|
|
end
|
|
end
|