numo-openblas 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/Rakefile +10 -1
- data/ext/numo/openblas/extconf.rb +76 -0
- data/ext/numo/openblas/openblas.c +34 -0
- data/lib/numo/openblas.rb +1 -0
- data/lib/numo/openblas/version.rb +2 -4
- data/numo-openblas.gemspec +1 -0
- metadata +6 -4
- data/lib/rubygems_plugin.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb28541f7f6f87b87410da68933898703b42d2987721e429b4d09ac7f1d23127
|
4
|
+
data.tar.gz: ea7a198b2c3d3c17c7b03898d9c9b31a4c747335401b521ae4415c63b7a45c74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2eec31d62b6cd6ee263b9219356835cb60fe52562dc2ab8090e7cb8261fa10de28eeb0c007a23d522def8af23a4d7d039ac5437f11270b2bc3e896e529ad645
|
7
|
+
data.tar.gz: dc3b17590715bf76411eb71e29b9cad3afea8c5ae13b57070638d55b63460e17914c0142428ebbf2ab71853e6d94f9e56e183f175c8378737037fb7d557d5d8b
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -3,4 +3,13 @@ require 'rspec/core/rake_task'
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
|
6
|
+
require 'rake/extensiontask'
|
7
|
+
|
8
|
+
task build: :compile
|
9
|
+
|
10
|
+
Rake::ExtensionTask.new('openblas') do |ext|
|
11
|
+
ext.ext_dir = 'ext/numo/openblas'
|
12
|
+
ext.lib_dir = 'lib/numo/openblas'
|
13
|
+
end
|
14
|
+
|
15
|
+
task default: %i[clobber compile spec]
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require 'digest/sha1'
|
4
|
+
require 'etc'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'mkmf'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'open3'
|
9
|
+
require 'rubygems/package'
|
10
|
+
|
11
|
+
OPENBLAS_VER = '0.3.10'
|
12
|
+
OPENBLAS_KEY = 'cbe3fdd0e6ee235debc611d76976dac62f3ddc1c'
|
13
|
+
OPENBLAS_URI = "https://github.com/xianyi/OpenBLAS/archive/v#{OPENBLAS_VER}.tar.gz"
|
14
|
+
OPENBLAS_DIR = File.expand_path(__dir__ + '/../../../vendor')
|
15
|
+
|
16
|
+
unless File.exist?("#{OPENBLAS_DIR}/installed_#{OPENBLAS_VER}")
|
17
|
+
puts "Downloading OpenBLAS #{OPENBLAS_VER}."
|
18
|
+
URI.open(OPENBLAS_URI) do |rf|
|
19
|
+
File.open("#{OPENBLAS_DIR}/tmp/openblas.tgz", 'wb') { |sf| sf.write(rf.read) }
|
20
|
+
end
|
21
|
+
|
22
|
+
if OPENBLAS_KEY != Digest::SHA1.file("#{OPENBLAS_DIR}/tmp/openblas.tgz").to_s
|
23
|
+
puts 'SHA1 digest of downloaded file does not match.'
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
puts 'Unpacking OpenBLAS tar.gz file.'
|
28
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.open("#{OPENBLAS_DIR}/tmp/openblas.tgz")) do |tar|
|
29
|
+
tar.each do |entry|
|
30
|
+
next unless entry.file?
|
31
|
+
|
32
|
+
filename = "#{OPENBLAS_DIR}/tmp/#{entry.full_name}"
|
33
|
+
next if filename == File.dirname(filename)
|
34
|
+
|
35
|
+
FileUtils.mkdir_p("#{OPENBLAS_DIR}/tmp/#{File.dirname(entry.full_name)}")
|
36
|
+
File.open(filename, 'wb') { |f| f.write(entry.read) }
|
37
|
+
File.chmod(entry.header.mode, filename)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Dir.chdir("#{OPENBLAS_DIR}/tmp/OpenBLAS-#{OPENBLAS_VER}") do
|
42
|
+
puts 'Building OpenBLAS. This could take a while...'
|
43
|
+
mkstdout, _mkstderr, mkstatus = Open3.capture3("make -j#{Etc.nprocessors}")
|
44
|
+
File.open("#{OPENBLAS_DIR}/tmp/openblas.log", 'w') { |f| f.puts(mkstdout) }
|
45
|
+
unless mkstatus.success?
|
46
|
+
puts 'Failed to build OpenBLAS.'
|
47
|
+
puts 'Check the make-openblas.log file for more details:'
|
48
|
+
puts "#{OPENBLAS_DIR}/tmp/openblas.log"
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
puts 'Installing OpenBLAS.'
|
53
|
+
insstdout, _insstderr, insstatus = Open3.capture3("make install PREFIX=#{OPENBLAS_DIR}")
|
54
|
+
File.open("#{OPENBLAS_DIR}/tmp/openblas.log", 'a') { |f| f.puts(insstdout) }
|
55
|
+
unless insstatus.success?
|
56
|
+
puts 'Failed to install OpenBLAS.'
|
57
|
+
puts 'Check the make-openblas.log file for more details:'
|
58
|
+
puts "#{OPENBLAS_DIR}/tmp/openblas.log"
|
59
|
+
exit(1)
|
60
|
+
end
|
61
|
+
|
62
|
+
FileUtils.touch("#{OPENBLAS_DIR}/installed_#{OPENBLAS_VER}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
unless find_library('openblas', nil, "#{OPENBLAS_DIR}/lib")
|
67
|
+
puts 'libopenblas is not found.'
|
68
|
+
exit(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
unless find_header('openblas_config.h', nil, "#{OPENBLAS_DIR}/include")
|
72
|
+
puts 'openblas_config.h is not found.'
|
73
|
+
exit(1)
|
74
|
+
end
|
75
|
+
|
76
|
+
create_makefile('numo/openblas/openblas')
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* Numo::OpenBLAS downloads and builds OpenBLAS during installation and
|
3
|
+
* uses that as a background library for Numo::Linalg.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <ruby.h>
|
7
|
+
#include <openblas_config.h>
|
8
|
+
|
9
|
+
VALUE mNumo;
|
10
|
+
VALUE mOpenBLAS;
|
11
|
+
|
12
|
+
void Init_openblas()
|
13
|
+
{
|
14
|
+
/**
|
15
|
+
* Document-module: Numo
|
16
|
+
* Numo is the top level namespace of NUmerical MOdules for Ruby.
|
17
|
+
*/
|
18
|
+
mNumo = rb_define_module("Numo");
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Document-module: Numo::Liblinear
|
22
|
+
* Numo::OpenBLAS loads Numo::NArray and Linalg with OpenBLAS used as backend library.
|
23
|
+
*/
|
24
|
+
mOpenBLAS = rb_define_module_under(mNumo, "OpenBLAS");
|
25
|
+
|
26
|
+
/* The number of cores detected by OpenBLAS. */
|
27
|
+
rb_define_const(mOpenBLAS, "OPENBLAS_NUM_CORES", INT2NUM(OPENBLAS_NUM_CORES));
|
28
|
+
|
29
|
+
/* The core name detected by OpenBLAS. */
|
30
|
+
rb_define_const(mOpenBLAS, "OPENBLAS_CHAR_CORENAME", rb_str_new_cstr(OPENBLAS_CHAR_CORENAME));
|
31
|
+
|
32
|
+
/* The version of OpenBLAS used in background library. */
|
33
|
+
rb_define_const(mOpenBLAS, "OPENBLAS_VERSION", rb_str_new_cstr(OPENBLAS_VERSION));
|
34
|
+
}
|
data/lib/numo/openblas.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Numo is the top level namespace of NUmerical MOdules for Ruby.
|
3
4
|
module Numo
|
4
5
|
# Numo::OpenBLAS loads Numo::NArray and Linalg with OpenBLAS used as backend library.
|
5
6
|
module OpenBLAS
|
6
7
|
# The version of Numo::OpenBLAS you install.
|
7
|
-
VERSION = '0.
|
8
|
-
|
9
|
-
# The version OpenBLAS that Numo::OpenBLAS build and use.
|
10
|
-
OPENBLAS_VERSION = '0.3.10'
|
8
|
+
VERSION = '0.2.0'
|
11
9
|
end
|
12
10
|
end
|
data/numo-openblas.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.bindir = 'exe'
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ['lib']
|
33
|
+
spec.extensions = ['ext/numo/openblas/extconf.rb']
|
33
34
|
|
34
35
|
spec.add_runtime_dependency 'numo-linalg', '>= 0.1.4'
|
35
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numo-openblas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-linalg
|
@@ -30,7 +30,8 @@ description: |
|
|
30
30
|
email:
|
31
31
|
- yoshoku@outlook.com
|
32
32
|
executables: []
|
33
|
-
extensions:
|
33
|
+
extensions:
|
34
|
+
- ext/numo/openblas/extconf.rb
|
34
35
|
extra_rdoc_files: []
|
35
36
|
files:
|
36
37
|
- ".gitignore"
|
@@ -42,9 +43,10 @@ files:
|
|
42
43
|
- LICENSE.txt
|
43
44
|
- README.md
|
44
45
|
- Rakefile
|
46
|
+
- ext/numo/openblas/extconf.rb
|
47
|
+
- ext/numo/openblas/openblas.c
|
45
48
|
- lib/numo/openblas.rb
|
46
49
|
- lib/numo/openblas/version.rb
|
47
|
-
- lib/rubygems_plugin.rb
|
48
50
|
- numo-openblas.gemspec
|
49
51
|
- vendor/tmp/.gitkeep
|
50
52
|
homepage: https://github.com/yoshoku/numo-openblas
|
data/lib/rubygems_plugin.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rubygems/package'
|
5
|
-
|
6
|
-
require 'digest/sha1'
|
7
|
-
require 'etc'
|
8
|
-
require 'fileutils'
|
9
|
-
require 'open-uri'
|
10
|
-
require 'open3'
|
11
|
-
|
12
|
-
Gem.post_install do
|
13
|
-
openblas_ver = '0.3.10'
|
14
|
-
openblas_key = 'cbe3fdd0e6ee235debc611d76976dac62f3ddc1c'
|
15
|
-
openblas_uri = "https://github.com/xianyi/OpenBLAS/archive/v#{openblas_ver}.tar.gz"
|
16
|
-
openblas_dir = File.expand_path(__dir__ + '/../vendor')
|
17
|
-
|
18
|
-
next true if File.exist?("#{openblas_dir}/installed_#{openblas_ver}")
|
19
|
-
|
20
|
-
puts "Downloading OpenBLAS #{openblas_ver}."
|
21
|
-
URI.open(openblas_uri) do |rf|
|
22
|
-
File.open("#{openblas_dir}/tmp/openblas.tgz", 'wb') { |sf| sf.write(rf.read) }
|
23
|
-
end
|
24
|
-
|
25
|
-
next false if openblas_key != Digest::SHA1.file("#{openblas_dir}/tmp/openblas.tgz").to_s
|
26
|
-
|
27
|
-
puts 'Unpacking OpenBLAS tar.gz file.'
|
28
|
-
Gem::Package::TarReader.new(Zlib::GzipReader.open("#{openblas_dir}/tmp/openblas.tgz")) do |tar|
|
29
|
-
tar.each do |entry|
|
30
|
-
next unless entry.file?
|
31
|
-
|
32
|
-
filename = "#{openblas_dir}/tmp/#{entry.full_name}"
|
33
|
-
next if filename == File.dirname(filename)
|
34
|
-
|
35
|
-
FileUtils.mkdir_p("#{openblas_dir}/tmp/#{File.dirname(entry.full_name)}")
|
36
|
-
File.open(filename, 'wb') { |f| f.write(entry.read) }
|
37
|
-
File.chmod(entry.header.mode, filename)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
Dir.chdir("#{openblas_dir}/tmp/OpenBLAS-#{openblas_ver}") do
|
42
|
-
puts 'Building OpenBLAS. This could take a while...'
|
43
|
-
mkstdout, _mkstderr, mkstatus = Open3.capture3("make -j#{Etc.nprocessors}")
|
44
|
-
File.open("#{openblas_dir}/tmp/openblas.log", 'w') { |f| f.puts(mkstdout) }
|
45
|
-
unless mkstatus.success?
|
46
|
-
puts 'Failed to build OpenBLAS.'
|
47
|
-
puts 'Check the make-openblas.log file for more details:'
|
48
|
-
puts "#{openblas_dir}/tmp/openblas.log"
|
49
|
-
break false
|
50
|
-
end
|
51
|
-
|
52
|
-
puts 'Installing OpenBLAS.'
|
53
|
-
insstdout, _insstderr, insstatus = Open3.capture3("make install PREFIX=#{openblas_dir}")
|
54
|
-
File.open("#{openblas_dir}/tmp/openblas.log", 'a') { |f| f.puts(insstdout) }
|
55
|
-
unless insstatus.success?
|
56
|
-
puts 'Failed to install OpenBLAS.'
|
57
|
-
puts 'Check the make-openblas.log file for more details:'
|
58
|
-
puts "#{openblas_dir}/tmp/openblas.log"
|
59
|
-
break false
|
60
|
-
end
|
61
|
-
|
62
|
-
FileUtils.touch("#{openblas_dir}/installed_#{openblas_ver}")
|
63
|
-
true
|
64
|
-
end
|
65
|
-
end
|