gumath 0.2.0dev5 → 0.2.0dev8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +7 -2
  3. data/Gemfile +0 -3
  4. data/ext/ruby_gumath/GPATH +0 -0
  5. data/ext/ruby_gumath/GRTAGS +0 -0
  6. data/ext/ruby_gumath/GTAGS +0 -0
  7. data/ext/ruby_gumath/extconf.rb +0 -5
  8. data/ext/ruby_gumath/functions.c +10 -2
  9. data/ext/ruby_gumath/gufunc_object.c +15 -4
  10. data/ext/ruby_gumath/gufunc_object.h +9 -3
  11. data/ext/ruby_gumath/gumath/Makefile +63 -0
  12. data/ext/ruby_gumath/gumath/Makefile.in +1 -0
  13. data/ext/ruby_gumath/gumath/config.h +56 -0
  14. data/ext/ruby_gumath/gumath/config.h.in +3 -0
  15. data/ext/ruby_gumath/gumath/config.log +497 -0
  16. data/ext/ruby_gumath/gumath/config.status +1034 -0
  17. data/ext/ruby_gumath/gumath/configure +375 -4
  18. data/ext/ruby_gumath/gumath/configure.ac +47 -3
  19. data/ext/ruby_gumath/gumath/libgumath/Makefile +236 -0
  20. data/ext/ruby_gumath/gumath/libgumath/Makefile.in +90 -24
  21. data/ext/ruby_gumath/gumath/libgumath/Makefile.vc +54 -15
  22. data/ext/ruby_gumath/gumath/libgumath/apply.c +92 -28
  23. data/ext/ruby_gumath/gumath/libgumath/apply.o +0 -0
  24. data/ext/ruby_gumath/gumath/libgumath/common.o +0 -0
  25. data/ext/ruby_gumath/gumath/libgumath/cpu_device_binary.o +0 -0
  26. data/ext/ruby_gumath/gumath/libgumath/cpu_device_unary.o +0 -0
  27. data/ext/ruby_gumath/gumath/libgumath/cpu_host_binary.o +0 -0
  28. data/ext/ruby_gumath/gumath/libgumath/cpu_host_unary.o +0 -0
  29. data/ext/ruby_gumath/gumath/libgumath/examples.o +0 -0
  30. data/ext/ruby_gumath/gumath/libgumath/extending/graph.c +27 -20
  31. data/ext/ruby_gumath/gumath/libgumath/extending/pdist.c +1 -1
  32. data/ext/ruby_gumath/gumath/libgumath/func.c +13 -9
  33. data/ext/ruby_gumath/gumath/libgumath/func.o +0 -0
  34. data/ext/ruby_gumath/gumath/libgumath/graph.o +0 -0
  35. data/ext/ruby_gumath/gumath/libgumath/gumath.h +55 -14
  36. data/ext/ruby_gumath/gumath/libgumath/kernels/common.c +513 -0
  37. data/ext/ruby_gumath/gumath/libgumath/kernels/common.h +155 -0
  38. data/ext/ruby_gumath/gumath/libgumath/kernels/contrib/bfloat16.h +520 -0
  39. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_binary.cc +1123 -0
  40. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_binary.h +1062 -0
  41. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_msvc.cc +555 -0
  42. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_unary.cc +368 -0
  43. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_unary.h +335 -0
  44. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_host_binary.c +2952 -0
  45. data/ext/ruby_gumath/gumath/libgumath/kernels/cpu_host_unary.c +1100 -0
  46. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_binary.cu +1143 -0
  47. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_binary.h +1061 -0
  48. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_unary.cu +528 -0
  49. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_unary.h +463 -0
  50. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_host_binary.c +2817 -0
  51. data/ext/ruby_gumath/gumath/libgumath/kernels/cuda_host_unary.c +1331 -0
  52. data/ext/ruby_gumath/gumath/libgumath/kernels/device.hh +614 -0
  53. data/ext/ruby_gumath/gumath/libgumath/libgumath.a +0 -0
  54. data/ext/ruby_gumath/gumath/libgumath/libgumath.so +1 -0
  55. data/ext/ruby_gumath/gumath/libgumath/libgumath.so.0 +1 -0
  56. data/ext/ruby_gumath/gumath/libgumath/libgumath.so.0.2.0dev3 +0 -0
  57. data/ext/ruby_gumath/gumath/libgumath/nploops.o +0 -0
  58. data/ext/ruby_gumath/gumath/libgumath/pdist.o +0 -0
  59. data/ext/ruby_gumath/gumath/libgumath/quaternion.o +0 -0
  60. data/ext/ruby_gumath/gumath/libgumath/tbl.o +0 -0
  61. data/ext/ruby_gumath/gumath/libgumath/thread.c +17 -4
  62. data/ext/ruby_gumath/gumath/libgumath/thread.o +0 -0
  63. data/ext/ruby_gumath/gumath/libgumath/xndloops.c +110 -0
  64. data/ext/ruby_gumath/gumath/libgumath/xndloops.o +0 -0
  65. data/ext/ruby_gumath/gumath/python/gumath/__init__.py +150 -0
  66. data/ext/ruby_gumath/gumath/python/gumath/_gumath.c +446 -80
  67. data/ext/ruby_gumath/gumath/python/gumath/cuda.c +78 -0
  68. data/ext/ruby_gumath/gumath/python/gumath/examples.c +0 -5
  69. data/ext/ruby_gumath/gumath/python/gumath/functions.c +2 -2
  70. data/ext/ruby_gumath/gumath/python/gumath/gumath.h +246 -0
  71. data/ext/ruby_gumath/gumath/python/gumath/libgumath.a +0 -0
  72. data/ext/ruby_gumath/gumath/python/gumath/libgumath.so +1 -0
  73. data/ext/ruby_gumath/gumath/python/gumath/libgumath.so.0 +1 -0
  74. data/ext/ruby_gumath/gumath/python/gumath/libgumath.so.0.2.0dev3 +0 -0
  75. data/ext/ruby_gumath/gumath/python/gumath/pygumath.h +31 -2
  76. data/ext/ruby_gumath/gumath/python/gumath_aux.py +767 -0
  77. data/ext/ruby_gumath/gumath/python/randdec.py +535 -0
  78. data/ext/ruby_gumath/gumath/python/randfloat.py +177 -0
  79. data/ext/ruby_gumath/gumath/python/test_gumath.py +1504 -24
  80. data/ext/ruby_gumath/gumath/python/test_xndarray.py +462 -0
  81. data/ext/ruby_gumath/gumath/setup.py +67 -6
  82. data/ext/ruby_gumath/gumath/tools/detect_cuda_arch.cc +35 -0
  83. data/ext/ruby_gumath/include/gumath.h +55 -14
  84. data/ext/ruby_gumath/include/ruby_gumath.h +4 -1
  85. data/ext/ruby_gumath/lib/libgumath.a +0 -0
  86. data/ext/ruby_gumath/lib/libgumath.so.0.2.0dev3 +0 -0
  87. data/ext/ruby_gumath/ruby_gumath.c +231 -70
  88. data/ext/ruby_gumath/ruby_gumath.h +4 -1
  89. data/ext/ruby_gumath/ruby_gumath_internal.h +25 -0
  90. data/ext/ruby_gumath/util.c +34 -0
  91. data/ext/ruby_gumath/util.h +9 -0
  92. data/gumath.gemspec +3 -2
  93. data/lib/gumath.rb +55 -1
  94. data/lib/gumath/version.rb +2 -2
  95. data/lib/ruby_gumath.so +0 -0
  96. metadata +63 -10
  97. data/ext/ruby_gumath/gumath/libgumath/extending/bfloat16.c +0 -130
  98. data/ext/ruby_gumath/gumath/libgumath/kernels/binary.c +0 -547
  99. data/ext/ruby_gumath/gumath/libgumath/kernels/unary.c +0 -449
@@ -33,8 +33,11 @@
33
33
  #define RUBY_GUMATH_H
34
34
 
35
35
  /* Classes */
36
- VALUE cGumath;
36
+ extern VALUE cGumath;
37
37
 
38
+ /* C API call for adding functions from a gumath kernel table to a Ruby module.
39
+ * Only adds CPU functions.
40
+ */
38
41
  int rb_gumath_add_functions(VALUE module, const gm_tbl_t *tbl);
39
42
  #define GUMATH_FUNCTION_HASH rb_intern("@gumath_functions")
40
43
 
@@ -42,4 +42,29 @@
42
42
  #include "ruby_gumath.h"
43
43
  #include "util.h"
44
44
 
45
+ #ifdef _MSC_VER
46
+ #ifndef UNUSED
47
+ #define UNUSED
48
+ #endif
49
+ #include <float.h>
50
+ #include <fenv.h>
51
+ #pragma fenv_access(on)
52
+ #else
53
+ #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
54
+ #define UNUSED __attribute__((unused))
55
+ #else
56
+ #define UNUSED
57
+ #endif
58
+ #include <fenv.h>
59
+ #if 0 /* Not supported by gcc and clang. */
60
+ #pragma STDC FENV_ACCESS ON
61
+ #endif
62
+ #endif
63
+
64
+
65
+ void Init_gumath_functions(void);
66
+ void Init_gumath_examples(void);
67
+
68
+ VALUE seterr(ndt_context_t *ctx);
69
+
45
70
  #endif /* RUBY_GUMATH_INTERNAL_H */
@@ -66,3 +66,37 @@ raise_error(void)
66
66
  rb_set_errinfo(Qnil);
67
67
  rb_exc_raise(exeception);
68
68
  }
69
+
70
+ /* Checks whether a given Ruby object is of a type using is_a? */
71
+ int
72
+ rb_is_a(VALUE obj, VALUE klass)
73
+ {
74
+ return RTEST(rb_funcall(obj, rb_intern("is_a?"), 1, klass));
75
+ }
76
+
77
+ int
78
+ rb_klass_has_ancestor(VALUE klass, VALUE ancestor)
79
+ {
80
+ return RTEST(
81
+ rb_funcall(
82
+ rb_funcall(klass, rb_intern("ancestors"),0,NULL),
83
+ rb_intern("include?"),
84
+ 1,
85
+ ancestor));
86
+ }
87
+
88
+ int
89
+ rb_ary_size(VALUE array)
90
+ {
91
+ Check_Type(array, T_ARRAY);
92
+ return FIX2INT(rb_funcall(array, rb_intern("size"), 0, NULL));
93
+ }
94
+
95
+ void
96
+ rb_puts(VALUE v) {
97
+ ID sym_puts = rb_intern("puts");
98
+ ID sym_inspect = rb_intern("inspect");
99
+ rb_funcall(rb_mKernel, sym_puts, 1,
100
+ rb_funcall(v, sym_inspect, 0));
101
+ }
102
+
@@ -45,4 +45,13 @@ int ndt_exists(void);
45
45
  /* Raise an error stored in $!. Clears it before raising. */
46
46
  void raise_error(void);
47
47
 
48
+ int rb_is_a(VALUE obj, VALUE klass);
49
+
50
+ int rb_klass_has_ancestor(VALUE klass, VALUE ancestor);
51
+
52
+ int rb_ary_size(VALUE array);
53
+
54
+ void rb_puts(VALUE v);
55
+
56
+
48
57
  #endif /* GUMATH_UTIL_H */
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.license = 'BSD-3 Clause'
34
34
 
35
35
  spec.files = files
36
+ spec.extensions = "ext/ruby_gumath/extconf.rb"
36
37
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
37
38
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
38
39
  spec.require_paths = ["lib"]
@@ -42,6 +43,6 @@ Gem::Specification.new do |spec|
42
43
  spec.add_development_dependency 'pry'
43
44
  spec.add_development_dependency 'pry-byebug'
44
45
 
45
- spec.add_runtime_dependency 'ndtypes', '>= 0.2.0dev5'
46
- spec.add_runtime_dependency 'xnd', '>= 0.2.0dev5'
46
+ spec.add_runtime_dependency 'ndtypes', '>= 0.2.0dev8'
47
+ spec.add_runtime_dependency 'xnd', '>= 0.2.0dev8'
47
48
  end
@@ -3,5 +3,59 @@ require 'xnd'
3
3
 
4
4
  require 'etc'
5
5
 
6
- require 'ruby_gumath.so'
6
+ begin
7
+ require 'ruby_gumath.so'
8
+ rescue LoadError
9
+ require 'ruby_gumath/ruby_gumath.so'
10
+ end
7
11
  require 'gumath/version'
12
+
13
+ class Gumath
14
+ MAXCAST = {
15
+ NDT.new("int8") => NDT.new("int64"),
16
+ NDT.new("int16") => NDT.new("int64"),
17
+ NDT.new("int32") => NDT.new("int64"),
18
+ NDT.new("int64") => NDT.new("int64"),
19
+ NDT.new("uint8") => NDT.new("uint64"),
20
+ NDT.new("uint16") => NDT.new("uint64"),
21
+ NDT.new("uint32") => NDT.new("uint64"),
22
+ NDT.new("uint64") => NDT.new("uint64"),
23
+ NDT.new("bfloat16")=> NDT.new("float64"),
24
+ NDT.new("float16") => NDT.new("float64"),
25
+ NDT.new("float32") => NDT.new("float64"),
26
+ NDT.new("float64") => NDT.new("float64"),
27
+ NDT.new("complex32") => NDT.new("complex128"),
28
+ NDT.new("complex64") => NDT.new("complex128"),
29
+ NDT.new("complex128")=> NDT.new("complex128"),
30
+
31
+ NDT.new("?int8") => NDT.new("?int64"),
32
+ NDT.new("?int16")=> NDT.new("?int64"),
33
+ NDT.new("?int32")=> NDT.new("?int64"),
34
+ NDT.new("?int64")=> NDT.new("?int64"),
35
+ NDT.new("?uint8")=> NDT.new("?uint64"),
36
+ NDT.new("?uint16")=> NDT.new("?uint64"),
37
+ NDT.new("?uint32")=> NDT.new("?uint64"),
38
+ NDT.new("?uint64")=> NDT.new("?uint64"),
39
+ NDT.new("?bfloat16") => NDT.new("?float64"),
40
+ NDT.new("?float16") => NDT.new("?float64"),
41
+ NDT.new("?float32") => NDT.new("?float64"),
42
+ NDT.new("?float64") => NDT.new("?float64"),
43
+ NDT.new("?complex32")=> NDT.new("?complex128"),
44
+ NDT.new("?complex64")=> NDT.new("?complex128"),
45
+ NDT.new("?complex128")=> NDT.new("?complex128"),
46
+ }
47
+
48
+ class << self
49
+ def reduce mod, meth, x, axes=0, dtype=nil
50
+ if dtype.nil?
51
+ dtype = MAXCAST[x.dtype]
52
+ end
53
+
54
+ reduce_cpu(mod, meth, x, axes, dtype)
55
+ end
56
+
57
+ def reduce_cpu mod, meth, x, axes, dtype
58
+
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  class Gumath
2
- VERSION = "0.2.0dev5"
2
+ VERSION = "0.2.0dev8"
3
3
 
4
- COMMIT = '5725aa2bda2d9a9581e7adedda00e9f1dcaa881a'
4
+ COMMIT="360ed454105ac5615a7cb7d216ad25bc4181b876"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gumath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0dev5
4
+ version: 0.2.0dev8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Deshmukh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2019-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -72,35 +72,36 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0dev5
75
+ version: 0.2.0dev8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0dev5
82
+ version: 0.2.0dev8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: xnd
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.2.0dev5
89
+ version: 0.2.0dev8
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.2.0dev5
96
+ version: 0.2.0dev8
97
97
  description: 'Gumath is library for function dispatch to XND containers.
98
98
 
99
99
  '
100
100
  email:
101
101
  - sameer.deshmukh93@gmail.com
102
102
  executables: []
103
- extensions: []
103
+ extensions:
104
+ - ext/ruby_gumath/extconf.rb
104
105
  extra_rdoc_files: []
105
106
  files:
106
107
  - CONTRIBUTING.md
@@ -108,6 +109,9 @@ files:
108
109
  - History.md
109
110
  - README.md
110
111
  - Rakefile
112
+ - ext/ruby_gumath/GPATH
113
+ - ext/ruby_gumath/GRTAGS
114
+ - ext/ruby_gumath/GTAGS
111
115
  - ext/ruby_gumath/examples.c
112
116
  - ext/ruby_gumath/extconf.rb
113
117
  - ext/ruby_gumath/functions.c
@@ -117,10 +121,14 @@ files:
117
121
  - ext/ruby_gumath/gumath/INSTALL.txt
118
122
  - ext/ruby_gumath/gumath/LICENSE.txt
119
123
  - ext/ruby_gumath/gumath/MANIFEST.in
124
+ - ext/ruby_gumath/gumath/Makefile
120
125
  - ext/ruby_gumath/gumath/Makefile.in
121
126
  - ext/ruby_gumath/gumath/README.rst
122
127
  - ext/ruby_gumath/gumath/config.guess
128
+ - ext/ruby_gumath/gumath/config.h
123
129
  - ext/ruby_gumath/gumath/config.h.in
130
+ - ext/ruby_gumath/gumath/config.log
131
+ - ext/ruby_gumath/gumath/config.status
124
132
  - ext/ruby_gumath/gumath/config.sub
125
133
  - ext/ruby_gumath/gumath/configure
126
134
  - ext/ruby_gumath/gumath/configure.ac
@@ -135,30 +143,75 @@ files:
135
143
  - ext/ruby_gumath/gumath/doc/libgumath/kernels.rst
136
144
  - ext/ruby_gumath/gumath/doc/releases/index.rst
137
145
  - ext/ruby_gumath/gumath/install-sh
146
+ - ext/ruby_gumath/gumath/libgumath/Makefile
138
147
  - ext/ruby_gumath/gumath/libgumath/Makefile.in
139
148
  - ext/ruby_gumath/gumath/libgumath/Makefile.vc
140
149
  - ext/ruby_gumath/gumath/libgumath/apply.c
141
- - ext/ruby_gumath/gumath/libgumath/extending/bfloat16.c
150
+ - ext/ruby_gumath/gumath/libgumath/apply.o
151
+ - ext/ruby_gumath/gumath/libgumath/common.o
152
+ - ext/ruby_gumath/gumath/libgumath/cpu_device_binary.o
153
+ - ext/ruby_gumath/gumath/libgumath/cpu_device_unary.o
154
+ - ext/ruby_gumath/gumath/libgumath/cpu_host_binary.o
155
+ - ext/ruby_gumath/gumath/libgumath/cpu_host_unary.o
156
+ - ext/ruby_gumath/gumath/libgumath/examples.o
142
157
  - ext/ruby_gumath/gumath/libgumath/extending/examples.c
143
158
  - ext/ruby_gumath/gumath/libgumath/extending/graph.c
144
159
  - ext/ruby_gumath/gumath/libgumath/extending/pdist.c
145
160
  - ext/ruby_gumath/gumath/libgumath/extending/quaternion.c
146
161
  - ext/ruby_gumath/gumath/libgumath/func.c
162
+ - ext/ruby_gumath/gumath/libgumath/func.o
163
+ - ext/ruby_gumath/gumath/libgumath/graph.o
147
164
  - ext/ruby_gumath/gumath/libgumath/gumath.h
148
- - ext/ruby_gumath/gumath/libgumath/kernels/binary.c
149
- - ext/ruby_gumath/gumath/libgumath/kernels/unary.c
165
+ - ext/ruby_gumath/gumath/libgumath/kernels/common.c
166
+ - ext/ruby_gumath/gumath/libgumath/kernels/common.h
167
+ - ext/ruby_gumath/gumath/libgumath/kernels/contrib/bfloat16.h
168
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_binary.cc
169
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_binary.h
170
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_msvc.cc
171
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_unary.cc
172
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_device_unary.h
173
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_host_binary.c
174
+ - ext/ruby_gumath/gumath/libgumath/kernels/cpu_host_unary.c
175
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_binary.cu
176
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_binary.h
177
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_unary.cu
178
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_device_unary.h
179
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_host_binary.c
180
+ - ext/ruby_gumath/gumath/libgumath/kernels/cuda_host_unary.c
181
+ - ext/ruby_gumath/gumath/libgumath/kernels/device.hh
182
+ - ext/ruby_gumath/gumath/libgumath/libgumath.a
183
+ - ext/ruby_gumath/gumath/libgumath/libgumath.so
184
+ - ext/ruby_gumath/gumath/libgumath/libgumath.so.0
185
+ - ext/ruby_gumath/gumath/libgumath/libgumath.so.0.2.0dev3
150
186
  - ext/ruby_gumath/gumath/libgumath/nploops.c
187
+ - ext/ruby_gumath/gumath/libgumath/nploops.o
188
+ - ext/ruby_gumath/gumath/libgumath/pdist.o
189
+ - ext/ruby_gumath/gumath/libgumath/quaternion.o
151
190
  - ext/ruby_gumath/gumath/libgumath/tbl.c
191
+ - ext/ruby_gumath/gumath/libgumath/tbl.o
152
192
  - ext/ruby_gumath/gumath/libgumath/thread.c
193
+ - ext/ruby_gumath/gumath/libgumath/thread.o
153
194
  - ext/ruby_gumath/gumath/libgumath/xndloops.c
195
+ - ext/ruby_gumath/gumath/libgumath/xndloops.o
154
196
  - ext/ruby_gumath/gumath/python/extending.py
155
197
  - ext/ruby_gumath/gumath/python/gumath/__init__.py
156
198
  - ext/ruby_gumath/gumath/python/gumath/_gumath.c
199
+ - ext/ruby_gumath/gumath/python/gumath/cuda.c
157
200
  - ext/ruby_gumath/gumath/python/gumath/examples.c
158
201
  - ext/ruby_gumath/gumath/python/gumath/functions.c
202
+ - ext/ruby_gumath/gumath/python/gumath/gumath.h
203
+ - ext/ruby_gumath/gumath/python/gumath/libgumath.a
204
+ - ext/ruby_gumath/gumath/python/gumath/libgumath.so
205
+ - ext/ruby_gumath/gumath/python/gumath/libgumath.so.0
206
+ - ext/ruby_gumath/gumath/python/gumath/libgumath.so.0.2.0dev3
159
207
  - ext/ruby_gumath/gumath/python/gumath/pygumath.h
208
+ - ext/ruby_gumath/gumath/python/gumath_aux.py
209
+ - ext/ruby_gumath/gumath/python/randdec.py
210
+ - ext/ruby_gumath/gumath/python/randfloat.py
160
211
  - ext/ruby_gumath/gumath/python/test_gumath.py
212
+ - ext/ruby_gumath/gumath/python/test_xndarray.py
161
213
  - ext/ruby_gumath/gumath/setup.py
214
+ - ext/ruby_gumath/gumath/tools/detect_cuda_arch.cc
162
215
  - ext/ruby_gumath/gumath/vcbuild/INSTALL.txt
163
216
  - ext/ruby_gumath/gumath/vcbuild/vcbuild32.bat
164
217
  - ext/ruby_gumath/gumath/vcbuild/vcbuild64.bat
@@ -1,130 +0,0 @@
1
- /*
2
- * BSD 3-Clause License
3
- *
4
- * Copyright (c) 2017-2018, plures
5
- * All rights reserved.
6
- *
7
- * Redistribution and use in source and binary forms, with or without
8
- * modification, are permitted provided that the following conditions are met:
9
- *
10
- * 1. Redistributions of source code must retain the above copyright notice,
11
- * this list of conditions and the following disclaimer.
12
- *
13
- * 2. Redistributions in binary form must reproduce the above copyright notice,
14
- * this list of conditions and the following disclaimer in the documentation
15
- * and/or other materials provided with the distribution.
16
- *
17
- * 3. Neither the name of the copyright holder nor the names of its
18
- * contributors may be used to endorse or promote products derived from
19
- * this software without specific prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
-
34
- #include <stdlib.h>
35
- #include <stdint.h>
36
- #include <string.h>
37
- #include <math.h>
38
- #include <complex.h>
39
- #include <inttypes.h>
40
- #include "ndtypes.h"
41
- #include "xnd.h"
42
- #include "gumath.h"
43
-
44
-
45
- /* Avoid Python.h dependency. */
46
- struct _object;
47
- double PyFloat_AsDouble(const struct _object *);
48
- struct _object *PyFloat_FromDouble (double v);
49
- struct _object *PyErr_Occurred(void);
50
-
51
-
52
- /*****************************************************************************/
53
- /* Initialize a single bfloat16 from a PyObject */
54
- /*****************************************************************************/
55
-
56
- /* XXX Maybe rename "init", "repr" to "from_object", "to_object". */
57
- static bool
58
- bfloat16_init(void *dest, const void *src, ndt_context_t *ctx)
59
- {
60
- const struct _object *v = (const struct _object *)src;
61
- xnd_t *x = (xnd_t *)dest;
62
- const ndt_t *t = x->type;
63
- float f;
64
- (void)ctx;
65
-
66
- f = (float)PyFloat_AsDouble(v);
67
- if (f == -1 && PyErr_Occurred()) {
68
- return 0;
69
- }
70
-
71
- const char *cp = ndt_is_big_endian(t) ? (char *)&f : ((char *)&f)+2;
72
- memcpy(x->ptr, cp, sizeof(uint16_t));
73
- return 1;
74
- }
75
-
76
- static void *
77
- bfloat16_repr(const void *src, ndt_context_t *ctx)
78
- {
79
- const xnd_t *x = (const xnd_t *)src;
80
- const ndt_t *t = x->type;
81
- float f = 0;
82
- (void)ctx;
83
-
84
- char *cp = ndt_is_big_endian(t) ? (char *)&f : ((char *)&f)+2;
85
- memcpy(cp, x->ptr, sizeof(uint16_t));
86
-
87
- return PyFloat_FromDouble(f);
88
- }
89
-
90
-
91
- static const ndt_methods_t bfloat16_methods = {
92
- .init = bfloat16_init,
93
- .constraint = NULL,
94
- .repr = bfloat16_repr,
95
- };
96
-
97
- static const gm_typedef_init_t typedefs[] = {
98
- { .name = "bfloat16", .type = "uint16", .meth=&bfloat16_methods },
99
- { .name = NULL, .type = NULL, .meth=NULL }
100
- };
101
-
102
- static const gm_kernel_init_t kernels[] = {
103
- { .name = NULL, .sig = NULL }
104
- };
105
-
106
-
107
- /****************************************************************************/
108
- /* Initialize kernel table */
109
- /****************************************************************************/
110
-
111
- int
112
- gm_init_bfloat16_kernels(gm_tbl_t *tbl, ndt_context_t *ctx)
113
- {
114
- const gm_typedef_init_t *t;
115
- const gm_kernel_init_t *k;
116
-
117
- for (t = typedefs; t->name != NULL; t++) {
118
- if (ndt_typedef_from_string(t->name, t->type, t->meth, ctx) < 0) {
119
- return -1;
120
- }
121
- }
122
-
123
- for (k = kernels; k->name != NULL; k++) {
124
- if (gm_add_kernel(tbl, k, ctx) < 0) {
125
- return -1;
126
- }
127
- }
128
-
129
- return 0;
130
- }