cumo 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +1272 -0
- data/3rd_party/mkmf-cu/Gemfile +2 -0
- data/3rd_party/mkmf-cu/Rakefile +2 -1
- data/3rd_party/mkmf-cu/bin/mkmf-cu-nvcc +2 -0
- data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +36 -7
- data/3rd_party/mkmf-cu/lib/mkmf-cu/nvcc.rb +51 -45
- data/3rd_party/mkmf-cu/lib/mkmf-cu.rb +2 -0
- data/3rd_party/mkmf-cu/mkmf-cu.gemspec +3 -1
- data/3rd_party/mkmf-cu/test/test_mkmf-cu.rb +5 -3
- data/CHANGELOG.md +69 -0
- data/Gemfile +6 -1
- data/README.md +2 -10
- data/Rakefile +8 -11
- data/bench/broadcast_fp32.rb +28 -26
- data/bench/cumo_bench.rb +18 -16
- data/bench/numo_bench.rb +18 -16
- data/bench/reduction_fp32.rb +14 -12
- data/bin/console +1 -0
- data/cumo.gemspec +5 -8
- data/ext/cumo/cuda/cudnn.c +2 -2
- data/ext/cumo/cumo.c +7 -3
- data/ext/cumo/depend.erb +15 -13
- data/ext/cumo/extconf.rb +32 -46
- data/ext/cumo/include/cumo/cuda/cudnn.h +3 -1
- data/ext/cumo/include/cumo/intern.h +1 -0
- data/ext/cumo/include/cumo/narray.h +13 -1
- data/ext/cumo/include/cumo/template.h +2 -4
- data/ext/cumo/include/cumo/types/complex_macro.h +1 -1
- data/ext/cumo/include/cumo/types/float_macro.h +2 -2
- data/ext/cumo/include/cumo/types/xint_macro.h +3 -2
- data/ext/cumo/include/cumo.h +2 -2
- data/ext/cumo/narray/array.c +3 -3
- data/ext/cumo/narray/data.c +23 -2
- data/ext/cumo/narray/gen/cogen.rb +8 -7
- data/ext/cumo/narray/gen/cogen_kernel.rb +8 -7
- data/ext/cumo/narray/gen/def/bit.rb +3 -1
- data/ext/cumo/narray/gen/def/dcomplex.rb +2 -0
- data/ext/cumo/narray/gen/def/dfloat.rb +2 -0
- data/ext/cumo/narray/gen/def/int16.rb +2 -0
- data/ext/cumo/narray/gen/def/int32.rb +2 -0
- data/ext/cumo/narray/gen/def/int64.rb +2 -0
- data/ext/cumo/narray/gen/def/int8.rb +2 -0
- data/ext/cumo/narray/gen/def/robject.rb +2 -0
- data/ext/cumo/narray/gen/def/scomplex.rb +2 -0
- data/ext/cumo/narray/gen/def/sfloat.rb +2 -0
- data/ext/cumo/narray/gen/def/uint16.rb +2 -0
- data/ext/cumo/narray/gen/def/uint32.rb +2 -0
- data/ext/cumo/narray/gen/def/uint64.rb +2 -0
- data/ext/cumo/narray/gen/def/uint8.rb +2 -0
- data/ext/cumo/narray/gen/erbln.rb +9 -7
- data/ext/cumo/narray/gen/erbpp2.rb +26 -24
- data/ext/cumo/narray/gen/narray_def.rb +13 -11
- data/ext/cumo/narray/gen/spec.rb +58 -55
- data/ext/cumo/narray/gen/tmpl/alloc_func.c +1 -1
- data/ext/cumo/narray/gen/tmpl/at.c +34 -0
- data/ext/cumo/narray/gen/tmpl/batch_norm.c +1 -1
- data/ext/cumo/narray/gen/tmpl/batch_norm_backward.c +2 -2
- data/ext/cumo/narray/gen/tmpl/conv.c +1 -1
- data/ext/cumo/narray/gen/tmpl/conv_grad_w.c +3 -1
- data/ext/cumo/narray/gen/tmpl/conv_transpose.c +1 -1
- data/ext/cumo/narray/gen/tmpl/fixed_batch_norm.c +1 -1
- data/ext/cumo/narray/gen/tmpl/init_class.c +1 -0
- data/ext/cumo/narray/gen/tmpl/pooling_backward.c +1 -1
- data/ext/cumo/narray/gen/tmpl/pooling_forward.c +1 -1
- data/ext/cumo/narray/gen/tmpl/qsort.c +1 -5
- data/ext/cumo/narray/gen/tmpl/sort.c +1 -1
- data/ext/cumo/narray/gen/tmpl_bit/binary.c +42 -14
- data/ext/cumo/narray/gen/tmpl_bit/bit_count.c +5 -0
- data/ext/cumo/narray/gen/tmpl_bit/bit_reduce.c +5 -0
- data/ext/cumo/narray/gen/tmpl_bit/mask.c +27 -7
- data/ext/cumo/narray/gen/tmpl_bit/store_bit.c +21 -7
- data/ext/cumo/narray/gen/tmpl_bit/unary.c +21 -7
- data/ext/cumo/narray/index.c +243 -39
- data/ext/cumo/narray/index_kernel.cu +84 -0
- data/ext/cumo/narray/narray.c +38 -1
- data/ext/cumo/narray/ndloop.c +1 -1
- data/ext/cumo/narray/struct.c +1 -1
- data/lib/cumo/cuda/compile_error.rb +1 -1
- data/lib/cumo/cuda/compiler.rb +23 -22
- data/lib/cumo/cuda/cudnn.rb +1 -1
- data/lib/cumo/cuda/device.rb +1 -1
- data/lib/cumo/cuda/link_state.rb +2 -2
- data/lib/cumo/cuda/module.rb +1 -2
- data/lib/cumo/cuda/nvrtc_program.rb +3 -2
- data/lib/cumo/cuda.rb +2 -0
- data/lib/cumo/linalg.rb +2 -0
- data/lib/cumo/narray/extra.rb +137 -185
- data/lib/cumo/narray.rb +2 -0
- data/lib/cumo.rb +3 -1
- data/test/bit_test.rb +157 -0
- data/test/cuda/compiler_test.rb +69 -0
- data/test/cuda/device_test.rb +30 -0
- data/test/cuda/memory_pool_test.rb +45 -0
- data/test/cuda/nvrtc_test.rb +51 -0
- data/test/cuda/runtime_test.rb +28 -0
- data/test/cudnn_test.rb +498 -0
- data/test/cumo_test.rb +27 -0
- data/test/narray_test.rb +745 -0
- data/test/ractor_test.rb +52 -0
- data/test/test_helper.rb +31 -0
- metadata +31 -54
- data/.travis.yml +0 -5
- data/numo-narray-version +0 -1
data/test/ractor_test.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
|
|
5
|
+
class NArrayRactorTest < CumoTestBase
|
|
6
|
+
if respond_to?(:ractor)
|
|
7
|
+
ractor keep: true
|
|
8
|
+
data(:dtype, TYPES, keep: true)
|
|
9
|
+
def test_non_frozen(data)
|
|
10
|
+
dtype = data.fetch(:dtype)
|
|
11
|
+
ary = random_array(dtype)
|
|
12
|
+
r = Ractor.new(ary) { |x| x }
|
|
13
|
+
ary2 = r.take
|
|
14
|
+
assert_equal(ary, ary2)
|
|
15
|
+
assert_not_same(ary, ary2)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_frozen(data)
|
|
19
|
+
dtype = data.fetch(:dtype)
|
|
20
|
+
ary1 = random_array(dtype)
|
|
21
|
+
ary1.freeze
|
|
22
|
+
r = Ractor.new(ary1) do |ary2|
|
|
23
|
+
[ary2, ary2 * 10]
|
|
24
|
+
end
|
|
25
|
+
ary2, res = r.take
|
|
26
|
+
assert_equal((dtype != Cumo::RObject),
|
|
27
|
+
ary1.equal?(ary2))
|
|
28
|
+
assert_equal(ary1 * 10, res)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_parallel(data)
|
|
32
|
+
dtype = data.fetch(:dtype)
|
|
33
|
+
ary1 = random_array(dtype, 100000)
|
|
34
|
+
r1 = Ractor.new(ary1) do |ary2|
|
|
35
|
+
ary2 * 10
|
|
36
|
+
end
|
|
37
|
+
r2 = Ractor.new(ary1) do |ary4|
|
|
38
|
+
ary4 * 10
|
|
39
|
+
end
|
|
40
|
+
assert_equal(r1.take, r2.take)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def random_array(dtype, n=1000)
|
|
44
|
+
case dtype
|
|
45
|
+
when Cumo::DFloat, Cumo::SFloat, Cumo::DComplex, Cumo::SComplex
|
|
46
|
+
dtype.new(n).rand_norm
|
|
47
|
+
else
|
|
48
|
+
dtype.new(n).rand(10)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
|
4
|
+
require "cumo"
|
|
5
|
+
|
|
6
|
+
require "pry"
|
|
7
|
+
require "test/unit"
|
|
8
|
+
|
|
9
|
+
class CumoTestBase < Test::Unit::TestCase
|
|
10
|
+
FLOAT_TYPES = [
|
|
11
|
+
Cumo::DFloat,
|
|
12
|
+
Cumo::DComplex,
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
TYPES = [
|
|
16
|
+
*FLOAT_TYPES,
|
|
17
|
+
Cumo::SFloat,
|
|
18
|
+
Cumo::SComplex,
|
|
19
|
+
Cumo::Int64,
|
|
20
|
+
Cumo::Int32,
|
|
21
|
+
Cumo::Int16,
|
|
22
|
+
Cumo::Int8,
|
|
23
|
+
Cumo::UInt64,
|
|
24
|
+
Cumo::UInt32,
|
|
25
|
+
Cumo::UInt16,
|
|
26
|
+
Cumo::UInt8,
|
|
27
|
+
|
|
28
|
+
## TODO: RObject causes failures on assertion
|
|
29
|
+
# Cumo::RObject,
|
|
30
|
+
]
|
|
31
|
+
end
|
metadata
CHANGED
|
@@ -1,57 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cumo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Naotoshi Seo
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: numo-narray
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.9.1.1
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.9.1.1
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: bundler
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.15'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.15'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '10.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '10.0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
55
12
|
description: Cumo is CUDA aware numerical library whose interface is highly compatible
|
|
56
13
|
with Ruby Numo.
|
|
57
14
|
email:
|
|
@@ -62,7 +19,8 @@ extensions:
|
|
|
62
19
|
extra_rdoc_files: []
|
|
63
20
|
files:
|
|
64
21
|
- ".gitignore"
|
|
65
|
-
- ".
|
|
22
|
+
- ".rubocop.yml"
|
|
23
|
+
- ".rubocop_todo.yml"
|
|
66
24
|
- 3rd_party/LICENSE.txt
|
|
67
25
|
- 3rd_party/mkmf-cu/.gitignore
|
|
68
26
|
- 3rd_party/mkmf-cu/Gemfile
|
|
@@ -206,6 +164,7 @@ files:
|
|
|
206
164
|
- ext/cumo/narray/gen/tmpl/aref.c
|
|
207
165
|
- ext/cumo/narray/gen/tmpl/aref_cpu.c
|
|
208
166
|
- ext/cumo/narray/gen/tmpl/aset.c
|
|
167
|
+
- ext/cumo/narray/gen/tmpl/at.c
|
|
209
168
|
- ext/cumo/narray/gen/tmpl/batch_norm.c
|
|
210
169
|
- ext/cumo/narray/gen/tmpl/batch_norm_backward.c
|
|
211
170
|
- ext/cumo/narray/gen/tmpl/binary.c
|
|
@@ -339,13 +298,22 @@ files:
|
|
|
339
298
|
- lib/cumo/linalg.rb
|
|
340
299
|
- lib/cumo/narray.rb
|
|
341
300
|
- lib/cumo/narray/extra.rb
|
|
342
|
-
- numo-narray-version
|
|
343
301
|
- run.gdb
|
|
302
|
+
- test/bit_test.rb
|
|
303
|
+
- test/cuda/compiler_test.rb
|
|
304
|
+
- test/cuda/device_test.rb
|
|
305
|
+
- test/cuda/memory_pool_test.rb
|
|
306
|
+
- test/cuda/nvrtc_test.rb
|
|
307
|
+
- test/cuda/runtime_test.rb
|
|
308
|
+
- test/cudnn_test.rb
|
|
309
|
+
- test/cumo_test.rb
|
|
310
|
+
- test/narray_test.rb
|
|
311
|
+
- test/ractor_test.rb
|
|
312
|
+
- test/test_helper.rb
|
|
344
313
|
homepage: https://github.com/sonots/cumo
|
|
345
314
|
licenses:
|
|
346
315
|
- BSD-3-Clause
|
|
347
316
|
metadata: {}
|
|
348
|
-
post_install_message:
|
|
349
317
|
rdoc_options: []
|
|
350
318
|
require_paths:
|
|
351
319
|
- lib
|
|
@@ -353,17 +321,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
353
321
|
requirements:
|
|
354
322
|
- - ">="
|
|
355
323
|
- !ruby/object:Gem::Version
|
|
356
|
-
version:
|
|
324
|
+
version: 3.0.0
|
|
357
325
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
326
|
requirements:
|
|
359
327
|
- - ">="
|
|
360
328
|
- !ruby/object:Gem::Version
|
|
361
329
|
version: '0'
|
|
362
330
|
requirements: []
|
|
363
|
-
|
|
364
|
-
rubygems_version: 2.7.6
|
|
365
|
-
signing_key:
|
|
331
|
+
rubygems_version: 3.7.2
|
|
366
332
|
specification_version: 4
|
|
367
333
|
summary: Cumo is CUDA aware numerical library whose interface is highly compatible
|
|
368
334
|
with Ruby Numo
|
|
369
|
-
test_files:
|
|
335
|
+
test_files:
|
|
336
|
+
- test/bit_test.rb
|
|
337
|
+
- test/cuda/compiler_test.rb
|
|
338
|
+
- test/cuda/device_test.rb
|
|
339
|
+
- test/cuda/memory_pool_test.rb
|
|
340
|
+
- test/cuda/nvrtc_test.rb
|
|
341
|
+
- test/cuda/runtime_test.rb
|
|
342
|
+
- test/cudnn_test.rb
|
|
343
|
+
- test/cumo_test.rb
|
|
344
|
+
- test/narray_test.rb
|
|
345
|
+
- test/ractor_test.rb
|
|
346
|
+
- test/test_helper.rb
|
data/.travis.yml
DELETED
data/numo-narray-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
>= 0.9.1.1
|