numo-blis 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +22 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +27 -0
- data/README.md +66 -0
- data/Rakefile +17 -0
- data/ext/numo/blis/blisext.c +30 -0
- data/ext/numo/blis/extconf.rb +119 -0
- data/lib/numo/blis.rb +36 -0
- data/lib/numo/blis/version.rb +10 -0
- data/numo-blis.gemspec +43 -0
- data/vendor/tmp/.gitkeep +0 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 971c5622cc488550e5121b2e5154ddc00a7bbf278af99ea9abb91e277a0bacb7
|
4
|
+
data.tar.gz: d839070587642f51b3093601db00bcfb8ac29a953318c1b85558be64222c4b6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aba94ef6eeed63d75af97281bff116635beb6d5121c87d0e6d8ccff5c7b48c2b6519e4a412b16be31471c1423024046f9283147f5ecbcbc1bc67e994b39613cf
|
7
|
+
data.tar.gz: e4870f8162f8a57e9fb3272935b9c9e617658974945adb5df8efbdbeae0cf43bb73a68b7e882587f5c02a616f2b104b2a9effdd7b3892bf85bfe617eb772e5b7
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Install gcc and gfortran
|
15
|
+
run: sudo apt-get install -y gcc gfortran
|
16
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler-cache: true
|
21
|
+
- name: Build and test with Rake
|
22
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
/vendor/lib/
|
11
|
+
/vendor/include/
|
12
|
+
/vendor/share/
|
13
|
+
/vendor/installed_*
|
14
|
+
/vendor/tmp/blis*
|
15
|
+
/vendor/tmp/lapack*
|
16
|
+
|
17
|
+
# rspec failure tracking
|
18
|
+
.rspec_status
|
19
|
+
|
20
|
+
*.bundle
|
21
|
+
.ruby-version
|
22
|
+
|
23
|
+
*.swp
|
24
|
+
.DS_Store
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at yoshoku@outlook.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2021 Atsushi Tatsuma
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of the copyright holder nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Numo::BLIS
|
2
|
+
|
3
|
+
[![Build Status](https://github.com/yoshoku/numo-blis/actions/workflows/build.yml/badge.svg)](https://github.com/yoshoku/numo-blis/actions/workflows/build.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/numo-blis.svg)](https://badge.fury.io/rb/numo-blis)
|
5
|
+
[![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/numo-blis/blob/main/LICENSE.txt)
|
6
|
+
|
7
|
+
Numo::BLIS downloads and builds [BLIS](https://github.com/flame/blis) during installation and
|
8
|
+
uses that as a background library for [Numo::Linalg](https://github.com/ruby-numo/numo-linalg).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Building LAPACK with BLIS requires cmake and Fortran compiler.
|
13
|
+
|
14
|
+
macOS:
|
15
|
+
|
16
|
+
$ brew install gcc gfortran cmake
|
17
|
+
|
18
|
+
Ubuntu:
|
19
|
+
|
20
|
+
$ sudo apt-get install gcc gfortran cmake
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'numo-blis'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle install
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install numo-blis
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
Numo::BLIS loads Numo::NArray and Numo::Linalg using BLIS as a background library.
|
39
|
+
You can use Numo::NArray and Numo::Linalg just by loading Numo::BLIS.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'numo/blis'
|
43
|
+
|
44
|
+
x = Numo::DFloat.new(5, 2).rand
|
45
|
+
c = x.transpose.dot(x)
|
46
|
+
eig_val, eig_vec = Numo::Linalg.eigh(c)
|
47
|
+
```
|
48
|
+
|
49
|
+
Moreover, the versions of background libraries are defined by constants.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
> Numo::BLIS::BLIS_VERSION
|
53
|
+
=> "0.8.1"
|
54
|
+
> Numo::BLIS::LAPACK_VERSION
|
55
|
+
=> "3.10.0"
|
56
|
+
```
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-blis.
|
61
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
62
|
+
and contributors are expected to adhere to the [code of conduct](https://github.com/yoshoku/numo-blis/blob/main/CODE_OF_CONDUCT.md).
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require 'rake/extensiontask'
|
9
|
+
|
10
|
+
task build: :compile
|
11
|
+
|
12
|
+
Rake::ExtensionTask.new('blisext') do |ext|
|
13
|
+
ext.ext_dir = 'ext/numo/blis'
|
14
|
+
ext.lib_dir = 'lib/numo/blis'
|
15
|
+
end
|
16
|
+
|
17
|
+
task default: %i[clobber compile spec]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Numo::BLIS downloads and builds BLIS during installation and
|
3
|
+
* uses that as a background library for Numo::Linalg.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <ruby.h>
|
7
|
+
|
8
|
+
VALUE mNumo;
|
9
|
+
VALUE mBLIS;
|
10
|
+
|
11
|
+
void Init_blisext()
|
12
|
+
{
|
13
|
+
/**
|
14
|
+
* Document-module: Numo
|
15
|
+
* Numo is the top level namespace of NUmerical MOdules for Ruby.
|
16
|
+
*/
|
17
|
+
mNumo = rb_define_module("Numo");
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Document-module: Numo::BLIS
|
21
|
+
* Numo::BLIS loads Numo::NArray and Linalg with BLIS used as a backend library.
|
22
|
+
*/
|
23
|
+
mBLIS = rb_define_module_under(mNumo, "BLIS");
|
24
|
+
|
25
|
+
/* The version of BLIS used as a background library. */
|
26
|
+
rb_define_const(mBLIS, "BLIS_VERSION", rb_str_new_cstr("0.8.1"));
|
27
|
+
|
28
|
+
/* The version of LAPACK used as a background library. */
|
29
|
+
rb_define_const(mBLIS, "LAPACK_VERSION", rb_str_new_cstr("3.10.0"));
|
30
|
+
}
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require 'etc'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'mkmf'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'open3'
|
8
|
+
require 'rbconfig'
|
9
|
+
require 'rubygems/package'
|
10
|
+
|
11
|
+
VENDOR_DIR = File.expand_path("#{__dir__}/../../../vendor")
|
12
|
+
SOEXT = RbConfig::CONFIG['SOEXT'] || case RUBY_PLATFORM
|
13
|
+
when /mswin|msys|mingw|cygwin/
|
14
|
+
'dll'
|
15
|
+
when /darwin|mac os/
|
16
|
+
'dylib'
|
17
|
+
else
|
18
|
+
'so'
|
19
|
+
end
|
20
|
+
|
21
|
+
BLIS_VERSION = '0.8.1'
|
22
|
+
LAPACK_VERSION = '3.10.0'
|
23
|
+
BLIS_URI = "https://github.com/flame/blis/archive/refs/tags/#{BLIS_VERSION}.tar.gz"
|
24
|
+
LAPACK_URI = "https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v#{LAPACK_VERSION}.tar.gz"
|
25
|
+
BLIS_TGZ = "#{VENDOR_DIR}/tmp/blis-#{BLIS_VERSION}.tgz"
|
26
|
+
LAPACK_TGZ = "#{VENDOR_DIR}/tmp/lapack-#{LAPACK_VERSION}.tgz"
|
27
|
+
BLIS_KEY = 'ce5998fccfac88153f1e52d6497020529a3b5217'
|
28
|
+
LAPACK_KEY = '4a9384523bf236c83568884e8c62d9517e41ac42'
|
29
|
+
BLIS_CONFIGURE_OPTIONS = ['--enable-cblas',
|
30
|
+
'--enable-threading=pthreads',
|
31
|
+
"--prefix=#{VENDOR_DIR}",
|
32
|
+
'auto'].join(' ')
|
33
|
+
LAPACK_CMAKE_OPTIONS = ["-DBLAS_LIBRARIES='#{VENDOR_DIR}/lib/libblis.#{SOEXT}'",
|
34
|
+
'-DLAPACKE=ON',
|
35
|
+
'-DBUILD_SHARED_LIBS=ON',
|
36
|
+
"-DCMAKE_INSTALL_PREFIX='#{VENDOR_DIR}'"].join(' ')
|
37
|
+
|
38
|
+
unless File.exist?("#{VENDOR_DIR}/installed_blis-#{BLIS_VERSION}")
|
39
|
+
puts "Downloading BLIS #{BLIS_VERSION}."
|
40
|
+
URI.parse(BLIS_URI).open { |rf| File.open(BLIS_TGZ, 'wb') { |sf| sf.write(rf.read) } }
|
41
|
+
abort('SHA1 digest of downloaded file does not match.') unless BLIS_KEY == Digest::SHA1.file(BLIS_TGZ).to_s
|
42
|
+
|
43
|
+
puts 'Unpacking BLIS tgz file.'
|
44
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.open(BLIS_TGZ)) do |tar|
|
45
|
+
tar.each do |entry|
|
46
|
+
next unless entry.file?
|
47
|
+
|
48
|
+
filename = "#{VENDOR_DIR}/tmp/#{entry.full_name}"
|
49
|
+
next if filename == File.dirname(filename)
|
50
|
+
|
51
|
+
FileUtils.mkdir_p("#{VENDOR_DIR}/tmp/#{File.dirname(entry.full_name)}")
|
52
|
+
File.open(filename, 'wb') { |f| f.write(entry.read) }
|
53
|
+
File.chmod(entry.header.mode, filename)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Dir.chdir("#{VENDOR_DIR}/tmp/blis-#{BLIS_VERSION}") do
|
58
|
+
puts 'Configuring BLIS.'
|
59
|
+
cfgstdout, _cfgstderr, cfgstatus = Open3.capture3("./configure #{BLIS_CONFIGURE_OPTIONS}")
|
60
|
+
File.open("#{VENDOR_DIR}/tmp/blis.log", 'w') { |f| f.puts(cfgstdout) }
|
61
|
+
abort('Failed to config BLIS.') unless cfgstatus.success?
|
62
|
+
|
63
|
+
puts 'Building BLIS. This could take a while...'
|
64
|
+
mkstdout, _mkstderr, mkstatus = Open3.capture3('make -j')
|
65
|
+
File.open("#{VENDOR_DIR}/tmp/blis.log", 'a') { |f| f.puts(mkstdout) }
|
66
|
+
abort('Failed to build BLIS.') unless mkstatus.success?
|
67
|
+
|
68
|
+
puts 'Installing BLIS.'
|
69
|
+
insstdout, _insstderr, insstatus = Open3.capture3('make install')
|
70
|
+
File.open("#{VENDOR_DIR}/tmp/blis.log", 'a') { |f| f.puts(insstdout) }
|
71
|
+
abort('Failed to install BLIS.') unless insstatus.success?
|
72
|
+
|
73
|
+
FileUtils.touch("#{VENDOR_DIR}/installed_blis-#{BLIS_VERSION}")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
unless File.exist?("#{VENDOR_DIR}/installed_lapack-#{LAPACK_VERSION}")
|
78
|
+
puts "Downloading LAPACK #{LAPACK_VERSION}."
|
79
|
+
URI.parse(LAPACK_URI).open { |rf| File.open(LAPACK_TGZ, 'wb') { |sf| sf.write(rf.read) } }
|
80
|
+
abort('SHA1 digest of downloaded file does not match.') unless LAPACK_KEY == Digest::SHA1.file(LAPACK_TGZ).to_s
|
81
|
+
|
82
|
+
puts 'Unpacking LAPACK tgz file.'
|
83
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.open(LAPACK_TGZ)) do |tar|
|
84
|
+
tar.each do |entry|
|
85
|
+
next unless entry.file?
|
86
|
+
|
87
|
+
filename = "#{VENDOR_DIR}/tmp/#{entry.full_name}"
|
88
|
+
next if filename == File.dirname(filename)
|
89
|
+
|
90
|
+
FileUtils.mkdir_p("#{VENDOR_DIR}/tmp/#{File.dirname(entry.full_name)}")
|
91
|
+
File.open(filename, 'wb') { |f| f.write(entry.read) }
|
92
|
+
File.chmod(entry.header.mode, filename)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
FileUtils.mkdir_p("#{VENDOR_DIR}/tmp/lapack-#{LAPACK_VERSION}/build")
|
97
|
+
Dir.chdir("#{VENDOR_DIR}/tmp/lapack-#{LAPACK_VERSION}/build") do
|
98
|
+
puts 'Configuring LAPACK.'
|
99
|
+
cmkstdout, _cmkstderr, cmkstatus = Open3.capture3("cmake #{LAPACK_CMAKE_OPTIONS} ../")
|
100
|
+
File.open("#{VENDOR_DIR}/tmp/lapack.log", 'w') { |f| f.puts(cmkstdout) }
|
101
|
+
abort('Failed to config LAPACK.') unless cmkstatus.success?
|
102
|
+
|
103
|
+
puts 'Building LAPACK. This could take a while...'
|
104
|
+
mkstdout, _mkstderr, mkstatus = Open3.capture3('make -j')
|
105
|
+
File.open("#{VENDOR_DIR}/tmp/lapack.log", 'a') { |f| f.puts(mkstdout) }
|
106
|
+
abort('Failed to build LAPACK.') unless mkstatus.success?
|
107
|
+
|
108
|
+
puts 'Installing LAPACK.'
|
109
|
+
insstdout, _insstderr, insstatus = Open3.capture3('make install')
|
110
|
+
File.open("#{VENDOR_DIR}/tmp/lapack.log", 'a') { |f| f.puts(insstdout) }
|
111
|
+
abort('Failed to install BLIS.') unless insstatus.success?
|
112
|
+
|
113
|
+
FileUtils.touch("#{VENDOR_DIR}/installed_lapack-#{LAPACK_VERSION}")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
abort('libblis is not found.') unless find_library('blis', nil, "#{VENDOR_DIR}/lib")
|
118
|
+
|
119
|
+
create_makefile('numo/blis/blisext')
|
data/lib/numo/blis.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'etc'
|
4
|
+
require 'numo/linalg/linalg'
|
5
|
+
|
6
|
+
require_relative 'blis/version'
|
7
|
+
require_relative 'blis/blisext'
|
8
|
+
|
9
|
+
module Numo
|
10
|
+
# @!visibility private
|
11
|
+
module Linalg
|
12
|
+
# @!visibility private
|
13
|
+
module Loader
|
14
|
+
module_function
|
15
|
+
|
16
|
+
# @!visibility private
|
17
|
+
def load_blis(*dirs, exc: true)
|
18
|
+
dirs.each do |d|
|
19
|
+
begin
|
20
|
+
f_blis = dlopen(Blas, 'libblis', d)
|
21
|
+
f_lapacke = dlopen(Lapack, 'liblapacke', d)
|
22
|
+
@@libs = [f_blis, f_lapacke].compact
|
23
|
+
return true
|
24
|
+
rescue
|
25
|
+
end
|
26
|
+
end
|
27
|
+
raise 'Failed to find BLIS/LAPACK library' if exc
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ENV['BLIS_NUM_THREADS'] ||= Etc.nprocessors.to_s
|
35
|
+
|
36
|
+
Numo::Linalg::Loader.load_blis(File.expand_path("#{__dir__}/../../vendor/lib/"))
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Numo is the top level namespace of NUmerical MOdules for Ruby.
|
4
|
+
module Numo
|
5
|
+
# Numo::BLIS loads Numo::NArray and Linalg with BLIS used as backend library.
|
6
|
+
module BLIS
|
7
|
+
# The version of Numo::BLIS you install.
|
8
|
+
VERSION = '0.1.0'
|
9
|
+
end
|
10
|
+
end
|
data/numo-blis.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/numo/blis/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'numo-blis'
|
7
|
+
spec.version = Numo::BLIS::VERSION
|
8
|
+
spec.authors = ['yoshoku']
|
9
|
+
spec.email = ['yoshoku@outlook.com']
|
10
|
+
|
11
|
+
spec.summary = <<~MSG
|
12
|
+
Numo::BLIS downloads and builds BLIS during installation and
|
13
|
+
uses that as a background library for Numo::Linalg.
|
14
|
+
MSG
|
15
|
+
spec.description = <<~MSG
|
16
|
+
Numo::BLIS downloads and builds BLIS during installation and
|
17
|
+
uses that as a background library for Numo::Linalg.
|
18
|
+
MSG
|
19
|
+
spec.homepage = 'https://github.com/yoshoku/numo-blis'
|
20
|
+
spec.license = 'BSD-3-Clause'
|
21
|
+
|
22
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/yoshoku/numo-blis/blob/main/CHANGELOG.md'
|
25
|
+
spec.metadata['documentation_uri'] = 'https://github.com/yoshoku/numo-blis/blob/main/README.md'
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = 'exe'
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ['lib']
|
35
|
+
spec.extensions = ['ext/numo/blis/extconf.rb']
|
36
|
+
|
37
|
+
# Uncomment to register a new dependency of your gem
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
39
|
+
spec.add_dependency 'numo-linalg', '>= 0.1.4'
|
40
|
+
|
41
|
+
# For more information and examples about making a new gem, checkout our
|
42
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
43
|
+
end
|
data/vendor/tmp/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: numo-blis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yoshoku
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: numo-linalg
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.4
|
27
|
+
description: |
|
28
|
+
Numo::BLIS downloads and builds BLIS during installation and
|
29
|
+
uses that as a background library for Numo::Linalg.
|
30
|
+
email:
|
31
|
+
- yoshoku@outlook.com
|
32
|
+
executables: []
|
33
|
+
extensions:
|
34
|
+
- ext/numo/blis/extconf.rb
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- ".github/workflows/build.yml"
|
38
|
+
- ".gitignore"
|
39
|
+
- ".rspec"
|
40
|
+
- CHANGELOG.md
|
41
|
+
- CODE_OF_CONDUCT.md
|
42
|
+
- Gemfile
|
43
|
+
- LICENSE.txt
|
44
|
+
- README.md
|
45
|
+
- Rakefile
|
46
|
+
- ext/numo/blis/blisext.c
|
47
|
+
- ext/numo/blis/extconf.rb
|
48
|
+
- lib/numo/blis.rb
|
49
|
+
- lib/numo/blis/version.rb
|
50
|
+
- numo-blis.gemspec
|
51
|
+
- vendor/tmp/.gitkeep
|
52
|
+
homepage: https://github.com/yoshoku/numo-blis
|
53
|
+
licenses:
|
54
|
+
- BSD-3-Clause
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/yoshoku/numo-blis
|
57
|
+
source_code_uri: https://github.com/yoshoku/numo-blis
|
58
|
+
changelog_uri: https://github.com/yoshoku/numo-blis/blob/main/CHANGELOG.md
|
59
|
+
documentation_uri: https://github.com/yoshoku/numo-blis/blob/main/README.md
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.1.6
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Numo::BLIS downloads and builds BLIS during installation and uses that as
|
79
|
+
a background library for Numo::Linalg.
|
80
|
+
test_files: []
|