jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / b / blis.rb
blob8b9273eb39514520898fdd2dd37c71ab04328f47
1 class Blis < Formula
2   desc "BLAS-like Library Instantiation Software Framework"
3   homepage "https://github.com/flame/blis"
4   url "https://github.com/flame/blis/archive/refs/tags/1.1.tar.gz"
5   sha256 "847c035809b8994c077ade737a4813601db96c4cf0d903d08ba6a9b8ee0fe03e"
6   license "BSD-3-Clause"
7   head "https://github.com/flame/blis.git", branch: "master"
9   bottle do
10     sha256 cellar: :any,                 arm64_sequoia: "7b54027b039fa551a50e4fb6e99c79f732a5b34aff78092d733e22c823450ad9"
11     sha256 cellar: :any,                 arm64_sonoma:  "0709aa01695e7ce672d9d8a0780d28fa3465f2cba5b49f976bd3c96f498c1448"
12     sha256 cellar: :any,                 arm64_ventura: "9630f05d848259bc7ffc9df96102b9655a0cd3284057dd77a5e59256b81a32ec"
13     sha256 cellar: :any,                 sonoma:        "eb365f3d3d6fc8eb1df33f83f72b88ee33984438392b78bdc58e4657f7cec66b"
14     sha256 cellar: :any,                 ventura:       "996841f0627e6a5f43d4f272bb0698e7fecb9f958fe05915c85b0814a6be34ac"
15     sha256 cellar: :any_skip_relocation, x86_64_linux:  "db5d4aed1ccf53d93eb65d37dd22cda09f5049e7c5fe4bd2f7db556ccaa57ad3"
16   end
18   uses_from_macos "python" => :build
20   def install
21     # https://github.com/flame/blis/blob/master/docs/ConfigurationHowTo.md
22     ENV.runtime_cpu_detection
23     config = if !build.bottle?
24       "auto"
25     elsif OS.mac?
26       # For Apple Silicon, we can optimize using the dedicated "firestorm" config.
27       # For Intel Macs, we build multiple Intel x86_64 to allow runtime optimization.
28       Hardware::CPU.arm? ? "firestorm" : "intel64"
29     else
30       # For x86_64 Linux, we build full "x86_64" family with Intel and AMD processors.
31       Hardware::CPU.arch
32     end
34     system "./configure", "--prefix=#{prefix}", "--enable-cblas", config
35     system "make"
36     system "make", "install"
37   end
39   test do
40     (testpath/"test.c").write <<~C
41       #include <stdio.h>
42       #include <stdlib.h>
43       #include <math.h>
44       #include "blis/blis.h"
46       int main(void) {
47         int i;
48         double A[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
49         double B[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
50         double C[9] = {.5, .5, .5, .5, .5, .5, .5, .5, .5};
51         cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,
52                     3, 3, 2, 1, A, 3, B, 3, 2, C, 3);
53         for (i = 0; i < 9; i++)
54           printf("%lf ", C[i]);
55         printf("\\n");
56         if (fabs(C[0]-11) > 1.e-5) abort();
57         if (fabs(C[4]-21) > 1.e-5) abort();
58         return 0;
59       }
60     C
61     system ENV.cc, "-o", "test", "test.c", "-I#{include}", "-L#{lib}", "-lblis", "-lm"
62     system "./test"
63   end
64 end