-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_wide.py
55 lines (48 loc) · 1.11 KB
/
build_wide.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import cffi
import os.path
source_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'wide_product',
)
ffibuilder = cffi.FFI()
ffibuilder.set_source(
'wide_product._wide',
r"""
#include "wide.c"
""",
extra_compile_args=[
'-Werror',
'-fno-unwind-tables',
'-fomit-frame-pointer',
],
include_dirs=[source_path],
)
ffibuilder.cdef(
r"""
typedef uint32_t wp_index;
typedef double wp_number;
wp_index wide_product(
wp_index height,
const wp_number* a_data,
const wp_index* a_indices,
const wp_index* a_indptr,
wp_index a_width,
wp_index a_nnz,
const wp_number* b_data,
const wp_index* b_indices,
const wp_index* b_indptr,
wp_index b_width,
wp_index b_nnz,
wp_number* out_data,
wp_index* out_indices,
wp_index* out_indptr
);
wp_index wide_product_max_nnz(
const wp_index* a_indptr,
const wp_index* b_indptr,
wp_index height
);
""",
)
if __name__ == '__main__':
ffibuilder.compile(verbose=True)