Skip to content

Commit 3eac1c6

Browse files
committed
Update to 6.2.0.beta3
1 parent 3f29283 commit 3eac1c6

File tree

7 files changed

+104
-930
lines changed

7 files changed

+104
-930
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
os: ["ubuntu-latest"]
1919
python-version: ["3.8", "3.9", "3.10"]
2020
source: ["source"] # ["conda-forge"]
21-
graphblas-version: ["6.2.0.beta2"]
21+
graphblas-version: ["6.2.0.beta3"]
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v2

suitesparse_graphblas/build.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88

99
ffibuilder = FFI()
1010

11-
if is_win:
12-
source_filename = "source_no_complex.c"
13-
else:
14-
source_filename = "source.c"
15-
16-
with open(os.path.join(thisdir, source_filename)) as f:
11+
with open(os.path.join(thisdir, "source.c")) as f:
1712
source = f.read()
1813

1914
include_dirs = [os.path.join(sys.prefix, "include")]

suitesparse_graphblas/create_headers.py

Lines changed: 17 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def get_groups(ast):
360360
seen = set()
361361
groups = {}
362362
vals = {x for x in lines if "extern GrB_Info GxB" in x} - seen
363+
vals |= {x for x in lines if "extern " in x and "GxB_Iterator" in x and "GB" not in x} - seen
363364
seen.update(vals)
364365
groups["GxB methods"] = sorted(vals, key=sort_key)
365366

@@ -368,6 +369,7 @@ def get_groups(ast):
368369
groups["GrB methods"] = sorted(vals, key=sort_key)
369370

370371
vals = {x for x in lines if "extern GrB_Info GB" in x} - seen
372+
vals |= {x for x in lines if "extern " in x and "GxB_Iterator" in x and "GB" in x} - seen
371373
seen.update(vals)
372374
groups["GB methods"] = sorted(vals, key=sort_key)
373375

@@ -427,23 +429,6 @@ def get_groups(ast):
427429
seen.update(vals)
428430
groups["GxB typedef funcs"] = sorted(vals, key=sort_key)
429431

430-
vals = []
431-
next_i = -1
432-
for i, line in enumerate(lines):
433-
if i < next_i or line in seen:
434-
continue
435-
if "inline static" in line and ("GB" in line or "GrB" in line or "GxB" in line):
436-
val = [line]
437-
i += 1
438-
while lines[i] != "}":
439-
val.append(lines[i])
440-
i += 1
441-
val.append(lines[i])
442-
next_i = i + 1
443-
seen.update(val)
444-
vals.append("\n".join(val))
445-
groups["static inline"] = vals
446-
447432
vals = {x for x in lines if "typedef" in x and "GrB" in x} - seen
448433
assert not vals, ", ".join(sorted(vals))
449434
groups["not seen"] = sorted(set(lines) - seen, key=sort_key)
@@ -597,21 +582,10 @@ def visit_Decl(self, node):
597582
if isinstance(node.type, c_ast.FuncDecl) and node.storage == ["extern"]:
598583
self.functions.append(node)
599584

600-
class FuncDefVisitorStaticInline(c_ast.NodeVisitor):
601-
def __init__(self):
602-
self.functions = []
603-
604-
def visit_FuncDef(self, node):
605-
decl = node.decl
606-
if (
607-
isinstance(decl.type, c_ast.FuncDecl)
608-
and decl.storage == ["static"]
609-
and decl.funcspec == ["inline"]
610-
):
611-
self.functions.append(node)
612-
613585
def handle_function_node(node):
614-
if generator.visit(node.type.type) != "GrB_Info":
586+
if generator.visit(node.type.type) != "GrB_Info" and "GxB_Iterator" not in generator.visit(
587+
node
588+
):
615589
raise ValueError(generator.visit(node))
616590
if node.name in DEPRECATED:
617591
return
@@ -625,6 +599,8 @@ def handle_function_node(node):
625599
group = "vector"
626600
elif "GxB_Scalar" in text or "GrB_Scalar" in text:
627601
group = "scalar"
602+
elif "GxB_Iterator" in text:
603+
group = "iterator"
628604
else:
629605
group = node.name.split("_", 2)[1]
630606
group = {
@@ -665,52 +641,26 @@ def handle_function_node(node):
665641
grb_nodes = [node for node in visitor.functions if node.name.startswith("GrB_")]
666642
gxb_nodes = [node for node in visitor.functions if node.name.startswith("GxB_")]
667643
gb_nodes = [node for node in visitor.functions if node.name.startswith("GB_")]
668-
assert len(grb_nodes) == len(groups["GrB methods"])
669-
assert len(gxb_nodes) == len(groups["GxB methods"])
670-
assert len(gb_nodes) == len(groups["GB methods"])
671-
672-
visitor = FuncDefVisitorStaticInline()
673-
visitor.visit(ast)
674-
static_inline_nodes = visitor.functions
675-
assert len(static_inline_nodes) == len(groups["static inline"])
676-
for node in static_inline_nodes:
677-
# Sanity check
678-
text = generator.visit(node).strip()
679-
assert text in groups["static inline"]
680-
681-
def handle_static_inline(node):
682-
decl = node.decl
683-
if decl.name in DEPRECATED:
684-
return
685-
# Append "_" to the name that we expose to Python
686-
decl.type.type.declname += "_"
687-
decl.storage = ["extern"]
688-
decl.funcspec = []
689-
text = generator.visit(node).strip()
690-
decl_text = generator.visit(decl).strip()
691-
if skip_complex and has_complex(text):
692-
return
693-
return {
694-
"name": decl.name,
695-
"group": "static inline",
696-
"node": node,
697-
"text": text + "\n",
698-
"decl_text": decl_text + ";",
699-
}
644+
assert len(grb_nodes) == len(groups["GrB methods"]), (
645+
len(grb_nodes),
646+
len(groups["GrB methods"]),
647+
)
648+
assert len(gxb_nodes) == len(groups["GxB methods"]), (
649+
len(gxb_nodes),
650+
len(groups["GxB methods"]),
651+
)
652+
assert len(gb_nodes) == len(groups["GB methods"]), (len(gb_nodes), len(groups["GB methods"]))
700653

701654
grb_funcs = (handle_function_node(node) for node in grb_nodes)
702655
gxb_funcs = (handle_function_node(node) for node in gxb_nodes)
703656
gb_funcs = (handle_function_node(node) for node in gb_nodes)
704-
si_funcs = (handle_static_inline(node) for node in static_inline_nodes)
705657
grb_funcs = [x for x in grb_funcs if x is not None]
706658
gxb_funcs = [x for x in gxb_funcs if x is not None]
707659
gb_funcs = [x for x in gb_funcs if x is not None]
708-
si_funcs = [x for x in si_funcs if x is not None]
709660

710661
rv["GrB methods"] = sorted(grb_funcs, key=lambda x: sort_key(x["text"]))
711662
rv["GxB methods"] = sorted(gxb_funcs, key=lambda x: sort_key(x["text"]))
712663
rv["GB methods"] = sorted(gb_funcs, key=lambda x: sort_key(x["text"]))
713-
rv["static inline"] = sorted(si_funcs, key=lambda x: sort_key(x["text"]))
714664
for key in groups.keys() - rv.keys():
715665
rv[key] = groups[key]
716666
return rv
@@ -797,13 +747,6 @@ def handle_funcs(group):
797747
text.append("****************/")
798748
text.extend(handle_funcs(groups["GxB methods"]))
799749

800-
# Declare wrapper functions with '_' appended to the name
801-
text.append("")
802-
text.append("/**************************")
803-
text.append("* static inline functions *")
804-
text.append("**************************/")
805-
text.extend(sorted((info["decl_text"] for info in groups["static inline"]), key=sort_key))
806-
807750
text.append("")
808751
text.append("/* int DEFINES */")
809752
for item in sorted(defines, key=sort_key):
@@ -825,9 +768,6 @@ def create_source_text(groups, *, char_defines=None):
825768
]
826769
for item in sorted(char_defines, key=sort_key):
827770
text.append(f"char *{item}_STR = {item};")
828-
text.append("")
829-
for node in groups["static inline"]:
830-
text.append(node["text"])
831771
return text
832772

833773

@@ -855,7 +795,6 @@ def main():
855795
final_h = os.path.join(thisdir, "suitesparse_graphblas.h")
856796
final_no_complex_h = os.path.join(thisdir, "suitesparse_graphblas_no_complex.h")
857797
source_c = os.path.join(thisdir, "source.c")
858-
source_no_complex_c = os.path.join(thisdir, "source_no_complex.c")
859798

860799
# Copy original file
861800
print(f"Step 1: copy {args.graphblas} to {graphblas_h}")
@@ -894,14 +833,8 @@ def main():
894833
with open(source_c, "w") as f:
895834
f.write("\n".join(text))
896835

897-
# Create source (no complex)
898-
print(f"Step 6: create {source_no_complex_c}")
899-
text = create_source_text(groups_no_complex)
900-
with open(source_no_complex_c, "w") as f:
901-
f.write("\n".join(text))
902-
903836
# Check defines
904-
print("Step 7: check #define definitions")
837+
print("Step 6: check #define definitions")
905838
with open(graphblas_h) as f:
906839
text = f.read()
907840
define_lines = re.compile(r".*?#define\s+\w+\s+")

0 commit comments

Comments
 (0)