vector_sse 0.0.3 → 0.0.4
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/.travis.yml +8 -0
- data/Gemfile +2 -2
- data/README.md +4 -2
- data/lib/vector_sse.rb +19 -21
- data/lib/vector_sse/version.rb +5 -0
- data/spec/vector_vec_spec.rb +45 -0
- data/vector_sse.gemspec +4 -2
- metadata +6 -4
- data/lib/.gitignore +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56fffce0ddf63910192cb3d6c02b2c7052b07f48
|
4
|
+
data.tar.gz: ad9f4491bf8a3f03fba24ee40f89f4ff6d1c2f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7424cccf7484b98e2e01f27e477737bf911517b21ee14143bfcbd127370ef8a33443f89e11dc07088e1eab68cd6c7cafab445ff8e16944b5187cd46925252bd
|
7
|
+
data.tar.gz: 54e9bf1e96ffe47dd57723413bc675751d20a6dd414b753f1f45688ec5496b83252d2dd53294aa177d6f01e8739742d8fb146b0788587142da3b1b91c8d1d6e2
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://travis-ci.org/rgmann/vector_sse)
|
2
|
+
|
1
3
|
## Welcome to VectorSSE ##
|
2
4
|
|
3
5
|
VectorSSE is a Ruby gem that uses x86 Streaming SIMD Extensions (SSE) to accelerate
|
@@ -18,9 +20,9 @@ normal, non-SSE instructions to yield the overall sum of the 1000-element array.
|
|
18
20
|
|
19
21
|
## Install the gem ##
|
20
22
|
|
21
|
-
Install it with [RubyGems](https://rubygems.org/)
|
23
|
+
Install it with [RubyGems](https://rubygems.org/)
|
22
24
|
|
23
|
-
gem install vector_sse
|
25
|
+
gem install vector_sse
|
24
26
|
|
25
27
|
or add this to your Gemfile if you use [Bundler](http://gembundler.com/):
|
26
28
|
|
data/lib/vector_sse.rb
CHANGED
@@ -36,8 +36,6 @@ require File.join( bin_root, 'vector_sse.so' )
|
|
36
36
|
|
37
37
|
module VectorSSE
|
38
38
|
|
39
|
-
VERSION = "0.0.3"
|
40
|
-
|
41
39
|
module Type
|
42
40
|
S32 = 0
|
43
41
|
S64 = 1
|
@@ -138,7 +136,7 @@ module VectorSSE
|
|
138
136
|
|
139
137
|
scalar_mul = false
|
140
138
|
|
141
|
-
if [
|
139
|
+
if [ Integer, Float ].include? other.class
|
142
140
|
|
143
141
|
scalar_mul = true
|
144
142
|
scalar_value = other
|
@@ -195,7 +193,7 @@ module VectorSSE
|
|
195
193
|
|
196
194
|
def +( other )
|
197
195
|
|
198
|
-
if [
|
196
|
+
if [ Integer, Float ].include? other.class
|
199
197
|
|
200
198
|
scalar_value = other
|
201
199
|
other = Mat.new( @type, @rows, @cols )
|
@@ -211,7 +209,7 @@ module VectorSSE
|
|
211
209
|
else
|
212
210
|
|
213
211
|
raise ArgumentError.new(
|
214
|
-
"expect argument of type #{self.class},
|
212
|
+
"expect argument of type #{self.class}, Integer, or Float for argument 0" )
|
215
213
|
|
216
214
|
end
|
217
215
|
|
@@ -233,7 +231,7 @@ module VectorSSE
|
|
233
231
|
|
234
232
|
def -( other )
|
235
233
|
|
236
|
-
if [
|
234
|
+
if [ Integer, Float ].include? other.class
|
237
235
|
|
238
236
|
scalar_value = other
|
239
237
|
other = Mat.new( @type, @rows, @cols )
|
@@ -249,7 +247,7 @@ module VectorSSE
|
|
249
247
|
else
|
250
248
|
|
251
249
|
raise ArgumentError.new(
|
252
|
-
"expect argument of type #{self.class},
|
250
|
+
"expect argument of type #{self.class}, Integer, or Float for argument 0" )
|
253
251
|
|
254
252
|
end
|
255
253
|
|
@@ -309,8 +307,8 @@ module VectorSSE
|
|
309
307
|
|
310
308
|
def valid_data_type( value )
|
311
309
|
|
312
|
-
unless [
|
313
|
-
raise ArgumentError.new( "expected argument of type
|
310
|
+
unless [ Integer, Float ].include? value.class
|
311
|
+
raise ArgumentError.new( "expected argument of type Integer or Float" )
|
314
312
|
end
|
315
313
|
|
316
314
|
end
|
@@ -336,27 +334,27 @@ module VectorSSE
|
|
336
334
|
end
|
337
335
|
|
338
336
|
def <<( value )
|
339
|
-
unless [
|
337
|
+
unless [ Integer, Float ].include? value.class
|
340
338
|
raise ArgumentError.new(
|
341
|
-
"expected argument of type
|
339
|
+
"expected argument of type Integer or Float for argument 0" )
|
342
340
|
end
|
343
341
|
super( value )
|
344
342
|
end
|
345
343
|
|
346
344
|
def insert( index, *values )
|
347
345
|
values.each_with_index do |value,arg_index|
|
348
|
-
unless [
|
346
|
+
unless [ Integer, Float ].include? value.class
|
349
347
|
raise ArgumentError.new(
|
350
|
-
"expected argument of type
|
348
|
+
"expected argument of type Integer or Float for argument #{arg_index}" )
|
351
349
|
end
|
352
350
|
end
|
353
351
|
super( index, values )
|
354
352
|
end
|
355
353
|
|
356
354
|
def []=( index, value )
|
357
|
-
unless [
|
355
|
+
unless [ Integer, Float ].include? value.class
|
358
356
|
raise ArgumentError.new(
|
359
|
-
"expected argument of type
|
357
|
+
"expected argument of type Integer or Float for argument 1" )
|
360
358
|
end
|
361
359
|
super( index, value )
|
362
360
|
end
|
@@ -367,14 +365,14 @@ module VectorSSE
|
|
367
365
|
#
|
368
366
|
def +( other )
|
369
367
|
|
370
|
-
if [
|
368
|
+
if [ Integer, Float ].include? other.class
|
371
369
|
|
372
370
|
other = ::Array.new( self.length, other )
|
373
371
|
|
374
372
|
elsif other.class != self.class
|
375
373
|
|
376
374
|
raise ArgumentError.new(
|
377
|
-
"expect argument of type #{self.class},
|
375
|
+
"expect argument of type #{self.class}, Integer, or Float for argument 0" )
|
378
376
|
|
379
377
|
end
|
380
378
|
|
@@ -400,11 +398,11 @@ module VectorSSE
|
|
400
398
|
#
|
401
399
|
def -( other )
|
402
400
|
|
403
|
-
if [
|
401
|
+
if [ Integer, Float ].include? other.class
|
404
402
|
other = ::Array.new( self.length, other )
|
405
403
|
elsif other.class != self.class
|
406
404
|
raise ArgumentError.new(
|
407
|
-
"expected argument of type #{self.class},
|
405
|
+
"expected argument of type #{self.class}, Integer, or Float for argument 0" )
|
408
406
|
end
|
409
407
|
|
410
408
|
result = self.class.new( @type )
|
@@ -444,9 +442,9 @@ module VectorSSE
|
|
444
442
|
|
445
443
|
def *( other )
|
446
444
|
|
447
|
-
unless [
|
445
|
+
unless [ Integer, Float ].include? other.class
|
448
446
|
|
449
|
-
raise ArgumentError.new( "expected argument of type Float or
|
447
|
+
raise ArgumentError.new( "expected argument of type Float or Integer for argument 0" )
|
450
448
|
|
451
449
|
end
|
452
450
|
|
data/spec/vector_vec_spec.rb
CHANGED
@@ -30,6 +30,51 @@ RSpec.describe VectorSSE::Array do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "vector addition" do
|
33
|
+
|
34
|
+
it "raises exception if right addend is shorter than the left addend in addition" do
|
35
|
+
left = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
36
|
+
left.replace [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
|
37
|
+
right = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
38
|
+
right.replace [ 1, 2, 3, 4, 5 ]
|
39
|
+
|
40
|
+
expect {
|
41
|
+
result = left + right
|
42
|
+
}.to raise_error "Vector lengths must be the same"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises exception if right addend is shorter than the left addend in subtraction" do
|
46
|
+
left = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
47
|
+
left.replace [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
|
48
|
+
right = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
49
|
+
right.replace [ 1, 2, 3, 4, 5 ]
|
50
|
+
|
51
|
+
expect {
|
52
|
+
result = left - right
|
53
|
+
}.to raise_error "Vector lengths must be the same"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises exception if right addend is longer than the left addend in addition" do
|
57
|
+
left = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
58
|
+
left.replace [ 1, 2, 3, 4, 5 ]
|
59
|
+
right = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
60
|
+
right.replace [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
|
61
|
+
|
62
|
+
expect {
|
63
|
+
result = left + right
|
64
|
+
}.to raise_error "Vector lengths must be the same"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "raises exception if right addend is longer than the left addend in subtraction" do
|
68
|
+
left = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
69
|
+
left.replace [ 1, 2, 3, 4, 5 ]
|
70
|
+
right = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
71
|
+
right.replace [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
|
72
|
+
|
73
|
+
expect {
|
74
|
+
result = left - right
|
75
|
+
}.to raise_error "Vector lengths must be the same"
|
76
|
+
end
|
77
|
+
|
33
78
|
it "returns difference between vectors" do
|
34
79
|
left = VectorSSE::Array.new( VectorSSE::Type::S32 )
|
35
80
|
left.replace [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
|
data/vector_sse.gemspec
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "vector_sse/version"
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
7
|
s.name = 'vector_sse'
|
6
|
-
s.version = VectorSSE::VERSION
|
8
|
+
s.version = VectorSSE::VERSION.dup
|
7
9
|
s.date = Time.now.to_date.strftime('%Y-%m-%d')
|
8
10
|
s.summary = "SIMD accelerated vector and matrix operations"
|
9
11
|
s.description = "VectorSse employs x86 Streaming SIMD Extensions (SSE), v3 or greater, to accelerate basic vector and matrix computations in Ruby."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vector_sse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Glissmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -47,6 +47,7 @@ extensions:
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
@@ -65,8 +66,8 @@ files:
|
|
65
66
|
- ext/vector_sse/vector_sse_sum.h
|
66
67
|
- ext/vector_sse/vector_sse_vec_mul.c
|
67
68
|
- ext/vector_sse/vector_sse_vec_mul.h
|
68
|
-
- lib/.gitignore
|
69
69
|
- lib/vector_sse.rb
|
70
|
+
- lib/vector_sse/version.rb
|
70
71
|
- spec/vector_mat_spec.rb
|
71
72
|
- spec/vector_vec_spec.rb
|
72
73
|
- vector_sse.gemspec
|
@@ -90,8 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.4.
|
94
|
+
rubygems_version: 2.4.5.1
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: SIMD accelerated vector and matrix operations
|
97
98
|
test_files: []
|
99
|
+
has_rdoc:
|
data/lib/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
vector_sse/
|