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
@@ -10,20 +10,20 @@
10
10
  static VALUE
11
11
  <%=c_func(0)%>(VALUE self)
12
12
  {
13
- BIT_DIGIT *ptr, val;
13
+ CUMO_BIT_DIGIT *ptr, val;
14
14
  size_t pos;
15
- narray_t *na;
16
- GetNArray(self,na);
15
+ cumo_narray_t *na;
16
+ CumoGetNArray(self,na);
17
17
 
18
18
  if (na->ndim==0) {
19
- pos = na_get_offset(self);
20
- ptr = (BIT_DIGIT*)na_get_pointer_for_read(self);
19
+ pos = cumo_na_get_offset(self);
20
+ ptr = (CUMO_BIT_DIGIT*)cumo_na_get_pointer_for_read(self);
21
21
 
22
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
22
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
23
23
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
24
24
 
25
- val = ((*((ptr)+(pos)/NB)) >> ((pos)%NB)) & 1u;
26
- na_release_lock(self);
25
+ val = ((*((ptr)+(pos)/CUMO_NB)) >> ((pos)%CUMO_NB)) & 1u;
26
+ cumo_na_release_lock(self);
27
27
  return INT2FIX(val);
28
28
  }
29
29
  return self;
@@ -9,20 +9,20 @@
9
9
  static VALUE
10
10
  <%=c_func(0)%>(VALUE self)
11
11
  {
12
- BIT_DIGIT *ptr, val;
12
+ CUMO_BIT_DIGIT *ptr, val;
13
13
  size_t pos;
14
- narray_t *na;
15
- GetNArray(self,na);
14
+ cumo_narray_t *na;
15
+ CumoGetNArray(self,na);
16
16
 
17
17
  if (na->ndim==0) {
18
- pos = na_get_offset(self);
19
- ptr = (BIT_DIGIT*)na_get_pointer_for_read(self);
18
+ pos = cumo_na_get_offset(self);
19
+ ptr = (CUMO_BIT_DIGIT*)cumo_na_get_pointer_for_read(self);
20
20
 
21
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
21
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
22
22
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
23
23
 
24
- val = ((*((ptr)+(pos)/NB)) >> ((pos)%NB)) & 1u;
25
- na_release_lock(self);
24
+ val = ((*((ptr)+(pos)/CUMO_NB)) >> ((pos)%CUMO_NB)) & 1u;
25
+ cumo_na_release_lock(self);
26
26
  return INT2FIX(val);
27
27
  }
28
28
  return self;
@@ -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 p3;
6
6
  ssize_t s3;
7
7
  size_t *idx3;
8
8
  int len;
9
- BIT_DIGIT *a3;
10
- BIT_DIGIT y;
9
+ CUMO_BIT_DIGIT *a3;
10
+ CUMO_BIT_DIGIT y;
11
11
  VALUE x = lp->option;
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
17
  if (x==INT2FIX(0) || x==Qfalse) {
18
18
  y = 0;
19
19
  } else
20
20
  if (x==INT2FIX(1) || x==Qtrue) {
21
- y = ~(BIT_DIGIT)0;
21
+ y = ~(CUMO_BIT_DIGIT)0;
22
22
  } else {
23
23
  rb_raise(rb_eArgError, "invalid value for Bit");
24
24
  }
25
25
 
26
- INIT_COUNTER(lp, n);
27
- INIT_PTR_BIT_IDX(lp, 0, a3, p3, s3, idx3);
26
+ CUMO_INIT_COUNTER(lp, n);
27
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a3, p3, s3, idx3);
28
28
  if (idx3) {
29
29
  y = y&1;
30
30
  for (; n--;) {
31
- STORE_BIT(a3, p3+*idx3, y); idx3++;
31
+ CUMO_STORE_BIT(a3, p3+*idx3, y); idx3++;
32
32
  }
33
33
  } else if (s3!=1) {
34
34
  y = y&1;
35
35
  for (; n--;) {
36
- STORE_BIT(a3, p3, y); p3+=s3;
36
+ CUMO_STORE_BIT(a3, p3, y); p3+=s3;
37
37
  }
38
38
  } else {
39
- if (p3>0 || n<NB) {
40
- len = NB - p3;
39
+ if (p3>0 || n<CUMO_NB) {
40
+ len = CUMO_NB - p3;
41
41
  if ((int)n<len) len=n;
42
- *a3 = (y & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
42
+ *a3 = (y & (CUMO_SLB(len)<<p3)) | (*a3 & ~(CUMO_SLB(len)<<p3));
43
43
  a3++;
44
44
  n -= len;
45
45
  }
46
- for (; n>=NB; n-=NB) {
46
+ for (; n>=CUMO_NB; n-=CUMO_NB) {
47
47
  *(a3++) = y;
48
48
  }
49
49
  if (n>0) {
50
- *a3 = (y & SLB(n)) | (*a3 & BALL<<n);
50
+ *a3 = (y & CUMO_SLB(n)) | (*a3 & CUMO_BALL<<n);
51
51
  }
52
52
  }
53
53
  }
@@ -61,9 +61,9 @@ static void
61
61
  static VALUE
62
62
  <%=c_func(1)%>(VALUE self, VALUE val)
63
63
  {
64
- ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
65
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
64
+ cumo_ndfunc_arg_in_t ain[2] = {{CUMO_OVERWRITE,0},{cumo_sym_option}};
65
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 2,0, ain,0};
66
66
 
67
- na_ndloop(&ndf, 2, self, val);
67
+ cumo_na_ndloop(&ndf, 2, self, val);
68
68
  return self;
69
69
  }
@@ -11,10 +11,10 @@ format_<%=type_name%>(VALUE fmt, dtype x)
11
11
  }
12
12
 
13
13
  static void
14
- <%=c_iter%>(na_loop_t *const lp)
14
+ <%=c_iter%>(cumo_na_loop_t *const lp)
15
15
  {
16
16
  size_t i;
17
- BIT_DIGIT *a1, x=0;
17
+ CUMO_BIT_DIGIT *a1, x=0;
18
18
  size_t p1;
19
19
  char *p2;
20
20
  ssize_t s1, s2;
@@ -22,24 +22,24 @@ static void
22
22
  VALUE y;
23
23
  VALUE fmt = lp->option;
24
24
 
25
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
25
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
26
26
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
27
27
 
28
- INIT_COUNTER(lp, i);
29
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
30
- INIT_PTR(lp, 1, p2, s2);
28
+ CUMO_INIT_COUNTER(lp, i);
29
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
30
+ CUMO_INIT_PTR(lp, 1, p2, s2);
31
31
 
32
32
  if (idx1) {
33
33
  for (; i--;) {
34
- LOAD_BIT(a1, p1+*idx1, x); idx1++;
34
+ CUMO_LOAD_BIT(a1, p1+*idx1, x); idx1++;
35
35
  y = format_<%=type_name%>(fmt, x);
36
- SET_DATA_STRIDE(p2, s2, VALUE, y);
36
+ CUMO_SET_DATA_STRIDE(p2, s2, VALUE, y);
37
37
  }
38
38
  } else {
39
39
  for (; i--;) {
40
- LOAD_BIT(a1, p1, x); p1+=s1;
40
+ CUMO_LOAD_BIT(a1, p1, x); p1+=s1;
41
41
  y = format_<%=type_name%>(fmt, x);
42
- SET_DATA_STRIDE(p2, s2, VALUE, y);
42
+ CUMO_SET_DATA_STRIDE(p2, s2, VALUE, y);
43
43
  }
44
44
  }
45
45
  }
@@ -55,10 +55,10 @@ static VALUE
55
55
  {
56
56
  VALUE fmt=Qnil;
57
57
 
58
- ndfunc_arg_in_t ain[2] = {{Qnil,0},{sym_option}};
59
- ndfunc_arg_out_t aout[1] = {{cumo_cRObject,0}};
60
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 2,1, ain,aout};
58
+ cumo_ndfunc_arg_in_t ain[2] = {{Qnil,0},{cumo_sym_option}};
59
+ cumo_ndfunc_arg_out_t aout[1] = {{cumo_cRObject,0}};
60
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP_NIP, 2,1, ain,aout};
61
61
 
62
62
  rb_scan_args(argc, argv, "01", &fmt);
63
- return na_ndloop(&ndf, 2, self, fmt);
63
+ return cumo_na_ndloop(&ndf, 2, self, fmt);
64
64
  }
@@ -1,8 +1,8 @@
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, x=0;
5
+ CUMO_BIT_DIGIT *a1, x=0;
6
6
  size_t p1;
7
7
  ssize_t s1;
8
8
  size_t *idx1;
@@ -10,19 +10,19 @@ static void
10
10
  VALUE fmt = lp->option;
11
11
  volatile VALUE a;
12
12
 
13
- INIT_COUNTER(lp, i);
14
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
13
+ CUMO_INIT_COUNTER(lp, i);
14
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
15
15
  a = rb_ary_new2(i);
16
16
  rb_ary_push(lp->args[1].value, a);
17
17
  if (idx1) {
18
18
  for (; i--;) {
19
- LOAD_BIT(a1, p1+*idx1, x); idx1++;
19
+ CUMO_LOAD_BIT(a1, p1+*idx1, x); idx1++;
20
20
  y = format_bit(fmt, x);
21
21
  rb_ary_push(a,y);
22
22
  }
23
23
  } else {
24
24
  for (; i--;) {
25
- LOAD_BIT(a1, p1, x); p1+=s1;
25
+ CUMO_LOAD_BIT(a1, p1, x); p1+=s1;
26
26
  y = format_bit(fmt, x);
27
27
  rb_ary_push(a,y);
28
28
  }
@@ -39,13 +39,13 @@ static VALUE
39
39
  <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
40
40
  {
41
41
  VALUE fmt=Qnil;
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
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
46
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
47
47
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
48
48
 
49
49
  rb_scan_args(argc, argv, "01", &fmt);
50
- return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
50
+ return cumo_na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
51
51
  }
@@ -2,7 +2,7 @@ static VALUE
2
2
  <%=c_iter%>(char *ptr, size_t pos, VALUE fmt)
3
3
  {
4
4
  dtype x;
5
- LOAD_BIT(ptr,pos,x);
5
+ CUMO_LOAD_BIT(ptr,pos,x);
6
6
  return format_<%=type_name%>(fmt, x);
7
7
  }
8
8
 
@@ -14,8 +14,8 @@ static VALUE
14
14
  static VALUE
15
15
  <%=c_func(0)%>(VALUE ary)
16
16
  {
17
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
17
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
18
18
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
19
19
 
20
- return na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
20
+ return cumo_na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
21
21
  }
@@ -1,24 +1,24 @@
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 p1, p2;
7
7
  ssize_t s1, s2;
8
8
  size_t *idx1, *idx2, *pidx;
9
- BIT_DIGIT x=0;
9
+ CUMO_BIT_DIGIT x=0;
10
10
  size_t count;
11
11
  where_opt_t *g;
12
12
 
13
- SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
13
+ CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
14
14
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
15
15
 
16
16
  g = (where_opt_t*)(lp->opt_ptr);
17
17
  count = g->count;
18
18
  pidx = (size_t*)(g->idx1);
19
- INIT_COUNTER(lp, i);
20
- INIT_PTR_BIT_IDX(lp, 0, a, p1, s1, idx1);
21
- //INIT_PTR_IDX(lp, 1, p2, s2, idx2);
19
+ CUMO_INIT_COUNTER(lp, i);
20
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a, p1, s1, idx1);
21
+ //CUMO_INIT_PTR_IDX(lp, 1, p2, s2, idx2);
22
22
  p2 = lp->args[1].iter[0].pos;
23
23
  s2 = lp->args[1].iter[0].step;
24
24
  idx2 = lp->args[1].iter[0].idx;
@@ -26,7 +26,7 @@ static void
26
26
  if (idx1) {
27
27
  if (idx2) {
28
28
  for (; i--;) {
29
- LOAD_BIT(a, p1+*idx1, x);
29
+ CUMO_LOAD_BIT(a, p1+*idx1, x);
30
30
  idx1++;
31
31
  if (x) {
32
32
  *(pidx++) = p2+*idx2;
@@ -36,7 +36,7 @@ static void
36
36
  }
37
37
  } else {
38
38
  for (; i--;) {
39
- LOAD_BIT(a, p1+*idx1, x);
39
+ CUMO_LOAD_BIT(a, p1+*idx1, x);
40
40
  idx1++;
41
41
  if (x) {
42
42
  *(pidx++) = p2;
@@ -48,7 +48,7 @@ static void
48
48
  } else {
49
49
  if (idx2) {
50
50
  for (; i--;) {
51
- LOAD_BIT(a, p1, x);
51
+ CUMO_LOAD_BIT(a, p1, x);
52
52
  p1 += s1;
53
53
  if (x) {
54
54
  *(pidx++) = p2+*idx2;
@@ -58,7 +58,7 @@ static void
58
58
  }
59
59
  } else {
60
60
  for (; i--;) {
61
- LOAD_BIT(a, p1, x);
61
+ CUMO_LOAD_BIT(a, p1, x);
62
62
  p1 += s1;
63
63
  if (x) {
64
64
  *(pidx++) = p2;
@@ -88,48 +88,48 @@ static VALUE
88
88
  <%=c_func(1)%>(VALUE mask, VALUE val)
89
89
  {
90
90
  volatile VALUE idx_1, view;
91
- narray_data_t *nidx;
92
- narray_view_t *nv;
93
- narray_t *na;
94
- narray_view_t *na1;
95
- stridx_t stridx0;
91
+ cumo_narray_data_t *nidx;
92
+ cumo_narray_view_t *nv;
93
+ cumo_narray_t *na;
94
+ cumo_narray_view_t *na1;
95
+ cumo_stridx_t stridx0;
96
96
  size_t n_1;
97
97
  where_opt_t g;
98
- ndfunc_arg_in_t ain[2] = {{cT,0},{Qnil,0}};
99
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2, 0, ain, 0};
98
+ cumo_ndfunc_arg_in_t ain[2] = {{cT,0},{Qnil,0}};
99
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 2, 0, ain, 0};
100
100
 
101
101
  // TODO(sonots): bit_count_true synchronizes with CPU. Avoid.
102
102
  n_1 = NUM2SIZET(<%=find_tmpl("count_true_cpu").c_func%>(0, NULL, mask));
103
- idx_1 = nary_new(cIndex, 1, &n_1);
103
+ idx_1 = cumo_na_new(cIndex, 1, &n_1);
104
104
  g.count = 0;
105
105
  g.elmsz = SIZEOF_VOIDP;
106
- g.idx1 = na_get_pointer_for_write(idx_1);
106
+ g.idx1 = cumo_na_get_pointer_for_write(idx_1);
107
107
  g.idx0 = NULL;
108
- na_ndloop3(&ndf, &g, 2, mask, val);
108
+ cumo_na_ndloop3(&ndf, &g, 2, mask, val);
109
109
 
110
- view = na_s_allocate_view(CLASS_OF(val));
111
- GetNArrayView(view, nv);
112
- na_setup_shape((narray_t*)nv, 1, &n_1);
110
+ view = cumo_na_s_allocate_view(rb_obj_class(val));
111
+ CumoGetNArrayView(view, nv);
112
+ cumo_na_setup_shape((cumo_narray_t*)nv, 1, &n_1);
113
113
 
114
- GetNArrayData(idx_1,nidx);
115
- SDX_SET_INDEX(stridx0,(size_t*)nidx->ptr);
114
+ CumoGetNArrayData(idx_1,nidx);
115
+ CUMO_SDX_SET_INDEX(stridx0,(size_t*)nidx->ptr);
116
116
  nidx->ptr = NULL;
117
117
 
118
- nv->stridx = ALLOC_N(stridx_t,1);
118
+ nv->stridx = ALLOC_N(cumo_stridx_t,1);
119
119
  nv->stridx[0] = stridx0;
120
120
  nv->offset = 0;
121
121
 
122
- GetNArray(val, na);
123
- switch(NA_TYPE(na)) {
124
- case NARRAY_DATA_T:
122
+ CumoGetNArray(val, na);
123
+ switch(CUMO_NA_TYPE(na)) {
124
+ case CUMO_NARRAY_DATA_T:
125
125
  nv->data = val;
126
126
  break;
127
- case NARRAY_VIEW_T:
128
- GetNArrayView(val, na1);
127
+ case CUMO_NARRAY_VIEW_T:
128
+ CumoGetNArrayView(val, na1);
129
129
  nv->data = na1->data;
130
130
  break;
131
131
  default:
132
- rb_raise(rb_eRuntimeError,"invalid NA_TYPE: %d",NA_TYPE(na));
132
+ rb_raise(rb_eRuntimeError,"invalid CUMO_NA_TYPE: %d",CUMO_NA_TYPE(na));
133
133
  }
134
134
 
135
135
  return view;
@@ -1,24 +1,24 @@
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, n;
5
5
  size_t i1, n1;
6
6
  VALUE v1, *ptr;
7
- BIT_DIGIT *a1;
7
+ CUMO_BIT_DIGIT *a1;
8
8
  size_t p1;
9
9
  size_t s1, *idx1;
10
10
  VALUE x;
11
11
  double y;
12
- BIT_DIGIT z;
12
+ CUMO_BIT_DIGIT z;
13
13
  size_t len, c;
14
14
  double beg, step;
15
15
 
16
16
  // TODO(sonots): CUDA kernelize
17
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
17
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
18
18
  cumo_cuda_runtime_check_status(cudaDeviceSynchronize());
19
19
 
20
- INIT_COUNTER(lp, n);
21
- INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
20
+ CUMO_INIT_COUNTER(lp, n);
21
+ CUMO_INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1);
22
22
  v1 = lp->args[1].value;
23
23
  i = 0;
24
24
 
@@ -52,34 +52,34 @@ static void
52
52
  if (idx1) {
53
53
  for (i=i1=0; i1<n1 && i<n; i++,i1++) {
54
54
  x = ptr[i1];
55
- if (rb_obj_is_kind_of(x, rb_cRange) || rb_obj_is_kind_of(x, na_cStep)) {
56
- nary_step_sequence(x,&len,&beg,&step);
55
+ if (rb_obj_is_kind_of(x, rb_cRange) || rb_obj_is_kind_of(x, cumo_na_cStep)) {
56
+ cumo_na_step_sequence(x,&len,&beg,&step);
57
57
  for (c=0; c<len && i<n; c++,i++) {
58
58
  y = beg + step * c;
59
59
  z = m_from_double(y);
60
- STORE_BIT(a1, p1+*idx1, z); idx1++;
60
+ CUMO_STORE_BIT(a1, p1+*idx1, z); idx1++;
61
61
  }
62
62
  }
63
63
  if (TYPE(x) != T_ARRAY) {
64
64
  if (x == Qnil) x = INT2FIX(0);
65
65
  z = m_num_to_data(x);
66
- STORE_BIT(a1, p1+*idx1, z); idx1++;
66
+ CUMO_STORE_BIT(a1, p1+*idx1, z); idx1++;
67
67
  }
68
68
  }
69
69
  } else {
70
70
  for (i=i1=0; i1<n1 && i<n; i++,i1++) {
71
71
  x = ptr[i1];
72
- if (rb_obj_is_kind_of(x, rb_cRange) || rb_obj_is_kind_of(x, na_cStep)) {
73
- nary_step_sequence(x,&len,&beg,&step);
72
+ if (rb_obj_is_kind_of(x, rb_cRange) || rb_obj_is_kind_of(x, cumo_na_cStep)) {
73
+ cumo_na_step_sequence(x,&len,&beg,&step);
74
74
  for (c=0; c<len && i<n; c++,i++) {
75
75
  y = beg + step * c;
76
76
  z = m_from_double(y);
77
- STORE_BIT(a1, p1, z); p1+=s1;
77
+ CUMO_STORE_BIT(a1, p1, z); p1+=s1;
78
78
  }
79
79
  }
80
80
  if (TYPE(x) != T_ARRAY) {
81
81
  z = m_num_to_data(x);
82
- STORE_BIT(a1, p1, z); p1+=s1;
82
+ CUMO_STORE_BIT(a1, p1, z); p1+=s1;
83
83
  }
84
84
  }
85
85
  }
@@ -88,11 +88,11 @@ static void
88
88
  z = m_zero;
89
89
  if (idx1) {
90
90
  for (; i<n; i++) {
91
- STORE_BIT(a1, p1+*idx1, z); idx1++;
91
+ CUMO_STORE_BIT(a1, p1+*idx1, z); idx1++;
92
92
  }
93
93
  } else {
94
94
  for (; i<n; i++) {
95
- STORE_BIT(a1, p1, z); p1+=s1;
95
+ CUMO_STORE_BIT(a1, p1, z); p1+=s1;
96
96
  }
97
97
  }
98
98
  }
@@ -100,9 +100,9 @@ static void
100
100
  static VALUE
101
101
  <%=c_func(:nodef)%>(VALUE self, VALUE rary)
102
102
  {
103
- ndfunc_arg_in_t ain[2] = {{OVERWRITE,0}, {rb_cArray,0}};
104
- ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2, 0, ain, 0};
103
+ cumo_ndfunc_arg_in_t ain[2] = {{CUMO_OVERWRITE,0}, {rb_cArray,0}};
104
+ cumo_ndfunc_t ndf = {<%=c_iter%>, CUMO_FULL_LOOP, 2, 0, ain, 0};
105
105
 
106
- na_ndloop_store_rarray(&ndf, self, rary);
106
+ cumo_na_ndloop_store_rarray(&ndf, self, rary);
107
107
  return self;
108
108
  }