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
@@ -3,23 +3,23 @@ void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, char *p3, ch
3
3
  <% end %>
4
4
 
5
5
  static void
6
- <%=c_iter%>(na_loop_t *const lp)
6
+ <%=c_iter%>(cumo_na_loop_t *const lp)
7
7
  {
8
8
  size_t i, n;
9
9
  char *p1, *p2, *p3, *p4;
10
10
  ssize_t s1, s2, s3, s4;
11
- INIT_COUNTER(lp, n);
12
- INIT_PTR(lp, 0, p1, s1);
13
- INIT_PTR(lp, 1, p2, s2);
14
- INIT_PTR(lp, 2, p3, s3);
15
- INIT_PTR(lp, 3, p4, s4);
11
+ CUMO_INIT_COUNTER(lp, n);
12
+ CUMO_INIT_PTR(lp, 0, p1, s1);
13
+ CUMO_INIT_PTR(lp, 1, p2, s2);
14
+ CUMO_INIT_PTR(lp, 2, p3, s3);
15
+ CUMO_INIT_PTR(lp, 3, p4, s4);
16
16
  for (i=n; i--;) {
17
17
  <% if type_name == 'robject' %>
18
18
  {
19
19
  dtype x, y, a, b;
20
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
21
- GET_DATA_STRIDE(p1,s1,dtype,x);
22
- GET_DATA_STRIDE(p2,s2,dtype,y);
20
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
21
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
22
+ CUMO_GET_DATA_STRIDE(p2,s2,dtype,y);
23
23
  <% if is_int and %w[divmod].include? name %>
24
24
  if (y==0) {
25
25
  lp->err_type = rb_eZeroDivError;
@@ -27,8 +27,8 @@ static void
27
27
  }
28
28
  <% end %>
29
29
  m_<%=name%>(x,y,a,b);
30
- SET_DATA_STRIDE(p3,s3,dtype,a);
31
- SET_DATA_STRIDE(p4,s4,dtype,b);
30
+ CUMO_SET_DATA_STRIDE(p3,s3,dtype,a);
31
+ CUMO_SET_DATA_STRIDE(p4,s4,dtype,b);
32
32
  }
33
33
  <% else %>
34
34
  <%="cumo_#{c_iter}_stride_kernel_launch"%>(p1,p2,p3,p4,s1,s2,s3,s4,n);
@@ -39,11 +39,11 @@ static void
39
39
  static VALUE
40
40
  <%=c_func%>_self(VALUE self, VALUE other)
41
41
  {
42
- ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
43
- ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
44
- ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP, 2, 2, ain, aout };
42
+ cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
43
+ cumo_ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
44
+ cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_STRIDE_LOOP, 2, 2, ain, aout };
45
45
 
46
- return na_ndloop(&ndf, 2, self, other);
46
+ return cumo_na_ndloop(&ndf, 2, self, other);
47
47
  }
48
48
 
49
49
  /*
@@ -59,12 +59,12 @@ static VALUE
59
59
  return <%=c_func%>_self(self, other);
60
60
  <% else %>
61
61
  VALUE klass, v;
62
- klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
62
+ klass = cumo_na_upcast(rb_obj_class(self),rb_obj_class(other));
63
63
  if (klass==cT) {
64
64
  return <%=c_func%>_self(self, other);
65
65
  } else {
66
- v = rb_funcall(klass, id_cast, 1, self);
67
- return rb_funcall(v, <%=id_op%>, 1, other);
66
+ v = rb_funcall(klass, cumo_id_cast, 1, self);
67
+ return rb_funcall(v, <%=cumo_id_op%>, 1, other);
68
68
  }
69
69
  <% end %>
70
70
  }
@@ -8,8 +8,8 @@ __global__ void <%="cumo_#{c_iter}_stride_kernel"%>(char *p1, char *p2, char *p3
8
8
 
9
9
  void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, char *p3, char *p4, ssize_t s1, ssize_t s2, ssize_t s3, ssize_t s4, uint64_t n)
10
10
  {
11
- size_t gridDim = get_gridDim(n);
12
- size_t blockDim = get_blockDim(n);
13
- <%="cumo_#{c_iter}_stride_kernel"%><<<gridDim, blockDim>>>(p1,p2,p3,p4,s1,s2,s3,s4,n);
11
+ size_t grid_dim = cumo_get_grid_dim(n);
12
+ size_t block_dim = cumo_get_block_dim(n);
13
+ <%="cumo_#{c_iter}_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,p3,p4,s1,s2,s3,s4,n);
14
14
  }
15
15
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <% unless type_name == 'robject' %>
2
2
 
3
3
  <% ((0..opt_indexer_ndim).to_a << '').each do |idim| %>
4
- __global__ void <%="cumo_#{c_iter}_kernel_dim#{idim}"%>(na_iarray_t a1, na_iarray_t a2, na_iarray_t a3, na_indexer_t indexer)
4
+ __global__ void <%="cumo_#{c_iter}_kernel_dim#{idim}"%>(cumo_na_iarray_t a1, cumo_na_iarray_t a2, cumo_na_iarray_t a3, cumo_na_indexer_t indexer)
5
5
  {
6
6
  for (uint64_t i = blockIdx.x * blockDim.x + threadIdx.x; i < indexer.total_size; i += blockDim.x * gridDim.x) {
7
7
  cumo_na_indexer_set_dim<%=idim%>(&indexer, i);
@@ -13,18 +13,18 @@ __global__ void <%="cumo_#{c_iter}_kernel_dim#{idim}"%>(na_iarray_t a1, na_iarra
13
13
  }
14
14
  <% end %>
15
15
 
16
- void <%="cumo_#{c_iter}_kernel_launch"%>(na_iarray_t* a1, na_iarray_t* a2, na_iarray_t* a3, na_indexer_t* indexer)
16
+ void <%="cumo_#{c_iter}_kernel_launch"%>(cumo_na_iarray_t* a1, cumo_na_iarray_t* a2, cumo_na_iarray_t* a3, cumo_na_indexer_t* indexer)
17
17
  {
18
- size_t gridDim = get_gridDim(indexer->total_size);
19
- size_t blockDim = get_blockDim(indexer->total_size);
18
+ size_t grid_dim = cumo_get_grid_dim(indexer->total_size);
19
+ size_t block_dim = cumo_get_block_dim(indexer->total_size);
20
20
  switch (indexer->ndim) {
21
21
  <% (0..opt_indexer_ndim).each do |idim| %>
22
22
  case <%=idim%>:
23
- <%="cumo_#{c_iter}_kernel_dim#{idim}"%><<<gridDim, blockDim>>>(*a1,*a2,*a3,*indexer);
23
+ <%="cumo_#{c_iter}_kernel_dim#{idim}"%><<<grid_dim, block_dim>>>(*a1,*a2,*a3,*indexer);
24
24
  break;
25
25
  <% end %>
26
26
  default:
27
- <%="cumo_#{c_iter}_kernel_dim"%><<<gridDim, blockDim>>>(*a1,*a2,*a3,*indexer);
27
+ <%="cumo_#{c_iter}_kernel_dim"%><<<grid_dim, block_dim>>>(*a1,*a2,*a3,*indexer);
28
28
  break;
29
29
  }
30
30
  }
@@ -3,24 +3,24 @@ void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, char *p3, ss
3
3
  <% end %>
4
4
 
5
5
  static void
6
- <%=c_iter%>(na_loop_t *const lp)
6
+ <%=c_iter%>(cumo_na_loop_t *const lp)
7
7
  {
8
8
  size_t i;
9
9
  char *p1, *p2, *p3;
10
10
  ssize_t s1, s2, s3;
11
- INIT_COUNTER(lp, i);
12
- INIT_PTR(lp, 0, p1, s1);
13
- INIT_PTR(lp, 1, p2, s2);
14
- INIT_PTR(lp, 2, p3, s3);
11
+ CUMO_INIT_COUNTER(lp, i);
12
+ CUMO_INIT_PTR(lp, 0, p1, s1);
13
+ CUMO_INIT_PTR(lp, 1, p2, s2);
14
+ CUMO_INIT_PTR(lp, 2, p3, s3);
15
15
  <% if type_name == 'robject' %>
16
16
  {
17
17
  dtype x, y;
18
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
18
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
19
19
  for (; i--;) {
20
- GET_DATA_STRIDE(p1,s1,dtype,x);
21
- GET_DATA_STRIDE(p2,s2,dtype,y);
20
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
21
+ CUMO_GET_DATA_STRIDE(p2,s2,dtype,y);
22
22
  x = m_<%=name%>(x,y);
23
- SET_DATA_STRIDE(p3,s3,dtype,x);
23
+ CUMO_SET_DATA_STRIDE(p3,s3,dtype,x);
24
24
  }
25
25
  }
26
26
  <% else %>
@@ -38,8 +38,8 @@ static void
38
38
  static VALUE
39
39
  <%=c_func(2)%>(VALUE mod, VALUE a1, VALUE a2)
40
40
  {
41
- ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
42
- ndfunc_arg_out_t aout[1] = {{cT,0}};
43
- ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP, 2, 1, ain, aout };
44
- return na_ndloop(&ndf, 2, a1, a2);
41
+ cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
42
+ cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
43
+ cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_STRIDE_LOOP, 2, 1, ain, aout };
44
+ return cumo_na_ndloop(&ndf, 2, a1, a2);
45
45
  }
@@ -8,8 +8,8 @@ __global__ void <%="cumo_#{c_iter}_stride_kernel"%>(char *p1, char *p2, char *p3
8
8
 
9
9
  void <%="cumo_#{c_iter}_stride_kernel_launch"%>(char *p1, char *p2, char *p3, ssize_t s1, ssize_t s2, ssize_t s3, uint64_t n)
10
10
  {
11
- size_t gridDim = get_gridDim(n);
12
- size_t blockDim = get_blockDim(n);
13
- <%="cumo_#{c_iter}_stride_kernel"%><<<gridDim, blockDim>>>(p1,p2,p3,s1,s2,s3,n);
11
+ size_t grid_dim = cumo_get_grid_dim(n);
12
+ size_t block_dim = cumo_get_block_dim(n);
13
+ <%="cumo_#{c_iter}_stride_kernel"%><<<grid_dim, block_dim>>>(p1,p2,p3,s1,s2,s3,n);
14
14
  }
15
15
  <% end %>
@@ -5,15 +5,15 @@
5
5
  cnt_type = "u_int#{bits}_t"
6
6
  %>
7
7
  static void
8
- <%=c_iter%>_<%=bits%>(na_loop_t *const lp)
8
+ <%=c_iter%>_<%=bits%>(cumo_na_loop_t *const lp)
9
9
  {
10
10
  size_t i, x, n;
11
11
  char *p1, *p2;
12
12
  ssize_t s1, s2;
13
13
  size_t *idx1;
14
14
 
15
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
16
- INIT_PTR(lp, 1, p2, s2);
15
+ CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
16
+ CUMO_INIT_PTR(lp, 1, p2, s2);
17
17
  i = lp->args[0].shape[0];
18
18
  n = lp->args[1].shape[0];
19
19
 
@@ -22,15 +22,15 @@ static void
22
22
  *(<%=cnt_type%>*)(p2 + s2*x) = 0;
23
23
  }
24
24
 
25
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_<%=bits%>", "<%=type_name%>");
25
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_<%=bits%>", "<%=type_name%>");
26
26
  if (idx1) {
27
27
  for (; i--;) {
28
- GET_DATA_INDEX(p1,idx1,dtype,x);
28
+ CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
29
29
  (*(<%=cnt_type%>*)(p2 + s2*x))++;
30
30
  }
31
31
  } else {
32
32
  for (; i--;) {
33
- GET_DATA_STRIDE(p1,s1,dtype,x);
33
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
34
34
  (*(<%=cnt_type%>*)(p2 + s2*x))++;
35
35
  }
36
36
  }
@@ -40,12 +40,12 @@ static VALUE
40
40
  <%=c_func%>_<%=bits%>(VALUE self, size_t length)
41
41
  {
42
42
  size_t shape_out[1] = {length};
43
- ndfunc_arg_in_t ain[1] = {{cT,1}};
44
- ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
45
- ndfunc_t ndf = {<%=c_iter%>_<%=bits%>, NO_LOOP|NDF_STRIDE_LOOP|NDF_INDEX_LOOP,
43
+ cumo_ndfunc_arg_in_t ain[1] = {{cT,1}};
44
+ cumo_ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
45
+ cumo_ndfunc_t ndf = {<%=c_iter%>_<%=bits%>, CUMO_NO_LOOP|CUMO_NDF_STRIDE_LOOP|CUMO_NDF_INDEX_LOOP,
46
46
  1, 1, ain, aout};
47
47
 
48
- return na_ndloop(&ndf, 1, self);
48
+ return cumo_na_ndloop(&ndf, 1, self);
49
49
  }
50
50
  <% end %>
51
51
  // ------- end of Integer count without weights -------
@@ -58,22 +58,22 @@ static VALUE
58
58
  fn = fn.downcase
59
59
  %>
60
60
  static void
61
- <%=c_iter%>_<%=fn%>(na_loop_t *const lp)
61
+ <%=c_iter%>_<%=fn%>(cumo_na_loop_t *const lp)
62
62
  {
63
63
  <%=cnt_type%> w;
64
64
  size_t i, x, n, m;
65
65
  char *p1, *p2, *p3;
66
66
  ssize_t s1, s2, s3;
67
67
 
68
- INIT_PTR(lp, 0, p1, s1);
69
- INIT_PTR(lp, 1, p2, s2);
70
- INIT_PTR(lp, 2, p3, s3);
68
+ CUMO_INIT_PTR(lp, 0, p1, s1);
69
+ CUMO_INIT_PTR(lp, 1, p2, s2);
70
+ CUMO_INIT_PTR(lp, 2, p3, s3);
71
71
  i = lp->args[0].shape[0];
72
72
  m = lp->args[1].shape[0];
73
73
  n = lp->args[2].shape[0];
74
74
 
75
75
  if (i != m) {
76
- rb_raise(nary_eShapeError,
76
+ rb_raise(cumo_na_eShapeError,
77
77
  "size mismatch along last axis between self and weight");
78
78
  }
79
79
 
@@ -82,8 +82,8 @@ static void
82
82
  *(<%=cnt_type%>*)(p3 + s3*x) = 0;
83
83
  }
84
84
  for (; i--;) {
85
- GET_DATA_STRIDE(p1,s1,dtype,x);
86
- GET_DATA_STRIDE(p2,s2,<%=cnt_type%>,w);
85
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
86
+ CUMO_GET_DATA_STRIDE(p2,s2,<%=cnt_type%>,w);
87
87
  (*(<%=cnt_type%>*)(p3 + s3*x)) += w;
88
88
  }
89
89
  }
@@ -92,12 +92,12 @@ static VALUE
92
92
  <%=c_func%>_<%=fn%>(VALUE self, VALUE weight, size_t length)
93
93
  {
94
94
  size_t shape_out[1] = {length};
95
- ndfunc_arg_in_t ain[2] = {{cT,1},{<%=cnt_cT%>,1}};
96
- ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
97
- ndfunc_t ndf = {<%=c_iter%>_<%=fn%>, NO_LOOP|NDF_STRIDE_LOOP,
95
+ cumo_ndfunc_arg_in_t ain[2] = {{cT,1},{<%=cnt_cT%>,1}};
96
+ cumo_ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
97
+ cumo_ndfunc_t ndf = {<%=c_iter%>_<%=fn%>, CUMO_NO_LOOP|CUMO_NDF_STRIDE_LOOP,
98
98
  2, 1, ain, aout};
99
99
 
100
- return na_ndloop(&ndf, 2, self, weight);
100
+ return cumo_na_ndloop(&ndf, 2, self, weight);
101
101
  }
102
102
  <% end %>
103
103
  // ------- end of Float count with weights -------
@@ -140,7 +140,7 @@ static VALUE
140
140
  VALUE weight=Qnil, kw=Qnil;
141
141
  VALUE opts[1] = {Qundef};
142
142
  VALUE v, wclass;
143
- ID table[1] = {id_minlength};
143
+ ID table[1] = {cumo_id_minlength};
144
144
  size_t length, minlength;
145
145
 
146
146
  rb_scan_args(argc, argv, "01:", &weight, &kw);
@@ -171,7 +171,7 @@ static VALUE
171
171
  return <%=c_func%>_32(self, length);
172
172
  }
173
173
  } else {
174
- wclass = CLASS_OF(weight);
174
+ wclass = rb_obj_class(weight);
175
175
  if (wclass == cumo_cSFloat) {
176
176
  return <%=c_func%>_sf(self, weight, length);
177
177
  } else {
@@ -14,10 +14,10 @@ static VALUE
14
14
  <%=c_func(1)%>(VALUE type, VALUE obj)
15
15
  {
16
16
  VALUE v;
17
- narray_t *na;
17
+ cumo_narray_t *na;
18
18
  dtype x;
19
19
 
20
- if (CLASS_OF(obj)==cT) {
20
+ if (rb_obj_class(obj)==cT) {
21
21
  return obj;
22
22
  }
23
23
  if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
@@ -27,10 +27,10 @@ static VALUE
27
27
  if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
28
28
  return <%=find_tmpl("cast_array").c_func%>(obj);
29
29
  }
30
- if (IsNArray(obj)) {
31
- GetNArray(obj,na);
32
- v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
33
- if (NA_SIZE(na) > 0) {
30
+ if (CumoIsNArray(obj)) {
31
+ CumoGetNArray(obj,na);
32
+ v = cumo_na_new(cT, CUMO_NA_NDIM(na), CUMO_NA_SHAPE(na));
33
+ if (CUMO_NA_SIZE(na) > 0) {
34
34
  <%=find_tmpl("store").c_func%>(v,obj);
35
35
  }
36
36
  return v;
@@ -38,7 +38,7 @@ static VALUE
38
38
  <% if is_object %>
39
39
  return robject_new_dim0(obj);
40
40
  <% else %>
41
- rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
41
+ rb_raise(cumo_na_eCastError,"cannot cast to %s",rb_class2name(type));
42
42
  return Qnil;
43
43
  <% end %>
44
44
  }
@@ -2,10 +2,10 @@ static VALUE
2
2
  <%=c_func(:nodef)%>(VALUE rary)
3
3
  {
4
4
  VALUE nary;
5
- narray_t *na;
5
+ cumo_narray_t *na;
6
6
 
7
- nary = na_s_new_like(cT, rary);
8
- GetNArray(nary,na);
7
+ nary = cumo_na_s_new_like(cT, rary);
8
+ CumoGetNArray(nary,na);
9
9
  if (na->size > 0) {
10
10
  <%=find_tmpl("store").find("array").c_func%>(nary,rary);
11
11
  }
@@ -1,64 +1,64 @@
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
5
  char *p1, *p2, *p3, *p4;
6
6
  ssize_t s1, s2, s3, s4;
7
7
  dtype x, min, max;
8
- INIT_COUNTER(lp, i);
9
- INIT_PTR(lp, 0, p1, s1);
10
- INIT_PTR(lp, 1, p2, s2);
11
- INIT_PTR(lp, 2, p3, s3);
12
- INIT_PTR(lp, 3, p4, s4);
13
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
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_INIT_PTR(lp, 3, p4, s4);
13
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
14
14
  for (; i--;) {
15
- GET_DATA_STRIDE(p1,s1,dtype,x);
16
- GET_DATA_STRIDE(p2,s2,dtype,min);
17
- GET_DATA_STRIDE(p3,s3,dtype,max);
18
- if (m_gt(min,max)) {rb_raise(nary_eOperationError,"min is greater than max");}
15
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
16
+ CUMO_GET_DATA_STRIDE(p2,s2,dtype,min);
17
+ CUMO_GET_DATA_STRIDE(p3,s3,dtype,max);
18
+ if (m_gt(min,max)) {rb_raise(cumo_na_eOperationError,"min is greater than max");}
19
19
  if (m_lt(x,min)) {x=min;}
20
20
  if (m_gt(x,max)) {x=max;}
21
- SET_DATA_STRIDE(p4,s4,dtype,x);
21
+ CUMO_SET_DATA_STRIDE(p4,s4,dtype,x);
22
22
  }
23
23
  }
24
24
 
25
25
  static void
26
- <%=c_iter%>_min(na_loop_t *const lp)
26
+ <%=c_iter%>_min(cumo_na_loop_t *const lp)
27
27
  {
28
28
  size_t i;
29
29
  char *p1, *p2, *p3;
30
30
  ssize_t s1, s2, s3;
31
31
  dtype x, min;
32
- INIT_COUNTER(lp, i);
33
- INIT_PTR(lp, 0, p1, s1);
34
- INIT_PTR(lp, 1, p2, s2);
35
- INIT_PTR(lp, 2, p3, s3);
36
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_min", "<%=type_name%>");
32
+ CUMO_INIT_COUNTER(lp, i);
33
+ CUMO_INIT_PTR(lp, 0, p1, s1);
34
+ CUMO_INIT_PTR(lp, 1, p2, s2);
35
+ CUMO_INIT_PTR(lp, 2, p3, s3);
36
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_min", "<%=type_name%>");
37
37
  for (; i--;) {
38
- GET_DATA_STRIDE(p1,s1,dtype,x);
39
- GET_DATA_STRIDE(p2,s2,dtype,min);
38
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
39
+ CUMO_GET_DATA_STRIDE(p2,s2,dtype,min);
40
40
  if (m_lt(x,min)) {x=min;}
41
- SET_DATA_STRIDE(p3,s3,dtype,x);
41
+ CUMO_SET_DATA_STRIDE(p3,s3,dtype,x);
42
42
  }
43
43
  }
44
44
 
45
45
  static void
46
- <%=c_iter%>_max(na_loop_t *const lp)
46
+ <%=c_iter%>_max(cumo_na_loop_t *const lp)
47
47
  {
48
48
  size_t i;
49
49
  char *p1, *p2, *p3;
50
50
  ssize_t s1, s2, s3;
51
51
  dtype x, max;
52
- INIT_COUNTER(lp, i);
53
- INIT_PTR(lp, 0, p1, s1);
54
- INIT_PTR(lp, 1, p2, s2);
55
- INIT_PTR(lp, 2, p3, s3);
56
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_max", "<%=type_name%>");
52
+ CUMO_INIT_COUNTER(lp, i);
53
+ CUMO_INIT_PTR(lp, 0, p1, s1);
54
+ CUMO_INIT_PTR(lp, 1, p2, s2);
55
+ CUMO_INIT_PTR(lp, 2, p3, s3);
56
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_max", "<%=type_name%>");
57
57
  for (; i--;) {
58
- GET_DATA_STRIDE(p1,s1,dtype,x);
59
- GET_DATA_STRIDE(p2,s2,dtype,max);
58
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
59
+ CUMO_GET_DATA_STRIDE(p2,s2,dtype,max);
60
60
  if (m_gt(x,max)) {x=max;}
61
- SET_DATA_STRIDE(p3,s3,dtype,x);
61
+ CUMO_SET_DATA_STRIDE(p3,s3,dtype,x);
62
62
  }
63
63
  }
64
64
 
@@ -99,21 +99,21 @@ static void
99
99
  static VALUE
100
100
  <%=c_func(2)%>(VALUE self, VALUE min, VALUE max)
101
101
  {
102
- ndfunc_arg_in_t ain[3] = {{Qnil,0},{cT,0},{cT,0}};
103
- ndfunc_arg_out_t aout[1] = {{cT,0}};
104
- ndfunc_t ndf_min = { <%=c_iter%>_min, STRIDE_LOOP, 2, 1, ain, aout };
105
- ndfunc_t ndf_max = { <%=c_iter%>_max, STRIDE_LOOP, 2, 1, ain, aout };
106
- ndfunc_t ndf_both = { <%=c_iter%>, STRIDE_LOOP, 3, 1, ain, aout };
102
+ cumo_ndfunc_arg_in_t ain[3] = {{Qnil,0},{cT,0},{cT,0}};
103
+ cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
104
+ cumo_ndfunc_t ndf_min = { <%=c_iter%>_min, CUMO_STRIDE_LOOP, 2, 1, ain, aout };
105
+ cumo_ndfunc_t ndf_max = { <%=c_iter%>_max, CUMO_STRIDE_LOOP, 2, 1, ain, aout };
106
+ cumo_ndfunc_t ndf_both = { <%=c_iter%>, CUMO_STRIDE_LOOP, 3, 1, ain, aout };
107
107
 
108
108
  if (RTEST(min)) {
109
109
  if (RTEST(max)) {
110
- return na_ndloop(&ndf_both, 3, self, min, max);
110
+ return cumo_na_ndloop(&ndf_both, 3, self, min, max);
111
111
  } else {
112
- return na_ndloop(&ndf_min, 2, self, min);
112
+ return cumo_na_ndloop(&ndf_min, 2, self, min);
113
113
  }
114
114
  } else {
115
115
  if (RTEST(max)) {
116
- return na_ndloop(&ndf_max, 2, self, max);
116
+ return cumo_na_ndloop(&ndf_max, 2, self, max);
117
117
  }
118
118
  }
119
119
  rb_raise(rb_eArgError,"min and max are not given");