simd 0.5.1 → 0.5.2
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 +5 -5
- data/ext/simd/simd_floatarray.c +33 -0
- data/ext/simd/simd_floatarray.h +4 -0
- data/ext/simd/simd_intarray.c +32 -0
- data/ext/simd/simd_intarray.h +6 -0
- data/ext/simd/simd_longarray.c +32 -0
- data/ext/simd/simd_longarray.h +7 -1
- data/ext/simd/simd_smallfloatarray.c +33 -0
- data/ext/simd/simd_smallfloatarray.h +4 -0
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d43585672169c7a727e7502dea99cb56e8103c2e6a8effe4f32521ee4cae6e5d
|
4
|
+
data.tar.gz: c404674a578002bdf5933baee75e54680717c562b1e8c839a0661e04dfee27a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c6b9e43f219190f4bd2a34d0ad1c309eacb56068dbdb0d44f46894b1ceee19bc68c77d4f682d42b335039250730c9637a1d19c5075861c9731fd13a48d71d0
|
7
|
+
data.tar.gz: a71afed09b9ead560531c9ec2a9ffb0260843398255963b549abe44db0b45dc036fb604a945c9caff7f5d54dd51626f78ed4f2877803a9a5d2bc455e68c5c332
|
data/ext/simd/simd_floatarray.c
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "simd_floatarray.h"
|
2
|
+
#include "simd_longarray.h"
|
2
3
|
|
3
4
|
VALUE SIMD_FloatArray = Qnil;
|
4
5
|
|
@@ -15,6 +16,10 @@ void Init_SIMD_FloatArray(VALUE parent)
|
|
15
16
|
rb_define_method(SIMD_FloatArray, "&", method_and, 1);
|
16
17
|
rb_define_method(SIMD_FloatArray, "|", method_or, 1);
|
17
18
|
rb_define_method(SIMD_FloatArray, "^", method_xor, 1);
|
19
|
+
rb_define_method(SIMD_FloatArray, "gt", method_gt, 1);
|
20
|
+
rb_define_method(SIMD_FloatArray, "lt", method_lt, 1);
|
21
|
+
rb_define_method(SIMD_FloatArray, ">", method_gt, 1);
|
22
|
+
rb_define_method(SIMD_FloatArray, "<", method_lt, 1);
|
18
23
|
rb_define_method(SIMD_FloatArray, "length", method_length, 0);
|
19
24
|
rb_define_method(SIMD_FloatArray, "to_a", method_to_a, 0);
|
20
25
|
}
|
@@ -99,6 +104,22 @@ static VALUE method_xor(VALUE self, VALUE obj)
|
|
99
104
|
return(internal_apply_operation(self, obj, sizeof(double), SIMD_FloatArray, func_xor));
|
100
105
|
}
|
101
106
|
|
107
|
+
/* Public: Compare values contained in the data array with those contained in
|
108
|
+
* another FloatArray object, return a new LongArray with each element being
|
109
|
+
* -1 if the data array's value is greater, and 0 otherwise. */
|
110
|
+
static VALUE method_gt(VALUE self, VALUE obj)
|
111
|
+
{
|
112
|
+
return(internal_apply_operation(self, obj, sizeof(double), SIMD_LongArray, func_gt));
|
113
|
+
}
|
114
|
+
|
115
|
+
/* Public: Compare values contained in the data array with those contained in
|
116
|
+
* another FloatArray object, return a new LongArray with each element being
|
117
|
+
* -1 if the data array's value is less, and 0 otherwise. */
|
118
|
+
static VALUE method_lt(VALUE self, VALUE obj)
|
119
|
+
{
|
120
|
+
return(internal_apply_operation(self, obj, sizeof(double), SIMD_LongArray, func_lt));
|
121
|
+
}
|
122
|
+
|
102
123
|
/* Public: Return a Ruby Array containing the doubles within the data array. */
|
103
124
|
static VALUE method_to_a(VALUE self)
|
104
125
|
{
|
@@ -158,3 +179,15 @@ static void func_xor(void *v1, void *v2, void *r)
|
|
158
179
|
{
|
159
180
|
*(l2v *)r = *(l2v *)v1 ^ *(l2v *)v2;
|
160
181
|
}
|
182
|
+
|
183
|
+
/* Function: Compare vectors, return -1 if v1 is greater than v2, 0 otherwise */
|
184
|
+
static void func_gt(void *v1, void *v2, void *r)
|
185
|
+
{
|
186
|
+
*(l2v *)r = (*(d2v *)v1 > *(d2v *)v2);
|
187
|
+
}
|
188
|
+
|
189
|
+
/* Function: Compare vectors, return -1 if v1 is greater than v2, 0 otherwise */
|
190
|
+
static void func_lt(void *v1, void *v2, void *r)
|
191
|
+
{
|
192
|
+
*(l2v *)r = (*(d2v *)v1 < *(d2v *)v2);
|
193
|
+
}
|
data/ext/simd/simd_floatarray.h
CHANGED
@@ -9,6 +9,8 @@ static VALUE method_subtract(VALUE self, VALUE obj);
|
|
9
9
|
static VALUE method_and(VALUE self, VALUE obj);
|
10
10
|
static VALUE method_or(VALUE self, VALUE obj);
|
11
11
|
static VALUE method_xor(VALUE self, VALUE obj);
|
12
|
+
static VALUE method_gt(VALUE self, VALUE obj);
|
13
|
+
static VALUE method_lt(VALUE self, VALUE obj);
|
12
14
|
static VALUE method_to_a(VALUE self);
|
13
15
|
|
14
16
|
static void func_multiply(void *v1, void *v2, void *r);
|
@@ -18,3 +20,5 @@ static void func_subtract(void *v1, void *v2, void *r);
|
|
18
20
|
static void func_and(void *v1, void *v2, void *r);
|
19
21
|
static void func_or(void *v1, void *v2, void *r);
|
20
22
|
static void func_xor(void *v1, void *v2, void *r);
|
23
|
+
static void func_gt(void *v1, void *v2, void *r);
|
24
|
+
static void func_lt(void *v1, void *v2, void *r);
|
data/ext/simd/simd_intarray.c
CHANGED
@@ -15,6 +15,10 @@ void Init_SIMD_IntArray(VALUE parent)
|
|
15
15
|
rb_define_method(SIMD_IntArray, "&", method_and, 1);
|
16
16
|
rb_define_method(SIMD_IntArray, "|", method_or, 1);
|
17
17
|
rb_define_method(SIMD_IntArray, "^", method_xor, 1);
|
18
|
+
rb_define_method(SIMD_IntArray, "gt", method_gt, 1);
|
19
|
+
rb_define_method(SIMD_IntArray, "lt", method_lt, 1);
|
20
|
+
rb_define_method(SIMD_IntArray, ">", method_gt, 1);
|
21
|
+
rb_define_method(SIMD_IntArray, "<", method_lt, 1);
|
18
22
|
rb_define_method(SIMD_IntArray, "length", method_length, 0);
|
19
23
|
rb_define_method(SIMD_IntArray, "to_a", method_to_a, 0);
|
20
24
|
}
|
@@ -92,6 +96,22 @@ static VALUE method_xor(VALUE self, VALUE obj)
|
|
92
96
|
return(internal_apply_operation(self, obj, sizeof(int), SIMD_IntArray, func_xor));
|
93
97
|
}
|
94
98
|
|
99
|
+
/* Public: Compare values contained in the data array with those contained in
|
100
|
+
* another IntArray object, return a new IntArray with each element being -1
|
101
|
+
* if the data array's value is greater, and 0 otherwise. */
|
102
|
+
static VALUE method_gt(VALUE self, VALUE obj)
|
103
|
+
{
|
104
|
+
return(internal_apply_operation(self, obj, sizeof(int), SIMD_IntArray, func_gt));
|
105
|
+
}
|
106
|
+
|
107
|
+
/* Public: Compare values contained in the data array with those contained in
|
108
|
+
* another IntArray object, return a new IntArray with each element being -1 if
|
109
|
+
* the data array's value is less, and 0 otherwise. */
|
110
|
+
static VALUE method_lt(VALUE self, VALUE obj)
|
111
|
+
{
|
112
|
+
return(internal_apply_operation(self, obj, sizeof(int), SIMD_IntArray, func_lt));
|
113
|
+
}
|
114
|
+
|
95
115
|
/* Public: Subtract values contained in another FloatArray object from those
|
96
116
|
* contained in the current data array object, returning a new FloatArray. */
|
97
117
|
static VALUE method_subtract(VALUE self, VALUE obj)
|
@@ -158,3 +178,15 @@ static void func_xor(void *v1, void *v2, void *r)
|
|
158
178
|
{
|
159
179
|
*(i4v *)r = *(i4v *)v1 ^ *(i4v *)v2;
|
160
180
|
}
|
181
|
+
|
182
|
+
/* Function: Compare vectors, return -1 if v1 is greater than v2, 0 otherwise */
|
183
|
+
static void func_gt(void *v1, void *v2, void *r)
|
184
|
+
{
|
185
|
+
*(i4v *)r = (*(i4v *)v1 > *(i4v *)v2);
|
186
|
+
}
|
187
|
+
|
188
|
+
/* Function: Compare vectors, return -1 if v1 is less than v2, 0 otherwise */
|
189
|
+
static void func_lt(void *v1, void *v2, void *r)
|
190
|
+
{
|
191
|
+
*(i4v *)r = (*(i4v *)v1 < *(i4v *)v2);
|
192
|
+
}
|
data/ext/simd/simd_intarray.h
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#include "ruby.h"
|
2
2
|
#include "simd_common.h"
|
3
3
|
|
4
|
+
extern VALUE SIMD_IntArray;
|
5
|
+
|
4
6
|
static VALUE method_initialize(VALUE self, VALUE rb_array);
|
5
7
|
static VALUE method_multiply(VALUE self, VALUE obj);
|
6
8
|
static VALUE method_divide(VALUE self, VALUE obj);
|
@@ -9,6 +11,8 @@ static VALUE method_subtract(VALUE self, VALUE obj);
|
|
9
11
|
static VALUE method_and(VALUE self, VALUE obj);
|
10
12
|
static VALUE method_or(VALUE self, VALUE obj);
|
11
13
|
static VALUE method_xor(VALUE self, VALUE obj);
|
14
|
+
static VALUE method_gt(VALUE self, VALUE obj);
|
15
|
+
static VALUE method_lt(VALUE self, VALUE obj);
|
12
16
|
static VALUE method_to_a(VALUE self);
|
13
17
|
|
14
18
|
static void func_multiply(void *v1, void *v2, void *r);
|
@@ -18,3 +22,5 @@ static void func_subtract(void *v1, void *v2, void *r);
|
|
18
22
|
static void func_and(void *v1, void *v2, void *r);
|
19
23
|
static void func_or(void *v1, void *v2, void *r);
|
20
24
|
static void func_xor(void *v1, void *v2, void *r);
|
25
|
+
static void func_gt(void *v1, void *v2, void *r);
|
26
|
+
static void func_lt(void *v1, void *v2, void *r);
|
data/ext/simd/simd_longarray.c
CHANGED
@@ -15,6 +15,10 @@ void Init_SIMD_LongArray(VALUE parent)
|
|
15
15
|
rb_define_method(SIMD_LongArray, "&", method_and, 1);
|
16
16
|
rb_define_method(SIMD_LongArray, "|", method_or, 1);
|
17
17
|
rb_define_method(SIMD_LongArray, "^", method_xor, 1);
|
18
|
+
rb_define_method(SIMD_LongArray, "gt", method_gt, 1);
|
19
|
+
rb_define_method(SIMD_LongArray, "lt", method_lt, 1);
|
20
|
+
rb_define_method(SIMD_LongArray, ">", method_gt, 1);
|
21
|
+
rb_define_method(SIMD_LongArray, "<", method_lt, 1);
|
18
22
|
rb_define_method(SIMD_LongArray, "length", method_length, 0);
|
19
23
|
rb_define_method(SIMD_LongArray, "to_a", method_to_a, 0);
|
20
24
|
}
|
@@ -92,6 +96,22 @@ static VALUE method_xor(VALUE self, VALUE obj)
|
|
92
96
|
return(internal_apply_operation(self, obj, sizeof(long long int), SIMD_LongArray, func_xor));
|
93
97
|
}
|
94
98
|
|
99
|
+
/* Public: Compare values contained in the data array with those contained in
|
100
|
+
* another Longrray object, return a new LongArray with each element being -1
|
101
|
+
* if the data array's value is greater, and 0 otherwise. */
|
102
|
+
static VALUE method_gt(VALUE self, VALUE obj)
|
103
|
+
{
|
104
|
+
return(internal_apply_operation(self, obj, sizeof(long long int), SIMD_LongArray, func_gt));
|
105
|
+
}
|
106
|
+
|
107
|
+
/* Public: Compare values contained in the data array with those contained in
|
108
|
+
* another LongArray object, return a new LongArray with each element being -1 if
|
109
|
+
* the data array's value is less, and 0 otherwise. */
|
110
|
+
static VALUE method_lt(VALUE self, VALUE obj)
|
111
|
+
{
|
112
|
+
return(internal_apply_operation(self, obj, sizeof(long long int), SIMD_LongArray, func_lt));
|
113
|
+
}
|
114
|
+
|
95
115
|
/* Public: Subtract values contained in another FloatArray object from those
|
96
116
|
* contained in the current data array object, returning a new FloatArray. */
|
97
117
|
static VALUE method_subtract(VALUE self, VALUE obj)
|
@@ -158,3 +178,15 @@ static void func_xor(void *v1, void *v2, void *r)
|
|
158
178
|
{
|
159
179
|
*(l2v *)r = *(l2v *)v1 ^ *(l2v *)v2;
|
160
180
|
}
|
181
|
+
|
182
|
+
/* Function: Compare vectors, return -1 if v1 is greater than v2, 0 otherwise */
|
183
|
+
static void func_gt(void *v1, void *v2, void *r)
|
184
|
+
{
|
185
|
+
*(l2v *)r = (*(l2v *)v1 > *(l2v *)v2);
|
186
|
+
}
|
187
|
+
|
188
|
+
/* Function: Compare vectors, return -1 if v1 is less than v2, 0 otherwise */
|
189
|
+
static void func_lt(void *v1, void *v2, void *r)
|
190
|
+
{
|
191
|
+
*(l2v *)r = (*(l2v *)v1 < *(l2v *)v2);
|
192
|
+
}
|
data/ext/simd/simd_longarray.h
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
#include "ruby.h"
|
2
2
|
#include "simd_common.h"
|
3
3
|
|
4
|
+
extern VALUE SIMD_LongArray;
|
5
|
+
|
4
6
|
static VALUE method_initialize(VALUE self, VALUE rb_array);
|
5
7
|
static VALUE method_multiply(VALUE self, VALUE obj);
|
6
8
|
static VALUE method_divide(VALUE self, VALUE obj);
|
7
9
|
static VALUE method_add(VALUE self, VALUE obj);
|
10
|
+
static VALUE method_subtract(VALUE self, VALUE obj);
|
8
11
|
static VALUE method_and(VALUE self, VALUE obj);
|
9
12
|
static VALUE method_or(VALUE self, VALUE obj);
|
10
13
|
static VALUE method_xor(VALUE self, VALUE obj);
|
11
|
-
static VALUE
|
14
|
+
static VALUE method_gt(VALUE self, VALUE obj);
|
15
|
+
static VALUE method_lt(VALUE self, VALUE obj);
|
12
16
|
static VALUE method_to_a(VALUE self);
|
13
17
|
|
14
18
|
static void func_multiply(void *v1, void *v2, void *r);
|
@@ -18,3 +22,5 @@ static void func_subtract(void *v1, void *v2, void *r);
|
|
18
22
|
static void func_and(void *v1, void *v2, void *r);
|
19
23
|
static void func_or(void *v1, void *v2, void *r);
|
20
24
|
static void func_xor(void *v1, void *v2, void *r);
|
25
|
+
static void func_gt(void *v1, void *v2, void *r);
|
26
|
+
static void func_lt(void *v1, void *v2, void *r);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "simd_smallfloatarray.h"
|
2
|
+
#include "simd_intarray.h"
|
2
3
|
|
3
4
|
VALUE SIMD_SmallFloatArray = Qnil;
|
4
5
|
|
@@ -15,6 +16,10 @@ void Init_SIMD_SmallFloatArray(VALUE parent)
|
|
15
16
|
rb_define_method(SIMD_SmallFloatArray, "&", method_and, 1);
|
16
17
|
rb_define_method(SIMD_SmallFloatArray, "|", method_or, 1);
|
17
18
|
rb_define_method(SIMD_SmallFloatArray, "^", method_xor, 1);
|
19
|
+
rb_define_method(SIMD_SmallFloatArray, "gt", method_gt, 1);
|
20
|
+
rb_define_method(SIMD_SmallFloatArray, "lt", method_lt, 1);
|
21
|
+
rb_define_method(SIMD_SmallFloatArray, ">", method_gt, 1);
|
22
|
+
rb_define_method(SIMD_SmallFloatArray, "<", method_lt, 1);
|
18
23
|
rb_define_method(SIMD_SmallFloatArray, "length", method_length, 0);
|
19
24
|
rb_define_method(SIMD_SmallFloatArray, "to_a", method_to_a, 0);
|
20
25
|
}
|
@@ -99,6 +104,22 @@ static VALUE method_xor(VALUE self, VALUE obj)
|
|
99
104
|
return(internal_apply_operation(self, obj, sizeof(float), SIMD_SmallFloatArray, func_xor));
|
100
105
|
}
|
101
106
|
|
107
|
+
/* Public: Compare values contained in the data array with those contained in
|
108
|
+
* another SmallFloatArray object, return a new IntArray with each element being
|
109
|
+
* -1 if the data array's value is greater, and 0 otherwise. */
|
110
|
+
static VALUE method_gt(VALUE self, VALUE obj)
|
111
|
+
{
|
112
|
+
return(internal_apply_operation(self, obj, sizeof(float), SIMD_IntArray, func_gt));
|
113
|
+
}
|
114
|
+
|
115
|
+
/* Public: Compare values contained in the data array with those contained in
|
116
|
+
* another SmallFloatArray object, return a new IntArray with each element being
|
117
|
+
* -1 if the data array's value is less, and 0 otherwise. */
|
118
|
+
static VALUE method_lt(VALUE self, VALUE obj)
|
119
|
+
{
|
120
|
+
return(internal_apply_operation(self, obj, sizeof(float), SIMD_IntArray, func_lt));
|
121
|
+
}
|
122
|
+
|
102
123
|
/* Public: Return a Ruby Array containing the doubles within the data array. */
|
103
124
|
static VALUE method_to_a(VALUE self)
|
104
125
|
{
|
@@ -158,3 +179,15 @@ static void func_xor(void *v1, void *v2, void *r)
|
|
158
179
|
{
|
159
180
|
*(i4v *)r = *(i4v *)v1 ^ *(i4v *)v2;
|
160
181
|
}
|
182
|
+
|
183
|
+
/* Function: Compare vectors, return -1 if v1 is greater than v2, 0 otherwise */
|
184
|
+
static void func_gt(void *v1, void *v2, void *r)
|
185
|
+
{
|
186
|
+
*(i4v *)r = (*(f4v *)v1 > *(f4v *)v2);
|
187
|
+
}
|
188
|
+
|
189
|
+
/* Function: Compare vectors, return -1 if v1 is less than v2, 0 otherwise */
|
190
|
+
static void func_lt(void *v1, void *v2, void *r)
|
191
|
+
{
|
192
|
+
*(i4v *)r = (*(f4v *)v1 < *(f4v *)v2);
|
193
|
+
}
|
@@ -9,6 +9,8 @@ static VALUE method_subtract(VALUE self, VALUE obj);
|
|
9
9
|
static VALUE method_and(VALUE self, VALUE obj);
|
10
10
|
static VALUE method_or(VALUE self, VALUE obj);
|
11
11
|
static VALUE method_xor(VALUE self, VALUE obj);
|
12
|
+
static VALUE method_gt(VALUE self, VALUE obj);
|
13
|
+
static VALUE method_lt(VALUE self, VALUE obj);
|
12
14
|
static VALUE method_to_a(VALUE self);
|
13
15
|
|
14
16
|
static void func_multiply(void *v1, void *v2, void *r);
|
@@ -18,3 +20,5 @@ static void func_subtract(void *v1, void *v2, void *r);
|
|
18
20
|
static void func_and(void *v1, void *v2, void *r);
|
19
21
|
static void func_or(void *v1, void *v2, void *r);
|
20
22
|
static void func_xor(void *v1, void *v2, void *r);
|
23
|
+
static void func_gt(void *v1, void *v2, void *r);
|
24
|
+
static void func_lt(void *v1, void *v2, void *r);
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tina Wuest
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.2'
|
27
27
|
description: Access to SIMD (Single Instruction Multiple Data) instructions in Ruby
|
28
28
|
email: tina@wuest.me
|
29
29
|
executables: []
|
@@ -48,7 +48,7 @@ files:
|
|
48
48
|
homepage: https://gitlab.com/wuest/simd-ruby
|
49
49
|
licenses: []
|
50
50
|
metadata: {}
|
51
|
-
post_install_message:
|
51
|
+
post_install_message:
|
52
52
|
rdoc_options: []
|
53
53
|
require_paths:
|
54
54
|
- lib
|
@@ -63,9 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
|
67
|
-
|
68
|
-
signing_key:
|
66
|
+
rubygems_version: 3.3.7
|
67
|
+
signing_key:
|
69
68
|
specification_version: 4
|
70
69
|
summary: SIMD instructions in ruby
|
71
70
|
test_files: []
|