67 lines
2.1 KiB
Ruby
67 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.12.tar.gz"
|
|
sha256 "65a7d3a4010a4e3bd5c0baa41a234797cd3a1735449a4a5902129152601dc57b"
|
|
license "BSD-3-Clause"
|
|
head "https://github.com/xianyi/OpenBLAS.git", branch: "develop"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "7ba7ba209680b05379b11cc82aa90961e46c77441205b7cec05566ac01707e0c" => :catalina
|
|
sha256 "f3fb72089ff3e7ea288027f9dbcac730caa3cb8fc3bb0b650f8a5ae6682c094f" => :mojave
|
|
sha256 "8433e192ab508dfdbfb4e1a7071ef01e7e5c2c3d38187c7bcfd32536be3b5590" => :high_sierra
|
|
end
|
|
|
|
keg_only :shadowed_by_macos, "macOS provides BLAS in Accelerate.framework"
|
|
|
|
depends_on "gcc" # for gfortran
|
|
fails_with :clang
|
|
|
|
def install
|
|
ENV["DYNAMIC_ARCH"] = "1"
|
|
ENV["USE_OPENMP"] = "1"
|
|
ENV["NO_AVX512"] = "1"
|
|
ENV["TARGET"] = case Hardware.oldest_cpu
|
|
when :arm_vortex_tempest
|
|
"VORTEX"
|
|
else
|
|
Hardware.oldest_cpu.upcase.to_s
|
|
end
|
|
|
|
# Must call in two steps
|
|
system "make", "CC=#{ENV.cc}", "FC=gfortran", "libs", "netlib", "shared"
|
|
system "make", "PREFIX=#{prefix}", "install"
|
|
|
|
lib.install_symlink shared_library("libopenblas") => shared_library("libblas")
|
|
lib.install_symlink shared_library("libopenblas") => shared_library("liblapack")
|
|
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
|