cumo 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/3rd_party/LICENSE.txt +60 -0
  4. data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +13 -1
  5. data/LICENSE.txt +1 -62
  6. data/README.md +33 -29
  7. data/bench/cumo_bench.rb +47 -25
  8. data/bench/numo_bench.rb +27 -25
  9. data/docs/src-tree.md +16 -0
  10. data/ext/cumo/cuda/cublas.c +69 -219
  11. data/ext/cumo/cuda/memory_pool_impl.hpp +1 -0
  12. data/ext/cumo/cuda/runtime.c +2 -14
  13. data/ext/cumo/cumo.c +16 -16
  14. data/ext/cumo/include/cumo.h +2 -2
  15. data/ext/cumo/include/cumo/cuda/cublas.h +6 -129
  16. data/ext/cumo/include/cumo/cuda/runtime.h +16 -0
  17. data/ext/cumo/include/cumo/indexer.h +46 -63
  18. data/ext/cumo/include/cumo/intern.h +58 -112
  19. data/ext/cumo/include/cumo/narray.h +214 -185
  20. data/ext/cumo/include/cumo/narray_kernel.h +66 -37
  21. data/ext/cumo/include/cumo/ndloop.h +42 -42
  22. data/ext/cumo/include/cumo/reduce_kernel.h +55 -71
  23. data/ext/cumo/include/cumo/template.h +56 -51
  24. data/ext/cumo/include/cumo/template_kernel.h +31 -31
  25. data/ext/cumo/include/cumo/types/bit.h +3 -3
  26. data/ext/cumo/include/cumo/types/bit_kernel.h +2 -2
  27. data/ext/cumo/include/cumo/types/complex.h +126 -126
  28. data/ext/cumo/include/cumo/types/complex_kernel.h +126 -126
  29. data/ext/cumo/include/cumo/types/complex_macro.h +28 -28
  30. data/ext/cumo/include/cumo/types/complex_macro_kernel.h +20 -20
  31. data/ext/cumo/include/cumo/types/dcomplex.h +5 -5
  32. data/ext/cumo/include/cumo/types/dcomplex_kernel.h +1 -1
  33. data/ext/cumo/include/cumo/types/int_macro.h +1 -1
  34. data/ext/cumo/include/cumo/types/int_macro_kernel.h +1 -1
  35. data/ext/cumo/include/cumo/types/robj_macro.h +30 -30
  36. data/ext/cumo/include/cumo/types/scomplex.h +5 -5
  37. data/ext/cumo/include/cumo/types/scomplex_kernel.h +1 -1
  38. data/ext/cumo/narray/array.c +143 -143
  39. data/ext/cumo/narray/data.c +184 -184
  40. data/ext/cumo/narray/gen/cogen.rb +5 -2
  41. data/ext/cumo/narray/gen/cogen_kernel.rb +5 -2
  42. data/ext/cumo/narray/gen/def/dcomplex.rb +1 -1
  43. data/ext/cumo/narray/gen/def/scomplex.rb +1 -1
  44. data/ext/cumo/narray/gen/erbln.rb +132 -0
  45. data/ext/cumo/narray/gen/erbpp2.rb +18 -13
  46. data/ext/cumo/narray/gen/narray_def.rb +3 -3
  47. data/ext/cumo/narray/gen/spec.rb +2 -2
  48. data/ext/cumo/narray/gen/tmpl/accum.c +15 -15
  49. data/ext/cumo/narray/gen/tmpl/accum_binary.c +22 -22
  50. data/ext/cumo/narray/gen/tmpl/accum_binary_kernel.cu +3 -3
  51. data/ext/cumo/narray/gen/tmpl/accum_index.c +30 -30
  52. data/ext/cumo/narray/gen/tmpl/accum_index_kernel.cu +2 -2
  53. data/ext/cumo/narray/gen/tmpl/accum_kernel.cu +3 -3
  54. data/ext/cumo/narray/gen/tmpl/alloc_func.c +14 -14
  55. data/ext/cumo/narray/gen/tmpl/allocate.c +11 -11
  56. data/ext/cumo/narray/gen/tmpl/aref.c +2 -2
  57. data/ext/cumo/narray/gen/tmpl/aref_cpu.c +4 -4
  58. data/ext/cumo/narray/gen/tmpl/aset.c +2 -2
  59. data/ext/cumo/narray/gen/tmpl/binary.c +28 -28
  60. data/ext/cumo/narray/gen/tmpl/binary2.c +18 -18
  61. data/ext/cumo/narray/gen/tmpl/binary2_kernel.cu +3 -3
  62. data/ext/cumo/narray/gen/tmpl/binary_kernel.cu +6 -6
  63. data/ext/cumo/narray/gen/tmpl/binary_s.c +13 -13
  64. data/ext/cumo/narray/gen/tmpl/binary_s_kernel.cu +3 -3
  65. data/ext/cumo/narray/gen/tmpl/bincount.c +23 -23
  66. data/ext/cumo/narray/gen/tmpl/cast.c +7 -7
  67. data/ext/cumo/narray/gen/tmpl/cast_array.c +3 -3
  68. data/ext/cumo/narray/gen/tmpl/clip.c +38 -38
  69. data/ext/cumo/narray/gen/tmpl/complex_accum_kernel.cu +2 -2
  70. data/ext/cumo/narray/gen/tmpl/cond_binary.c +19 -19
  71. data/ext/cumo/narray/gen/tmpl/cond_binary_kernel.cu +7 -7
  72. data/ext/cumo/narray/gen/tmpl/cond_unary.c +15 -15
  73. data/ext/cumo/narray/gen/tmpl/cum.c +15 -15
  74. data/ext/cumo/narray/gen/tmpl/each.c +9 -9
  75. data/ext/cumo/narray/gen/tmpl/each_with_index.c +9 -9
  76. data/ext/cumo/narray/gen/tmpl/ewcomp.c +15 -15
  77. data/ext/cumo/narray/gen/tmpl/ewcomp_kernel.cu +3 -3
  78. data/ext/cumo/narray/gen/tmpl/extract_cpu.c +5 -5
  79. data/ext/cumo/narray/gen/tmpl/extract_data.c +12 -12
  80. data/ext/cumo/narray/gen/tmpl/eye.c +9 -9
  81. data/ext/cumo/narray/gen/tmpl/eye_kernel.cu +3 -3
  82. data/ext/cumo/narray/gen/tmpl/fill.c +9 -9
  83. data/ext/cumo/narray/gen/tmpl/fill_kernel.cu +6 -6
  84. data/ext/cumo/narray/gen/tmpl/float_accum_kernel.cu +1 -1
  85. data/ext/cumo/narray/gen/tmpl/format.c +11 -11
  86. data/ext/cumo/narray/gen/tmpl/format_to_a.c +8 -8
  87. data/ext/cumo/narray/gen/tmpl/frexp.c +13 -13
  88. data/ext/cumo/narray/gen/tmpl/gemm.c +252 -108
  89. data/ext/cumo/narray/gen/tmpl/inspect.c +1 -1
  90. data/ext/cumo/narray/gen/tmpl/lib.c +2 -2
  91. data/ext/cumo/narray/gen/tmpl/logseq.c +7 -7
  92. data/ext/cumo/narray/gen/tmpl/logseq_kernel.cu +6 -6
  93. data/ext/cumo/narray/gen/tmpl/map_with_index.c +17 -17
  94. data/ext/cumo/narray/gen/tmpl/median.c +10 -10
  95. data/ext/cumo/narray/gen/tmpl/minmax.c +10 -10
  96. data/ext/cumo/narray/gen/tmpl/new_dim0.c +3 -3
  97. data/ext/cumo/narray/gen/tmpl/poly.c +6 -6
  98. data/ext/cumo/narray/gen/tmpl/pow.c +28 -28
  99. data/ext/cumo/narray/gen/tmpl/pow_kernel.cu +6 -6
  100. data/ext/cumo/narray/gen/tmpl/rand.c +10 -10
  101. data/ext/cumo/narray/gen/tmpl/rand_norm.c +7 -7
  102. data/ext/cumo/narray/gen/tmpl/real_accum_kernel.cu +6 -6
  103. data/ext/cumo/narray/gen/tmpl/seq.c +7 -7
  104. data/ext/cumo/narray/gen/tmpl/seq_kernel.cu +6 -6
  105. data/ext/cumo/narray/gen/tmpl/set2.c +20 -20
  106. data/ext/cumo/narray/gen/tmpl/sort.c +11 -11
  107. data/ext/cumo/narray/gen/tmpl/sort_index.c +18 -18
  108. data/ext/cumo/narray/gen/tmpl/store.c +6 -6
  109. data/ext/cumo/narray/gen/tmpl/store_array.c +19 -19
  110. data/ext/cumo/narray/gen/tmpl/store_array_kernel.cu +12 -12
  111. data/ext/cumo/narray/gen/tmpl/store_bit.c +23 -23
  112. data/ext/cumo/narray/gen/tmpl/store_bit_kernel.cu +28 -28
  113. data/ext/cumo/narray/gen/tmpl/store_from.c +16 -16
  114. data/ext/cumo/narray/gen/tmpl/store_from_kernel.cu +12 -12
  115. data/ext/cumo/narray/gen/tmpl/to_a.c +10 -10
  116. data/ext/cumo/narray/gen/tmpl/unary.c +25 -25
  117. data/ext/cumo/narray/gen/tmpl/unary2.c +17 -17
  118. data/ext/cumo/narray/gen/tmpl/unary_kernel.cu +15 -15
  119. data/ext/cumo/narray/gen/tmpl/unary_ret2.c +13 -13
  120. data/ext/cumo/narray/gen/tmpl/unary_s.c +17 -17
  121. data/ext/cumo/narray/gen/tmpl/unary_s_kernel.cu +12 -12
  122. data/ext/cumo/narray/gen/tmpl_bit/allocate.c +9 -9
  123. data/ext/cumo/narray/gen/tmpl_bit/aref.c +2 -2
  124. data/ext/cumo/narray/gen/tmpl_bit/aref_cpu.c +5 -5
  125. data/ext/cumo/narray/gen/tmpl_bit/aset.c +2 -2
  126. data/ext/cumo/narray/gen/tmpl_bit/binary.c +29 -29
  127. data/ext/cumo/narray/gen/tmpl_bit/bit_count.c +14 -14
  128. data/ext/cumo/narray/gen/tmpl_bit/bit_count_cpu.c +21 -21
  129. data/ext/cumo/narray/gen/tmpl_bit/bit_count_kernel.cu +28 -28
  130. data/ext/cumo/narray/gen/tmpl_bit/bit_reduce.c +29 -29
  131. data/ext/cumo/narray/gen/tmpl_bit/each.c +10 -10
  132. data/ext/cumo/narray/gen/tmpl_bit/each_with_index.c +10 -10
  133. data/ext/cumo/narray/gen/tmpl_bit/extract.c +8 -8
  134. data/ext/cumo/narray/gen/tmpl_bit/extract_cpu.c +8 -8
  135. data/ext/cumo/narray/gen/tmpl_bit/fill.c +17 -17
  136. data/ext/cumo/narray/gen/tmpl_bit/format.c +14 -14
  137. data/ext/cumo/narray/gen/tmpl_bit/format_to_a.c +11 -11
  138. data/ext/cumo/narray/gen/tmpl_bit/inspect.c +3 -3
  139. data/ext/cumo/narray/gen/tmpl_bit/mask.c +33 -33
  140. data/ext/cumo/narray/gen/tmpl_bit/store_array.c +19 -19
  141. data/ext/cumo/narray/gen/tmpl_bit/store_bit.c +22 -22
  142. data/ext/cumo/narray/gen/tmpl_bit/store_from.c +18 -18
  143. data/ext/cumo/narray/gen/tmpl_bit/to_a.c +12 -12
  144. data/ext/cumo/narray/gen/tmpl_bit/unary.c +24 -24
  145. data/ext/cumo/narray/gen/tmpl_bit/where.c +16 -16
  146. data/ext/cumo/narray/gen/tmpl_bit/where2.c +20 -20
  147. data/ext/cumo/narray/index.c +213 -213
  148. data/ext/cumo/narray/math.c +27 -27
  149. data/ext/cumo/narray/narray.c +484 -484
  150. data/ext/cumo/narray/ndloop.c +259 -258
  151. data/ext/cumo/narray/rand.c +3 -3
  152. data/ext/cumo/narray/step.c +70 -70
  153. data/ext/cumo/narray/struct.c +139 -139
  154. metadata +6 -7
  155. data/ext/cumo/include/cumo/intern_fwd.h +0 -38
  156. data/lib/erbpp.rb +0 -294
  157. data/lib/erbpp/line_number.rb +0 -137
  158. data/lib/erbpp/narray_def.rb +0 -381
@@ -1,49 +1,49 @@
1
1
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
2
+ <%=c_iter%>(cumo_na_loop_t *const lp)
3
3
  {
4
4
  size_t n;
5
5
  size_t p1, p3;
6
6
  ssize_t s1, s3;
7
7
  size_t *idx1, *idx3;
8
8
  int o1, l1, r1, len;
9
- BIT_DIGIT *a1, *a3;
10
- BIT_DIGIT x;
9
+ CUMO_BIT_DIGIT *a1, *a3;
10
+ CUMO_BIT_DIGIT x;
11
11
 
12
12
  // TODO(sonots): CUDA kernelize
13
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
13
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
14
14
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
15
15
 
16
- INIT_COUNTER(lp, n);
17
- INIT_PTR_BIT_IDX(lp, 0, a3, p3, s3, idx3);
18
- INIT_PTR_BIT_IDX(lp, 1, a1, p1, s1, idx1);
16
+ CUMO_INIT_COUNTER(lp, n);
17
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a3, p3, s3, idx3);
18
+ CUMO_INIT_PTR_BIT_IDX(lp, 1, a1, p1, s1, idx1);
19
19
  if (s1!=1 || s3!=1 || idx1 || idx3) {
20
20
  for (; n--;) {
21
- LOAD_BIT_STEP(a1, p1, s1, idx1, x);
22
- STORE_BIT_STEP(a3, p3, s3, idx3, x);
21
+ CUMO_LOAD_BIT_STEP(a1, p1, s1, idx1, x);
22
+ CUMO_STORE_BIT_STEP(a3, p3, s3, idx3, x);
23
23
  }
24
24
  } else {
25
- o1 = p1 % NB;
25
+ o1 = p1 % CUMO_NB;
26
26
  o1 -= p3;
27
- l1 = NB+o1;
28
- r1 = NB-o1;
29
- if (p3>0 || n<NB) {
30
- len = NB - p3;
27
+ l1 = CUMO_NB+o1;
28
+ r1 = CUMO_NB-o1;
29
+ if (p3>0 || n<CUMO_NB) {
30
+ len = CUMO_NB - p3;
31
31
  if ((int)n<len) len=n;
32
32
  if (o1>=0) x = *a1>>o1;
33
33
  else x = *a1<<-o1;
34
- if (p1+len>NB) x |= *(a1+1)<<r1;
34
+ if (p1+len>CUMO_NB) x |= *(a1+1)<<r1;
35
35
  a1++;
36
- *a3 = (x & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
36
+ *a3 = (x & (CUMO_SLB(len)<<p3)) | (*a3 & ~(CUMO_SLB(len)<<p3));
37
37
  a3++;
38
38
  n -= len;
39
39
  }
40
40
  if (o1==0) {
41
- for (; n>=NB; n-=NB) {
41
+ for (; n>=CUMO_NB; n-=CUMO_NB) {
42
42
  x = *(a1++);
43
43
  *(a3++) = x;
44
44
  }
45
45
  } else {
46
- for (; n>=NB; n-=NB) {
46
+ for (; n>=CUMO_NB; n-=CUMO_NB) {
47
47
  x = *a1>>o1;
48
48
  if (o1<0) x |= *(a1-1)>>l1;
49
49
  if (o1>0) x |= *(a1+1)<<r1;
@@ -54,7 +54,7 @@ static void
54
54
  if (n>0) {
55
55
  x = *a1>>o1;
56
56
  if (o1<0) x |= *(a1-1)>>l1;
57
- *a3 = (x & SLB(n)) | (*a3 & BALL<<n);
57
+ *a3 = (x & CUMO_SLB(n)) | (*a3 & CUMO_BALL<<n);
58
58
  }
59
59
  }
60
60
  }
@@ -62,9 +62,9 @@ static void
62
62
  static VALUE
63
63
  <%=c_func(:nodef)%>(VALUE self, VALUE obj)
64
64
  {
65
- ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{Qnil,0}};
66
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
65
+ cumo_ndfunc_arg_in_t ain[2] = {{CUMO_OVERWRITE,0},{Qnil,0}};
66
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 2,0, ain,0};
67
67
 
68
- na_ndloop(&ndf, 2, self, obj);
68
+ cumo_na_ndloop(&ndf, 2, self, obj);
69
69
  return self;
70
70
  }
@@ -1,48 +1,48 @@
1
1
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
2
+ <%=c_iter%>(cumo_na_loop_t *const lp)
3
3
  {
4
4
  ssize_t i, s1, s2;
5
5
  size_t p1;
6
6
  char *p2;
7
7
  size_t *idx1, *idx2;
8
8
  <%=dtype%> x;
9
- BIT_DIGIT *a1;
10
- BIT_DIGIT y;
9
+ CUMO_BIT_DIGIT *a1;
10
+ CUMO_BIT_DIGIT y;
11
11
 
12
12
  // TODO(sonots): CUDA kernelize
13
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
13
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("store_<%=name%>", "<%=type_name%>");
14
14
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
15
15
 
16
- INIT_COUNTER(lp, i);
17
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
18
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
16
+ CUMO_INIT_COUNTER(lp, i);
17
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
18
+ CUMO_INIT_PTR_IDX(lp, 1, p2, s2, idx2);
19
19
 
20
20
  if (idx2) {
21
21
  if (idx1) {
22
22
  for (; i--;) {
23
- GET_DATA_INDEX(p2,idx2,<%=dtype%>,x);
23
+ CUMO_GET_DATA_INDEX(p2,idx2,<%=dtype%>,x);
24
24
  y = <%=macro%>(x);
25
- STORE_BIT(a1, p1+*idx1, y); idx1++;
25
+ CUMO_STORE_BIT(a1, p1+*idx1, y); idx1++;
26
26
  }
27
27
  } else {
28
28
  for (; i--;) {
29
- GET_DATA_INDEX(p2,idx2,<%=dtype%>,x);
29
+ CUMO_GET_DATA_INDEX(p2,idx2,<%=dtype%>,x);
30
30
  y = <%=macro%>(x);
31
- STORE_BIT(a1, p1, y); p1+=s1;
31
+ CUMO_STORE_BIT(a1, p1, y); p1+=s1;
32
32
  }
33
33
  }
34
34
  } else {
35
35
  if (idx1) {
36
36
  for (; i--;) {
37
- GET_DATA_STRIDE(p2,s2,<%=dtype%>,x);
37
+ CUMO_GET_DATA_STRIDE(p2,s2,<%=dtype%>,x);
38
38
  y = <%=macro%>(x);
39
- STORE_BIT(a1, p1+*idx1, y); idx1++;
39
+ CUMO_STORE_BIT(a1, p1+*idx1, y); idx1++;
40
40
  }
41
41
  } else {
42
42
  for (; i--;) {
43
- GET_DATA_STRIDE(p2,s2,<%=dtype%>,x);
43
+ CUMO_GET_DATA_STRIDE(p2,s2,<%=dtype%>,x);
44
44
  y = <%=macro%>(x);
45
- STORE_BIT(a1, p1, y); p1+=s1;
45
+ CUMO_STORE_BIT(a1, p1, y); p1+=s1;
46
46
  }
47
47
  }
48
48
  }
@@ -52,9 +52,9 @@ static void
52
52
  static VALUE
53
53
  <%=c_func(:nodef)%>(VALUE self, VALUE obj)
54
54
  {
55
- ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{Qnil,0}};
56
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
55
+ cumo_ndfunc_arg_in_t ain[2] = {{CUMO_OVERWRITE,0},{Qnil,0}};
56
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 2,0, ain,0};
57
57
 
58
- na_ndloop(&ndf, 2, self, obj);
58
+ cumo_na_ndloop(&ndf, 2, self, obj);
59
59
  return self;
60
60
  }
@@ -1,30 +1,30 @@
1
1
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
2
+ <%=c_iter%>(cumo_na_loop_t *const lp)
3
3
  {
4
4
  size_t i;
5
- BIT_DIGIT *a1;
5
+ CUMO_BIT_DIGIT *a1;
6
6
  size_t p1;
7
7
  ssize_t s1;
8
8
  size_t *idx1;
9
- BIT_DIGIT x=0;
9
+ CUMO_BIT_DIGIT x=0;
10
10
  VALUE a, y;
11
11
 
12
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
12
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
13
13
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
14
14
 
15
- INIT_COUNTER(lp, i);
16
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
15
+ CUMO_INIT_COUNTER(lp, i);
16
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
17
17
  a = rb_ary_new2(i);
18
18
  rb_ary_push(lp->args[1].value, a);
19
19
  if (idx1) {
20
20
  for (; i--;) {
21
- LOAD_BIT(a1,p1+*idx1,x); idx1++;
21
+ CUMO_LOAD_BIT(a1,p1+*idx1,x); idx1++;
22
22
  y = m_data_to_num(x);
23
23
  rb_ary_push(a,y);
24
24
  }
25
25
  } else {
26
26
  for (; i--;) {
27
- LOAD_BIT(a1,p1,x); p1+=s1;
27
+ CUMO_LOAD_BIT(a1,p1,x); p1+=s1;
28
28
  y = m_data_to_num(x);
29
29
  rb_ary_push(a,y);
30
30
  }
@@ -39,9 +39,9 @@ static void
39
39
  static VALUE
40
40
  <%=c_func(0)%>(VALUE self)
41
41
  {
42
- ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
43
- ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
44
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 3,1, ain,aout};
42
+ cumo_ndfunc_arg_in_t ain[3] = {{Qnil,0},{cumo_sym_loop_opt},{cumo_sym_option}};
43
+ cumo_ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
44
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP_NIP, 3,1, ain,aout};
45
45
 
46
- return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
46
+ return cumo_na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
47
47
  }
@@ -1,53 +1,53 @@
1
1
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
2
+ <%=c_iter%>(cumo_na_loop_t *const lp)
3
3
  {
4
4
  size_t n;
5
5
  size_t p1, p3;
6
6
  ssize_t s1, s3;
7
7
  size_t *idx1, *idx3;
8
8
  int o1, l1, r1, len;
9
- BIT_DIGIT *a1, *a3;
10
- BIT_DIGIT x;
11
- BIT_DIGIT y;
9
+ CUMO_BIT_DIGIT *a1, *a3;
10
+ CUMO_BIT_DIGIT x;
11
+ CUMO_BIT_DIGIT y;
12
12
 
13
13
  // TODO(sonots): CUDA kernelize
14
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
14
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
15
15
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
16
16
 
17
- INIT_COUNTER(lp, n);
18
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
19
- INIT_PTR_BIT_IDX(lp, 1, a3, p3, s3, idx3);
17
+ CUMO_INIT_COUNTER(lp, n);
18
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
19
+ CUMO_INIT_PTR_BIT_IDX(lp, 1, a3, p3, s3, idx3);
20
20
  if (s1!=1 || s3!=1 || idx1 || idx3) {
21
21
  for (; n--;) {
22
- LOAD_BIT_STEP(a1, p1, s1, idx1, x);
22
+ CUMO_LOAD_BIT_STEP(a1, p1, s1, idx1, x);
23
23
  y = m_<%=name%>(x);
24
- STORE_BIT_STEP(a3, p3, s3, idx3, y);
24
+ CUMO_STORE_BIT_STEP(a3, p3, s3, idx3, y);
25
25
  }
26
26
  } else {
27
- o1 = p1 % NB;
27
+ o1 = p1 % CUMO_NB;
28
28
  o1 -= p3;
29
- l1 = NB+o1;
30
- r1 = NB-o1;
31
- if (p3>0 || n<NB) {
32
- len = NB - p3;
29
+ l1 = CUMO_NB+o1;
30
+ r1 = CUMO_NB-o1;
31
+ if (p3>0 || n<CUMO_NB) {
32
+ len = CUMO_NB - p3;
33
33
  if ((int)n<len) len=n;
34
34
  if (o1>=0) x = *a1>>o1;
35
35
  else x = *a1<<-o1;
36
- if (p1+len>NB) x |= *(a1+1)<<r1;
36
+ if (p1+len>CUMO_NB) x |= *(a1+1)<<r1;
37
37
  a1++;
38
38
  y = m_<%=name%>(x);
39
- *a3 = (y & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
39
+ *a3 = (y & (CUMO_SLB(len)<<p3)) | (*a3 & ~(CUMO_SLB(len)<<p3));
40
40
  a3++;
41
41
  n -= len;
42
42
  }
43
43
  if (o1==0) {
44
- for (; n>=NB; n-=NB) {
44
+ for (; n>=CUMO_NB; n-=CUMO_NB) {
45
45
  x = *(a1++);
46
46
  y = m_<%=name%>(x);
47
47
  *(a3++) = y;
48
48
  }
49
49
  } else {
50
- for (; n>=NB; n-=NB) {
50
+ for (; n>=CUMO_NB; n-=CUMO_NB) {
51
51
  x = *a1>>o1;
52
52
  if (o1<0) x |= *(a1-1)>>l1;
53
53
  if (o1>0) x |= *(a1+1)<<r1;
@@ -60,7 +60,7 @@ static void
60
60
  x = *a1>>o1;
61
61
  if (o1<0) x |= *(a1-1)>>l1;
62
62
  y = m_<%=name%>(x);
63
- *a3 = (y & SLB(n)) | (*a3 & BALL<<n);
63
+ *a3 = (y & CUMO_SLB(n)) | (*a3 & CUMO_BALL<<n);
64
64
  }
65
65
  }
66
66
  }
@@ -73,9 +73,9 @@ static void
73
73
  static VALUE
74
74
  <%=c_func(0)%>(VALUE self)
75
75
  {
76
- ndfunc_arg_in_t ain[1] = {{cT,0}};
77
- ndfunc_arg_out_t aout[1] = {{cT,0}};
78
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 1,1, ain,aout};
76
+ cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
77
+ cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
78
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 1,1, ain,aout};
79
79
 
80
- return na_ndloop(&ndf, 1, self);
80
+ return cumo_na_ndloop(&ndf, 1, self);
81
81
  }
@@ -8,32 +8,32 @@ typedef struct {
8
8
  #define STORE_INT(ptr, esz, x) memcpy(ptr,&(x),esz)
9
9
 
10
10
  static void
11
- <%=c_iter%>(na_loop_t *const lp)
11
+ <%=c_iter%>(cumo_na_loop_t *const lp)
12
12
  {
13
13
  size_t i;
14
- BIT_DIGIT *a;
14
+ CUMO_BIT_DIGIT *a;
15
15
  size_t p;
16
16
  ssize_t s;
17
17
  size_t *idx;
18
- BIT_DIGIT x=0;
18
+ CUMO_BIT_DIGIT x=0;
19
19
  char *idx1;
20
20
  size_t count;
21
21
  size_t e;
22
22
  where_opt_t *g;
23
23
 
24
24
  // TODO(sonots): CUDA kernelize
25
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
25
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
26
26
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
27
27
 
28
28
  g = (where_opt_t*)(lp->opt_ptr);
29
29
  count = g->count;
30
30
  idx1 = g->idx1;
31
31
  e = g->elmsz;
32
- INIT_COUNTER(lp, i);
33
- INIT_PTR_BIT_IDX(lp, 0, a, p, s, idx);
32
+ CUMO_INIT_COUNTER(lp, i);
33
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a, p, s, idx);
34
34
  if (idx) {
35
35
  for (; i--;) {
36
- LOAD_BIT(a, p+*idx, x);
36
+ CUMO_LOAD_BIT(a, p+*idx, x);
37
37
  idx++;
38
38
  if (x!=0) {
39
39
  STORE_INT(idx1,e,count);
@@ -43,7 +43,7 @@ static void
43
43
  }
44
44
  } else {
45
45
  for (; i--;) {
46
- LOAD_BIT(a, p, x);
46
+ CUMO_LOAD_BIT(a, p, x);
47
47
  p+=s;
48
48
  if (x!=0) {
49
49
  STORE_INT(idx1,e,count);
@@ -68,23 +68,23 @@ static VALUE
68
68
  size_t size, n_1;
69
69
  where_opt_t *g;
70
70
 
71
- ndfunc_arg_in_t ain[1] = {{cT,0}};
72
- ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 1, 0, ain, 0 };
71
+ cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
72
+ cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 1, 0, ain, 0 };
73
73
 
74
- size = RNARRAY_SIZE(self);
74
+ size = CUMO_RNARRAY_SIZE(self);
75
75
  n_1 = NUM2SIZET(<%=find_tmpl("count_true_cpu").c_func%>(0, NULL, self));
76
76
  g = ALLOCA_N(where_opt_t,1);
77
77
  g->count = 0;
78
78
  if (size>4294967295ul) {
79
- idx_1 = nary_new(cumo_cInt64, 1, &n_1);
79
+ idx_1 = cumo_na_new(cumo_cInt64, 1, &n_1);
80
80
  g->elmsz = 8;
81
81
  } else {
82
- idx_1 = nary_new(cumo_cInt32, 1, &n_1);
82
+ idx_1 = cumo_na_new(cumo_cInt32, 1, &n_1);
83
83
  g->elmsz = 4;
84
84
  }
85
- g->idx1 = na_get_pointer_for_write(idx_1);
85
+ g->idx1 = cumo_na_get_pointer_for_write(idx_1);
86
86
  g->idx0 = NULL;
87
- na_ndloop3(&ndf, g, 1, self);
88
- na_release_lock(idx_1);
87
+ cumo_na_ndloop3(&ndf, g, 1, self);
88
+ cumo_na_release_lock(idx_1);
89
89
  return idx_1;
90
90
  }
@@ -1,19 +1,19 @@
1
1
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
2
+ <%=c_iter%>(cumo_na_loop_t *const lp)
3
3
  {
4
4
  size_t i;
5
- BIT_DIGIT *a;
5
+ CUMO_BIT_DIGIT *a;
6
6
  size_t p;
7
7
  ssize_t s;
8
8
  size_t *idx;
9
- BIT_DIGIT x=0;
9
+ CUMO_BIT_DIGIT x=0;
10
10
  char *idx0, *idx1;
11
11
  size_t count;
12
12
  size_t e;
13
13
  where_opt_t *g;
14
14
 
15
15
  // TODO(sonots): CUDA kernelize
16
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
16
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
17
17
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
18
18
 
19
19
  g = (where_opt_t*)(lp->opt_ptr);
@@ -21,11 +21,11 @@ static void
21
21
  idx0 = g->idx0;
22
22
  idx1 = g->idx1;
23
23
  e = g->elmsz;
24
- INIT_COUNTER(lp, i);
25
- INIT_PTR_BIT_IDX(lp, 0, a, p, s, idx);
24
+ CUMO_INIT_COUNTER(lp, i);
25
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a, p, s, idx);
26
26
  if (idx) {
27
27
  for (; i--;) {
28
- LOAD_BIT(a, p+*idx, x);
28
+ CUMO_LOAD_BIT(a, p+*idx, x);
29
29
  idx++;
30
30
  if (x==0) {
31
31
  STORE_INT(idx0,e,count);
@@ -38,7 +38,7 @@ static void
38
38
  }
39
39
  } else {
40
40
  for (; i--;) {
41
- LOAD_BIT(a, p, x);
41
+ CUMO_LOAD_BIT(a, p, x);
42
42
  p+=s;
43
43
  if (x==0) {
44
44
  STORE_INT(idx0,e,count);
@@ -69,27 +69,27 @@ static VALUE
69
69
  size_t size, n_1, n_0;
70
70
  where_opt_t *g;
71
71
 
72
- ndfunc_arg_in_t ain[1] = {{cT,0}};
73
- ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 1, 0, ain, 0 };
72
+ cumo_ndfunc_arg_in_t ain[1] = {{cT,0}};
73
+ cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_FULL_LOOP, 1, 0, ain, 0 };
74
74
 
75
- size = RNARRAY_SIZE(self);
75
+ size = CUMO_RNARRAY_SIZE(self);
76
76
  n_1 = NUM2SIZET(<%=find_tmpl("count_true_cpu").c_func%>(0, NULL, self));
77
77
  n_0 = size - n_1;
78
78
  g = ALLOCA_N(where_opt_t,1);
79
79
  g->count = 0;
80
80
  if (size>4294967295ul) {
81
- idx_1 = nary_new(cumo_cInt64, 1, &n_1);
82
- idx_0 = nary_new(cumo_cInt64, 1, &n_0);
81
+ idx_1 = cumo_na_new(cumo_cInt64, 1, &n_1);
82
+ idx_0 = cumo_na_new(cumo_cInt64, 1, &n_0);
83
83
  g->elmsz = 8;
84
84
  } else {
85
- idx_1 = nary_new(cumo_cInt32, 1, &n_1);
86
- idx_0 = nary_new(cumo_cInt32, 1, &n_0);
85
+ idx_1 = cumo_na_new(cumo_cInt32, 1, &n_1);
86
+ idx_0 = cumo_na_new(cumo_cInt32, 1, &n_0);
87
87
  g->elmsz = 4;
88
88
  }
89
- g->idx1 = na_get_pointer_for_write(idx_1);
90
- g->idx0 = na_get_pointer_for_write(idx_0);
91
- na_ndloop3(&ndf, g, 1, self);
92
- na_release_lock(idx_0);
93
- na_release_lock(idx_1);
89
+ g->idx1 = cumo_na_get_pointer_for_write(idx_1);
90
+ g->idx0 = cumo_na_get_pointer_for_write(idx_0);
91
+ cumo_na_ndloop3(&ndf, g, 1, self);
92
+ cumo_na_release_lock(idx_0);
93
+ cumo_na_release_lock(idx_1);
94
94
  return rb_assoc_new(idx_1,idx_0);
95
95
  }