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
@@ -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;
|
5
5
|
char *p1, *p2;
|
@@ -7,37 +7,37 @@ static void
|
|
7
7
|
size_t *idx1, *idx2;
|
8
8
|
dtype x;
|
9
9
|
<%=dtype%> y;
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
CUMO_INIT_COUNTER(lp, i);
|
11
|
+
CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
12
|
+
CUMO_INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
13
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
14
14
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
15
15
|
if (idx1) {
|
16
16
|
if (idx2) {
|
17
17
|
for (; i--;) {
|
18
|
-
|
18
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
19
19
|
y = m_<%=name%>(x);
|
20
|
-
|
20
|
+
CUMO_SET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
|
21
21
|
}
|
22
22
|
} else {
|
23
23
|
for (; i--;) {
|
24
|
-
|
24
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
25
25
|
y = m_<%=name%>(x);
|
26
|
-
|
26
|
+
CUMO_SET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
|
27
27
|
}
|
28
28
|
}
|
29
29
|
} else {
|
30
30
|
if (idx2) {
|
31
31
|
for (; i--;) {
|
32
|
-
|
32
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
33
33
|
y = m_<%=name%>(x);
|
34
|
-
|
34
|
+
CUMO_SET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
|
35
35
|
}
|
36
36
|
} else {
|
37
37
|
for (; i--;) {
|
38
|
-
|
38
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
39
39
|
y = m_<%=name%>(x);
|
40
|
-
|
40
|
+
CUMO_SET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
|
41
41
|
}
|
42
42
|
}
|
43
43
|
}
|
@@ -52,9 +52,9 @@ static void
|
|
52
52
|
static VALUE
|
53
53
|
<%=c_func(0)%>(VALUE self)
|
54
54
|
{
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
|
56
|
+
cumo_ndfunc_arg_out_t aout[1] = {{<%=result_class%>,0}};
|
57
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 1, 1, ain, aout };
|
58
58
|
|
59
|
-
return
|
59
|
+
return cumo_na_ndloop(&ndf, 1, self);
|
60
60
|
}
|
@@ -37,36 +37,36 @@ __global__ void <%="cumo_#{c_iter}_contiguous_kernel"%>(char *p1, char *p2, uint
|
|
37
37
|
|
38
38
|
void <%="cumo_#{c_iter}_index_index_kernel_launch"%>(char *p1, char *p2, size_t *idx1, size_t *idx2, uint64_t n)
|
39
39
|
{
|
40
|
-
size_t
|
41
|
-
size_t
|
42
|
-
<%="cumo_#{c_iter}_index_index_kernel"%><<<
|
40
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
41
|
+
size_t block_dim = cumo_get_block_dim(n);
|
42
|
+
<%="cumo_#{c_iter}_index_index_kernel"%><<<grid_dim, block_dim>>>(p1,p2,idx1,idx2,n);
|
43
43
|
}
|
44
44
|
|
45
45
|
void <%="cumo_#{c_iter}_index_stride_kernel_launch"%>(char *p1, char *p2, size_t *idx1, ssize_t s2, uint64_t n)
|
46
46
|
{
|
47
|
-
size_t
|
48
|
-
size_t
|
49
|
-
<%="cumo_#{c_iter}_index_stride_kernel"%><<<
|
47
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
48
|
+
size_t block_dim = cumo_get_block_dim(n);
|
49
|
+
<%="cumo_#{c_iter}_index_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,idx1,s2,n);
|
50
50
|
}
|
51
51
|
|
52
52
|
void <%="cumo_#{c_iter}_stride_index_kernel_launch"%>(char *p1, char *p2, ssize_t s1, size_t *idx2, uint64_t n)
|
53
53
|
{
|
54
|
-
size_t
|
55
|
-
size_t
|
56
|
-
<%="cumo_#{c_iter}_stride_index_kernel"%><<<
|
54
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
55
|
+
size_t block_dim = cumo_get_block_dim(n);
|
56
|
+
<%="cumo_#{c_iter}_stride_index_kernel"%><<<grid_dim, block_dim>>>(p1,p2,s1,idx2,n);
|
57
57
|
}
|
58
58
|
|
59
59
|
void <%="cumo_#{c_iter}_stride_stride_kernel_launch"%>(char *p1, char *p2, ssize_t s1, ssize_t s2, uint64_t n)
|
60
60
|
{
|
61
|
-
size_t
|
62
|
-
size_t
|
63
|
-
<%="cumo_#{c_iter}_stride_stride_kernel"%><<<
|
61
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
62
|
+
size_t block_dim = cumo_get_block_dim(n);
|
63
|
+
<%="cumo_#{c_iter}_stride_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,s1,s2,n);
|
64
64
|
}
|
65
65
|
|
66
66
|
void <%="cumo_#{c_iter}_contiguous_kernel_launch"%>(char *p1, char *p2, uint64_t n)
|
67
67
|
{
|
68
|
-
size_t
|
69
|
-
size_t
|
70
|
-
<%="cumo_#{c_iter}_contiguous_kernel"%><<<
|
68
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
69
|
+
size_t block_dim = cumo_get_block_dim(n);
|
70
|
+
<%="cumo_#{c_iter}_contiguous_kernel"%><<<grid_dim, block_dim>>>(p1,p2,n);
|
71
71
|
}
|
72
72
|
<% end %>
|
@@ -1,20 +1,20 @@
|
|
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, *p2, *p3;
|
6
6
|
ssize_t s1, s2, s3;
|
7
7
|
dtype x, y, z;
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
CUMO_INIT_COUNTER(lp, i);
|
9
|
+
CUMO_INIT_PTR(lp, 0, p1, s1);
|
10
|
+
CUMO_INIT_PTR(lp, 1, p2, s2);
|
11
|
+
CUMO_INIT_PTR(lp, 2, p3, s3);
|
12
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
13
13
|
for (; i--;) {
|
14
|
-
|
14
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
15
15
|
m_<%=name%>(x,y,z);
|
16
|
-
|
17
|
-
|
16
|
+
CUMO_SET_DATA_STRIDE(p2,s2,dtype,y);
|
17
|
+
CUMO_SET_DATA_STRIDE(p3,s3,dtype,z);
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
@@ -26,9 +26,9 @@ static void
|
|
26
26
|
static VALUE
|
27
27
|
<%=c_func(0)%>(VALUE self)
|
28
28
|
{
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
|
30
|
+
cumo_ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
|
31
|
+
cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_STRIDE_LOOP, 1,2, ain,aout};
|
32
32
|
|
33
|
-
return
|
33
|
+
return cumo_na_ndloop(&ndf, 1, self);
|
34
34
|
}
|
@@ -6,46 +6,46 @@ void <%="cumo_#{c_iter}_stride_stride_kernel_launch"%>(char *p1, char *p2, ssize
|
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
static void
|
9
|
-
<%=c_iter%>(
|
9
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
10
10
|
{
|
11
11
|
size_t i;
|
12
12
|
char *p1, *p2;
|
13
13
|
ssize_t s1, s2;
|
14
14
|
size_t *idx1, *idx2;
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
CUMO_INIT_COUNTER(lp, i);
|
16
|
+
CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
17
|
+
CUMO_INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
18
18
|
|
19
19
|
<% if type_name == 'robject' %>
|
20
20
|
{
|
21
21
|
dtype x;
|
22
|
-
|
22
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
23
23
|
if (idx1) {
|
24
24
|
if (idx2) {
|
25
25
|
for (; i--;) {
|
26
|
-
|
26
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
27
27
|
x = m_<%=name%>(x);
|
28
|
-
|
28
|
+
CUMO_SET_DATA_INDEX(p2,idx2,dtype,x);
|
29
29
|
}
|
30
30
|
} else {
|
31
31
|
for (; i--;) {
|
32
|
-
|
32
|
+
CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
|
33
33
|
x = m_<%=name%>(x);
|
34
|
-
|
34
|
+
CUMO_SET_DATA_STRIDE(p2,s2,dtype,x);
|
35
35
|
}
|
36
36
|
}
|
37
37
|
} else {
|
38
38
|
if (idx2) {
|
39
39
|
for (; i--;) {
|
40
|
-
|
40
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
41
41
|
x = m_<%=name%>(x);
|
42
|
-
|
42
|
+
CUMO_SET_DATA_INDEX(p2,idx2,dtype,x);
|
43
43
|
}
|
44
44
|
} else {
|
45
45
|
for (; i--;) {
|
46
|
-
|
46
|
+
CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
|
47
47
|
x = m_<%=name%>(x);
|
48
|
-
|
48
|
+
CUMO_SET_DATA_STRIDE(p2,s2,dtype,x);
|
49
49
|
}
|
50
50
|
}
|
51
51
|
}
|
@@ -78,9 +78,9 @@ static void
|
|
78
78
|
static VALUE
|
79
79
|
<%=c_func(1)%>(VALUE mod, VALUE a1)
|
80
80
|
{
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
|
82
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
|
83
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 1, 1, ain, aout };
|
84
84
|
|
85
|
-
return
|
85
|
+
return cumo_na_ndloop(&ndf, 1, a1);
|
86
86
|
}
|
@@ -29,30 +29,30 @@ __global__ void <%="cumo_#{c_iter}_stride_stride_kernel"%>(char *p1, char *p2, s
|
|
29
29
|
|
30
30
|
void <%="cumo_#{c_iter}_index_index_kernel_launch"%>(char *p1, char *p2, size_t *idx1, size_t *idx2, uint64_t n)
|
31
31
|
{
|
32
|
-
size_t
|
33
|
-
size_t
|
34
|
-
<%="cumo_#{c_iter}_index_index_kernel"%><<<
|
32
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
33
|
+
size_t block_dim = cumo_get_block_dim(n);
|
34
|
+
<%="cumo_#{c_iter}_index_index_kernel"%><<<grid_dim, block_dim>>>(p1,p2,idx1,idx2,n);
|
35
35
|
}
|
36
36
|
|
37
37
|
void <%="cumo_#{c_iter}_index_stride_kernel_launch"%>(char *p1, char *p2, size_t *idx1, ssize_t s2, uint64_t n)
|
38
38
|
{
|
39
|
-
size_t
|
40
|
-
size_t
|
41
|
-
<%="cumo_#{c_iter}_index_stride_kernel"%><<<
|
39
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
40
|
+
size_t block_dim = cumo_get_block_dim(n);
|
41
|
+
<%="cumo_#{c_iter}_index_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,idx1,s2,n);
|
42
42
|
}
|
43
43
|
|
44
44
|
void <%="cumo_#{c_iter}_stride_index_kernel_launch"%>(char *p1, char *p2, ssize_t s1, size_t *idx2, uint64_t n)
|
45
45
|
{
|
46
|
-
size_t
|
47
|
-
size_t
|
48
|
-
<%="cumo_#{c_iter}_stride_index_kernel"%><<<
|
46
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
47
|
+
size_t block_dim = cumo_get_block_dim(n);
|
48
|
+
<%="cumo_#{c_iter}_stride_index_kernel"%><<<grid_dim, block_dim>>>(p1,p2,s1,idx2,n);
|
49
49
|
}
|
50
50
|
|
51
51
|
void <%="cumo_#{c_iter}_stride_stride_kernel_launch"%>(char *p1, char *p2, ssize_t s1, ssize_t s2, uint64_t n)
|
52
52
|
{
|
53
|
-
size_t
|
54
|
-
size_t
|
55
|
-
<%="cumo_#{c_iter}_stride_stride_kernel"%><<<
|
53
|
+
size_t grid_dim = cumo_get_grid_dim(n);
|
54
|
+
size_t block_dim = cumo_get_block_dim(n);
|
55
|
+
<%="cumo_#{c_iter}_stride_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,s1,s2,n);
|
56
56
|
}
|
57
57
|
|
58
58
|
<% end %>
|
@@ -1,21 +1,21 @@
|
|
1
1
|
static VALUE
|
2
2
|
<%=c_func(0)%>(VALUE self)
|
3
3
|
{
|
4
|
-
|
4
|
+
cumo_narray_t *na;
|
5
5
|
char *ptr;
|
6
6
|
|
7
|
-
|
7
|
+
CumoGetNArray(self,na);
|
8
8
|
|
9
|
-
switch(
|
10
|
-
case
|
11
|
-
ptr =
|
9
|
+
switch(CUMO_NA_TYPE(na)) {
|
10
|
+
case CUMO_NARRAY_DATA_T:
|
11
|
+
ptr = CUMO_NA_DATA_PTR(na);
|
12
12
|
if (na->size > 0 && ptr == NULL) {
|
13
|
-
ptr = cumo_cuda_runtime_malloc(((na->size-1)/8/sizeof(
|
14
|
-
|
13
|
+
ptr = cumo_cuda_runtime_malloc(((na->size-1)/8/sizeof(CUMO_BIT_DIGIT)+1)*sizeof(CUMO_BIT_DIGIT));
|
14
|
+
CUMO_NA_DATA_PTR(na) = ptr;
|
15
15
|
}
|
16
16
|
break;
|
17
|
-
case
|
18
|
-
rb_funcall(
|
17
|
+
case CUMO_NARRAY_VIEW_T:
|
18
|
+
rb_funcall(CUMO_NA_VIEW_DATA(na), rb_intern("allocate"), 0);
|
19
19
|
break;
|
20
20
|
default:
|
21
21
|
rb_raise(rb_eRuntimeError,"invalid narray type");
|
@@ -48,7 +48,7 @@ static VALUE
|
|
48
48
|
int result_nd;
|
49
49
|
size_t pos;
|
50
50
|
|
51
|
-
result_nd =
|
52
|
-
return
|
51
|
+
result_nd = cumo_na_get_result_dimension(self, argc, argv, 1, &pos);
|
52
|
+
return cumo_na_aref_main(argc, argv, self, 0, result_nd, pos);
|
53
53
|
}
|
54
54
|
}
|
@@ -44,14 +44,14 @@ static VALUE
|
|
44
44
|
char *ptr;
|
45
45
|
dtype x;
|
46
46
|
|
47
|
-
nd =
|
47
|
+
nd = cumo_na_get_result_dimension(self, argc, argv, 1, &pos);
|
48
48
|
if (nd) {
|
49
|
-
return
|
49
|
+
return cumo_na_aref_main(argc, argv, self, 0, nd, pos);
|
50
50
|
} else {
|
51
|
-
ptr =
|
52
|
-
|
51
|
+
ptr = cumo_na_get_pointer_for_read(self);
|
52
|
+
CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
53
53
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
54
|
-
|
54
|
+
CUMO_LOAD_BIT(ptr,pos,x);
|
55
55
|
return m_data_to_num(x);
|
56
56
|
}
|
57
57
|
}
|
@@ -48,8 +48,8 @@ static VALUE
|
|
48
48
|
if (argc==0) {
|
49
49
|
<%=c_func.sub(/_aset/,"_store")%>(self, argv[argc]);
|
50
50
|
} else {
|
51
|
-
nd =
|
52
|
-
a =
|
51
|
+
nd = cumo_na_get_result_dimension(self, argc, argv, 1, &pos);
|
52
|
+
a = cumo_na_aref_main(argc, argv, self, 0, nd, pos);
|
53
53
|
<%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
|
54
54
|
}
|
55
55
|
return argv[argc];
|
@@ -1,63 +1,63 @@
|
|
1
1
|
static void
|
2
|
-
<%=c_iter%>(
|
2
|
+
<%=c_iter%>(cumo_na_loop_t *const lp)
|
3
3
|
{
|
4
4
|
size_t n;
|
5
5
|
size_t p1, p2, p3;
|
6
6
|
ssize_t s1, s2, s3;
|
7
7
|
size_t *idx1, *idx2, *idx3;
|
8
8
|
int o1, o2, l1, l2, r1, r2, len;
|
9
|
-
|
10
|
-
|
9
|
+
CUMO_BIT_DIGIT *a1, *a2, *a3;
|
10
|
+
CUMO_BIT_DIGIT x, y;
|
11
11
|
|
12
12
|
// TODO(sonots): CUDA kernelize
|
13
|
-
|
13
|
+
CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
|
14
14
|
cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
CUMO_INIT_COUNTER(lp, n);
|
17
|
+
CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
|
18
|
+
CUMO_INIT_PTR_BIT_IDX(lp, 1, a2, p2, s2, idx2);
|
19
|
+
CUMO_INIT_PTR_BIT_IDX(lp, 2, a3, p3, s3, idx3);
|
20
20
|
if (s1!=1 || s2!=1 || s3!=1 || idx1 || idx2 || idx3) {
|
21
21
|
for (; n--;) {
|
22
|
-
|
23
|
-
|
22
|
+
CUMO_LOAD_BIT_STEP(a1, p1, s1, idx1, x);
|
23
|
+
CUMO_LOAD_BIT_STEP(a2, p2, s2, idx2, y);
|
24
24
|
x = m_<%=name%>(x,y);
|
25
|
-
|
25
|
+
CUMO_STORE_BIT_STEP(a3, p3, s3, idx3, x);
|
26
26
|
}
|
27
27
|
} else {
|
28
|
-
o1 = p1 %
|
28
|
+
o1 = p1 % CUMO_NB;
|
29
29
|
o1 -= p3;
|
30
|
-
o2 = p2 %
|
30
|
+
o2 = p2 % CUMO_NB;
|
31
31
|
o2 -= p3;
|
32
|
-
l1 =
|
33
|
-
r1 =
|
34
|
-
l2 =
|
35
|
-
r2 =
|
36
|
-
if (p3>0 || n<
|
37
|
-
len =
|
32
|
+
l1 = CUMO_NB+o1;
|
33
|
+
r1 = CUMO_NB-o1;
|
34
|
+
l2 = CUMO_NB+o2;
|
35
|
+
r2 = CUMO_NB-o2;
|
36
|
+
if (p3>0 || n<CUMO_NB) {
|
37
|
+
len = CUMO_NB - p3;
|
38
38
|
if ((int)n<len) len=n;
|
39
39
|
if (o1>=0) x = *a1>>o1;
|
40
40
|
else x = *a1<<-o1;
|
41
|
-
if (p1+len>
|
41
|
+
if (p1+len>CUMO_NB) x |= *(a1+1)<<r1;
|
42
42
|
a1++;
|
43
43
|
if (o2>=0) y = *a2>>o2;
|
44
44
|
else y = *a2<<-o2;
|
45
|
-
if (p2+len>
|
45
|
+
if (p2+len>CUMO_NB) y |= *(a2+1)<<r2;
|
46
46
|
a2++;
|
47
47
|
x = m_<%=name%>(x,y);
|
48
|
-
*a3 = (x & (
|
48
|
+
*a3 = (x & (CUMO_SLB(len)<<p3)) | (*a3 & ~(CUMO_SLB(len)<<p3));
|
49
49
|
a3++;
|
50
50
|
n -= len;
|
51
51
|
}
|
52
52
|
if (o1==0 && o2==0) {
|
53
|
-
for (; n>=
|
53
|
+
for (; n>=CUMO_NB; n-=CUMO_NB) {
|
54
54
|
x = *(a1++);
|
55
55
|
y = *(a2++);
|
56
56
|
x = m_<%=name%>(x,y);
|
57
57
|
*(a3++) = x;
|
58
58
|
}
|
59
59
|
} else {
|
60
|
-
for (; n>=
|
60
|
+
for (; n>=CUMO_NB; n-=CUMO_NB) {
|
61
61
|
x = *a1>>o1;
|
62
62
|
if (o1<0) x |= *(a1-1)>>l1;
|
63
63
|
if (o1>0) x |= *(a1+1)<<r1;
|
@@ -76,7 +76,7 @@ static void
|
|
76
76
|
y = *a2>>o2;
|
77
77
|
if (o2<0) y |= *(a2-1)>>l2;
|
78
78
|
x = m_<%=name%>(x,y);
|
79
|
-
*a3 = (x &
|
79
|
+
*a3 = (x & CUMO_SLB(n)) | (*a3 & CUMO_BALL<<n);
|
80
80
|
}
|
81
81
|
}
|
82
82
|
}
|
@@ -90,9 +90,9 @@ static void
|
|
90
90
|
static VALUE
|
91
91
|
<%=c_func(1)%>(VALUE self, VALUE other)
|
92
92
|
{
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
|
94
|
+
cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
|
95
|
+
cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 2, 1, ain, aout };
|
96
96
|
|
97
|
-
return
|
97
|
+
return cumo_na_ndloop(&ndf, 2, self, other);
|
98
98
|
}
|