From 2acdba6fa2ad453e2f36ce09f193bc8cb4eeb7aa Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sat, 8 Aug 2026 21:46:59 -0500 Subject: [PATCH 1/2] Update to SS:GB v10.4.0 (and run pre-commit linting) --- .flake8 | 2 + .pre-commit-config.yaml | 6 +- GB_VERSION.txt | 2 +- suitesparse.sh | 8 +- suitesparse_graphblas/__init__.py | 10 +- suitesparse_graphblas/api/__init__.py | 5 +- suitesparse_graphblas/api/binaryop.py | 26 +- suitesparse_graphblas/api/context.py | 26 +- suitesparse_graphblas/api/descriptor.py | 37 +- suitesparse_graphblas/api/examples/bfs.py | 29 +- suitesparse_graphblas/api/grb_type.py | 26 +- suitesparse_graphblas/api/indexbinaryop.py | 30 +- suitesparse_graphblas/api/indexunaryop.py | 30 +- suitesparse_graphblas/api/iterator.py | 16 +- suitesparse_graphblas/api/matrix.py | 921 +++++++++++------- suitesparse_graphblas/api/monoid.py | 34 +- suitesparse_graphblas/api/scalar.py | 26 +- suitesparse_graphblas/api/selectop.py | 12 +- suitesparse_graphblas/api/semiring.py | 34 +- suitesparse_graphblas/api/unaryop.py | 26 +- suitesparse_graphblas/api/vector.py | 759 +++++++++------ suitesparse_graphblas/create_headers.py | 25 +- suitesparse_graphblas/suitesparse_graphblas.h | 86 +- .../suitesparse_graphblas_no_complex.h | 82 +- 24 files changed, 1478 insertions(+), 780 deletions(-) diff --git a/.flake8 b/.flake8 index efbe9a5..617214e 100644 --- a/.flake8 +++ b/.flake8 @@ -7,3 +7,5 @@ extend-ignore = per-file-ignores = suitesparse_graphblas/io/binary.py:C408, suitesparse_graphblas/tests/test_io.py:E721, +# The api package re-exports its submodules for `from suitesparse_graphblas import api` + suitesparse_graphblas/api/__init__.py:F401, diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a88a72c..6f168de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: - id: autoflake args: [--in-place] - repo: https://github.com/pycqa/isort - rev: 8.0.1 + rev: 9.0.0b2 hooks: - id: isort - repo: https://github.com/asottile/pyupgrade @@ -50,7 +50,7 @@ repos: - id: pyupgrade args: [--py311-plus] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 26.3.1 + rev: 26.5.1 hooks: - id: black - repo: https://github.com/PyCQA/flake8 @@ -89,7 +89,7 @@ repos: - id: python-no-log-warn - id: text-unicode-replacement-char - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.37.0 + rev: 0.37.4 hooks: - id: check-dependabot - id: check-github-workflows diff --git a/GB_VERSION.txt b/GB_VERSION.txt index a936832..816c071 100644 --- a/GB_VERSION.txt +++ b/GB_VERSION.txt @@ -1 +1 @@ -10.3.1 +10.4.0 diff --git a/suitesparse.sh b/suitesparse.sh index 0b47855..ad05bbf 100755 --- a/suitesparse.sh +++ b/suitesparse.sh @@ -3,7 +3,13 @@ set -x # echo on # parse SuiteSparse version from first argument, a git tag that ends in the version (no leading v) -if [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*\.beta[0-9]*).*$ ]]; then +if [[ $1 =~ refs/tags/v?([0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+) ]]; then + # Naming used since v10.4.0-beta.1, e.g. "10.4.0-beta.2". Note that callers + # append the psg patch level (".0"), which is not part of the upstream tag. + echo "Beta version detected (X.Y.Z-beta.N)" + VERSION=${BASH_REMATCH[1]} +elif [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*\.beta[0-9]*).*$ ]]; then + # Older naming, e.g. "8.0.1.beta1" echo "Beta version detected" VERSION=${BASH_REMATCH[1]} elif [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*)\..*$ ]]; then diff --git a/suitesparse_graphblas/__init__.py b/suitesparse_graphblas/__init__.py index e2b650a..895a66f 100644 --- a/suitesparse_graphblas/__init__.py +++ b/suitesparse_graphblas/__init__.py @@ -309,9 +309,13 @@ def __repr__(self): burble = burble() -# Backward-compatible re-exports: functional API moved to suitesparse_graphblas.api -from suitesparse_graphblas.api import iterator, matrix, scalar, vector # noqa: E402,F401 -from suitesparse_graphblas.api.global_options import ( # noqa: E402,F401 +# isort: off +# Backward-compatible re-exports: functional API moved to suitesparse_graphblas.api. +# These must stay at the bottom of the file: the api modules import names defined +# above (`check_status`, `ffi`, `lib`), so letting isort's `float_to_top` hoist them +# to the top would make `import suitesparse_graphblas` a circular import. +from suitesparse_graphblas.api import iterator, matrix, scalar, vector # noqa: E402, F401 +from suitesparse_graphblas.api.global_options import ( # noqa: E402, F401 global_option_get_char, global_option_get_fp64, global_option_get_int32, diff --git a/suitesparse_graphblas/api/__init__.py b/suitesparse_graphblas/api/__init__.py index 15cadfb..3006c1f 100644 --- a/suitesparse_graphblas/api/__init__.py +++ b/suitesparse_graphblas/api/__init__.py @@ -20,6 +20,8 @@ Guide](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Doc/GraphBLAS_UserGuide.pdf) """ + +from suitesparse_graphblas.api import io # noqa: F401 from suitesparse_graphblas.api import ( binaryop, container, @@ -33,9 +35,8 @@ matrix, monoid, scalar, - semiring, selectop, + semiring, unaryop, vector, ) -from suitesparse_graphblas.api import io # noqa: F401 diff --git a/suitesparse_graphblas/api/binaryop.py b/suitesparse_graphblas/api/binaryop.py index 970a541..cc87358 100644 --- a/suitesparse_graphblas/api/binaryop.py +++ b/suitesparse_graphblas/api/binaryop.py @@ -104,10 +104,15 @@ def binaryop_print(op, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_BinaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + op, + lib.GxB_BinaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def binaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): @@ -122,10 +127,15 @@ def binaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_BinaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + op, + lib.GxB_BinaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- diff --git a/suitesparse_graphblas/api/context.py b/suitesparse_graphblas/api/context.py index da6bc49..5549bd5 100644 --- a/suitesparse_graphblas/api/context.py +++ b/suitesparse_graphblas/api/context.py @@ -201,10 +201,15 @@ def context_print(ctx, name="", level=lib.GxB_COMPLETE): True """ - check_status(ctx, lib.GxB_Context_fprint( - ctx[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + ctx, + lib.GxB_Context_fprint( + ctx[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def context_fprint(ctx, f, name="", level=lib.GxB_COMPLETE): @@ -219,7 +224,12 @@ def context_fprint(ctx, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(ctx, lib.GxB_Context_fprint( - ctx[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + ctx, + lib.GxB_Context_fprint( + ctx[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) diff --git a/suitesparse_graphblas/api/descriptor.py b/suitesparse_graphblas/api/descriptor.py index 7fde590..308a071 100644 --- a/suitesparse_graphblas/api/descriptor.py +++ b/suitesparse_graphblas/api/descriptor.py @@ -24,10 +24,15 @@ def descriptor_print(desc, name="", level=lib.GxB_COMPLETE): True """ - check_status(desc, lib.GxB_Descriptor_fprint( - desc, name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + desc, + lib.GxB_Descriptor_fprint( + desc, + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def descriptor_fprint(desc, f, name="", level=lib.GxB_COMPLETE): @@ -41,10 +46,15 @@ def descriptor_fprint(desc, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(desc, lib.GxB_Descriptor_fprint( - desc, name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + desc, + lib.GxB_Descriptor_fprint( + desc, + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- @@ -72,9 +82,14 @@ def descriptor_set_int32(desc, field, value): False """ - check_status(desc, lib.GrB_Descriptor_set_INT32( - desc, ffi.cast("int32_t", value), field, - )) + check_status( + desc, + lib.GrB_Descriptor_set_INT32( + desc, + ffi.cast("int32_t", value), + field, + ), + ) def descriptor_get_size(desc, field): diff --git a/suitesparse_graphblas/api/examples/bfs.py b/suitesparse_graphblas/api/examples/bfs.py index 3ae7b5e..feb122c 100644 --- a/suitesparse_graphblas/api/examples/bfs.py +++ b/suitesparse_graphblas/api/examples/bfs.py @@ -95,29 +95,44 @@ def bfs(A, src, compute_level=True, compute_parent=True): if compute_level: scalar.set_int64(level_scalar, current_level) vector.vector_assign_scalar( - level_vec, level_scalar, lib.GrB_ALL, n, - mask=frontier, desc=lib.GrB_DESC_S, + level_vec, + level_scalar, + lib.GrB_ALL, + n, + mask=frontier, + desc=lib.GrB_DESC_S, ) if compute_parent: # Record parent IDs: parent = frontier vector.vector_assign( - parent_vec, frontier, lib.GrB_ALL, n, - mask=frontier, desc=lib.GrB_DESC_S, + parent_vec, + frontier, + lib.GrB_ALL, + n, + mask=frontier, + desc=lib.GrB_DESC_S, ) # Convert frontier values to their own indices (ROWINDEX). # After this, frontier(i) == i for every stored entry, # so the next vxm propagates node i as the parent ID. vector.vector_apply_indexop( - frontier, lib.GrB_ROWINDEX_INT64, frontier, index_thunk, + frontier, + lib.GrB_ROWINDEX_INT64, + frontier, + index_thunk, ) current_level += 1 # Expand frontier: frontier = frontier * A vector.vector_vxm( - frontier, semiring, frontier, A, - mask=mask, desc=lib.GrB_DESC_RSC, + frontier, + semiring, + frontier, + A, + mask=mask, + desc=lib.GrB_DESC_RSC, ) # Stop when the frontier is empty. diff --git a/suitesparse_graphblas/api/grb_type.py b/suitesparse_graphblas/api/grb_type.py index 39f8024..1c01fc3 100644 --- a/suitesparse_graphblas/api/grb_type.py +++ b/suitesparse_graphblas/api/grb_type.py @@ -69,10 +69,15 @@ def grb_type_print(T, name="", level=lib.GxB_COMPLETE): True """ - check_status(T, lib.GxB_Type_fprint( - T[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + T, + lib.GxB_Type_fprint( + T[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def grb_type_fprint(T, f, name="", level=lib.GxB_COMPLETE): @@ -87,10 +92,15 @@ def grb_type_fprint(T, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(T, lib.GxB_Type_fprint( - T[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + T, + lib.GxB_Type_fprint( + T[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- diff --git a/suitesparse_graphblas/api/indexbinaryop.py b/suitesparse_graphblas/api/indexbinaryop.py index 6587c89..4d513ae 100644 --- a/suitesparse_graphblas/api/indexbinaryop.py +++ b/suitesparse_graphblas/api/indexbinaryop.py @@ -66,10 +66,15 @@ def indexbinaryop_print(op, name="", level=lib.GxB_COMPLETE): ``lib.GxB_SHORT``, ``lib.GxB_COMPLETE``, ``lib.GxB_SHORT_VERBOSE``, or ``lib.GxB_COMPLETE_VERBOSE``. """ - check_status(op, lib.GxB_IndexBinaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + op, + lib.GxB_IndexBinaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def indexbinaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): @@ -78,10 +83,15 @@ def indexbinaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): Pass ``ffi.NULL`` for ``f`` to print to stdout. ``level`` controls verbosity (see :func:`indexbinaryop_print`). """ - check_status(op, lib.GxB_IndexBinaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + op, + lib.GxB_IndexBinaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- @@ -98,9 +108,7 @@ def indexbinaryop_get_int32(op, field): def indexbinaryop_set_int32(op, field, value): """Set an operator option from an int32.""" - check_status( - op, lib.GxB_IndexBinaryOp_set_INT32(op[0], ffi.cast("int32_t", value), field) - ) + check_status(op, lib.GxB_IndexBinaryOp_set_INT32(op[0], ffi.cast("int32_t", value), field)) def indexbinaryop_get_size(op, field): diff --git a/suitesparse_graphblas/api/indexunaryop.py b/suitesparse_graphblas/api/indexunaryop.py index 06a24e9..b333fc1 100644 --- a/suitesparse_graphblas/api/indexunaryop.py +++ b/suitesparse_graphblas/api/indexunaryop.py @@ -89,10 +89,15 @@ def indexunaryop_print(op, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_IndexUnaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + op, + lib.GxB_IndexUnaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def indexunaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): @@ -107,10 +112,15 @@ def indexunaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_IndexUnaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + op, + lib.GxB_IndexUnaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- @@ -133,9 +143,7 @@ def indexunaryop_get_int32(op, field): def indexunaryop_set_int32(op, field, value): """Set an operator option from an int32.""" - check_status( - op, lib.GrB_IndexUnaryOp_set_INT32(op[0], ffi.cast("int32_t", value), field) - ) + check_status(op, lib.GrB_IndexUnaryOp_set_INT32(op[0], ffi.cast("int32_t", value), field)) def indexunaryop_get_size(op, field): diff --git a/suitesparse_graphblas/api/iterator.py b/suitesparse_graphblas/api/iterator.py index 5df331e..bf47f1a 100644 --- a/suitesparse_graphblas/api/iterator.py +++ b/suitesparse_graphblas/api/iterator.py @@ -56,7 +56,9 @@ def matrix_iterator_attach(it, A, desc=None): """ info = lib.GxB_Matrix_Iterator_attach( - it[0], A[0], ffi.NULL if desc is None else desc, + it[0], + A[0], + ffi.NULL if desc is None else desc, ) return _check_info(info) @@ -79,7 +81,9 @@ def row_iterator_attach(it, A, desc=None): """ info = lib.GxB_rowIterator_attach( - it[0], A[0], ffi.NULL if desc is None else desc, + it[0], + A[0], + ffi.NULL if desc is None else desc, ) return _check_info(info) @@ -102,7 +106,9 @@ def col_iterator_attach(it, A, desc=None): """ info = lib.GxB_colIterator_attach( - it[0], A[0], ffi.NULL if desc is None else desc, + it[0], + A[0], + ffi.NULL if desc is None else desc, ) return _check_info(info) @@ -124,7 +130,9 @@ def vector_iterator_attach(it, v, desc=None): """ info = lib.GxB_Vector_Iterator_attach( - it[0], v[0], ffi.NULL if desc is None else desc, + it[0], + v[0], + ffi.NULL if desc is None else desc, ) return _check_info(info) diff --git a/suitesparse_graphblas/api/matrix.py b/suitesparse_graphblas/api/matrix.py index 0feedaa..157d733 100644 --- a/suitesparse_graphblas/api/matrix.py +++ b/suitesparse_graphblas/api/matrix.py @@ -4,10 +4,9 @@ from suitesparse_graphblas import check_status, ffi, lib, supports_complex -from .utils import _capture_c_output # noqa: F401 - from .io.serialize import deserialize_matrix as deserialize # noqa: F401 from .io.serialize import serialize_matrix as serialize # noqa: F401 +from .utils import _capture_c_output # noqa: F401 def matrix_free(A): @@ -204,9 +203,14 @@ def matrix_option_set_int32(A, field, value): True """ - check_status(A, lib.GxB_Matrix_Option_set_INT32( - A[0], field, ffi.cast("int32_t", value), - )) + check_status( + A, + lib.GxB_Matrix_Option_set_INT32( + A[0], + field, + ffi.cast("int32_t", value), + ), + ) def matrix_option_get_fp64(A, field): @@ -231,9 +235,14 @@ def matrix_option_set_fp64(A, field, value): True """ - check_status(A, lib.GxB_Matrix_Option_set_FP64( - A[0], field, ffi.cast("double", value), - )) + check_status( + A, + lib.GxB_Matrix_Option_set_FP64( + A[0], + field, + ffi.cast("double", value), + ), + ) # --------------------------------------------------------------------------- @@ -300,10 +309,15 @@ def matrix_print(A, name="", level=lib.GxB_COMPLETE): True """ - check_status(A, lib.GxB_Matrix_fprint( - A[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + A, + lib.GxB_Matrix_fprint( + A[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def matrix_fprint(A, f, name="", level=lib.GxB_COMPLETE): @@ -322,10 +336,15 @@ def matrix_fprint(A, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(A, lib.GxB_Matrix_fprint( - A[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + A, + lib.GxB_Matrix_fprint( + A[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) def matrix_mxm(C, semiring, A, B, mask=None, accum=None, desc=None): @@ -341,15 +360,18 @@ def matrix_mxm(C, semiring, A, B, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_mxm( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - semiring, - A[0], - B[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_mxm( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + semiring, + A[0], + B[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_ewise_add(C, op, A, B, mask=None, accum=None, desc=None): @@ -365,15 +387,18 @@ def matrix_ewise_add(C, op, A, B, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_eWiseAdd_BinaryOp( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - B[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_eWiseAdd_BinaryOp( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + B[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_ewise_mult(C, op, A, B, mask=None, accum=None, desc=None): @@ -389,15 +414,18 @@ def matrix_ewise_mult(C, op, A, B, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_eWiseMult_BinaryOp( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - B[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_eWiseMult_BinaryOp( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + B[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_ewise_union(C, op, A, alpha, B, beta, mask=None, accum=None, desc=None): @@ -423,15 +451,20 @@ def matrix_ewise_union(C, op, A, alpha, B, beta, mask=None, accum=None, desc=Non True """ - check_status(C, lib.GxB_Matrix_eWiseUnion( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], alpha[0], - B[0], beta[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GxB_Matrix_eWiseUnion( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + alpha[0], + B[0], + beta[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_apply(C, op, A, mask=None, accum=None, desc=None): @@ -445,14 +478,17 @@ def matrix_apply(C, op, A, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_apply( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_apply( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_apply_first(C, op, x, A, mask=None, accum=None, desc=None): @@ -469,15 +505,18 @@ def matrix_apply_first(C, op, x, A, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_apply_BinaryOp1st_Scalar( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - x[0], - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_apply_BinaryOp1st_Scalar( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + x[0], + A[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_apply_second(C, op, A, y, mask=None, accum=None, desc=None): @@ -494,15 +533,18 @@ def matrix_apply_second(C, op, A, y, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_apply_BinaryOp2nd_Scalar( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - y[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_apply_BinaryOp2nd_Scalar( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + y[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_apply_indexop(C, op, A, thunk, mask=None, accum=None, desc=None): @@ -522,15 +564,18 @@ def matrix_apply_indexop(C, op, A, thunk, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_apply_IndexOp_Scalar( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - thunk[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_apply_IndexOp_Scalar( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + thunk[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_select(C, op, A, thunk, mask=None, accum=None, desc=None): @@ -550,15 +595,18 @@ def matrix_select(C, op, A, thunk, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_select_Scalar( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - thunk[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_select_Scalar( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + thunk[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_reduce(w, monoid, A, mask=None, accum=None, desc=None): @@ -574,14 +622,17 @@ def matrix_reduce(w, monoid, A, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Matrix_reduce_Monoid( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - monoid, - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Matrix_reduce_Monoid( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + monoid, + A[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_reduce_scalar(s, monoid, A, accum=None, desc=None): @@ -597,13 +648,16 @@ def matrix_reduce_scalar(s, monoid, A, accum=None, desc=None): True """ - check_status(s, lib.GrB_Matrix_reduce_Monoid_Scalar( - s[0], - ffi.NULL if accum is None else accum, - monoid, - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + s, + lib.GrB_Matrix_reduce_Monoid_Scalar( + s[0], + ffi.NULL if accum is None else accum, + monoid, + A[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_transpose(C, A, mask=None, accum=None, desc=None): @@ -617,13 +671,16 @@ def matrix_transpose(C, A, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_transpose( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_transpose( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + A[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_kronecker(C, op, A, B, mask=None, accum=None, desc=None): @@ -639,15 +696,18 @@ def matrix_kronecker(C, op, A, B, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Matrix_kronecker_BinaryOp( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - A[0], - B[0], - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_kronecker_BinaryOp( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + A[0], + B[0], + ffi.NULL if desc is None else desc, + ), + ) def matrix_diag(C, v, k=0, desc=None): @@ -671,10 +731,15 @@ def matrix_diag(C, v, k=0, desc=None): True """ - check_status(C, lib.GxB_Matrix_diag( - C[0], v[0], k, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GxB_Matrix_diag( + C[0], + v[0], + k, + ffi.NULL if desc is None else desc, + ), + ) def matrix_concat(C, tiles, m, n, desc=None): @@ -698,10 +763,16 @@ def matrix_concat(C, tiles, m, n, desc=None): """ tile_array = ffi.new("GrB_Matrix[]", [t[0] for t in tiles]) - check_status(C, lib.GxB_Matrix_concat( - C[0], tile_array, m, n, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GxB_Matrix_concat( + C[0], + tile_array, + m, + n, + ffi.NULL if desc is None else desc, + ), + ) def matrix_assign(C, A, rows, nrows, cols, ncols, mask=None, accum=None, desc=None): @@ -720,14 +791,20 @@ def matrix_assign(C, A, rows, nrows, cols, ncols, mask=None, accum=None, desc=No True """ - check_status(C, lib.GrB_Matrix_assign( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - A[0], - rows, nrows, cols, ncols, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_assign( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + A[0], + rows, + nrows, + cols, + ncols, + ffi.NULL if desc is None else desc, + ), + ) def matrix_assign_scalar(C, x, rows, nrows, cols, ncols, mask=None, accum=None, desc=None): @@ -746,14 +823,20 @@ def matrix_assign_scalar(C, x, rows, nrows, cols, ncols, mask=None, accum=None, True """ - check_status(C, lib.GrB_Matrix_assign_Scalar( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - x[0], - rows, nrows, cols, ncols, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_assign_Scalar( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + x[0], + rows, + nrows, + cols, + ncols, + ffi.NULL if desc is None else desc, + ), + ) def matrix_extract(C, A, rows, nrows, cols, ncols, mask=None, accum=None, desc=None): @@ -769,14 +852,20 @@ def matrix_extract(C, A, rows, nrows, cols, ncols, mask=None, accum=None, desc=N True """ - check_status(C, lib.GrB_Matrix_extract( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - A[0], - rows, nrows, cols, ncols, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Matrix_extract( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + A[0], + rows, + nrows, + cols, + ncols, + ffi.NULL if desc is None else desc, + ), + ) def matrix_col_extract(w, A, rows, nrows, j, mask=None, accum=None, desc=None): @@ -791,14 +880,19 @@ def matrix_col_extract(w, A, rows, nrows, j, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Col_extract( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - A[0], - rows, nrows, j, - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Col_extract( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + A[0], + rows, + nrows, + j, + ffi.NULL if desc is None else desc, + ), + ) def matrix_col_assign(C, u, rows, nrows, j, mask=None, accum=None, desc=None): @@ -813,14 +907,19 @@ def matrix_col_assign(C, u, rows, nrows, j, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Col_assign( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - u[0], - rows, nrows, j, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Col_assign( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + u[0], + rows, + nrows, + j, + ffi.NULL if desc is None else desc, + ), + ) def matrix_row_assign(C, u, i, cols, ncols, mask=None, accum=None, desc=None): @@ -835,14 +934,19 @@ def matrix_row_assign(C, u, i, cols, ncols, mask=None, accum=None, desc=None): True """ - check_status(C, lib.GrB_Row_assign( - C[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - u[0], - i, cols, ncols, - ffi.NULL if desc is None else desc, - )) + check_status( + C, + lib.GrB_Row_assign( + C[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + u[0], + i, + cols, + ncols, + ffi.NULL if desc is None else desc, + ), + ) def matrix_build_bool(C, rows, cols, vals, nvals, dup): @@ -857,13 +961,17 @@ def matrix_build_bool(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_BOOL( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("bool*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_BOOL( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("bool*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_int8(C, rows, cols, vals, nvals, dup): @@ -878,13 +986,17 @@ def matrix_build_int8(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_INT8( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int8_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_INT8( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int8_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_int16(C, rows, cols, vals, nvals, dup): @@ -899,13 +1011,17 @@ def matrix_build_int16(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_INT16( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int16_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_INT16( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int16_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_int32(C, rows, cols, vals, nvals, dup): @@ -920,13 +1036,17 @@ def matrix_build_int32(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_INT32( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_INT32( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_int64(C, rows, cols, vals, nvals, dup): @@ -941,13 +1061,17 @@ def matrix_build_int64(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_INT64( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_INT64( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_uint8(C, rows, cols, vals, nvals, dup): @@ -962,13 +1086,17 @@ def matrix_build_uint8(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_UINT8( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint8_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_UINT8( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint8_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_uint16(C, rows, cols, vals, nvals, dup): @@ -983,13 +1111,17 @@ def matrix_build_uint16(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_UINT16( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint16_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_UINT16( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint16_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_uint32(C, rows, cols, vals, nvals, dup): @@ -1004,13 +1136,17 @@ def matrix_build_uint32(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_UINT32( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_UINT32( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_uint64(C, rows, cols, vals, nvals, dup): @@ -1025,13 +1161,17 @@ def matrix_build_uint64(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_UINT64( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_UINT64( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_fp32(C, rows, cols, vals, nvals, dup): @@ -1046,13 +1186,17 @@ def matrix_build_fp32(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_FP32( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("float*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_FP32( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("float*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_build_fp64(C, rows, cols, vals, nvals, dup): @@ -1067,13 +1211,17 @@ def matrix_build_fp64(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GrB_Matrix_build_FP64( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("double*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GrB_Matrix_build_FP64( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("double*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_extract_tuples_int64(A): @@ -1096,12 +1244,16 @@ def matrix_extract_tuples_int64(A): vals = np.empty(n, dtype=np.int64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_INT64( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int64_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_INT64( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int64_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals @@ -1125,14 +1277,19 @@ def matrix_extract_tuples_fp64(A): vals = np.empty(n, dtype=np.float64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_FP64( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("double*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_FP64( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("double*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_bool(A): """Extract all tuples from a matrix as numpy arrays. @@ -1153,14 +1310,19 @@ def matrix_extract_tuples_bool(A): vals = np.empty(n, dtype=np.bool_) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_BOOL( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("bool*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_BOOL( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("bool*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_int8(A): """Extract all tuples from a matrix as numpy arrays. @@ -1181,14 +1343,19 @@ def matrix_extract_tuples_int8(A): vals = np.empty(n, dtype=np.int8) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_INT8( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int8_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_INT8( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int8_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_int16(A): """Extract all tuples from a matrix as numpy arrays. @@ -1209,14 +1376,19 @@ def matrix_extract_tuples_int16(A): vals = np.empty(n, dtype=np.int16) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_INT16( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int16_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_INT16( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int16_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_int32(A): """Extract all tuples from a matrix as numpy arrays. @@ -1237,14 +1409,19 @@ def matrix_extract_tuples_int32(A): vals = np.empty(n, dtype=np.int32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_INT32( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("int32_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_INT32( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("int32_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_uint8(A): """Extract all tuples from a matrix as numpy arrays. @@ -1265,14 +1442,19 @@ def matrix_extract_tuples_uint8(A): vals = np.empty(n, dtype=np.uint8) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_UINT8( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint8_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_UINT8( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint8_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_uint16(A): """Extract all tuples from a matrix as numpy arrays. @@ -1293,14 +1475,19 @@ def matrix_extract_tuples_uint16(A): vals = np.empty(n, dtype=np.uint16) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_UINT16( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint16_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_UINT16( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint16_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_uint32(A): """Extract all tuples from a matrix as numpy arrays. @@ -1321,14 +1508,19 @@ def matrix_extract_tuples_uint32(A): vals = np.empty(n, dtype=np.uint32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_UINT32( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint32_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_UINT32( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint32_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_uint64(A): """Extract all tuples from a matrix as numpy arrays. @@ -1349,14 +1541,19 @@ def matrix_extract_tuples_uint64(A): vals = np.empty(n, dtype=np.uint64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_UINT64( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("uint64_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_UINT64( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("uint64_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals + def matrix_extract_tuples_fp32(A): """Extract all tuples from a matrix as numpy arrays. @@ -1377,12 +1574,16 @@ def matrix_extract_tuples_fp32(A): vals = np.empty(n, dtype=np.float32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GrB_Matrix_extractTuples_FP32( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("float*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GrB_Matrix_extractTuples_FP32( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("float*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals @@ -1734,13 +1935,17 @@ def matrix_build_fc32(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GxB_Matrix_build_FC32( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GxB_Matrix_build_FC32( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_extract_tuples_fc32(A): """Extract all tuples from a matrix as numpy arrays. @@ -1762,12 +1967,16 @@ def matrix_extract_tuples_fc32(A): vals = np.empty(n, dtype=np.complex64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GxB_Matrix_extractTuples_FC32( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GxB_Matrix_extractTuples_FC32( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals def matrix_build_fc64(C, rows, cols, vals, nvals, dup): @@ -1782,13 +1991,17 @@ def matrix_build_fc64(C, rows, cols, vals, nvals, dup): True """ - check_status(C, lib.GxB_Matrix_build_FC64( - C[0], - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + C, + lib.GxB_Matrix_build_FC64( + C[0], + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def matrix_extract_tuples_fc64(A): """Extract all tuples from a matrix as numpy arrays. @@ -1810,10 +2023,14 @@ def matrix_extract_tuples_fc64(A): vals = np.empty(n, dtype=np.complex128) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(A, lib.GxB_Matrix_extractTuples_FC64( - ffi.cast("GrB_Index*", ffi.from_buffer(rows)), - ffi.cast("GrB_Index*", ffi.from_buffer(cols)), - ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), - nvals_p, A[0], - )) + check_status( + A, + lib.GxB_Matrix_extractTuples_FC64( + ffi.cast("GrB_Index*", ffi.from_buffer(rows)), + ffi.cast("GrB_Index*", ffi.from_buffer(cols)), + ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), + nvals_p, + A[0], + ), + ) return rows, cols, vals diff --git a/suitesparse_graphblas/api/monoid.py b/suitesparse_graphblas/api/monoid.py index 64dcc9d..4706b05 100644 --- a/suitesparse_graphblas/api/monoid.py +++ b/suitesparse_graphblas/api/monoid.py @@ -471,10 +471,15 @@ def monoid_print(m, name="", level=lib.GxB_COMPLETE): True """ - check_status(m, lib.GxB_Monoid_fprint( - m[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + m, + lib.GxB_Monoid_fprint( + m[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def monoid_fprint(m, f, name="", level=lib.GxB_COMPLETE): @@ -489,10 +494,15 @@ def monoid_fprint(m, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(m, lib.GxB_Monoid_fprint( - m[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + m, + lib.GxB_Monoid_fprint( + m[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- @@ -514,9 +524,7 @@ def monoid_get_int32(m, field): def monoid_set_int32(m, field, value): - """Set a monoid option from an int32. - - """ + """Set a monoid option from an int32.""" check_status(m, lib.GrB_Monoid_set_INT32(m[0], ffi.cast("int32_t", value), field)) @@ -547,9 +555,7 @@ def monoid_get_string(m, field): def monoid_set_string(m, field, value): - """Set a monoid option from a string. - - """ + """Set a monoid option from a string.""" check_status(m, lib.GrB_Monoid_set_String(m[0], value.encode(), field)) diff --git a/suitesparse_graphblas/api/scalar.py b/suitesparse_graphblas/api/scalar.py index b76e7b6..f4537a3 100644 --- a/suitesparse_graphblas/api/scalar.py +++ b/suitesparse_graphblas/api/scalar.py @@ -104,10 +104,15 @@ def scalar_print(s, name="", level=lib.GxB_COMPLETE): True """ - check_status(s, lib.GxB_Scalar_fprint( - s[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + s, + lib.GxB_Scalar_fprint( + s[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def scalar_fprint(s, f, name="", level=lib.GxB_COMPLETE): @@ -125,10 +130,15 @@ def scalar_fprint(s, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(s, lib.GxB_Scalar_fprint( - s[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + s, + lib.GxB_Scalar_fprint( + s[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) def set_bool(s, value): diff --git a/suitesparse_graphblas/api/selectop.py b/suitesparse_graphblas/api/selectop.py index b68b389..f80aa75 100644 --- a/suitesparse_graphblas/api/selectop.py +++ b/suitesparse_graphblas/api/selectop.py @@ -51,8 +51,10 @@ def selectop_print(op, name="", level=lib.GxB_COMPLETE): """ info = lib.GxB_SelectOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, + op[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, ) if info != lib.GrB_SUCCESS: raise _error_code_lookup.get(info, RuntimeError)( @@ -73,8 +75,10 @@ def selectop_fprint(op, f, name="", level=lib.GxB_COMPLETE): """ info = lib.GxB_SelectOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, f, + op[0], + name.encode() if isinstance(name, str) else name, + level, + f, ) if info != lib.GrB_SUCCESS: raise _error_code_lookup.get(info, RuntimeError)( diff --git a/suitesparse_graphblas/api/semiring.py b/suitesparse_graphblas/api/semiring.py index 03ef469..e942c3c 100644 --- a/suitesparse_graphblas/api/semiring.py +++ b/suitesparse_graphblas/api/semiring.py @@ -69,10 +69,15 @@ def semiring_print(s, name="", level=lib.GxB_COMPLETE): True """ - check_status(s, lib.GxB_Semiring_fprint( - s[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + s, + lib.GxB_Semiring_fprint( + s[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def semiring_fprint(s, f, name="", level=lib.GxB_COMPLETE): @@ -87,10 +92,15 @@ def semiring_fprint(s, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(s, lib.GxB_Semiring_fprint( - s[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + s, + lib.GxB_Semiring_fprint( + s[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- @@ -112,9 +122,7 @@ def semiring_get_int32(s, field): def semiring_set_int32(s, field, value): - """Set a semiring option from an int32. - - """ + """Set a semiring option from an int32.""" check_status(s, lib.GrB_Semiring_set_INT32(s[0], ffi.cast("int32_t", value), field)) @@ -145,9 +153,7 @@ def semiring_get_string(s, field): def semiring_set_string(s, field, value): - """Set a semiring option from a string. - - """ + """Set a semiring option from a string.""" check_status(s, lib.GrB_Semiring_set_String(s[0], value.encode(), field)) diff --git a/suitesparse_graphblas/api/unaryop.py b/suitesparse_graphblas/api/unaryop.py index e16dd21..f5f4fc3 100644 --- a/suitesparse_graphblas/api/unaryop.py +++ b/suitesparse_graphblas/api/unaryop.py @@ -88,10 +88,15 @@ def unaryop_print(op, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_UnaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + op, + lib.GxB_UnaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def unaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): @@ -106,10 +111,15 @@ def unaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(op, lib.GxB_UnaryOp_fprint( - op[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + op, + lib.GxB_UnaryOp_fprint( + op[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) # --------------------------------------------------------------------------- diff --git a/suitesparse_graphblas/api/vector.py b/suitesparse_graphblas/api/vector.py index f144cc4..f123028 100644 --- a/suitesparse_graphblas/api/vector.py +++ b/suitesparse_graphblas/api/vector.py @@ -4,10 +4,9 @@ from suitesparse_graphblas import check_status, ffi, lib, supports_complex -from .utils import _capture_c_output # noqa: F401 - from .io.serialize import deserialize_vector as deserialize # noqa: F401 from .io.serialize import serialize_vector as serialize # noqa: F401 +from .utils import _capture_c_output # noqa: F401 def vector_free(v): @@ -105,9 +104,14 @@ def vector_option_set_int32(v, field, value): True """ - check_status(v, lib.GxB_Vector_Option_set_INT32( - v[0], field, ffi.cast("int32_t", value), - )) + check_status( + v, + lib.GxB_Vector_Option_set_INT32( + v[0], + field, + ffi.cast("int32_t", value), + ), + ) def vector_option_get_fp64(v, field): @@ -132,9 +136,14 @@ def vector_option_set_fp64(v, field, value): True """ - check_status(v, lib.GxB_Vector_Option_set_FP64( - v[0], field, ffi.cast("double", value), - )) + check_status( + v, + lib.GxB_Vector_Option_set_FP64( + v[0], + field, + ffi.cast("double", value), + ), + ) # --------------------------------------------------------------------------- @@ -201,10 +210,15 @@ def vector_print(v, name="", level=lib.GxB_COMPLETE): True """ - check_status(v, lib.GxB_Vector_fprint( - v[0], name.encode() if isinstance(name, str) else name, - level, ffi.NULL, - )) + check_status( + v, + lib.GxB_Vector_fprint( + v[0], + name.encode() if isinstance(name, str) else name, + level, + ffi.NULL, + ), + ) def vector_fprint(v, f, name="", level=lib.GxB_COMPLETE): @@ -223,10 +237,15 @@ def vector_fprint(v, f, name="", level=lib.GxB_COMPLETE): True """ - check_status(v, lib.GxB_Vector_fprint( - v[0], name.encode() if isinstance(name, str) else name, - level, f, - )) + check_status( + v, + lib.GxB_Vector_fprint( + v[0], + name.encode() if isinstance(name, str) else name, + level, + f, + ), + ) def vector_mxv(w, semiring, A, u, mask=None, accum=None, desc=None): @@ -243,15 +262,18 @@ def vector_mxv(w, semiring, A, u, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_mxv( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - semiring, - A[0], - u[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_mxv( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + semiring, + A[0], + u[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_vxm(w, semiring, u, A, mask=None, accum=None, desc=None): @@ -268,15 +290,18 @@ def vector_vxm(w, semiring, u, A, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_vxm( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - semiring, - u[0], - A[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_vxm( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + semiring, + u[0], + A[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_ewise_add(w, op, u, v, mask=None, accum=None, desc=None): @@ -292,15 +317,18 @@ def vector_ewise_add(w, op, u, v, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_eWiseAdd_BinaryOp( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - v[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_eWiseAdd_BinaryOp( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + v[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_ewise_mult(w, op, u, v, mask=None, accum=None, desc=None): @@ -316,15 +344,18 @@ def vector_ewise_mult(w, op, u, v, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_eWiseMult_BinaryOp( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - v[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_eWiseMult_BinaryOp( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + v[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_ewise_union(w, op, u, alpha, v, beta, mask=None, accum=None, desc=None): @@ -350,15 +381,20 @@ def vector_ewise_union(w, op, u, alpha, v, beta, mask=None, accum=None, desc=Non True """ - check_status(w, lib.GxB_Vector_eWiseUnion( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], alpha[0], - v[0], beta[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GxB_Vector_eWiseUnion( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + alpha[0], + v[0], + beta[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_apply(w, op, u, mask=None, accum=None, desc=None): @@ -372,14 +408,17 @@ def vector_apply(w, op, u, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_apply( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_apply( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_apply_first(w, op, x, u, mask=None, accum=None, desc=None): @@ -396,15 +435,18 @@ def vector_apply_first(w, op, x, u, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_apply_BinaryOp1st_Scalar( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - x[0], - u[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_apply_BinaryOp1st_Scalar( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + x[0], + u[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_apply_second(w, op, u, y, mask=None, accum=None, desc=None): @@ -421,15 +463,18 @@ def vector_apply_second(w, op, u, y, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_apply_BinaryOp2nd_Scalar( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - y[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_apply_BinaryOp2nd_Scalar( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + y[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_apply_indexop(w, op, u, thunk, mask=None, accum=None, desc=None): @@ -449,15 +494,18 @@ def vector_apply_indexop(w, op, u, thunk, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_apply_IndexOp_Scalar( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - thunk[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_apply_IndexOp_Scalar( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + thunk[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_select(w, op, u, thunk, mask=None, accum=None, desc=None): @@ -477,15 +525,18 @@ def vector_select(w, op, u, thunk, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_select_Scalar( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - op, - u[0], - thunk[0], - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_select_Scalar( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + op, + u[0], + thunk[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_reduce(s, monoid, u, accum=None, desc=None): @@ -501,13 +552,16 @@ def vector_reduce(s, monoid, u, accum=None, desc=None): True """ - check_status(s, lib.GrB_Vector_reduce_Monoid_Scalar( - s[0], - ffi.NULL if accum is None else accum, - monoid, - u[0], - ffi.NULL if desc is None else desc, - )) + check_status( + s, + lib.GrB_Vector_reduce_Monoid_Scalar( + s[0], + ffi.NULL if accum is None else accum, + monoid, + u[0], + ffi.NULL if desc is None else desc, + ), + ) def vector_diag(v, A, k=0, desc=None): @@ -530,10 +584,15 @@ def vector_diag(v, A, k=0, desc=None): True """ - check_status(v, lib.GxB_Vector_diag( - v[0], A[0], k, - ffi.NULL if desc is None else desc, - )) + check_status( + v, + lib.GxB_Vector_diag( + v[0], + A[0], + k, + ffi.NULL if desc is None else desc, + ), + ) def vector_assign(w, u, indices, ni, mask=None, accum=None, desc=None): @@ -548,14 +607,18 @@ def vector_assign(w, u, indices, ni, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_assign( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - u[0], - indices, ni, - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_assign( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + u[0], + indices, + ni, + ffi.NULL if desc is None else desc, + ), + ) def vector_assign_scalar(w, x, indices, ni, mask=None, accum=None, desc=None): @@ -573,14 +636,18 @@ def vector_assign_scalar(w, x, indices, ni, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_assign_Scalar( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - x[0], - indices, ni, - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_assign_Scalar( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + x[0], + indices, + ni, + ffi.NULL if desc is None else desc, + ), + ) def vector_extract(w, u, indices, ni, mask=None, accum=None, desc=None): @@ -595,14 +662,18 @@ def vector_extract(w, u, indices, ni, mask=None, accum=None, desc=None): True """ - check_status(w, lib.GrB_Vector_extract( - w[0], - ffi.NULL if mask is None else mask[0], - ffi.NULL if accum is None else accum, - u[0], - indices, ni, - ffi.NULL if desc is None else desc, - )) + check_status( + w, + lib.GrB_Vector_extract( + w[0], + ffi.NULL if mask is None else mask[0], + ffi.NULL if accum is None else accum, + u[0], + indices, + ni, + ffi.NULL if desc is None else desc, + ), + ) def vector_build_int64(w, indices, vals, nvals, dup): @@ -618,12 +689,16 @@ def vector_build_int64(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_INT64( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_INT64( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def vector_build_fp64(w, indices, vals, nvals, dup): @@ -637,12 +712,16 @@ def vector_build_fp64(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_FP64( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("double*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_FP64( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("double*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def vector_extract_tuples_int64(v): @@ -666,11 +745,15 @@ def vector_extract_tuples_int64(v): vals = np.empty(n, dtype=np.int64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_INT64( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int64_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_INT64( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int64_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals @@ -693,13 +776,18 @@ def vector_extract_tuples_fp64(v): vals = np.empty(n, dtype=np.float64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_FP64( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("double*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_FP64( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("double*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_build_bool(w, indices, vals, nvals, dup): """Build a vector from index and bool value arrays. @@ -711,12 +799,17 @@ def vector_build_bool(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_BOOL( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("bool*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_BOOL( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("bool*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_int8(w, indices, vals, nvals, dup): """Build a vector from index and int8 value arrays. @@ -729,12 +822,17 @@ def vector_build_int8(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_INT8( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int8_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_INT8( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int8_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_int16(w, indices, vals, nvals, dup): """Build a vector from index and int16 value arrays. @@ -747,12 +845,17 @@ def vector_build_int16(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_INT16( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int16_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_INT16( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int16_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_int32(w, indices, vals, nvals, dup): """Build a vector from index and int32 value arrays. @@ -765,12 +868,17 @@ def vector_build_int32(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_INT32( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_INT32( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_uint8(w, indices, vals, nvals, dup): """Build a vector from index and uint8 value arrays. @@ -783,12 +891,17 @@ def vector_build_uint8(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_UINT8( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint8_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_UINT8( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint8_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_uint16(w, indices, vals, nvals, dup): """Build a vector from index and uint16 value arrays. @@ -801,12 +914,17 @@ def vector_build_uint16(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_UINT16( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint16_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_UINT16( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint16_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_uint32(w, indices, vals, nvals, dup): """Build a vector from index and uint32 value arrays. @@ -819,12 +937,17 @@ def vector_build_uint32(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_UINT32( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_UINT32( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_uint64(w, indices, vals, nvals, dup): """Build a vector from index and uint64 value arrays. @@ -837,12 +960,17 @@ def vector_build_uint64(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_UINT64( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_UINT64( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_build_fp32(w, indices, vals, nvals, dup): """Build a vector from index and fp32 value arrays. @@ -855,12 +983,17 @@ def vector_build_fp32(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GrB_Vector_build_FP32( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("float*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GrB_Vector_build_FP32( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("float*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) + def vector_extract_tuples_bool(v): """Extract all tuples from a vector as numpy arrays. @@ -881,13 +1014,18 @@ def vector_extract_tuples_bool(v): vals = np.empty(n, dtype=np.bool_) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_BOOL( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("bool*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_BOOL( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("bool*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_int8(v): """Extract all tuples from a vector as numpy arrays. @@ -907,13 +1045,18 @@ def vector_extract_tuples_int8(v): vals = np.empty(n, dtype=np.int8) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_INT8( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int8_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_INT8( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int8_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_int16(v): """Extract all tuples from a vector as numpy arrays. @@ -933,13 +1076,18 @@ def vector_extract_tuples_int16(v): vals = np.empty(n, dtype=np.int16) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_INT16( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int16_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_INT16( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int16_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_int32(v): """Extract all tuples from a vector as numpy arrays. @@ -959,13 +1107,18 @@ def vector_extract_tuples_int32(v): vals = np.empty(n, dtype=np.int32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_INT32( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("int32_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_INT32( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("int32_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_uint8(v): """Extract all tuples from a vector as numpy arrays. @@ -985,13 +1138,18 @@ def vector_extract_tuples_uint8(v): vals = np.empty(n, dtype=np.uint8) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_UINT8( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint8_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_UINT8( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint8_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_uint16(v): """Extract all tuples from a vector as numpy arrays. @@ -1011,13 +1169,18 @@ def vector_extract_tuples_uint16(v): vals = np.empty(n, dtype=np.uint16) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_UINT16( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint16_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_UINT16( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint16_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_uint32(v): """Extract all tuples from a vector as numpy arrays. @@ -1037,13 +1200,18 @@ def vector_extract_tuples_uint32(v): vals = np.empty(n, dtype=np.uint32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_UINT32( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint32_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_UINT32( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint32_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_uint64(v): """Extract all tuples from a vector as numpy arrays. @@ -1063,13 +1231,18 @@ def vector_extract_tuples_uint64(v): vals = np.empty(n, dtype=np.uint64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_UINT64( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("uint64_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_UINT64( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("uint64_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals + def vector_extract_tuples_fp32(v): """Extract all tuples from a vector as numpy arrays. @@ -1089,11 +1262,15 @@ def vector_extract_tuples_fp32(v): vals = np.empty(n, dtype=np.float32) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GrB_Vector_extractTuples_FP32( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("float*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GrB_Vector_extractTuples_FP32( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("float*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals @@ -1444,12 +1621,16 @@ def vector_build_fc32(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GxB_Vector_build_FC32( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GxB_Vector_build_FC32( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def vector_extract_tuples_fc32(v): """Extract all tuples from a vector as numpy arrays. @@ -1470,11 +1651,15 @@ def vector_extract_tuples_fc32(v): vals = np.empty(n, dtype=np.complex64) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GxB_Vector_extractTuples_FC32( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GxB_Vector_extractTuples_FC32( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("GxB_FC32_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals def vector_build_fc64(w, indices, vals, nvals, dup): @@ -1488,12 +1673,16 @@ def vector_build_fc64(w, indices, vals, nvals, dup): True """ - check_status(w, lib.GxB_Vector_build_FC64( - w[0], - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), - nvals, dup, - )) + check_status( + w, + lib.GxB_Vector_build_FC64( + w[0], + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), + nvals, + dup, + ), + ) def vector_extract_tuples_fc64(v): """Extract all tuples from a vector as numpy arrays. @@ -1514,9 +1703,13 @@ def vector_extract_tuples_fc64(v): vals = np.empty(n, dtype=np.complex128) nvals_p = ffi.new("GrB_Index*", n) if n > 0: - check_status(v, lib.GxB_Vector_extractTuples_FC64( - ffi.cast("GrB_Index*", ffi.from_buffer(indices)), - ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), - nvals_p, v[0], - )) + check_status( + v, + lib.GxB_Vector_extractTuples_FC64( + ffi.cast("GrB_Index*", ffi.from_buffer(indices)), + ffi.cast("GxB_FC64_t*", ffi.from_buffer(vals)), + nvals_p, + v[0], + ), + ) return indices, vals diff --git a/suitesparse_graphblas/create_headers.py b/suitesparse_graphblas/create_headers.py index 0ec57fb..dcfb5f4 100644 --- a/suitesparse_graphblas/create_headers.py +++ b/suitesparse_graphblas/create_headers.py @@ -302,6 +302,10 @@ def groupby(index, seq): "GxB_COMPRESSION_ZSTD", "GxB_COMPRESSION_NONE", "GxB_USE_VALUES", + # Memory arenas, added in version 10.4 + "GxB_ARENA_DATA", + "GxB_ARENA_HEADER", + "GxB_NARENAS", } CHAR_DEFINES = { @@ -340,6 +344,12 @@ def groupby(index, seq): "GxB_cuda_malloc", "GxB_cuda_free", } + +# Declared in GraphBLAS.h, but not actually defined by libgraphblas. cffi would +# happily bind these, but then importing `_graphblas` fails at dlopen time with +# "symbol not found in flat namespace". Remove entries here once upstream +# implements them. This is most common in beta releases. +NOT_IMPLEMENTED = set() IGNORE_ENUMS = { "memory_order", "RMM_MODE", @@ -388,6 +398,8 @@ def get_groups(ast): groups = {} vals = {x for x in lines if "GrB_Info GxB" in x} - seen vals |= {x for x in lines if "GxB_Iterator" in x and "GB" not in x} - seen + # A few GxB functions return void, e.g. GxB_atfork_* (added in v10.4.0) + vals |= {x for x in lines if x.startswith("void GxB")} - seen seen.update(vals) groups["GxB methods"] = sorted(vals, key=sort_key) @@ -631,11 +643,14 @@ def visit_Decl(self, node): self.functions.append(node) def handle_function_node(node): - if generator.visit(node.type.type) != "GrB_Info" and "GxB_Iterator" not in generator.visit( - node + if ( + generator.visit(node.type.type) != "GrB_Info" + and "GxB_Iterator" not in generator.visit(node) + # e.g. GxB_atfork_* (added in v10.4.0) return void + and not (node.name.startswith("GxB_") and generator.visit(node.type.type) == "void") ): raise ValueError(generator.visit(node)) - if node.name in DEPRECATED: + if node.name in DEPRECATED or node.name in NOT_IMPLEMENTED: return text = generator.visit(node) text += ";" @@ -679,6 +694,10 @@ def handle_function_node(node): "wait": "core", "deserialize": "core", "Serialized": "core", # Added in version 9 + "arena": "core", # Added in version 10.4 + "atfork": "core", # Added in version 10.4 + "initialized": "core", # Added in version 10.4 + "finalized": "core", # Added in version 10.4 }[group] return { "name": node.name, diff --git a/suitesparse_graphblas/suitesparse_graphblas.h b/suitesparse_graphblas/suitesparse_graphblas.h index 2e3e66b..c50f31f 100644 --- a/suitesparse_graphblas/suitesparse_graphblas.h +++ b/suitesparse_graphblas/suitesparse_graphblas.h @@ -24,7 +24,7 @@ typedef struct GB_SelectOp_opaque *GxB_SelectOp; typedef struct GxB_Container_struct *GxB_Container; /* GxB typedefs (functions) */ -typedef int64_t (*GxB_print_function)(char *string, size_t string_size, const void *value, int verbose); +typedef int64_t (*GxB_print_function)(char *string, size_t string_len, const void *value, int verbose); typedef void (*GxB_binary_function)(void *, const void *, const void *); typedef void (*GxB_index_binary_function)(void *, const void *, GrB_Index, GrB_Index, const void *, GrB_Index, GrB_Index, const void *); typedef void (*GxB_index_unary_function)(void *z, const void *x, GrB_Index i, GrB_Index j, const void *y); @@ -41,7 +41,8 @@ struct GxB_Container_struct uint64_t u64_future[11]; int32_t format; int32_t orientation; - uint32_t u32_future[14]; + int32_t header_arena; + uint32_t u32_future[13]; GrB_Vector p; GrB_Vector h; GrB_Vector b; @@ -256,6 +257,10 @@ typedef enum GxB_CALLOC_FUNCTION = 7038, GxB_REALLOC_FUNCTION = 7039, GxB_FREE_FUNCTION = 7040, + GxB_ARENA_MALLOC = 0x10000, + GxB_ARENA_CALLOC = 0x20000, + GxB_ARENA_REALLOC = 0x30000, + GxB_ARENA_FREE = 0x40000, GxB_GLOBAL_NTHREADS = 7086, GxB_GLOBAL_CHUNK = 7087, GxB_GLOBAL_NGPUS = 7102, @@ -2993,8 +2998,8 @@ GrB_Info GrB_Matrix_select_UINT8(GrB_Matrix C, const GrB_Matrix Mask, const GrB_ GrB_Info GrB_Matrix_select_UINT16(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint16_t y, const GrB_Descriptor desc); GrB_Info GrB_Matrix_select_UINT32(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint32_t y, const GrB_Descriptor desc); GrB_Info GrB_Matrix_select_UINT64(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint64_t y, const GrB_Descriptor desc); -GrB_Info GrB_Matrix_serialize(void *blob, GrB_Index *blob_size_handle, GrB_Matrix A); -GrB_Info GrB_Matrix_serializeSize(GrB_Index *blob_size_handle, GrB_Matrix A); +GrB_Info GrB_Matrix_serialize(void *blob, GrB_Index *blob_size, GrB_Matrix A); +GrB_Info GrB_Matrix_serializeSize(GrB_Index *blob_size, GrB_Matrix A); GrB_Info GrB_Matrix_setElement_BOOL(GrB_Matrix C, bool x, GrB_Index i, GrB_Index j); GrB_Info GrB_Matrix_setElement_FP32(GrB_Matrix C, float x, GrB_Index i, GrB_Index j); GrB_Info GrB_Matrix_setElement_FP64(GrB_Matrix C, double x, GrB_Index i, GrB_Index j); @@ -3318,6 +3323,7 @@ GrB_Info GB_Iterator_attach(GxB_Iterator iterator, GrB_Matrix A, int format, GrB /* binary */ GrB_Info GxB_BinaryOp_fprint(GrB_BinaryOp binaryop, const char *name, int pr, FILE *f); GrB_Info GxB_BinaryOp_new(GrB_BinaryOp *op, GxB_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *binop_name, const char *binop_defn); +GrB_Info GxB_BinaryOp_new_arena(GrB_BinaryOp *op_handle, GxB_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *binop_name, const char *binop_defn, const int header_arena); GrB_Info GxB_BinaryOp_xtype(GrB_Type *, GrB_BinaryOp); GrB_Info GxB_BinaryOp_xtype_name(char *, const GrB_BinaryOp); GrB_Info GxB_BinaryOp_ytype(GrB_Type *, GrB_BinaryOp); @@ -3328,6 +3334,7 @@ GrB_Info GxB_BinaryOp_ztype_name(char *, const GrB_BinaryOp); /* container */ GrB_Info GxB_Container_free(GxB_Container *object); GrB_Info GxB_Container_new(GxB_Container *Container); +GrB_Info GxB_Container_new_arena(GxB_Container *Container, const int header_arena, const int data_arena); /* context */ GrB_Info GxB_Context_disengage(GxB_Context Context); @@ -3343,6 +3350,7 @@ GrB_Info GxB_Context_get_SIZE(GxB_Context, size_t *, int); GrB_Info GxB_Context_get_String(GxB_Context, char *, int); GrB_Info GxB_Context_get_VOID(GxB_Context, void *, int); GrB_Info GxB_Context_new(GxB_Context *Context); +GrB_Info GxB_Context_new_arena(GxB_Context *Context_handle, const int header_arena); GrB_Info GxB_Context_set(GxB_Context, int, ...); GrB_Info GxB_Context_set_FP64(GxB_Context, int, double); GrB_Info GxB_Context_set_INT(GxB_Context, int32_t, int); @@ -3369,8 +3377,15 @@ GrB_Info GxB_Serialized_get_INT32(const void *, int32_t *, int, size_t); GrB_Info GxB_Serialized_get_SIZE(const void *, size_t *, int, size_t); GrB_Info GxB_Serialized_get_String(const void *, char *, int, size_t); GrB_Info GxB_Serialized_get_VOID(const void *, void *, int, size_t); +GrB_Info GxB_arena_init(int arena, void *(*user_malloc_function)(size_t), void *(*user_calloc_function)(size_t, size_t), void *(*user_realloc_function)(void *, size_t), void (*user_free_function)(void *)); +GrB_Info GxB_arena_initialized(int *flag, int arena); GrB_Info GxB_deserialize_type_name(char *, const void *, uint64_t); +GrB_Info GxB_finalized(int *flag); GrB_Info GxB_init(int mode, void *(*user_malloc_function)(size_t), void *(*user_calloc_function)(size_t, size_t), void *(*user_realloc_function)(void *, size_t), void (*user_free_function)(void *)); +GrB_Info GxB_initialized(int *flag); +void GxB_atfork_child(void); +void GxB_atfork_parent(void); +void GxB_atfork_prepare(void); /* descriptor */ GrB_Info GxB_Desc_get(GrB_Descriptor, int, ...); @@ -3381,6 +3396,7 @@ GrB_Info GxB_Desc_set_FP64(GrB_Descriptor, int, double); GrB_Info GxB_Desc_set_INT32(GrB_Descriptor, int, int32_t); GrB_Info GxB_Descriptor_fprint(GrB_Descriptor descriptor, const char *name, int pr, FILE *f); GrB_Info GxB_Descriptor_get(int32_t *, GrB_Descriptor, int); +GrB_Info GxB_Descriptor_new_arena(GrB_Descriptor *descriptor, const int header_arena); /* indexbinary */ GrB_Info GxB_IndexBinaryOp_error(const char **error, const GxB_IndexBinaryOp object); @@ -3391,6 +3407,7 @@ GrB_Info GxB_IndexBinaryOp_get_SIZE(GxB_IndexBinaryOp object, size_t *, int); GrB_Info GxB_IndexBinaryOp_get_String(GxB_IndexBinaryOp object, char *, int); GrB_Info GxB_IndexBinaryOp_get_VOID(GxB_IndexBinaryOp object, void *, int); GrB_Info GxB_IndexBinaryOp_new(GxB_IndexBinaryOp *op, GxB_index_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, GrB_Type theta_type, const char *idxbinop_name, const char *idxbinop_defn); +GrB_Info GxB_IndexBinaryOp_new_arena(GxB_IndexBinaryOp *op_handle, GxB_index_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, GrB_Type theta_type, const char *idxop_name, const char *idxop_defn, const int header_arena); GrB_Info GxB_IndexBinaryOp_set_INT32(GxB_IndexBinaryOp object, int32_t, int); GrB_Info GxB_IndexBinaryOp_set_String(GxB_IndexBinaryOp object, char *, int); GrB_Info GxB_IndexBinaryOp_set_VOID(GxB_IndexBinaryOp object, void *, int, size_t); @@ -3399,6 +3416,7 @@ GrB_Info GxB_IndexBinaryOp_wait(GxB_IndexBinaryOp object, int waitmode); /* indexunary */ GrB_Info GxB_IndexUnaryOp_fprint(GrB_IndexUnaryOp op, const char *name, int pr, FILE *f); GrB_Info GxB_IndexUnaryOp_new(GrB_IndexUnaryOp *op, GxB_index_unary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *idxop_name, const char *idxop_defn); +GrB_Info GxB_IndexUnaryOp_new_arena(GrB_IndexUnaryOp *op_handle, GxB_index_unary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *idxop_name, const char *idxop_defn, const int header_arena); GrB_Info GxB_IndexUnaryOp_xtype_name(char *, const GrB_IndexUnaryOp); GrB_Info GxB_IndexUnaryOp_ytype_name(char *, const GrB_IndexUnaryOp); GrB_Info GxB_IndexUnaryOp_ztype_name(char *, const GrB_IndexUnaryOp); @@ -3417,6 +3435,7 @@ GrB_Index GxB_rowIterator_getRowIndex(GxB_Iterator iterator); GrB_Index GxB_rowIterator_kount(GxB_Iterator iterator); GrB_Info GxB_Iterator_free(GxB_Iterator *object); GrB_Info GxB_Iterator_new(GxB_Iterator *iterator); +GrB_Info GxB_Iterator_new_arena(GxB_Iterator *iterator, const int header_arena); GrB_Info GxB_Matrix_Iterator_next(GxB_Iterator iterator); GrB_Info GxB_Matrix_Iterator_seek(GxB_Iterator iterator, GrB_Index p); GrB_Info GxB_Vector_Iterator_next(GxB_Iterator iterator); @@ -3476,7 +3495,10 @@ GrB_Info GxB_Matrix_build_Scalar_Vector(GrB_Matrix C, const GrB_Vector I_vector, GrB_Info GxB_Matrix_build_Vector(GrB_Matrix C, const GrB_Vector I_vector, const GrB_Vector J_vector, const GrB_Vector X_vector, const GrB_BinaryOp dup, const GrB_Descriptor desc); GrB_Info GxB_Matrix_concat(GrB_Matrix C, const GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Descriptor desc); GrB_Info GxB_Matrix_deserialize(GrB_Matrix *C, GrB_Type type, const void *blob, GrB_Index blob_size, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_deserialize_arena(GrB_Matrix *C, GrB_Type type, const void *blob, uint64_t blob_memsize, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_diag(GrB_Matrix C, const GrB_Vector v, int64_t k, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_diag_arena(GrB_Matrix *C, const GrB_Vector v, int64_t k, const int header_arena, const int data_arena); +GrB_Info GxB_Matrix_dup_arena(GrB_Matrix *C, const GrB_Matrix A, const int header_arena, const int data_arena); GrB_Info GxB_Matrix_eWiseUnion(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_BinaryOp add, const GrB_Matrix A, const GrB_Scalar alpha, const GrB_Matrix B, const GrB_Scalar beta, const GrB_Descriptor desc); GrB_Info GxB_Matrix_export_BitmapC(GrB_Matrix *, GrB_Type *, uint64_t *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Matrix_export_BitmapR(GrB_Matrix *, GrB_Type *, uint64_t *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); @@ -3508,6 +3530,7 @@ GrB_Info GxB_Matrix_import_HyperCSR(GrB_Matrix *, GrB_Type, uint64_t, uint64_t, GrB_Info GxB_Matrix_isStoredElement(const GrB_Matrix A, GrB_Index i, GrB_Index j); GrB_Info GxB_Matrix_iso(bool *, const GrB_Matrix); GrB_Info GxB_Matrix_memoryUsage(size_t *size, const GrB_Matrix A); +GrB_Info GxB_Matrix_new_arena(GrB_Matrix *A, GrB_Type type, GrB_Index nrows, GrB_Index ncols, const int header_arena, const int data_arena); GrB_Info GxB_Matrix_pack_BitmapC(GrB_Matrix, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Matrix_pack_BitmapR(GrB_Matrix, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Matrix_pack_CSC(GrB_Matrix, uint64_t **, uint64_t **, void **, uint64_t, uint64_t, uint64_t, bool, bool, const GrB_Descriptor); @@ -3520,14 +3543,18 @@ GrB_Info GxB_Matrix_reduce_FC32(GxB_FC32_t *c, const GrB_BinaryOp accum, const G GrB_Info GxB_Matrix_reduce_FC64(GxB_FC64_t *c, const GrB_BinaryOp accum, const GrB_Monoid monoid, const GrB_Matrix A, const GrB_Descriptor desc); GrB_Info GxB_Matrix_reshape(GrB_Matrix C, bool by_col, GrB_Index nrows_new, GrB_Index ncols_new, const GrB_Descriptor desc); GrB_Info GxB_Matrix_reshapeDup(GrB_Matrix *C, GrB_Matrix A, bool by_col, GrB_Index nrows_new, GrB_Index ncols_new, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_reshapeDup_arena(GrB_Matrix *C, GrB_Matrix A, bool by_col, uint64_t nrows_new, uint64_t ncols_new, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_select(GrB_Matrix, const GrB_Matrix, const GrB_BinaryOp, const GxB_SelectOp, const GrB_Matrix, const GrB_Scalar, const GrB_Descriptor); GrB_Info GxB_Matrix_select_FC32(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, GxB_FC32_t y, const GrB_Descriptor desc); GrB_Info GxB_Matrix_select_FC64(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, GxB_FC64_t y, const GrB_Descriptor desc); -GrB_Info GxB_Matrix_serialize(void **blob_handle, GrB_Index *blob_size_handle, GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_serialize(void **blob_handle, GrB_Index *blob_size, GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_serialize_arena(void **blob_handle, GrB_Index *blob_size, GrB_Matrix A, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_setElement_FC32(GrB_Matrix C, GxB_FC32_t x, GrB_Index i, GrB_Index j); GrB_Info GxB_Matrix_setElement_FC64(GrB_Matrix C, GxB_FC64_t x, GrB_Index i, GrB_Index j); +GrB_Info GxB_Matrix_set_arenas(GrB_Matrix *Ahandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Matrix_sort(GrB_Matrix C, GrB_Matrix P, GrB_BinaryOp op, GrB_Matrix A, const GrB_Descriptor desc); GrB_Info GxB_Matrix_split(GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Index *Tile_nrows, const GrB_Index *Tile_ncols, const GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_split_arena(GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Index *Tile_nrows, const GrB_Index *Tile_ncols, const GrB_Matrix A, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_Matrix A, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign_BOOL(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, bool x, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign_FC32(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, GxB_FC32_t x, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); @@ -3572,6 +3599,20 @@ GrB_Info GxB_Monoid_fprint(GrB_Monoid monoid, const char *name, int pr, FILE *f) GrB_Info GxB_Monoid_identity(void *, GrB_Monoid); GrB_Info GxB_Monoid_new_FC32(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC32_t identity); GrB_Info GxB_Monoid_new_FC64(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC64_t identity); +GrB_Info GxB_Monoid_new_arena_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FC32(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC32_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FC64(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC64_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FP32(GrB_Monoid *monoid, GrB_BinaryOp op, float identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FP64(GrB_Monoid *monoid, GrB_BinaryOp op, double identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT8(GrB_Monoid *monoid, GrB_BinaryOp op, int8_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT16(GrB_Monoid *monoid, GrB_BinaryOp op, int16_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT32(GrB_Monoid *monoid, GrB_BinaryOp op, int32_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT64(GrB_Monoid *monoid, GrB_BinaryOp op, int64_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UDT(GrB_Monoid *monoid, GrB_BinaryOp op, void *identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint8_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, const int header_arena); GrB_Info GxB_Monoid_operator(GrB_BinaryOp *, GrB_Monoid); GrB_Info GxB_Monoid_terminal(bool *, void *, GrB_Monoid); GrB_Info GxB_Monoid_terminal_new_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, bool terminal); @@ -3588,15 +3629,31 @@ GrB_Info GxB_Monoid_terminal_new_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint GrB_Info GxB_Monoid_terminal_new_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, uint16_t terminal); GrB_Info GxB_Monoid_terminal_new_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, uint32_t terminal); GrB_Info GxB_Monoid_terminal_new_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, uint64_t terminal); +GrB_Info GxB_Monoid_terminal_new_arena_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, bool terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FC32(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC32_t identity, GxB_FC32_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FC64(GrB_Monoid *monoid, GrB_BinaryOp op, GxB_FC64_t identity, GxB_FC64_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FP32(GrB_Monoid *monoid, GrB_BinaryOp op, float identity, float terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FP64(GrB_Monoid *monoid, GrB_BinaryOp op, double identity, double terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT8(GrB_Monoid *monoid, GrB_BinaryOp op, int8_t identity, int8_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT16(GrB_Monoid *monoid, GrB_BinaryOp op, int16_t identity, int16_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT32(GrB_Monoid *monoid, GrB_BinaryOp op, int32_t identity, int32_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT64(GrB_Monoid *monoid, GrB_BinaryOp op, int64_t identity, int64_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UDT(GrB_Monoid *monoid, GrB_BinaryOp op, void *identity, void *terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint8_t identity, uint8_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, uint16_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, uint32_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, uint64_t terminal, const int header_arena); /* scalar */ GrB_Info GxB_BinaryOp_new_IndexOp(GrB_BinaryOp *binop, GxB_IndexBinaryOp idxbinop, GrB_Scalar theta); +GrB_Info GxB_BinaryOp_new_IndexOp_arena(GrB_BinaryOp *binop_handle, GxB_IndexBinaryOp idxbinop, GrB_Scalar theta, const int header_arena); GrB_Info GxB_Context_get_Scalar(GxB_Context, GrB_Scalar, int); GrB_Info GxB_Context_set_Scalar(GxB_Context, GrB_Scalar, int); GrB_Info GxB_IndexBinaryOp_get_Scalar(GxB_IndexBinaryOp object, GrB_Scalar, int); GrB_Info GxB_IndexBinaryOp_set_Scalar(GxB_IndexBinaryOp object, GrB_Scalar, int); GrB_Info GxB_Scalar_clear(GrB_Scalar); GrB_Info GxB_Scalar_dup(GrB_Scalar *, const GrB_Scalar); +GrB_Info GxB_Scalar_dup_arena(GrB_Scalar *s, const GrB_Scalar t, const int header_arena, const int data_arena); GrB_Info GxB_Scalar_error(const char **, const GrB_Scalar); GrB_Info GxB_Scalar_extractElement_BOOL(bool *, const GrB_Scalar); GrB_Info GxB_Scalar_extractElement_FC32(GxB_FC32_t *x, const GrB_Scalar s); @@ -3616,6 +3673,7 @@ GrB_Info GxB_Scalar_fprint(GrB_Scalar s, const char *name, int pr, FILE *f); GrB_Info GxB_Scalar_free(GrB_Scalar *); GrB_Info GxB_Scalar_memoryUsage(size_t *size, const GrB_Scalar s); GrB_Info GxB_Scalar_new(GrB_Scalar *, GrB_Type); +GrB_Info GxB_Scalar_new_arena(GrB_Scalar *s, GrB_Type type, const int header_arena, const int data_arena); GrB_Info GxB_Scalar_nvals(uint64_t *, const GrB_Scalar); GrB_Info GxB_Scalar_setElement_BOOL(GrB_Scalar, bool); GrB_Info GxB_Scalar_setElement_FC32(GrB_Scalar s, GxB_FC32_t x); @@ -3631,6 +3689,7 @@ GrB_Info GxB_Scalar_setElement_UINT8(GrB_Scalar, uint8_t); GrB_Info GxB_Scalar_setElement_UINT16(GrB_Scalar, uint16_t); GrB_Info GxB_Scalar_setElement_UINT32(GrB_Scalar, uint32_t); GrB_Info GxB_Scalar_setElement_UINT64(GrB_Scalar, uint64_t); +GrB_Info GxB_Scalar_set_arenas(GrB_Scalar *Shandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Scalar_type(GrB_Type *type, const GrB_Scalar s); GrB_Info GxB_Scalar_type_name(char *, const GrB_Scalar); GrB_Info GxB_Scalar_wait(GrB_Scalar *); @@ -3645,17 +3704,20 @@ GrB_Info GxB_SelectOp_xtype(GrB_Type *, GxB_SelectOp); GrB_Info GxB_Semiring_add(GrB_Monoid *, GrB_Semiring); GrB_Info GxB_Semiring_fprint(GrB_Semiring semiring, const char *name, int pr, FILE *f); GrB_Info GxB_Semiring_multiply(GrB_BinaryOp *, GrB_Semiring); +GrB_Info GxB_Semiring_new_arena(GrB_Semiring *semiring, GrB_Monoid add, GrB_BinaryOp multiply, const int header_arena); /* type */ GrB_Info GxB_Type_fprint(GrB_Type type, const char *name, int pr, FILE *f); GrB_Info GxB_Type_from_name(GrB_Type *type, const char *type_name); GrB_Info GxB_Type_name(char *, const GrB_Type); GrB_Info GxB_Type_new(GrB_Type *type, size_t sizeof_ctype, const char *type_name, const char *type_defn); +GrB_Info GxB_Type_new_arena(GrB_Type *type, size_t sizeof_type, const char *type_name, const char *type_defn, const int header_arena); GrB_Info GxB_Type_size(size_t *, const GrB_Type); /* unary */ GrB_Info GxB_UnaryOp_fprint(GrB_UnaryOp unaryop, const char *name, int pr, FILE *f); GrB_Info GxB_UnaryOp_new(GrB_UnaryOp *unaryop, GxB_unary_function function, GrB_Type ztype, GrB_Type xtype, const char *unop_name, const char *unop_defn); +GrB_Info GxB_UnaryOp_new_arena(GrB_UnaryOp *op_handle, GxB_unary_function function, GrB_Type ztype, GrB_Type xtype, const char *unop_name, const char *unop_defn, const int header_arena); GrB_Info GxB_UnaryOp_xtype(GrB_Type *, GrB_UnaryOp); GrB_Info GxB_UnaryOp_xtype_name(char *, const GrB_UnaryOp); GrB_Info GxB_UnaryOp_ztype(GrB_Type *, GrB_UnaryOp); @@ -3687,6 +3749,8 @@ GrB_Info GxB_Vector_build_Scalar(GrB_Vector w, const GrB_Index *I_, const GrB_Sc GrB_Info GxB_Vector_build_Scalar_Vector(GrB_Vector w, const GrB_Vector I_vector, const GrB_Scalar scalar, const GrB_Descriptor desc); GrB_Info GxB_Vector_build_Vector(GrB_Vector w, const GrB_Vector I_vector, const GrB_Vector X_vector, const GrB_BinaryOp dup, const GrB_Descriptor desc); GrB_Info GxB_Vector_deserialize(GrB_Vector *w, GrB_Type type, const void *blob, GrB_Index blob_size, const GrB_Descriptor desc); +GrB_Info GxB_Vector_deserialize_arena(GrB_Vector *w, GrB_Type type, const void *blob, GrB_Index blob_size, const int header_arena, const int data_arena, const GrB_Descriptor desc); +GrB_Info GxB_Vector_dup_arena(GrB_Vector *w, const GrB_Vector u, const int header_arena, const int data_arena); GrB_Info GxB_Vector_eWiseUnion(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_BinaryOp add, const GrB_Vector u, const GrB_Scalar alpha, const GrB_Vector v, const GrB_Scalar beta, const GrB_Descriptor desc); GrB_Info GxB_Vector_export_Bitmap(GrB_Vector *, GrB_Type *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Vector_export_CSC(GrB_Vector *, GrB_Type *, uint64_t *, uint64_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, bool *, const GrB_Descriptor); @@ -3703,8 +3767,9 @@ GrB_Info GxB_Vector_import_CSC(GrB_Vector *, GrB_Type, uint64_t, uint64_t **, vo GrB_Info GxB_Vector_import_Full(GrB_Vector *, GrB_Type, uint64_t, void **, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Vector_isStoredElement(const GrB_Vector v, GrB_Index i); GrB_Info GxB_Vector_iso(bool *, const GrB_Vector); -GrB_Info GxB_Vector_load(GrB_Vector V, void **X, GrB_Type type, uint64_t n, uint64_t X_size, int handling, const GrB_Descriptor desc); +GrB_Info GxB_Vector_load(GrB_Vector V, void **X, GrB_Type type, uint64_t n, uint64_t X_memsize, int handling, const GrB_Descriptor desc); GrB_Info GxB_Vector_memoryUsage(size_t *size, const GrB_Vector v); +GrB_Info GxB_Vector_new_arena(GrB_Vector *v, GrB_Type type, GrB_Index n, const int header_arena, const int data_arena); GrB_Info GxB_Vector_pack_Bitmap(GrB_Vector, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Vector_pack_CSC(GrB_Vector, uint64_t **, void **, uint64_t, uint64_t, bool, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Vector_pack_Full(GrB_Vector, void **, uint64_t, bool, const GrB_Descriptor); @@ -3713,9 +3778,11 @@ GrB_Info GxB_Vector_reduce_FC64(GxB_FC64_t *c, const GrB_BinaryOp accum, const G GrB_Info GxB_Vector_select(GrB_Vector, const GrB_Vector, const GrB_BinaryOp, const GxB_SelectOp, const GrB_Vector, const GrB_Scalar, const GrB_Descriptor); GrB_Info GxB_Vector_select_FC32(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Vector u, GxB_FC32_t y, const GrB_Descriptor desc); GrB_Info GxB_Vector_select_FC64(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Vector u, GxB_FC64_t y, const GrB_Descriptor desc); -GrB_Info GxB_Vector_serialize(void **blob_handle, GrB_Index *blob_size_handle, GrB_Vector u, const GrB_Descriptor desc); +GrB_Info GxB_Vector_serialize(void **blob_handle, GrB_Index *blob_size, GrB_Vector u, const GrB_Descriptor desc); +GrB_Info GxB_Vector_serialize_arena(void **blob_handle, GrB_Index *blob_size, GrB_Vector u, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Vector_setElement_FC32(GrB_Vector w, GxB_FC32_t x, GrB_Index i); GrB_Info GxB_Vector_setElement_FC64(GrB_Vector w, GxB_FC64_t x, GrB_Index i); +GrB_Info GxB_Vector_set_arenas(GrB_Vector *Vhandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Vector_sort(GrB_Vector w, GrB_Vector p, GrB_BinaryOp op, GrB_Vector u, const GrB_Descriptor desc); GrB_Info GxB_Vector_subassign(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_Vector u, const GrB_Index *I_, GrB_Index ni, const GrB_Descriptor desc); GrB_Info GxB_Vector_subassign_BOOL(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, bool x, const GrB_Index *I_, GrB_Index ni, const GrB_Descriptor desc); @@ -3737,7 +3804,7 @@ GrB_Info GxB_Vector_subassign_UINT64(GrB_Vector w, const GrB_Vector mask, const GrB_Info GxB_Vector_subassign_Vector(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_Vector u, const GrB_Vector I_vector, const GrB_Descriptor desc); GrB_Info GxB_Vector_type(GrB_Type *type, const GrB_Vector v); GrB_Info GxB_Vector_type_name(char *, const GrB_Vector); -GrB_Info GxB_Vector_unload(GrB_Vector V, void **X, GrB_Type *type, uint64_t *n, uint64_t *X_size, int *handling, const GrB_Descriptor desc); +GrB_Info GxB_Vector_unload(GrB_Vector V, void **X, GrB_Type *type, uint64_t *n, uint64_t *X_memsize, int *handling, const GrB_Descriptor desc); GrB_Info GxB_Vector_unpack_Bitmap(GrB_Vector, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Vector_unpack_CSC(GrB_Vector, uint64_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, bool *, const GrB_Descriptor); GrB_Info GxB_Vector_unpack_Full(GrB_Vector, void **, uint64_t *, bool *, const GrB_Descriptor); @@ -3749,6 +3816,8 @@ GrB_Info GxB_unload_Vector_into_Container(GrB_Vector V, GxB_Container Container, #define GRB_VERSION ... #define GrB_INDEX_MAX ... #define GxB_ANY_SPARSITY ... +#define GxB_ARENA_DATA ... +#define GxB_ARENA_HEADER ... #define GxB_AUTO_SPARSITY ... #define GxB_BACKWARDS ... #define GxB_BEGIN ... @@ -3771,6 +3840,7 @@ GrB_Info GxB_unload_Vector_into_Container(GrB_Vector V, GxB_Container Container, #define GxB_INC ... #define GxB_INDEX_MAX ... #define GxB_MAX_NAME_LEN ... +#define GxB_NARENAS ... #define GxB_NBITMAP_SWITCH ... #define GxB_NGPUS ... #define GxB_NTHREADS ... diff --git a/suitesparse_graphblas/suitesparse_graphblas_no_complex.h b/suitesparse_graphblas/suitesparse_graphblas_no_complex.h index 4376bec..dea3086 100644 --- a/suitesparse_graphblas/suitesparse_graphblas_no_complex.h +++ b/suitesparse_graphblas/suitesparse_graphblas_no_complex.h @@ -22,7 +22,7 @@ typedef struct GB_SelectOp_opaque *GxB_SelectOp; typedef struct GxB_Container_struct *GxB_Container; /* GxB typedefs (functions) */ -typedef int64_t (*GxB_print_function)(char *string, size_t string_size, const void *value, int verbose); +typedef int64_t (*GxB_print_function)(char *string, size_t string_len, const void *value, int verbose); typedef void (*GxB_binary_function)(void *, const void *, const void *); typedef void (*GxB_index_binary_function)(void *, const void *, GrB_Index, GrB_Index, const void *, GrB_Index, GrB_Index, const void *); typedef void (*GxB_index_unary_function)(void *z, const void *x, GrB_Index i, GrB_Index j, const void *y); @@ -39,7 +39,8 @@ struct GxB_Container_struct uint64_t u64_future[11]; int32_t format; int32_t orientation; - uint32_t u32_future[14]; + int32_t header_arena; + uint32_t u32_future[13]; GrB_Vector p; GrB_Vector h; GrB_Vector b; @@ -252,6 +253,10 @@ typedef enum GxB_CALLOC_FUNCTION = 7038, GxB_REALLOC_FUNCTION = 7039, GxB_FREE_FUNCTION = 7040, + GxB_ARENA_MALLOC = 0x10000, + GxB_ARENA_CALLOC = 0x20000, + GxB_ARENA_REALLOC = 0x30000, + GxB_ARENA_FREE = 0x40000, GxB_GLOBAL_NTHREADS = 7086, GxB_GLOBAL_CHUNK = 7087, GxB_GLOBAL_NGPUS = 7102, @@ -2817,8 +2822,8 @@ GrB_Info GrB_Matrix_select_UINT8(GrB_Matrix C, const GrB_Matrix Mask, const GrB_ GrB_Info GrB_Matrix_select_UINT16(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint16_t y, const GrB_Descriptor desc); GrB_Info GrB_Matrix_select_UINT32(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint32_t y, const GrB_Descriptor desc); GrB_Info GrB_Matrix_select_UINT64(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_IndexUnaryOp op, const GrB_Matrix A, uint64_t y, const GrB_Descriptor desc); -GrB_Info GrB_Matrix_serialize(void *blob, GrB_Index *blob_size_handle, GrB_Matrix A); -GrB_Info GrB_Matrix_serializeSize(GrB_Index *blob_size_handle, GrB_Matrix A); +GrB_Info GrB_Matrix_serialize(void *blob, GrB_Index *blob_size, GrB_Matrix A); +GrB_Info GrB_Matrix_serializeSize(GrB_Index *blob_size, GrB_Matrix A); GrB_Info GrB_Matrix_setElement_BOOL(GrB_Matrix C, bool x, GrB_Index i, GrB_Index j); GrB_Info GrB_Matrix_setElement_FP32(GrB_Matrix C, float x, GrB_Index i, GrB_Index j); GrB_Info GrB_Matrix_setElement_FP64(GrB_Matrix C, double x, GrB_Index i, GrB_Index j); @@ -3142,6 +3147,7 @@ GrB_Info GB_Iterator_attach(GxB_Iterator iterator, GrB_Matrix A, int format, GrB /* binary */ GrB_Info GxB_BinaryOp_fprint(GrB_BinaryOp binaryop, const char *name, int pr, FILE *f); GrB_Info GxB_BinaryOp_new(GrB_BinaryOp *op, GxB_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *binop_name, const char *binop_defn); +GrB_Info GxB_BinaryOp_new_arena(GrB_BinaryOp *op_handle, GxB_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *binop_name, const char *binop_defn, const int header_arena); GrB_Info GxB_BinaryOp_xtype(GrB_Type *, GrB_BinaryOp); GrB_Info GxB_BinaryOp_xtype_name(char *, const GrB_BinaryOp); GrB_Info GxB_BinaryOp_ytype(GrB_Type *, GrB_BinaryOp); @@ -3152,6 +3158,7 @@ GrB_Info GxB_BinaryOp_ztype_name(char *, const GrB_BinaryOp); /* container */ GrB_Info GxB_Container_free(GxB_Container *object); GrB_Info GxB_Container_new(GxB_Container *Container); +GrB_Info GxB_Container_new_arena(GxB_Container *Container, const int header_arena, const int data_arena); /* context */ GrB_Info GxB_Context_disengage(GxB_Context Context); @@ -3167,6 +3174,7 @@ GrB_Info GxB_Context_get_SIZE(GxB_Context, size_t *, int); GrB_Info GxB_Context_get_String(GxB_Context, char *, int); GrB_Info GxB_Context_get_VOID(GxB_Context, void *, int); GrB_Info GxB_Context_new(GxB_Context *Context); +GrB_Info GxB_Context_new_arena(GxB_Context *Context_handle, const int header_arena); GrB_Info GxB_Context_set(GxB_Context, int, ...); GrB_Info GxB_Context_set_FP64(GxB_Context, int, double); GrB_Info GxB_Context_set_INT(GxB_Context, int32_t, int); @@ -3193,8 +3201,15 @@ GrB_Info GxB_Serialized_get_INT32(const void *, int32_t *, int, size_t); GrB_Info GxB_Serialized_get_SIZE(const void *, size_t *, int, size_t); GrB_Info GxB_Serialized_get_String(const void *, char *, int, size_t); GrB_Info GxB_Serialized_get_VOID(const void *, void *, int, size_t); +GrB_Info GxB_arena_init(int arena, void *(*user_malloc_function)(size_t), void *(*user_calloc_function)(size_t, size_t), void *(*user_realloc_function)(void *, size_t), void (*user_free_function)(void *)); +GrB_Info GxB_arena_initialized(int *flag, int arena); GrB_Info GxB_deserialize_type_name(char *, const void *, uint64_t); +GrB_Info GxB_finalized(int *flag); GrB_Info GxB_init(int mode, void *(*user_malloc_function)(size_t), void *(*user_calloc_function)(size_t, size_t), void *(*user_realloc_function)(void *, size_t), void (*user_free_function)(void *)); +GrB_Info GxB_initialized(int *flag); +void GxB_atfork_child(void); +void GxB_atfork_parent(void); +void GxB_atfork_prepare(void); /* descriptor */ GrB_Info GxB_Desc_get(GrB_Descriptor, int, ...); @@ -3205,6 +3220,7 @@ GrB_Info GxB_Desc_set_FP64(GrB_Descriptor, int, double); GrB_Info GxB_Desc_set_INT32(GrB_Descriptor, int, int32_t); GrB_Info GxB_Descriptor_fprint(GrB_Descriptor descriptor, const char *name, int pr, FILE *f); GrB_Info GxB_Descriptor_get(int32_t *, GrB_Descriptor, int); +GrB_Info GxB_Descriptor_new_arena(GrB_Descriptor *descriptor, const int header_arena); /* indexbinary */ GrB_Info GxB_IndexBinaryOp_error(const char **error, const GxB_IndexBinaryOp object); @@ -3215,6 +3231,7 @@ GrB_Info GxB_IndexBinaryOp_get_SIZE(GxB_IndexBinaryOp object, size_t *, int); GrB_Info GxB_IndexBinaryOp_get_String(GxB_IndexBinaryOp object, char *, int); GrB_Info GxB_IndexBinaryOp_get_VOID(GxB_IndexBinaryOp object, void *, int); GrB_Info GxB_IndexBinaryOp_new(GxB_IndexBinaryOp *op, GxB_index_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, GrB_Type theta_type, const char *idxbinop_name, const char *idxbinop_defn); +GrB_Info GxB_IndexBinaryOp_new_arena(GxB_IndexBinaryOp *op_handle, GxB_index_binary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, GrB_Type theta_type, const char *idxop_name, const char *idxop_defn, const int header_arena); GrB_Info GxB_IndexBinaryOp_set_INT32(GxB_IndexBinaryOp object, int32_t, int); GrB_Info GxB_IndexBinaryOp_set_String(GxB_IndexBinaryOp object, char *, int); GrB_Info GxB_IndexBinaryOp_set_VOID(GxB_IndexBinaryOp object, void *, int, size_t); @@ -3223,6 +3240,7 @@ GrB_Info GxB_IndexBinaryOp_wait(GxB_IndexBinaryOp object, int waitmode); /* indexunary */ GrB_Info GxB_IndexUnaryOp_fprint(GrB_IndexUnaryOp op, const char *name, int pr, FILE *f); GrB_Info GxB_IndexUnaryOp_new(GrB_IndexUnaryOp *op, GxB_index_unary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *idxop_name, const char *idxop_defn); +GrB_Info GxB_IndexUnaryOp_new_arena(GrB_IndexUnaryOp *op_handle, GxB_index_unary_function function, GrB_Type ztype, GrB_Type xtype, GrB_Type ytype, const char *idxop_name, const char *idxop_defn, const int header_arena); GrB_Info GxB_IndexUnaryOp_xtype_name(char *, const GrB_IndexUnaryOp); GrB_Info GxB_IndexUnaryOp_ytype_name(char *, const GrB_IndexUnaryOp); GrB_Info GxB_IndexUnaryOp_ztype_name(char *, const GrB_IndexUnaryOp); @@ -3241,6 +3259,7 @@ GrB_Index GxB_rowIterator_getRowIndex(GxB_Iterator iterator); GrB_Index GxB_rowIterator_kount(GxB_Iterator iterator); GrB_Info GxB_Iterator_free(GxB_Iterator *object); GrB_Info GxB_Iterator_new(GxB_Iterator *iterator); +GrB_Info GxB_Iterator_new_arena(GxB_Iterator *iterator, const int header_arena); GrB_Info GxB_Matrix_Iterator_next(GxB_Iterator iterator); GrB_Info GxB_Matrix_Iterator_seek(GxB_Iterator iterator, GrB_Index p); GrB_Info GxB_Vector_Iterator_next(GxB_Iterator iterator); @@ -3288,7 +3307,10 @@ GrB_Info GxB_Matrix_build_Scalar_Vector(GrB_Matrix C, const GrB_Vector I_vector, GrB_Info GxB_Matrix_build_Vector(GrB_Matrix C, const GrB_Vector I_vector, const GrB_Vector J_vector, const GrB_Vector X_vector, const GrB_BinaryOp dup, const GrB_Descriptor desc); GrB_Info GxB_Matrix_concat(GrB_Matrix C, const GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Descriptor desc); GrB_Info GxB_Matrix_deserialize(GrB_Matrix *C, GrB_Type type, const void *blob, GrB_Index blob_size, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_deserialize_arena(GrB_Matrix *C, GrB_Type type, const void *blob, uint64_t blob_memsize, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_diag(GrB_Matrix C, const GrB_Vector v, int64_t k, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_diag_arena(GrB_Matrix *C, const GrB_Vector v, int64_t k, const int header_arena, const int data_arena); +GrB_Info GxB_Matrix_dup_arena(GrB_Matrix *C, const GrB_Matrix A, const int header_arena, const int data_arena); GrB_Info GxB_Matrix_eWiseUnion(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_BinaryOp add, const GrB_Matrix A, const GrB_Scalar alpha, const GrB_Matrix B, const GrB_Scalar beta, const GrB_Descriptor desc); GrB_Info GxB_Matrix_export_BitmapC(GrB_Matrix *, GrB_Type *, uint64_t *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Matrix_export_BitmapR(GrB_Matrix *, GrB_Type *, uint64_t *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); @@ -3312,6 +3334,7 @@ GrB_Info GxB_Matrix_import_HyperCSR(GrB_Matrix *, GrB_Type, uint64_t, uint64_t, GrB_Info GxB_Matrix_isStoredElement(const GrB_Matrix A, GrB_Index i, GrB_Index j); GrB_Info GxB_Matrix_iso(bool *, const GrB_Matrix); GrB_Info GxB_Matrix_memoryUsage(size_t *size, const GrB_Matrix A); +GrB_Info GxB_Matrix_new_arena(GrB_Matrix *A, GrB_Type type, GrB_Index nrows, GrB_Index ncols, const int header_arena, const int data_arena); GrB_Info GxB_Matrix_pack_BitmapC(GrB_Matrix, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Matrix_pack_BitmapR(GrB_Matrix, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Matrix_pack_CSC(GrB_Matrix, uint64_t **, uint64_t **, void **, uint64_t, uint64_t, uint64_t, bool, bool, const GrB_Descriptor); @@ -3322,10 +3345,14 @@ GrB_Info GxB_Matrix_pack_HyperCSC(GrB_Matrix, uint64_t **, uint64_t **, uint64_t GrB_Info GxB_Matrix_pack_HyperCSR(GrB_Matrix, uint64_t **, uint64_t **, uint64_t **, void **, uint64_t, uint64_t, uint64_t, uint64_t, bool, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Matrix_reshape(GrB_Matrix C, bool by_col, GrB_Index nrows_new, GrB_Index ncols_new, const GrB_Descriptor desc); GrB_Info GxB_Matrix_reshapeDup(GrB_Matrix *C, GrB_Matrix A, bool by_col, GrB_Index nrows_new, GrB_Index ncols_new, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_reshapeDup_arena(GrB_Matrix *C, GrB_Matrix A, bool by_col, uint64_t nrows_new, uint64_t ncols_new, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_select(GrB_Matrix, const GrB_Matrix, const GrB_BinaryOp, const GxB_SelectOp, const GrB_Matrix, const GrB_Scalar, const GrB_Descriptor); -GrB_Info GxB_Matrix_serialize(void **blob_handle, GrB_Index *blob_size_handle, GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_serialize(void **blob_handle, GrB_Index *blob_size, GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_serialize_arena(void **blob_handle, GrB_Index *blob_size, GrB_Matrix A, const int data_arena, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_set_arenas(GrB_Matrix *Ahandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Matrix_sort(GrB_Matrix C, GrB_Matrix P, GrB_BinaryOp op, GrB_Matrix A, const GrB_Descriptor desc); GrB_Info GxB_Matrix_split(GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Index *Tile_nrows, const GrB_Index *Tile_ncols, const GrB_Matrix A, const GrB_Descriptor desc); +GrB_Info GxB_Matrix_split_arena(GrB_Matrix *Tiles, const GrB_Index m, const GrB_Index n, const GrB_Index *Tile_nrows, const GrB_Index *Tile_ncols, const GrB_Matrix A, const int header_arena, const int data_arena, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_Matrix A, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign_BOOL(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, bool x, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); GrB_Info GxB_Matrix_subassign_FP32(GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, float x, const GrB_Index *I_, GrB_Index ni, const GrB_Index *J, GrB_Index nj, const GrB_Descriptor desc); @@ -3366,6 +3393,18 @@ GrB_Info GxB_unpack_HyperHash(GrB_Matrix, GrB_Matrix *, const GrB_Descriptor); /* monoid */ GrB_Info GxB_Monoid_fprint(GrB_Monoid monoid, const char *name, int pr, FILE *f); GrB_Info GxB_Monoid_identity(void *, GrB_Monoid); +GrB_Info GxB_Monoid_new_arena_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FP32(GrB_Monoid *monoid, GrB_BinaryOp op, float identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_FP64(GrB_Monoid *monoid, GrB_BinaryOp op, double identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT8(GrB_Monoid *monoid, GrB_BinaryOp op, int8_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT16(GrB_Monoid *monoid, GrB_BinaryOp op, int16_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT32(GrB_Monoid *monoid, GrB_BinaryOp op, int32_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_INT64(GrB_Monoid *monoid, GrB_BinaryOp op, int64_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UDT(GrB_Monoid *monoid, GrB_BinaryOp op, void *identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint8_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, const int header_arena); +GrB_Info GxB_Monoid_new_arena_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, const int header_arena); GrB_Info GxB_Monoid_operator(GrB_BinaryOp *, GrB_Monoid); GrB_Info GxB_Monoid_terminal(bool *, void *, GrB_Monoid); GrB_Info GxB_Monoid_terminal_new_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, bool terminal); @@ -3380,15 +3419,29 @@ GrB_Info GxB_Monoid_terminal_new_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint GrB_Info GxB_Monoid_terminal_new_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, uint16_t terminal); GrB_Info GxB_Monoid_terminal_new_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, uint32_t terminal); GrB_Info GxB_Monoid_terminal_new_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, uint64_t terminal); +GrB_Info GxB_Monoid_terminal_new_arena_BOOL(GrB_Monoid *monoid, GrB_BinaryOp op, bool identity, bool terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FP32(GrB_Monoid *monoid, GrB_BinaryOp op, float identity, float terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_FP64(GrB_Monoid *monoid, GrB_BinaryOp op, double identity, double terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT8(GrB_Monoid *monoid, GrB_BinaryOp op, int8_t identity, int8_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT16(GrB_Monoid *monoid, GrB_BinaryOp op, int16_t identity, int16_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT32(GrB_Monoid *monoid, GrB_BinaryOp op, int32_t identity, int32_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_INT64(GrB_Monoid *monoid, GrB_BinaryOp op, int64_t identity, int64_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UDT(GrB_Monoid *monoid, GrB_BinaryOp op, void *identity, void *terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT8(GrB_Monoid *monoid, GrB_BinaryOp op, uint8_t identity, uint8_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT16(GrB_Monoid *monoid, GrB_BinaryOp op, uint16_t identity, uint16_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT32(GrB_Monoid *monoid, GrB_BinaryOp op, uint32_t identity, uint32_t terminal, const int header_arena); +GrB_Info GxB_Monoid_terminal_new_arena_UINT64(GrB_Monoid *monoid, GrB_BinaryOp op, uint64_t identity, uint64_t terminal, const int header_arena); /* scalar */ GrB_Info GxB_BinaryOp_new_IndexOp(GrB_BinaryOp *binop, GxB_IndexBinaryOp idxbinop, GrB_Scalar theta); +GrB_Info GxB_BinaryOp_new_IndexOp_arena(GrB_BinaryOp *binop_handle, GxB_IndexBinaryOp idxbinop, GrB_Scalar theta, const int header_arena); GrB_Info GxB_Context_get_Scalar(GxB_Context, GrB_Scalar, int); GrB_Info GxB_Context_set_Scalar(GxB_Context, GrB_Scalar, int); GrB_Info GxB_IndexBinaryOp_get_Scalar(GxB_IndexBinaryOp object, GrB_Scalar, int); GrB_Info GxB_IndexBinaryOp_set_Scalar(GxB_IndexBinaryOp object, GrB_Scalar, int); GrB_Info GxB_Scalar_clear(GrB_Scalar); GrB_Info GxB_Scalar_dup(GrB_Scalar *, const GrB_Scalar); +GrB_Info GxB_Scalar_dup_arena(GrB_Scalar *s, const GrB_Scalar t, const int header_arena, const int data_arena); GrB_Info GxB_Scalar_error(const char **, const GrB_Scalar); GrB_Info GxB_Scalar_extractElement_BOOL(bool *, const GrB_Scalar); GrB_Info GxB_Scalar_extractElement_FP32(float *, const GrB_Scalar); @@ -3406,6 +3459,7 @@ GrB_Info GxB_Scalar_fprint(GrB_Scalar s, const char *name, int pr, FILE *f); GrB_Info GxB_Scalar_free(GrB_Scalar *); GrB_Info GxB_Scalar_memoryUsage(size_t *size, const GrB_Scalar s); GrB_Info GxB_Scalar_new(GrB_Scalar *, GrB_Type); +GrB_Info GxB_Scalar_new_arena(GrB_Scalar *s, GrB_Type type, const int header_arena, const int data_arena); GrB_Info GxB_Scalar_nvals(uint64_t *, const GrB_Scalar); GrB_Info GxB_Scalar_setElement_BOOL(GrB_Scalar, bool); GrB_Info GxB_Scalar_setElement_FP32(GrB_Scalar, float); @@ -3419,6 +3473,7 @@ GrB_Info GxB_Scalar_setElement_UINT8(GrB_Scalar, uint8_t); GrB_Info GxB_Scalar_setElement_UINT16(GrB_Scalar, uint16_t); GrB_Info GxB_Scalar_setElement_UINT32(GrB_Scalar, uint32_t); GrB_Info GxB_Scalar_setElement_UINT64(GrB_Scalar, uint64_t); +GrB_Info GxB_Scalar_set_arenas(GrB_Scalar *Shandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Scalar_type(GrB_Type *type, const GrB_Scalar s); GrB_Info GxB_Scalar_type_name(char *, const GrB_Scalar); GrB_Info GxB_Scalar_wait(GrB_Scalar *); @@ -3433,17 +3488,20 @@ GrB_Info GxB_SelectOp_xtype(GrB_Type *, GxB_SelectOp); GrB_Info GxB_Semiring_add(GrB_Monoid *, GrB_Semiring); GrB_Info GxB_Semiring_fprint(GrB_Semiring semiring, const char *name, int pr, FILE *f); GrB_Info GxB_Semiring_multiply(GrB_BinaryOp *, GrB_Semiring); +GrB_Info GxB_Semiring_new_arena(GrB_Semiring *semiring, GrB_Monoid add, GrB_BinaryOp multiply, const int header_arena); /* type */ GrB_Info GxB_Type_fprint(GrB_Type type, const char *name, int pr, FILE *f); GrB_Info GxB_Type_from_name(GrB_Type *type, const char *type_name); GrB_Info GxB_Type_name(char *, const GrB_Type); GrB_Info GxB_Type_new(GrB_Type *type, size_t sizeof_ctype, const char *type_name, const char *type_defn); +GrB_Info GxB_Type_new_arena(GrB_Type *type, size_t sizeof_type, const char *type_name, const char *type_defn, const int header_arena); GrB_Info GxB_Type_size(size_t *, const GrB_Type); /* unary */ GrB_Info GxB_UnaryOp_fprint(GrB_UnaryOp unaryop, const char *name, int pr, FILE *f); GrB_Info GxB_UnaryOp_new(GrB_UnaryOp *unaryop, GxB_unary_function function, GrB_Type ztype, GrB_Type xtype, const char *unop_name, const char *unop_defn); +GrB_Info GxB_UnaryOp_new_arena(GrB_UnaryOp *op_handle, GxB_unary_function function, GrB_Type ztype, GrB_Type xtype, const char *unop_name, const char *unop_defn, const int header_arena); GrB_Info GxB_UnaryOp_xtype(GrB_Type *, GrB_UnaryOp); GrB_Info GxB_UnaryOp_xtype_name(char *, const GrB_UnaryOp); GrB_Info GxB_UnaryOp_ztype(GrB_Type *, GrB_UnaryOp); @@ -3465,6 +3523,8 @@ GrB_Info GxB_Vector_build_Scalar(GrB_Vector w, const GrB_Index *I_, const GrB_Sc GrB_Info GxB_Vector_build_Scalar_Vector(GrB_Vector w, const GrB_Vector I_vector, const GrB_Scalar scalar, const GrB_Descriptor desc); GrB_Info GxB_Vector_build_Vector(GrB_Vector w, const GrB_Vector I_vector, const GrB_Vector X_vector, const GrB_BinaryOp dup, const GrB_Descriptor desc); GrB_Info GxB_Vector_deserialize(GrB_Vector *w, GrB_Type type, const void *blob, GrB_Index blob_size, const GrB_Descriptor desc); +GrB_Info GxB_Vector_deserialize_arena(GrB_Vector *w, GrB_Type type, const void *blob, GrB_Index blob_size, const int header_arena, const int data_arena, const GrB_Descriptor desc); +GrB_Info GxB_Vector_dup_arena(GrB_Vector *w, const GrB_Vector u, const int header_arena, const int data_arena); GrB_Info GxB_Vector_eWiseUnion(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_BinaryOp add, const GrB_Vector u, const GrB_Scalar alpha, const GrB_Vector v, const GrB_Scalar beta, const GrB_Descriptor desc); GrB_Info GxB_Vector_export_Bitmap(GrB_Vector *, GrB_Type *, uint64_t *, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Vector_export_CSC(GrB_Vector *, GrB_Type *, uint64_t *, uint64_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, bool *, const GrB_Descriptor); @@ -3477,13 +3537,16 @@ GrB_Info GxB_Vector_import_CSC(GrB_Vector *, GrB_Type, uint64_t, uint64_t **, vo GrB_Info GxB_Vector_import_Full(GrB_Vector *, GrB_Type, uint64_t, void **, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Vector_isStoredElement(const GrB_Vector v, GrB_Index i); GrB_Info GxB_Vector_iso(bool *, const GrB_Vector); -GrB_Info GxB_Vector_load(GrB_Vector V, void **X, GrB_Type type, uint64_t n, uint64_t X_size, int handling, const GrB_Descriptor desc); +GrB_Info GxB_Vector_load(GrB_Vector V, void **X, GrB_Type type, uint64_t n, uint64_t X_memsize, int handling, const GrB_Descriptor desc); GrB_Info GxB_Vector_memoryUsage(size_t *size, const GrB_Vector v); +GrB_Info GxB_Vector_new_arena(GrB_Vector *v, GrB_Type type, GrB_Index n, const int header_arena, const int data_arena); GrB_Info GxB_Vector_pack_Bitmap(GrB_Vector, int8_t **, void **, uint64_t, uint64_t, bool, uint64_t, const GrB_Descriptor); GrB_Info GxB_Vector_pack_CSC(GrB_Vector, uint64_t **, void **, uint64_t, uint64_t, bool, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Vector_pack_Full(GrB_Vector, void **, uint64_t, bool, const GrB_Descriptor); GrB_Info GxB_Vector_select(GrB_Vector, const GrB_Vector, const GrB_BinaryOp, const GxB_SelectOp, const GrB_Vector, const GrB_Scalar, const GrB_Descriptor); -GrB_Info GxB_Vector_serialize(void **blob_handle, GrB_Index *blob_size_handle, GrB_Vector u, const GrB_Descriptor desc); +GrB_Info GxB_Vector_serialize(void **blob_handle, GrB_Index *blob_size, GrB_Vector u, const GrB_Descriptor desc); +GrB_Info GxB_Vector_serialize_arena(void **blob_handle, GrB_Index *blob_size, GrB_Vector u, const int data_arena, const GrB_Descriptor desc); +GrB_Info GxB_Vector_set_arenas(GrB_Vector *Vhandle, const int new_header_arena, const int new_data_arena); GrB_Info GxB_Vector_sort(GrB_Vector w, GrB_Vector p, GrB_BinaryOp op, GrB_Vector u, const GrB_Descriptor desc); GrB_Info GxB_Vector_subassign(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_Vector u, const GrB_Index *I_, GrB_Index ni, const GrB_Descriptor desc); GrB_Info GxB_Vector_subassign_BOOL(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, bool x, const GrB_Index *I_, GrB_Index ni, const GrB_Descriptor desc); @@ -3503,7 +3566,7 @@ GrB_Info GxB_Vector_subassign_UINT64(GrB_Vector w, const GrB_Vector mask, const GrB_Info GxB_Vector_subassign_Vector(GrB_Vector w, const GrB_Vector mask, const GrB_BinaryOp accum, const GrB_Vector u, const GrB_Vector I_vector, const GrB_Descriptor desc); GrB_Info GxB_Vector_type(GrB_Type *type, const GrB_Vector v); GrB_Info GxB_Vector_type_name(char *, const GrB_Vector); -GrB_Info GxB_Vector_unload(GrB_Vector V, void **X, GrB_Type *type, uint64_t *n, uint64_t *X_size, int *handling, const GrB_Descriptor desc); +GrB_Info GxB_Vector_unload(GrB_Vector V, void **X, GrB_Type *type, uint64_t *n, uint64_t *X_memsize, int *handling, const GrB_Descriptor desc); GrB_Info GxB_Vector_unpack_Bitmap(GrB_Vector, int8_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, const GrB_Descriptor); GrB_Info GxB_Vector_unpack_CSC(GrB_Vector, uint64_t **, void **, uint64_t *, uint64_t *, bool *, uint64_t *, bool *, const GrB_Descriptor); GrB_Info GxB_Vector_unpack_Full(GrB_Vector, void **, uint64_t *, bool *, const GrB_Descriptor); @@ -3515,6 +3578,8 @@ GrB_Info GxB_unload_Vector_into_Container(GrB_Vector V, GxB_Container Container, #define GRB_VERSION ... #define GrB_INDEX_MAX ... #define GxB_ANY_SPARSITY ... +#define GxB_ARENA_DATA ... +#define GxB_ARENA_HEADER ... #define GxB_AUTO_SPARSITY ... #define GxB_BACKWARDS ... #define GxB_BEGIN ... @@ -3537,6 +3602,7 @@ GrB_Info GxB_unload_Vector_into_Container(GrB_Vector V, GxB_Container Container, #define GxB_INC ... #define GxB_INDEX_MAX ... #define GxB_MAX_NAME_LEN ... +#define GxB_NARENAS ... #define GxB_NBITMAP_SWITCH ... #define GxB_NGPUS ... #define GxB_NTHREADS ... From 6de31404fb126d2d5d900d1700cf966222ed6b20 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sat, 8 Aug 2026 22:42:08 -0500 Subject: [PATCH 2/2] Handle free-threaded Python explicitly in CI --- .github/workflows/test.yml | 47 +++++++++++++++++++++++++++++++----- .github/workflows/wheels.yml | 8 ++++-- .gitignore | 3 +++ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c93034..07815f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,19 +18,38 @@ jobs: source: ["conda-forge"] # os: ["ubuntu-latest"] # source: ["source"] - python-version: ["3.11", "3.12", "3.13", "3.14"] + # A trailing "t" means the free-threaded (no-GIL) build of that version. + python-version: ["3.11", "3.12", "3.13", "3.14", "3.14t"] steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 persist-credentials: false + - name: Compose conda environment file + run: | + # conda-forge ships two ABIs for CPython 3.13+ ("cp314" and "cp314t"), + # and `python=3.14` alone lets the solver pick either one: it resolved + # to free-threaded on Linux and Windows but to the GIL build on macOS. + # The `python-gil` and `python-freethreading` metapackages pin + # `python_abi` to one or the other, so ask for the one this matrix + # entry wants instead of leaving it to the solver. + pyver="${{ matrix.python-version }}" + if [[ $pyver == *t ]]; then + variant=python-freethreading + pyver=${pyver%t} + else + variant=python-gil + fi + cp continuous_integration/environment.yml environment-ci.yml + echo " - python=$pyver" >> environment-ci.yml + echo " - $variant" >> environment-ci.yml + cat environment-ci.yml - name: Conda uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true - python-version: ${{ matrix.python-version }} - environment-file: continuous_integration/environment.yml + environment-file: environment-ci.yml channels: conda-forge,nodefaults channel-priority: strict activate-environment: suitesparse-graphblas @@ -62,15 +81,31 @@ jobs: - name: Build run: | pip install -e . --no-deps + - name: Configure coverage + run: | + # Cython's coverage plugin (see [tool.coverage.run] in pyproject.toml) + # needs coverage's C tracer. conda-forge builds coverage without its C + # extension for free-threaded Python, and conda resolves `python=3.14` + # to the free-threaded build (3.14t) on some platforms. There, loading + # the plugin raises ImportError and every `coverage run` dies before it + # runs anything, so run the tests directly instead. + if python -c "import Cython.Coverage" 2>/dev/null; then + coverage erase + echo "COV=coverage run -a --branch" >> $GITHUB_ENV + else + echo "Cython coverage plugin unusable here; running without coverage" + python -VV + echo "COV=python" >> $GITHUB_ENV + fi - name: Test env: CYTHON_COVERAGE: true run: | pytest -s -k test_print_jit_config - coverage run --branch -m pytest - coverage run -a --branch suitesparse_graphblas/tests/test_initialize.py + $COV -m pytest + $COV suitesparse_graphblas/tests/test_initialize.py - name: create_headers.py check if: (! contains(matrix.os, 'windows')) run: | - coverage run -a --branch suitesparse_graphblas/create_headers.py + $COV suitesparse_graphblas/create_headers.py git diff --exit-code # error if anything changed diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 591ca63..a35412b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -138,8 +138,12 @@ jobs: # very verbose CIBW_BUILD_VERBOSITY: 3 - # cibuildwheel v3: PyPy no longer built by default; enable explicitly - # Note: cpython-freethreading not enabled because cffi doesn't support it yet + # cibuildwheel v3: PyPy no longer built by default; enable explicitly. + # Free-threaded wheels: cibuildwheel only gates cp313t behind + # "cpython-freethreading" (see its selector.py), so cp314t is already + # built and tested here by default. cp313t stays off because cffi + # publishes no cp313t wheels, so enabling it would build cffi from + # source in every wheel job. CIBW_ENABLE: "pypy" # Build SuiteSparse diff --git a/.gitignore b/.gitignore index e382cda..d079cfe 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,9 @@ GraphBLAS-*/ pip-log.txt pip-delete-this-directory.txt +# Conda environment file composed by CI (see .github/workflows/test.yml) +environment-ci.yml + # Unit test / coverage reports htmlcov/ .tox/