cumo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/3rd_party/LICENSE.txt +60 -0
- data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +13 -1
- data/LICENSE.txt +1 -62
- data/README.md +33 -29
- data/bench/cumo_bench.rb +47 -25
- data/bench/numo_bench.rb +27 -25
- data/docs/src-tree.md +16 -0
- data/ext/cumo/cuda/cublas.c +69 -219
- data/ext/cumo/cuda/memory_pool_impl.hpp +1 -0
- data/ext/cumo/cuda/runtime.c +2 -14
- data/ext/cumo/cumo.c +16 -16
- data/ext/cumo/include/cumo.h +2 -2
- data/ext/cumo/include/cumo/cuda/cublas.h +6 -129
- data/ext/cumo/include/cumo/cuda/runtime.h +16 -0
- data/ext/cumo/include/cumo/indexer.h +46 -63
- data/ext/cumo/include/cumo/intern.h +58 -112
- data/ext/cumo/include/cumo/narray.h +214 -185
- data/ext/cumo/include/cumo/narray_kernel.h +66 -37
- data/ext/cumo/include/cumo/ndloop.h +42 -42
- data/ext/cumo/include/cumo/reduce_kernel.h +55 -71
- data/ext/cumo/include/cumo/template.h +56 -51
- data/ext/cumo/include/cumo/template_kernel.h +31 -31
- data/ext/cumo/include/cumo/types/bit.h +3 -3
- data/ext/cumo/include/cumo/types/bit_kernel.h +2 -2
- data/ext/cumo/include/cumo/types/complex.h +126 -126
- data/ext/cumo/include/cumo/types/complex_kernel.h +126 -126
- data/ext/cumo/include/cumo/types/complex_macro.h +28 -28
- data/ext/cumo/include/cumo/types/complex_macro_kernel.h +20 -20
- data/ext/cumo/include/cumo/types/dcomplex.h +5 -5
- data/ext/cumo/include/cumo/types/dcomplex_kernel.h +1 -1
- data/ext/cumo/include/cumo/types/int_macro.h +1 -1
- data/ext/cumo/include/cumo/types/int_macro_kernel.h +1 -1
- data/ext/cumo/include/cumo/types/robj_macro.h +30 -30
- data/ext/cumo/include/cumo/types/scomplex.h +5 -5
- data/ext/cumo/include/cumo/types/scomplex_kernel.h +1 -1
- data/ext/cumo/narray/array.c +143 -143
- data/ext/cumo/narray/data.c +184 -184
- data/ext/cumo/narray/gen/cogen.rb +5 -2
- data/ext/cumo/narray/gen/cogen_kernel.rb +5 -2
- data/ext/cumo/narray/gen/def/dcomplex.rb +1 -1
- data/ext/cumo/narray/gen/def/scomplex.rb +1 -1
- data/ext/cumo/narray/gen/erbln.rb +132 -0
- data/ext/cumo/narray/gen/erbpp2.rb +18 -13
- data/ext/cumo/narray/gen/narray_def.rb +3 -3
- data/ext/cumo/narray/gen/spec.rb +2 -2
- data/ext/cumo/narray/gen/tmpl/accum.c +15 -15
- data/ext/cumo/narray/gen/tmpl/accum_binary.c +22 -22
- data/ext/cumo/narray/gen/tmpl/accum_binary_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/accum_index.c +30 -30
- data/ext/cumo/narray/gen/tmpl/accum_index_kernel.cu +2 -2
- data/ext/cumo/narray/gen/tmpl/accum_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/alloc_func.c +14 -14
- data/ext/cumo/narray/gen/tmpl/allocate.c +11 -11
- data/ext/cumo/narray/gen/tmpl/aref.c +2 -2
- data/ext/cumo/narray/gen/tmpl/aref_cpu.c +4 -4
- data/ext/cumo/narray/gen/tmpl/aset.c +2 -2
- data/ext/cumo/narray/gen/tmpl/binary.c +28 -28
- data/ext/cumo/narray/gen/tmpl/binary2.c +18 -18
- data/ext/cumo/narray/gen/tmpl/binary2_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/binary_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/binary_s.c +13 -13
- data/ext/cumo/narray/gen/tmpl/binary_s_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/bincount.c +23 -23
- data/ext/cumo/narray/gen/tmpl/cast.c +7 -7
- data/ext/cumo/narray/gen/tmpl/cast_array.c +3 -3
- data/ext/cumo/narray/gen/tmpl/clip.c +38 -38
- data/ext/cumo/narray/gen/tmpl/complex_accum_kernel.cu +2 -2
- data/ext/cumo/narray/gen/tmpl/cond_binary.c +19 -19
- data/ext/cumo/narray/gen/tmpl/cond_binary_kernel.cu +7 -7
- data/ext/cumo/narray/gen/tmpl/cond_unary.c +15 -15
- data/ext/cumo/narray/gen/tmpl/cum.c +15 -15
- data/ext/cumo/narray/gen/tmpl/each.c +9 -9
- data/ext/cumo/narray/gen/tmpl/each_with_index.c +9 -9
- data/ext/cumo/narray/gen/tmpl/ewcomp.c +15 -15
- data/ext/cumo/narray/gen/tmpl/ewcomp_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/extract_cpu.c +5 -5
- data/ext/cumo/narray/gen/tmpl/extract_data.c +12 -12
- data/ext/cumo/narray/gen/tmpl/eye.c +9 -9
- data/ext/cumo/narray/gen/tmpl/eye_kernel.cu +3 -3
- data/ext/cumo/narray/gen/tmpl/fill.c +9 -9
- data/ext/cumo/narray/gen/tmpl/fill_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/float_accum_kernel.cu +1 -1
- data/ext/cumo/narray/gen/tmpl/format.c +11 -11
- data/ext/cumo/narray/gen/tmpl/format_to_a.c +8 -8
- data/ext/cumo/narray/gen/tmpl/frexp.c +13 -13
- data/ext/cumo/narray/gen/tmpl/gemm.c +252 -108
- data/ext/cumo/narray/gen/tmpl/inspect.c +1 -1
- data/ext/cumo/narray/gen/tmpl/lib.c +2 -2
- data/ext/cumo/narray/gen/tmpl/logseq.c +7 -7
- data/ext/cumo/narray/gen/tmpl/logseq_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/map_with_index.c +17 -17
- data/ext/cumo/narray/gen/tmpl/median.c +10 -10
- data/ext/cumo/narray/gen/tmpl/minmax.c +10 -10
- data/ext/cumo/narray/gen/tmpl/new_dim0.c +3 -3
- data/ext/cumo/narray/gen/tmpl/poly.c +6 -6
- data/ext/cumo/narray/gen/tmpl/pow.c +28 -28
- data/ext/cumo/narray/gen/tmpl/pow_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/rand.c +10 -10
- data/ext/cumo/narray/gen/tmpl/rand_norm.c +7 -7
- data/ext/cumo/narray/gen/tmpl/real_accum_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/seq.c +7 -7
- data/ext/cumo/narray/gen/tmpl/seq_kernel.cu +6 -6
- data/ext/cumo/narray/gen/tmpl/set2.c +20 -20
- data/ext/cumo/narray/gen/tmpl/sort.c +11 -11
- data/ext/cumo/narray/gen/tmpl/sort_index.c +18 -18
- data/ext/cumo/narray/gen/tmpl/store.c +6 -6
- data/ext/cumo/narray/gen/tmpl/store_array.c +19 -19
- data/ext/cumo/narray/gen/tmpl/store_array_kernel.cu +12 -12
- data/ext/cumo/narray/gen/tmpl/store_bit.c +23 -23
- data/ext/cumo/narray/gen/tmpl/store_bit_kernel.cu +28 -28
- data/ext/cumo/narray/gen/tmpl/store_from.c +16 -16
- data/ext/cumo/narray/gen/tmpl/store_from_kernel.cu +12 -12
- data/ext/cumo/narray/gen/tmpl/to_a.c +10 -10
- data/ext/cumo/narray/gen/tmpl/unary.c +25 -25
- data/ext/cumo/narray/gen/tmpl/unary2.c +17 -17
- data/ext/cumo/narray/gen/tmpl/unary_kernel.cu +15 -15
- data/ext/cumo/narray/gen/tmpl/unary_ret2.c +13 -13
- data/ext/cumo/narray/gen/tmpl/unary_s.c +17 -17
- data/ext/cumo/narray/gen/tmpl/unary_s_kernel.cu +12 -12
- data/ext/cumo/narray/gen/tmpl_bit/allocate.c +9 -9
- data/ext/cumo/narray/gen/tmpl_bit/aref.c +2 -2
- data/ext/cumo/narray/gen/tmpl_bit/aref_cpu.c +5 -5
- data/ext/cumo/narray/gen/tmpl_bit/aset.c +2 -2
- data/ext/cumo/narray/gen/tmpl_bit/binary.c +29 -29
- data/ext/cumo/narray/gen/tmpl_bit/bit_count.c +14 -14
- data/ext/cumo/narray/gen/tmpl_bit/bit_count_cpu.c +21 -21
- data/ext/cumo/narray/gen/tmpl_bit/bit_count_kernel.cu +28 -28
- data/ext/cumo/narray/gen/tmpl_bit/bit_reduce.c +29 -29
- data/ext/cumo/narray/gen/tmpl_bit/each.c +10 -10
- data/ext/cumo/narray/gen/tmpl_bit/each_with_index.c +10 -10
- data/ext/cumo/narray/gen/tmpl_bit/extract.c +8 -8
- data/ext/cumo/narray/gen/tmpl_bit/extract_cpu.c +8 -8
- data/ext/cumo/narray/gen/tmpl_bit/fill.c +17 -17
- data/ext/cumo/narray/gen/tmpl_bit/format.c +14 -14
- data/ext/cumo/narray/gen/tmpl_bit/format_to_a.c +11 -11
- data/ext/cumo/narray/gen/tmpl_bit/inspect.c +3 -3
- data/ext/cumo/narray/gen/tmpl_bit/mask.c +33 -33
- data/ext/cumo/narray/gen/tmpl_bit/store_array.c +19 -19
- data/ext/cumo/narray/gen/tmpl_bit/store_bit.c +22 -22
- data/ext/cumo/narray/gen/tmpl_bit/store_from.c +18 -18
- data/ext/cumo/narray/gen/tmpl_bit/to_a.c +12 -12
- data/ext/cumo/narray/gen/tmpl_bit/unary.c +24 -24
- data/ext/cumo/narray/gen/tmpl_bit/where.c +16 -16
- data/ext/cumo/narray/gen/tmpl_bit/where2.c +20 -20
- data/ext/cumo/narray/index.c +213 -213
- data/ext/cumo/narray/math.c +27 -27
- data/ext/cumo/narray/narray.c +484 -484
- data/ext/cumo/narray/ndloop.c +259 -258
- data/ext/cumo/narray/rand.c +3 -3
- data/ext/cumo/narray/step.c +70 -70
- data/ext/cumo/narray/struct.c +139 -139
- metadata +6 -7
- data/ext/cumo/include/cumo/intern_fwd.h +0 -38
- data/lib/erbpp.rb +0 -294
- data/lib/erbpp/line_number.rb +0 -137
- data/lib/erbpp/narray_def.rb +0 -381
@@ -65,12 +65,12 @@ extern "C" {
|
|
65
65
|
#endif
|
66
66
|
#endif
|
67
67
|
|
68
|
-
void cumo_<%=type_name%>_sum_kernel_launch(
|
68
|
+
void cumo_<%=type_name%>_sum_kernel_launch(cumo_na_reduction_arg_t* arg)
|
69
69
|
{
|
70
70
|
cumo_reduce<dtype, <%=dtype%>, cumo_<%=type_name%>_sum_impl>(*arg, cumo_<%=type_name%>_sum_impl{});
|
71
71
|
}
|
72
72
|
|
73
|
-
void cumo_<%=type_name%>_prod_kernel_launch(
|
73
|
+
void cumo_<%=type_name%>_prod_kernel_launch(cumo_na_reduction_arg_t* arg)
|
74
74
|
{
|
75
75
|
cumo_reduce<dtype, <%=dtype%>, cumo_<%=type_name%>_prod_impl>(*arg, cumo_<%=type_name%>_prod_impl{});
|
76
76
|
}
|
@@ -1,29 +1,29 @@
|
|
1
1
|
<% unless type_name == 'robject' %>
|
2
|
-
void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2,
|
2
|
+
void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, CUMO_BIT_DIGIT *a3, size_t p3, ssize_t s1, ssize_t s2, ssize_t s3, uint64_t n);
|
3
3
|
<% end %>
|
4
4
|
|
5
5
|
static void
|
6
|
-
<%=c_iter%>(
|
6
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
7
7
|
{
|
8
8
|
size_t i;
|
9
9
|
char *p1, *p2;
|
10
|
-
|
10
|
+
CUMO_BIT_DIGIT *a3;
|
11
11
|
size_t p3;
|
12
12
|
ssize_t s1, s2, s3;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
CUMO_INIT_COUNTER(lp, i);
|
14
|
+
CUMO_INIT_PTR(lp, 0, p1, s1);
|
15
|
+
CUMO_INIT_PTR(lp, 1, p2, s2);
|
16
|
+
CUMO_INIT_PTR_BIT(lp, 2, a3, p3, s3);
|
17
17
|
<% if type_name == 'robject' %>
|
18
18
|
{
|
19
19
|
dtype x, y;
|
20
|
-
|
21
|
-
|
20
|
+
CUMO_BIT_DIGIT b;
|
21
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
22
22
|
for (; i--;) {
|
23
|
-
|
24
|
-
|
23
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
24
|
+
CUMO_GET_DATA_STRIDE(p2,s2,dtype,y);
|
25
25
|
b = (m_<%=name%>(x,y)) ? 1:0;
|
26
|
-
|
26
|
+
CUMO_STORE_BIT(a3,p3,b);
|
27
27
|
p3+=s3;
|
28
28
|
}
|
29
29
|
}
|
@@ -37,11 +37,11 @@ static void
|
|
37
37
|
static VALUE
|
38
38
|
<%=c_func%>_self(VALUE self, VALUE other)
|
39
39
|
{
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
|
41
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cumo_cBit,0}};
|
42
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_STRIDE_LOOP, 2, 1, ain, aout };
|
43
43
|
|
44
|
-
return
|
44
|
+
return cumo_na_ndloop(&ndf, 2, self, other);
|
45
45
|
}
|
46
46
|
|
47
47
|
/*
|
@@ -57,12 +57,12 @@ static VALUE
|
|
57
57
|
return <%=c_func%>_self(self, other);
|
58
58
|
<% else %>
|
59
59
|
VALUE klass, v;
|
60
|
-
klass =
|
60
|
+
klass = cumo_na_upcast(rb_obj_class(self),rb_obj_class(other));
|
61
61
|
if (klass==cT) {
|
62
62
|
return <%=c_func%>_self(self, other);
|
63
63
|
} else {
|
64
|
-
v = rb_funcall(klass,
|
65
|
-
return rb_funcall(v, <%=
|
64
|
+
v = rb_funcall(klass, cumo_id_cast, 1, self);
|
65
|
+
return rb_funcall(v, <%=cumo_id_op%>, 1, other);
|
66
66
|
}
|
67
67
|
<% end %>
|
68
68
|
}
|
@@ -1,18 +1,18 @@
|
|
1
1
|
<% unless type_name == 'robject' %>
|
2
|
-
__global__ void <%="cumo_#{c_iter}_stride_kernel"%>(char *p1, char *p2,
|
2
|
+
__global__ void <%="cumo_#{c_iter}_stride_kernel"%>(char *p1, char *p2, CUMO_BIT_DIGIT *a3, size_t p3, ssize_t s1, ssize_t s2, ssize_t s3, uint64_t n)
|
3
3
|
{
|
4
4
|
for (uint64_t i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += blockDim.x * gridDim.x) {
|
5
5
|
dtype x = *(dtype*)(p1+(i*s1));
|
6
6
|
dtype y = *(dtype*)(p2+(i*s2));
|
7
|
-
|
8
|
-
|
7
|
+
CUMO_BIT_DIGIT b = (m_<%=name%>(x,y)) ? 1:0;
|
8
|
+
CUMO_STORE_BIT(a3,p3+(i*s3),b);
|
9
9
|
}
|
10
10
|
}
|
11
11
|
|
12
|
-
void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2,
|
12
|
+
void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, CUMO_BIT_DIGIT *a3, size_t p3, ssize_t s1, ssize_t s2, ssize_t s3, uint64_t n)
|
13
13
|
{
|
14
|
-
size_t
|
15
|
-
size_t
|
16
|
-
<%="cumo_#{c_iter}_stride_kernel"%><<<
|
14
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
15
|
+
size_t block_dim = cumo_get_block_dim(n);
|
16
|
+
<%="cumo_#{c_iter}_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,a3,p3,s1,s2,s3,n);
|
17
17
|
}
|
18
18
|
<% end %>
|
@@ -1,30 +1,30 @@
|
|
1
1
|
static void
|
2
|
-
<%=c_iter%>(
|
2
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
3
3
|
{
|
4
4
|
size_t i;
|
5
5
|
char *p1;
|
6
|
-
|
6
|
+
CUMO_BIT_DIGIT *a2;
|
7
7
|
size_t p2;
|
8
8
|
ssize_t s1, s2;
|
9
9
|
size_t *idx1;
|
10
10
|
dtype x;
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
CUMO_BIT_DIGIT b;
|
12
|
+
CUMO_INIT_COUNTER(lp, i);
|
13
|
+
CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
14
|
+
CUMO_INIT_PTR_BIT(lp, 1, a2, p2, s2);
|
15
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
16
16
|
if (idx1) {
|
17
17
|
for (; i--;) {
|
18
|
-
|
18
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
19
19
|
b = (m_<%=name%>(x)) ? 1:0;
|
20
|
-
|
20
|
+
CUMO_STORE_BIT(a2,p2,b);
|
21
21
|
p2+=s2;
|
22
22
|
}
|
23
23
|
} else {
|
24
24
|
for (; i--;) {
|
25
|
-
|
25
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
26
26
|
b = (m_<%=name%>(x)) ? 1:0;
|
27
|
-
|
27
|
+
CUMO_STORE_BIT(a2,p2,b);
|
28
28
|
p2+=s2;
|
29
29
|
}
|
30
30
|
}
|
@@ -38,9 +38,9 @@ static void
|
|
38
38
|
static VALUE
|
39
39
|
<%=c_func(0)%>(VALUE self)
|
40
40
|
{
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
|
42
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cumo_cBit,0}};
|
43
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 1, 1, ain, aout };
|
44
44
|
|
45
|
-
return
|
45
|
+
return cumo_na_ndloop(&ndf, 1, self);
|
46
46
|
}
|
@@ -1,25 +1,25 @@
|
|
1
1
|
<% (is_float ? ["","_nan"] : [""]).each do |j| %>
|
2
2
|
static void
|
3
|
-
<%=c_iter%><%=j%>(
|
3
|
+
<%=c_iter%><%=j%>(cumo_na_loop_t *const lp)
|
4
4
|
{
|
5
5
|
size_t i;
|
6
6
|
char *p1, *p2;
|
7
7
|
ssize_t s1, s2;
|
8
8
|
dtype x, y;
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
CUMO_INIT_COUNTER(lp, i);
|
11
|
+
CUMO_INIT_PTR(lp, 0, p1, s1);
|
12
|
+
CUMO_INIT_PTR(lp, 1, p2, s2);
|
13
13
|
//printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
16
|
+
CUMO_SET_DATA_STRIDE(p2,s2,dtype,x);
|
17
17
|
//printf("i=%lu x=%f\n",i,x);
|
18
|
-
|
18
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%><%=j%>", "<%=type_name%>");
|
19
19
|
for (i--; i--;) {
|
20
|
-
|
20
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,y);
|
21
21
|
m_<%=name%><%=j%>(x,y);
|
22
|
-
|
22
|
+
CUMO_SET_DATA_STRIDE(p2,s2,dtype,x);
|
23
23
|
//printf("i=%lu x=%f\n",i,x);
|
24
24
|
}
|
25
25
|
}
|
@@ -36,15 +36,15 @@ static VALUE
|
|
36
36
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
37
37
|
{
|
38
38
|
VALUE reduce;
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cumo_sym_reduce,0}};
|
40
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
|
41
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_STRIDE_LOOP|CUMO_NDF_FLAT_REDUCE|CUMO_NDF_CUM,
|
42
42
|
2, 1, ain, aout };
|
43
43
|
|
44
44
|
<% if is_float %>
|
45
|
-
reduce =
|
45
|
+
reduce = cumo_na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_nan);
|
46
46
|
<% else %>
|
47
|
-
reduce =
|
47
|
+
reduce = cumo_na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
48
48
|
<% end %>
|
49
|
-
return
|
49
|
+
return cumo_na_ndloop(&ndf, 2, self, reduce);
|
50
50
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
static void
|
2
|
-
<%=c_iter%>(
|
2
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
3
3
|
{
|
4
4
|
size_t i, s1;
|
5
5
|
char *p1;
|
@@ -7,21 +7,21 @@ static void
|
|
7
7
|
dtype x;
|
8
8
|
VALUE y;
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
CUMO_INIT_COUNTER(lp, i);
|
11
|
+
CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
12
12
|
|
13
|
-
|
13
|
+
CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
14
14
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
15
15
|
|
16
16
|
if (idx1) {
|
17
17
|
for (; i--;) {
|
18
|
-
|
18
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
19
19
|
y = m_data_to_num(x);
|
20
20
|
rb_yield(y);
|
21
21
|
}
|
22
22
|
} else {
|
23
23
|
for (; i--;) {
|
24
|
-
|
24
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
25
25
|
y = m_data_to_num(x);
|
26
26
|
rb_yield(y);
|
27
27
|
}
|
@@ -39,9 +39,9 @@ static void
|
|
39
39
|
static VALUE
|
40
40
|
<%=c_func(0)%>(VALUE self)
|
41
41
|
{
|
42
|
-
|
43
|
-
|
42
|
+
cumo_ndfunc_arg_in_t ain[1] = {{Qnil,0}};
|
43
|
+
cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP_NIP, 1,0, ain,0};
|
44
44
|
|
45
|
-
|
45
|
+
cumo_na_ndloop(&ndf, 1, self);
|
46
46
|
return self;
|
47
47
|
}
|
@@ -12,7 +12,7 @@ yield_each_with_index(dtype x, size_t *c, VALUE *a, int nd, int md)
|
|
12
12
|
|
13
13
|
|
14
14
|
static void
|
15
|
-
<%=c_iter%>(
|
15
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
16
16
|
{
|
17
17
|
size_t i, s1;
|
18
18
|
char *p1;
|
@@ -28,23 +28,23 @@ static void
|
|
28
28
|
md = nd + 2;
|
29
29
|
a = ALLOCA_N(VALUE,md);
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
CUMO_INIT_COUNTER(lp, i);
|
32
|
+
CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
33
33
|
c[nd] = 0;
|
34
34
|
|
35
|
-
|
35
|
+
CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
36
36
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
37
37
|
|
38
38
|
if (idx1) {
|
39
39
|
for (; i--;) {
|
40
|
-
|
40
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
41
41
|
yield_each_with_index(x,c,a,nd,md);
|
42
42
|
c[nd]++;
|
43
43
|
}
|
44
44
|
} else {
|
45
45
|
for (; i--;) {
|
46
46
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
47
|
-
|
47
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
48
48
|
yield_each_with_index(x,c,a,nd,md);
|
49
49
|
c[nd]++;
|
50
50
|
}
|
@@ -62,9 +62,9 @@ static void
|
|
62
62
|
static VALUE
|
63
63
|
<%=c_func(0)%>(VALUE self)
|
64
64
|
{
|
65
|
-
|
66
|
-
|
65
|
+
cumo_ndfunc_arg_in_t ain[1] = {{Qnil,0}};
|
66
|
+
cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP_NIP, 1,0, ain,0};
|
67
67
|
|
68
|
-
|
68
|
+
cumo_na_ndloop_with_index(&ndf, 1, self);
|
69
69
|
return self;
|
70
70
|
}
|
@@ -20,28 +20,28 @@ void cumo_<%=type_name%>_<%=name%><%=nan%>_kernel_launch(char *p1, char* p2, cha
|
|
20
20
|
<% end %>
|
21
21
|
|
22
22
|
static void
|
23
|
-
<%=c_iter%><%=nan%>(
|
23
|
+
<%=c_iter%><%=nan%>(cumo_na_loop_t *const lp)
|
24
24
|
{
|
25
25
|
size_t n;
|
26
26
|
char *p1, *p2, *p3;
|
27
27
|
ssize_t s1, s2, s3;
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
CUMO_INIT_COUNTER(lp, n);
|
30
|
+
CUMO_INIT_PTR(lp, 0, p1, s1);
|
31
|
+
CUMO_INIT_PTR(lp, 1, p2, s2);
|
32
|
+
CUMO_INIT_PTR(lp, 2, p3, s3);
|
33
33
|
|
34
34
|
<% if type_name == 'robject' %>
|
35
35
|
{
|
36
36
|
size_t i;
|
37
|
-
|
37
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%><%=nan%>", "<%=type_name%>");
|
38
38
|
for (i=0; i<n; i++) {
|
39
39
|
dtype x, y, z;
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
41
|
+
CUMO_GET_DATA_STRIDE(p2,s2,dtype,y);
|
42
|
+
CUMO_GET_DATA(p3,dtype,z);
|
43
43
|
z = f_<%=name%><%=nan%>(x,y);
|
44
|
-
|
44
|
+
CUMO_SET_DATA_STRIDE(p3,s3,dtype,z);
|
45
45
|
}
|
46
46
|
}
|
47
47
|
<% else %>
|
@@ -57,13 +57,13 @@ static VALUE
|
|
57
57
|
{
|
58
58
|
VALUE a1 = Qnil;
|
59
59
|
VALUE a2 = Qnil;
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
|
61
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
|
62
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
63
63
|
|
64
64
|
<% if is_float %>
|
65
65
|
VALUE kw_hash = Qnil;
|
66
|
-
ID kw_table[1] = {
|
66
|
+
ID kw_table[1] = {cumo_id_nan};
|
67
67
|
VALUE opts[1] = {Qundef};
|
68
68
|
|
69
69
|
rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
|
@@ -75,5 +75,5 @@ static VALUE
|
|
75
75
|
rb_scan_args(argc, argv, "20", &a1, &a2);
|
76
76
|
<% end %>
|
77
77
|
|
78
|
-
return
|
78
|
+
return cumo_na_ndloop(&ndf, 2, a1, a2);
|
79
79
|
}
|
@@ -10,9 +10,9 @@ __global__ void <%="cumo_#{type_name}_#{name}#{nan}_kernel"%>(char* p1, char* p2
|
|
10
10
|
|
11
11
|
void cumo_<%=type_name%>_<%=name%><%=nan%>_kernel_launch(char *p1, char *p2, char* p3, ssize_t s1, ssize_t s2, ssize_t s3, size_t n)
|
12
12
|
{
|
13
|
-
size_t
|
14
|
-
size_t
|
15
|
-
<%="cumo_#{type_name}_#{name}#{nan}_kernel"%><<<
|
13
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
14
|
+
size_t block_dim = cumo_get_block_dim(n);
|
15
|
+
<%="cumo_#{type_name}_#{name}#{nan}_kernel"%><<<grid_dim, block_dim>>>(p1,p2,p3,s1,s2,s3,n);
|
16
16
|
}
|
17
17
|
|
18
18
|
<% end %>
|
@@ -11,15 +11,15 @@ static VALUE
|
|
11
11
|
{
|
12
12
|
volatile VALUE v;
|
13
13
|
char *ptr;
|
14
|
-
|
15
|
-
|
14
|
+
cumo_narray_t *na;
|
15
|
+
CumoGetNArray(self,na);
|
16
16
|
|
17
17
|
if (na->ndim==0) {
|
18
|
-
ptr =
|
19
|
-
|
18
|
+
ptr = cumo_na_get_pointer_for_read(self) + cumo_na_get_offset(self);
|
19
|
+
CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
20
20
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
21
21
|
v = m_extract(ptr);
|
22
|
-
|
22
|
+
cumo_na_release_lock(self);
|
23
23
|
return v;
|
24
24
|
}
|
25
25
|
return self;
|
@@ -5,23 +5,23 @@
|
|
5
5
|
static dtype
|
6
6
|
<%=c_func(:nodef)%>(VALUE obj)
|
7
7
|
{
|
8
|
-
|
8
|
+
cumo_narray_t *na;
|
9
9
|
dtype x;
|
10
10
|
char *ptr;
|
11
11
|
size_t pos;
|
12
12
|
VALUE r, klass;
|
13
13
|
|
14
|
-
|
14
|
+
CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
15
15
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
16
16
|
|
17
|
-
if (
|
18
|
-
|
17
|
+
if (CumoIsNArray(obj)) {
|
18
|
+
CumoGetNArray(obj,na);
|
19
19
|
if (na->size != 1) {
|
20
|
-
rb_raise(
|
20
|
+
rb_raise(cumo_na_eShapeError,"narray size should be 1");
|
21
21
|
}
|
22
|
-
klass =
|
23
|
-
ptr =
|
24
|
-
pos =
|
22
|
+
klass = rb_obj_class(obj);
|
23
|
+
ptr = cumo_na_get_pointer_for_read(obj);
|
24
|
+
pos = cumo_na_get_offset(obj);
|
25
25
|
<% find_tmpl("store").definitions.select{|x| x.class==Store}.each do |x| %>
|
26
26
|
if (<%=x.condition("klass")%>) {
|
27
27
|
<%=x.extract_data("ptr","pos","x")%>;
|
@@ -31,20 +31,20 @@ static dtype
|
|
31
31
|
|
32
32
|
// coerce
|
33
33
|
r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
|
34
|
-
if (
|
34
|
+
if (rb_obj_class(r)==cT) {
|
35
35
|
return <%=c_func%>(r);
|
36
36
|
}
|
37
37
|
<% if is_object %>
|
38
38
|
return obj;
|
39
39
|
<% else %>
|
40
|
-
rb_raise(
|
41
|
-
rb_class2name(
|
40
|
+
rb_raise(cumo_na_eCastError, "unknown conversion from %s to %s",
|
41
|
+
rb_class2name(rb_obj_class(obj)),
|
42
42
|
rb_class2name(cT));
|
43
43
|
<% end %>
|
44
44
|
}
|
45
45
|
if (TYPE(obj)==T_ARRAY) {
|
46
46
|
if (RARRAY_LEN(obj) != 1) {
|
47
|
-
rb_raise(
|
47
|
+
rb_raise(cumo_na_eShapeError,"array size should be 1");
|
48
48
|
}
|
49
49
|
return m_num_to_data(RARRAY_AREF(obj,0));
|
50
50
|
}
|