xnd 0.2.0dev6 → 0.2.0dev7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/Rakefile +1 -1
- data/ext/ruby_xnd/GPATH +0 -0
- data/ext/ruby_xnd/GRTAGS +0 -0
- data/ext/ruby_xnd/GTAGS +0 -0
- data/ext/ruby_xnd/extconf.rb +8 -5
- data/ext/ruby_xnd/gc_guard.c +53 -2
- data/ext/ruby_xnd/gc_guard.h +8 -2
- data/ext/ruby_xnd/include/overflow.h +147 -0
- data/ext/ruby_xnd/include/ruby_xnd.h +62 -0
- data/ext/ruby_xnd/include/xnd.h +590 -0
- data/ext/ruby_xnd/lib/libxnd.a +0 -0
- data/ext/ruby_xnd/lib/libxnd.so +1 -0
- data/ext/ruby_xnd/lib/libxnd.so.0 +1 -0
- data/ext/ruby_xnd/lib/libxnd.so.0.2.0dev3 +0 -0
- data/ext/ruby_xnd/ruby_xnd.c +556 -47
- data/ext/ruby_xnd/ruby_xnd.h +2 -1
- data/ext/ruby_xnd/xnd/Makefile +80 -0
- data/ext/ruby_xnd/xnd/config.h +26 -0
- data/ext/ruby_xnd/xnd/config.h.in +3 -0
- data/ext/ruby_xnd/xnd/config.log +421 -0
- data/ext/ruby_xnd/xnd/config.status +1023 -0
- data/ext/ruby_xnd/xnd/configure +376 -8
- data/ext/ruby_xnd/xnd/configure.ac +48 -7
- data/ext/ruby_xnd/xnd/doc/xnd/index.rst +3 -1
- data/ext/ruby_xnd/xnd/doc/xnd/{types.rst → xnd.rst} +3 -18
- data/ext/ruby_xnd/xnd/libxnd/Makefile +142 -0
- data/ext/ruby_xnd/xnd/libxnd/Makefile.in +43 -3
- data/ext/ruby_xnd/xnd/libxnd/Makefile.vc +19 -3
- data/ext/ruby_xnd/xnd/libxnd/bitmaps.c +42 -3
- data/ext/ruby_xnd/xnd/libxnd/bitmaps.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/bounds.c +366 -0
- data/ext/ruby_xnd/xnd/libxnd/bounds.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/contrib.h +98 -0
- data/ext/ruby_xnd/xnd/libxnd/contrib/bfloat16.h +213 -0
- data/ext/ruby_xnd/xnd/libxnd/copy.c +155 -4
- data/ext/ruby_xnd/xnd/libxnd/copy.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/cuda/cuda_memory.cu +121 -0
- data/ext/ruby_xnd/xnd/libxnd/cuda/cuda_memory.h +58 -0
- data/ext/ruby_xnd/xnd/libxnd/equal.c +195 -7
- data/ext/ruby_xnd/xnd/libxnd/equal.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/inline.h +32 -0
- data/ext/ruby_xnd/xnd/libxnd/libxnd.a +0 -0
- data/ext/ruby_xnd/xnd/libxnd/libxnd.so +1 -0
- data/ext/ruby_xnd/xnd/libxnd/libxnd.so.0 +1 -0
- data/ext/ruby_xnd/xnd/libxnd/libxnd.so.0.2.0dev3 +0 -0
- data/ext/ruby_xnd/xnd/libxnd/shape.c +207 -0
- data/ext/ruby_xnd/xnd/libxnd/shape.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/split.c +2 -2
- data/ext/ruby_xnd/xnd/libxnd/split.o +0 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/Makefile +39 -0
- data/ext/ruby_xnd/xnd/libxnd/xnd.c +613 -91
- data/ext/ruby_xnd/xnd/libxnd/xnd.h +145 -4
- data/ext/ruby_xnd/xnd/libxnd/xnd.o +0 -0
- data/ext/ruby_xnd/xnd/python/test_xnd.py +1125 -50
- data/ext/ruby_xnd/xnd/python/xnd/__init__.py +609 -124
- data/ext/ruby_xnd/xnd/python/xnd/_version.py +1 -0
- data/ext/ruby_xnd/xnd/python/xnd/_xnd.c +1652 -101
- data/ext/ruby_xnd/xnd/python/xnd/libxnd.a +0 -0
- data/ext/ruby_xnd/xnd/python/xnd/libxnd.so +1 -0
- data/ext/ruby_xnd/xnd/python/xnd/libxnd.so.0 +1 -0
- data/ext/ruby_xnd/xnd/python/xnd/libxnd.so.0.2.0dev3 +0 -0
- data/ext/ruby_xnd/xnd/python/xnd/pyxnd.h +1 -1
- data/ext/ruby_xnd/xnd/python/xnd/util.h +25 -0
- data/ext/ruby_xnd/xnd/python/xnd/xnd.h +590 -0
- data/ext/ruby_xnd/xnd/python/xnd_randvalue.py +106 -6
- data/ext/ruby_xnd/xnd/python/xnd_support.py +4 -0
- data/ext/ruby_xnd/xnd/setup.py +46 -4
- data/lib/ruby_xnd.so +0 -0
- data/lib/xnd.rb +39 -3
- data/lib/xnd/version.rb +2 -2
- data/xnd.gemspec +2 -1
- metadata +58 -5
@@ -41,9 +41,12 @@ AC_SUBST(host)
|
|
41
41
|
|
42
42
|
# Language and compiler:
|
43
43
|
AC_LANG_C
|
44
|
-
saved_cflags
|
44
|
+
saved_cflags="$CFLAGS"
|
45
|
+
saved_cxxflags="$CXXFLAGS"
|
45
46
|
AC_PROG_CC
|
46
|
-
|
47
|
+
AC_PROG_CXX
|
48
|
+
CFLAGS="$saved_cflags"
|
49
|
+
CXXFLAGS="$saved_cxxflags"
|
47
50
|
|
48
51
|
# ar and ranlib:
|
49
52
|
AC_CHECK_TOOL(AR, ar, ar)
|
@@ -58,6 +61,37 @@ AC_HEADER_STDC
|
|
58
61
|
AC_PROG_INSTALL
|
59
62
|
AC_SUBST(INSTALL)
|
60
63
|
|
64
|
+
# Cuda compiler:
|
65
|
+
AC_MSG_CHECKING(for nvcc)
|
66
|
+
saved_cc="$CC"
|
67
|
+
saved_cflags="$CFLAGS"
|
68
|
+
saved_cxxflags="$CXXFLAGS"
|
69
|
+
CC=nvcc
|
70
|
+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
71
|
+
void
|
72
|
+
f(void)
|
73
|
+
{
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
]])],
|
77
|
+
[have_nvcc=yes],
|
78
|
+
[have_nvcc=no],
|
79
|
+
[have_nvcc=undefined])
|
80
|
+
CC="$saved_cc"
|
81
|
+
CFLAGS="$saved_cflags"
|
82
|
+
CXXFLAGS="$saved_cxxflags"
|
83
|
+
AC_MSG_RESULT($have_nvcc)
|
84
|
+
|
85
|
+
CUDA_CXX=
|
86
|
+
CONFIGURE_CUDA_CXXFLAGS=
|
87
|
+
if test "$have_nvcc" = yes; then
|
88
|
+
CUDA_CXX="nvcc"
|
89
|
+
CONFIGURE_CUDA_CXXFLAGS="-std=c++11"
|
90
|
+
AC_DEFINE(HAVE_CUDA, 1, [Define to 1 if you have the nvcc cuda compiler.])
|
91
|
+
fi
|
92
|
+
AC_SUBST(CUDA_CXX)
|
93
|
+
AC_SUBST(CONFIGURE_CUDA_CXXFLAGS)
|
94
|
+
|
61
95
|
# Add an explicit include directory.
|
62
96
|
AC_MSG_CHECKING(for --with-includes)
|
63
97
|
AC_ARG_WITH(includes,
|
@@ -116,20 +150,20 @@ AC_SUBST(NDT_INSTALL_DOCS)
|
|
116
150
|
|
117
151
|
# Compiler dependent settings:
|
118
152
|
XND_WARN=
|
119
|
-
XND_OPT="-O2"
|
153
|
+
XND_OPT="-O2 -g"
|
120
154
|
case $CC in
|
121
155
|
*gcc*)
|
122
156
|
XND_WARN="-Wall -Wextra -std=c11 -pedantic"
|
123
|
-
XND_OPT="-O2"
|
157
|
+
XND_OPT="-O2 -g"
|
124
158
|
;;
|
125
159
|
*icc*)
|
126
160
|
AR=xiar
|
127
161
|
XND_WARN="-Wall"
|
128
|
-
XND_OPT="-O2"
|
162
|
+
XND_OPT="-O2 -g"
|
129
163
|
;;
|
130
164
|
*clang*)
|
131
165
|
XND_WARN="-Wall -Wextra -std=c11 -pedantic"
|
132
|
-
XND_OPT="-O2"
|
166
|
+
XND_OPT="-O2 -g"
|
133
167
|
;;
|
134
168
|
esac
|
135
169
|
|
@@ -137,7 +171,7 @@ esac
|
|
137
171
|
|
138
172
|
# Substitute variables and generate output:
|
139
173
|
if test -z "$LD"; then
|
140
|
-
LD="$
|
174
|
+
LD="$CXX"
|
141
175
|
fi
|
142
176
|
AC_SUBST(LD)
|
143
177
|
AC_SUBST(AR)
|
@@ -151,6 +185,12 @@ else
|
|
151
185
|
CONFIGURE_CFLAGS="$XND_INCLUDE $XND_WARN $XND_CONFIG $XND_OPT $CFLAGS"
|
152
186
|
fi
|
153
187
|
|
188
|
+
if test -z "$CXXFLAGS"; then
|
189
|
+
CONFIGURE_CXXFLAGS="$XND_INCLUDE -Wall -Wextra -O2 -g"
|
190
|
+
else
|
191
|
+
CONFIGURE_CXXFLAGS="$XND_INCLUDE -Wall -Wextra -O2 -g $CXXFLAGS"
|
192
|
+
fi
|
193
|
+
|
154
194
|
if test -z "$LDFLAGS"; then
|
155
195
|
CONFIGURE_LDFLAGS="$XND_LINK $CONFIGURE_LDFLAGS"
|
156
196
|
else
|
@@ -158,6 +198,7 @@ else
|
|
158
198
|
fi
|
159
199
|
|
160
200
|
AC_SUBST(CONFIGURE_CFLAGS)
|
201
|
+
AC_SUBST(CONFIGURE_CXXFLAGS)
|
161
202
|
AC_SUBST(CONFIGURE_LDFLAGS)
|
162
203
|
|
163
204
|
AC_OUTPUT
|
@@ -21,10 +21,12 @@ Operations like indexing and slicing return zero-copy typed views on the data.
|
|
21
21
|
Importing PEP-3118 buffers is supported.
|
22
22
|
|
23
23
|
|
24
|
+
|
24
25
|
.. toctree::
|
25
26
|
:maxdepth: 1
|
26
27
|
|
27
|
-
|
28
|
+
xnd.rst
|
29
|
+
array.rst
|
28
30
|
align-pack.rst
|
29
31
|
buffer-protocol.rst
|
30
32
|
quickstart.rst
|
@@ -233,21 +233,6 @@ Here, type inference would deduce :c:macro:`int64`, so :c:macro:`uint8` needs
|
|
233
233
|
to be passed explicitly.
|
234
234
|
|
235
235
|
|
236
|
-
Performance
|
237
|
-
~~~~~~~~~~~
|
238
|
-
|
239
|
-
For large arrays, explicit types are significantly faster. Type inference
|
240
|
-
supports arbitrary nesting depth, is complex and still implemented in pure
|
241
|
-
Python. Compare:
|
242
|
-
|
243
|
-
.. doctest::
|
244
|
-
|
245
|
-
>>> lst = [1] * 1000000
|
246
|
-
>>> x = xnd(lst) # inference
|
247
|
-
>>>
|
248
|
-
>>> x = xnd(lst, type='1000000 * int64') # explicit
|
249
|
-
|
250
|
-
|
251
236
|
All supported types
|
252
237
|
-------------------
|
253
238
|
|
@@ -666,9 +651,9 @@ As a short example, here is a tuple that contains all primitive types:
|
|
666
651
|
... (bool,
|
667
652
|
... int8, int16, int32, int64,
|
668
653
|
... uint8, uint16, uint32, uint64,
|
669
|
-
... float16, float32, float64,
|
670
|
-
... complex32, complex64, complex128)
|
654
|
+
... bfloat16, float16, float32, float64,
|
655
|
+
... bcomplex32, complex32, complex64, complex128)
|
671
656
|
... """
|
672
657
|
>>> x = xnd.empty(s)
|
673
658
|
>>> x.value
|
674
|
-
(False, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0j, 0j, 0j)
|
659
|
+
(False, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0j, 0j, 0j, 0j)
|
@@ -0,0 +1,142 @@
|
|
1
|
+
|
2
|
+
# ==============================================================================
|
3
|
+
# Unix Makefile for libxnd
|
4
|
+
# ==============================================================================
|
5
|
+
|
6
|
+
|
7
|
+
LIBSTATIC = libxnd.a
|
8
|
+
LIBNAME = libxnd.so
|
9
|
+
LIBSONAME = libxnd.so.0
|
10
|
+
LIBSHARED = libxnd.so.0.2.0dev3
|
11
|
+
|
12
|
+
CC = gcc
|
13
|
+
LD = g++
|
14
|
+
AR = ar
|
15
|
+
RANLIB = ranlib
|
16
|
+
CUDA_CXX =
|
17
|
+
|
18
|
+
XND_INCLUDES = /home/sameer/.rvm/gems/ruby-2.4.1/gems/ndtypes-0.2.0dev6/ext/ruby_ndtypes/include
|
19
|
+
|
20
|
+
CONFIGURE_CFLAGS = -Wall -Wextra -std=c11 -pedantic -O2 -g
|
21
|
+
XND_CFLAGS = $(strip -I.. -I$(XND_INCLUDES) $(CONFIGURE_CFLAGS) $(CFLAGS))
|
22
|
+
XND_CFLAGS_SHARED = $(XND_CFLAGS) -fPIC
|
23
|
+
|
24
|
+
CONFIGURE_CXXFLAGS = -Wall -Wextra -O2 -g
|
25
|
+
XND_CXXFLAGS = $(strip -I.. -I$(XND_INCLUDES) $(CONFIGURE_CXXFLAGS) $(CXXFLAGS))
|
26
|
+
XND_CXXFLAGS_SHARED = $(XND_CXXFLAGS) -fPIC
|
27
|
+
|
28
|
+
CONFIGURE_LDFLAGS = -shared -Wl,-soname,libxnd.so.0
|
29
|
+
XND_LDFLAGS = $(strip $(CONFIGURE_LDFLAGS) $(LDFLAGS))
|
30
|
+
|
31
|
+
CONFIGURE_CUDA_CXXFLAGS =
|
32
|
+
GM_CUDA_CXXFLAGS = $(strip $(CONFIGURE_CUDA_CXXFLAGS) $(CUDA_CXXFLAGS))
|
33
|
+
|
34
|
+
|
35
|
+
default: $(LIBSTATIC) $(LIBSHARED)
|
36
|
+
|
37
|
+
|
38
|
+
OBJS = bitmaps.o bounds.o copy.o equal.o shape.o split.o xnd.o
|
39
|
+
|
40
|
+
SHARED_OBJS = .objs/bitmaps.o .objs/bounds.o .objs/copy.o .objs/equal.o .objs/shape.o .objs/split.o .objs/xnd.o
|
41
|
+
|
42
|
+
ifdef CUDA_CXX
|
43
|
+
OBJS += cuda_memory.o
|
44
|
+
SHARED_OBJS += .objs/cuda_memory.o
|
45
|
+
endif
|
46
|
+
|
47
|
+
|
48
|
+
$(LIBSTATIC): Makefile $(OBJS)
|
49
|
+
$(AR) rc $(LIBSTATIC) $(OBJS)
|
50
|
+
$(RANLIB) $(LIBSTATIC)
|
51
|
+
|
52
|
+
$(LIBSHARED): Makefile $(SHARED_OBJS)
|
53
|
+
$(LD) $(XND_LDFLAGS) -o $(LIBSHARED) $(SHARED_OBJS)
|
54
|
+
ln -sf $(LIBSHARED) $(LIBNAME)
|
55
|
+
ln -sf $(LIBSHARED) $(LIBSONAME)
|
56
|
+
|
57
|
+
|
58
|
+
bitmaps.o:\
|
59
|
+
Makefile bitmaps.c xnd.h
|
60
|
+
$(CC) $(XND_CFLAGS) -c bitmaps.c
|
61
|
+
|
62
|
+
.objs/bitmaps.o:\
|
63
|
+
Makefile bitmaps.c xnd.h
|
64
|
+
$(CC) $(XND_CFLAGS_SHARED) -c bitmaps.c -o .objs/bitmaps.o
|
65
|
+
|
66
|
+
bounds.o:\
|
67
|
+
Makefile bounds.c xnd.h
|
68
|
+
$(CC) $(XND_CFLAGS) -c bounds.c
|
69
|
+
|
70
|
+
.objs/bounds.o:\
|
71
|
+
Makefile bounds.c xnd.h
|
72
|
+
$(CC) $(XND_CFLAGS_SHARED) -c bounds.c -o .objs/bounds.o
|
73
|
+
|
74
|
+
copy.o:\
|
75
|
+
Makefile copy.c xnd.h
|
76
|
+
$(CC) $(XND_CFLAGS) -c copy.c
|
77
|
+
|
78
|
+
.objs/copy.o:\
|
79
|
+
Makefile copy.c xnd.h
|
80
|
+
$(CC) $(XND_CFLAGS_SHARED) -c copy.c -o .objs/copy.o
|
81
|
+
|
82
|
+
equal.o:\
|
83
|
+
Makefile equal.c xnd.h
|
84
|
+
$(CC) $(XND_CFLAGS) -c equal.c
|
85
|
+
|
86
|
+
.objs/equal.o:\
|
87
|
+
Makefile equal.c xnd.h
|
88
|
+
$(CC) $(XND_CFLAGS_SHARED) -c equal.c -o .objs/equal.o
|
89
|
+
|
90
|
+
shape.o:\
|
91
|
+
Makefile shape.c overflow.h xnd.h
|
92
|
+
$(CC) $(XND_CFLAGS) -c shape.c
|
93
|
+
|
94
|
+
.objs/shape.o:\
|
95
|
+
Makefile shape.c overflow.h xnd.h
|
96
|
+
$(CC) $(XND_CFLAGS_SHARED) -c shape.c -o .objs/shape.o
|
97
|
+
|
98
|
+
split.o:\
|
99
|
+
Makefile split.c overflow.h xnd.h
|
100
|
+
$(CC) $(XND_CFLAGS) -c split.c
|
101
|
+
|
102
|
+
.objs/split.o:\
|
103
|
+
Makefile split.c overflow.h xnd.h
|
104
|
+
$(CC) $(XND_CFLAGS_SHARED) -c split.c -o .objs/split.o
|
105
|
+
|
106
|
+
xnd.o:\
|
107
|
+
Makefile xnd.c xnd.h
|
108
|
+
$(CC) $(XND_CFLAGS) -c xnd.c
|
109
|
+
|
110
|
+
.objs/xnd.o:\
|
111
|
+
Makefile xnd.c xnd.h
|
112
|
+
$(CC) $(XND_CFLAGS_SHARED) -c xnd.c -o .objs/xnd.o
|
113
|
+
|
114
|
+
|
115
|
+
# Cuda
|
116
|
+
cuda_memory.o:\
|
117
|
+
Makefile cuda/cuda_memory.cu cuda/cuda_memory.h
|
118
|
+
$(CUDA_CXX) --compiler-options "$(XND_CXXFLAGS)" $(GM_CUDA_CXXFLAGS) -c cuda/cuda_memory.cu
|
119
|
+
|
120
|
+
.objs/cuda_memory.o:\
|
121
|
+
Makefile cuda/cuda_memory.cu cuda/cuda_memory.h
|
122
|
+
$(CUDA_CXX) --compiler-options "$(XND_CXXFLAGS_SHARED)" $(GM_CUDA_CXXFLAGS) -c cuda/cuda_memory.cu -o .objs/cuda_memory.o
|
123
|
+
|
124
|
+
|
125
|
+
# Coverage
|
126
|
+
coverage:\
|
127
|
+
Makefile clean runtest
|
128
|
+
./tests/runtest
|
129
|
+
for file in *.c; do gcov -l "$$file" > /dev/null 2>&1; done
|
130
|
+
|
131
|
+
FORCE:
|
132
|
+
|
133
|
+
clean: FORCE
|
134
|
+
rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
|
135
|
+
rm -f $(LIBSTATIC) $(LIBSHARED) $(LIBSONAME) $(LIBNAME)
|
136
|
+
cd .objs && rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
|
137
|
+
|
138
|
+
distclean: clean
|
139
|
+
rm -f Makefile
|
140
|
+
|
141
|
+
|
142
|
+
|
@@ -13,23 +13,36 @@ CC = @CC@
|
|
13
13
|
LD = @LD@
|
14
14
|
AR = @AR@
|
15
15
|
RANLIB = @RANLIB@
|
16
|
+
CUDA_CXX = @CUDA_CXX@
|
16
17
|
|
17
18
|
XND_INCLUDES = @CONFIGURE_INCLUDES@
|
18
19
|
|
19
20
|
CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@
|
20
|
-
XND_CFLAGS = $(strip -I$(XND_INCLUDES) $(CONFIGURE_CFLAGS) $(CFLAGS))
|
21
|
+
XND_CFLAGS = $(strip -I.. -I$(XND_INCLUDES) $(CONFIGURE_CFLAGS) $(CFLAGS))
|
21
22
|
XND_CFLAGS_SHARED = $(XND_CFLAGS) -fPIC
|
22
23
|
|
24
|
+
CONFIGURE_CXXFLAGS = @CONFIGURE_CXXFLAGS@
|
25
|
+
XND_CXXFLAGS = $(strip -I.. -I$(XND_INCLUDES) $(CONFIGURE_CXXFLAGS) $(CXXFLAGS))
|
26
|
+
XND_CXXFLAGS_SHARED = $(XND_CXXFLAGS) -fPIC
|
27
|
+
|
23
28
|
CONFIGURE_LDFLAGS = @CONFIGURE_LDFLAGS@
|
24
29
|
XND_LDFLAGS = $(strip $(CONFIGURE_LDFLAGS) $(LDFLAGS))
|
25
30
|
|
31
|
+
CONFIGURE_CUDA_CXXFLAGS = @CONFIGURE_CUDA_CXXFLAGS@
|
32
|
+
GM_CUDA_CXXFLAGS = $(strip $(CONFIGURE_CUDA_CXXFLAGS) $(CUDA_CXXFLAGS))
|
33
|
+
|
26
34
|
|
27
35
|
default: $(LIBSTATIC) $(LIBSHARED)
|
28
36
|
|
29
37
|
|
30
|
-
OBJS = bitmaps.o copy.o equal.o split.o xnd.o
|
38
|
+
OBJS = bitmaps.o bounds.o copy.o equal.o shape.o split.o xnd.o
|
39
|
+
|
40
|
+
SHARED_OBJS = .objs/bitmaps.o .objs/bounds.o .objs/copy.o .objs/equal.o .objs/shape.o .objs/split.o .objs/xnd.o
|
31
41
|
|
32
|
-
|
42
|
+
ifdef CUDA_CXX
|
43
|
+
OBJS += cuda_memory.o
|
44
|
+
SHARED_OBJS += .objs/cuda_memory.o
|
45
|
+
endif
|
33
46
|
|
34
47
|
|
35
48
|
$(LIBSTATIC): Makefile $(OBJS)
|
@@ -41,6 +54,7 @@ $(LIBSHARED): Makefile $(SHARED_OBJS)
|
|
41
54
|
ln -sf $(LIBSHARED) $(LIBNAME)
|
42
55
|
ln -sf $(LIBSHARED) $(LIBSONAME)
|
43
56
|
|
57
|
+
|
44
58
|
bitmaps.o:\
|
45
59
|
Makefile bitmaps.c xnd.h
|
46
60
|
$(CC) $(XND_CFLAGS) -c bitmaps.c
|
@@ -49,6 +63,14 @@ Makefile bitmaps.c xnd.h
|
|
49
63
|
Makefile bitmaps.c xnd.h
|
50
64
|
$(CC) $(XND_CFLAGS_SHARED) -c bitmaps.c -o .objs/bitmaps.o
|
51
65
|
|
66
|
+
bounds.o:\
|
67
|
+
Makefile bounds.c xnd.h
|
68
|
+
$(CC) $(XND_CFLAGS) -c bounds.c
|
69
|
+
|
70
|
+
.objs/bounds.o:\
|
71
|
+
Makefile bounds.c xnd.h
|
72
|
+
$(CC) $(XND_CFLAGS_SHARED) -c bounds.c -o .objs/bounds.o
|
73
|
+
|
52
74
|
copy.o:\
|
53
75
|
Makefile copy.c xnd.h
|
54
76
|
$(CC) $(XND_CFLAGS) -c copy.c
|
@@ -65,6 +87,14 @@ Makefile equal.c xnd.h
|
|
65
87
|
Makefile equal.c xnd.h
|
66
88
|
$(CC) $(XND_CFLAGS_SHARED) -c equal.c -o .objs/equal.o
|
67
89
|
|
90
|
+
shape.o:\
|
91
|
+
Makefile shape.c overflow.h xnd.h
|
92
|
+
$(CC) $(XND_CFLAGS) -c shape.c
|
93
|
+
|
94
|
+
.objs/shape.o:\
|
95
|
+
Makefile shape.c overflow.h xnd.h
|
96
|
+
$(CC) $(XND_CFLAGS_SHARED) -c shape.c -o .objs/shape.o
|
97
|
+
|
68
98
|
split.o:\
|
69
99
|
Makefile split.c overflow.h xnd.h
|
70
100
|
$(CC) $(XND_CFLAGS) -c split.c
|
@@ -82,6 +112,16 @@ Makefile xnd.c xnd.h
|
|
82
112
|
$(CC) $(XND_CFLAGS_SHARED) -c xnd.c -o .objs/xnd.o
|
83
113
|
|
84
114
|
|
115
|
+
# Cuda
|
116
|
+
cuda_memory.o:\
|
117
|
+
Makefile cuda/cuda_memory.cu cuda/cuda_memory.h
|
118
|
+
$(CUDA_CXX) --compiler-options "$(XND_CXXFLAGS)" $(GM_CUDA_CXXFLAGS) -c cuda/cuda_memory.cu
|
119
|
+
|
120
|
+
.objs/cuda_memory.o:\
|
121
|
+
Makefile cuda/cuda_memory.cu cuda/cuda_memory.h
|
122
|
+
$(CUDA_CXX) --compiler-options "$(XND_CXXFLAGS_SHARED)" $(GM_CUDA_CXXFLAGS) -c cuda/cuda_memory.cu -o .objs/cuda_memory.o
|
123
|
+
|
124
|
+
|
85
125
|
# Coverage
|
86
126
|
coverage:\
|
87
127
|
Makefile clean runtest
|
@@ -19,7 +19,7 @@ LIBNDTYPESDIR = ..\ndtypes\libndtypes
|
|
19
19
|
OPT = /MT /Ox /GS /EHsc
|
20
20
|
OPT_SHARED = /DXND_EXPORT /MD /Ox /GS /EHsc /Fo.objs^\
|
21
21
|
|
22
|
-
COMMON_CFLAGS = /nologo /W4 /wd4200 /wd4201 /wd4204
|
22
|
+
COMMON_CFLAGS = -I.. /nologo /W4 /wd4200 /wd4201 /wd4204
|
23
23
|
CFLAGS = $(COMMON_CFLAGS) $(OPT)
|
24
24
|
CFLAGS_SHARED = $(COMMON_CFLAGS) $(OPT_SHARED)
|
25
25
|
|
@@ -31,9 +31,9 @@ default: $(LIBSTATIC) $(LIBSHARED)
|
|
31
31
|
copy /y $(LIBSHARED) ..\python\xnd
|
32
32
|
|
33
33
|
|
34
|
-
OBJS = bitmaps.obj copy.obj equal.obj split.obj xnd.obj
|
34
|
+
OBJS = bitmaps.obj bounds.obj copy.obj equal.obj shape.obj split.obj xnd.obj
|
35
35
|
|
36
|
-
SHARED_OBJS = .objs\bitmaps.obj .objs\copy.obj .objs\equal.obj .objs\split.obj .objs\xnd.obj
|
36
|
+
SHARED_OBJS = .objs\bitmaps.obj .objs\bounds.obj .objs\copy.obj .objs\equal.obj .objs\shape.obj .objs\split.obj .objs\xnd.obj
|
37
37
|
|
38
38
|
|
39
39
|
$(LIBSTATIC):\
|
@@ -55,6 +55,14 @@ Makefile bitmaps.c xnd.h
|
|
55
55
|
Makefile bitmaps.c xnd.h
|
56
56
|
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS_SHARED) -c bitmaps.c
|
57
57
|
|
58
|
+
bounds.obj:\
|
59
|
+
Makefile bounds.c xnd.h
|
60
|
+
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS) -c bounds.c
|
61
|
+
|
62
|
+
.objs\bounds.obj:\
|
63
|
+
Makefile bounds.c xnd.h
|
64
|
+
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS_SHARED) -c bounds.c
|
65
|
+
|
58
66
|
copy.obj:\
|
59
67
|
Makefile copy.c xnd.h
|
60
68
|
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS) -c copy.c
|
@@ -71,6 +79,14 @@ Makefile equal.c xnd.h
|
|
71
79
|
Makefile equal.c xnd.h
|
72
80
|
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS_SHARED) -c equal.c
|
73
81
|
|
82
|
+
shape.obj:\
|
83
|
+
Makefile shape.c overflow.h xnd.h
|
84
|
+
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS) -c shape.c
|
85
|
+
|
86
|
+
.objs\shape.obj:\
|
87
|
+
Makefile shape.c overflow.h xnd.h
|
88
|
+
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS_SHARED) -c shape.c
|
89
|
+
|
74
90
|
split.obj:\
|
75
91
|
Makefile split.c overflow.h xnd.h
|
76
92
|
$(CC) "-I$(LIBNDTYPESINCLUDE)" $(CFLAGS) -c split.c
|
@@ -86,7 +86,13 @@ bitmap_init(xnd_bitmap_t *b, const ndt_t *t, int64_t nitems, ndt_context_t *ctx)
|
|
86
86
|
assert(b->size == 0);
|
87
87
|
assert(b->next == NULL);
|
88
88
|
|
89
|
-
if (
|
89
|
+
if (ndt_is_optional(t)) {
|
90
|
+
if (t->ndim > 0) {
|
91
|
+
ndt_err_format(ctx, NDT_NotImplementedError,
|
92
|
+
"optional dimensions are not implemented");
|
93
|
+
return -1;
|
94
|
+
}
|
95
|
+
|
90
96
|
b->data = bits_new(nitems, ctx);
|
91
97
|
if (b->data == NULL) {
|
92
98
|
return -1;
|
@@ -108,8 +114,8 @@ bitmap_init(xnd_bitmap_t *b, const ndt_t *t, int64_t nitems, ndt_context_t *ctx)
|
|
108
114
|
n = nitems;
|
109
115
|
|
110
116
|
if (t->ndim == 1) {
|
111
|
-
int32_t noffsets = t->Concrete.VarDim.
|
112
|
-
n = t->Concrete.VarDim.offsets[noffsets-1];
|
117
|
+
int32_t noffsets = t->Concrete.VarDim.offsets->n;
|
118
|
+
n = t->Concrete.VarDim.offsets->v[noffsets-1];
|
113
119
|
}
|
114
120
|
|
115
121
|
return bitmap_init(b, t->VarDim.type, n, ctx);
|
@@ -163,6 +169,30 @@ bitmap_init(xnd_bitmap_t *b, const ndt_t *t, int64_t nitems, ndt_context_t *ctx)
|
|
163
169
|
return 0;
|
164
170
|
}
|
165
171
|
|
172
|
+
case Union: {
|
173
|
+
shape = t->Union.ntags;
|
174
|
+
|
175
|
+
n = nitems * shape;
|
176
|
+
b->next = bitmap_array_new(n, ctx);
|
177
|
+
if (b->next == NULL) {
|
178
|
+
xnd_bitmap_clear(b);
|
179
|
+
return -1;
|
180
|
+
}
|
181
|
+
b->size = n;
|
182
|
+
|
183
|
+
for (i = 0; i < nitems; i++) {
|
184
|
+
for (k = 0; k < shape; k++) {
|
185
|
+
next = b->next + i*shape + k;
|
186
|
+
if (bitmap_init(next, t->Union.types[k], 1, ctx) < 0) {
|
187
|
+
xnd_bitmap_clear(b);
|
188
|
+
return -1;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
return 0;
|
194
|
+
}
|
195
|
+
|
166
196
|
case Ref: {
|
167
197
|
b->next = bitmap_array_new(nitems, ctx);
|
168
198
|
if (b->next == NULL) {
|
@@ -220,6 +250,12 @@ bitmap_init(xnd_bitmap_t *b, const ndt_t *t, int64_t nitems, ndt_context_t *ctx)
|
|
220
250
|
return 0;
|
221
251
|
}
|
222
252
|
|
253
|
+
case Array: {
|
254
|
+
ndt_err_format(ctx, NDT_NotImplementedError,
|
255
|
+
"the element type of flexible arrays cannot be optional");
|
256
|
+
return -1;
|
257
|
+
}
|
258
|
+
|
223
259
|
default:
|
224
260
|
return 0;
|
225
261
|
}
|
@@ -272,6 +308,9 @@ xnd_bitmap_next(const xnd_t *x, int64_t i, ndt_context_t *ctx)
|
|
272
308
|
case Record:
|
273
309
|
shape = t->Record.shape;
|
274
310
|
break;
|
311
|
+
case Union:
|
312
|
+
shape = t->Union.ntags;
|
313
|
+
break;
|
275
314
|
case Ref: case Constr: case Nominal:
|
276
315
|
shape = 1;
|
277
316
|
break;
|