Skip to content

Commit

Permalink
Merge pull request #46 from mahrud/openblas
Browse files Browse the repository at this point in the history
OpenBLAS with gcc@9
  • Loading branch information
mahrud authored Jan 9, 2021
2 parents ff982d6 + 82daf1b commit a98bed9
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Formula/csdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Csdp < Formula
url "https://github.com/coin-or/Csdp/archive/releases/6.2.0.tar.gz"
sha256 "3d341974af1f8ed70e1a37cc896e7ae4a513375875e5b46db8e8f38b7680b32f"
license "EPL-2.0"
revision 4
revision 5

bottle do
root_url "https://github.com/mahrud/homebrew-tap/releases/download/csdp-6.2.0_4"
Expand All @@ -14,7 +14,7 @@ class Csdp < Formula
end

depends_on "libomp" if OS.mac?
depends_on "openblas" unless OS.mac?
depends_on "openblas@0.3.13" unless OS.mac?

# patch for compatibility with macOS
patch do
Expand Down
4 changes: 2 additions & 2 deletions Formula/fflas-ffpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FflasFfpack < Formula
url "https://github.com/mahrud/fflas-ffpack.git", using: :git, branch: "master"
version "2.4.3"
license "LGPL-2.1-or-later"
revision 3
revision 4

bottle do
root_url "https://github.com/mahrud/homebrew-tap/releases/download/fflas-ffpack-2.4.3_3"
Expand All @@ -31,7 +31,7 @@ class FflasFfpack < Formula
depends_on "givaro"
depends_on "gmp"
depends_on "libomp" if OS.mac?
depends_on "openblas" unless OS.mac?
depends_on "openblas@0.3.13" unless OS.mac?

def install
ENV.cxx11
Expand Down
68 changes: 68 additions & 0 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class OpenblasAT0313 < Formula
desc "Optimized BLAS library"
homepage "https://www.openblas.net/"
url "https://github.com/xianyi/OpenBLAS/archive/v0.3.13.tar.gz"
sha256 "79197543b17cc314b7e43f7a33148c308b0807cd6381ee77f77e15acf3e6459e"
license "BSD-3-Clause"
head "https://github.com/xianyi/OpenBLAS.git", branch: "develop"

keg_only :shadowed_by_macos, "macOS provides BLAS in Accelerate.framework"

depends_on "gcc@9" # for gfortran
fails_with :clang

# Build script fix. Remove at version bump.
# https://github.com/xianyi/OpenBLAS/pull/3038
patch do
url "https://github.com/xianyi/OpenBLAS/commit/00ce35336ee1eb1089f30d1e117a8a6a933f9654.patch?full_index=1"
sha256 "555e3a8ab042bef2320549db2bad57249d9cf351a6f28e82d6ba53f008920465"
end

def install
ENV["DYNAMIC_ARCH"] = "1"
ENV["USE_OPENMP"] = "1"
ENV["NO_AVX512"] = "1"
# Force a large NUM_THREADS to support larger Macs than the VMs that build the bottles
ENV["NUM_THREADS"] = "56"
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

0 comments on commit a98bed9

Please sign in to comment.