metagraph-dev / mlir-graphblas

MLIR tools and dialect for GraphBLAS
https://mlir-graphblas.readthedocs.io/en/latest/
Apache License 2.0
15 stars 6 forks source link

Operator standardization #235

Closed jim22k closed 2 years ago

jim22k commented 2 years ago

Operations:

Some important things to note:

  1. Operators are now listed by usage
    • unary1 are unary ops taking one argument (value)
    • unary3 are unary ops taking three arguments (value, row, column)
    • monoid2 are monoid ops taking two arguments (aVal, bVal)
    • binary2 are binary ops taking 2 arguments (leftVal, rightVal)
    • binary4 are binary ops taking 4 arguments (leftVal, rightVal, row, column)
    • binary5 are binary ops taking 5 arguments (leftVal, rightVal, row, column, overlap) -- these are only applicable for matrix multiplication in a semiring.
  2. All usage of (row, column) above are called as (index, index) for vectors, meaning the code can use either row or column and the meaning will be the same for vectors. It's always just the index position. Passing it twice makes the API simpler.
  3. Operators are also listed by operation. This lets each operation filter what operators make sense. For example, gt makes sense for intersection, but not union.
  4. Thunks are handled by calling populateBinary, followed by code to grab the thunk argument from the block, replace all usages with the thunk, and then removing the argument from the block. This effectively turns it into a unary op, but keeps the definition consistent.
  5. A new pattern has emerged for handling operation-specific custom operators (ex. select with probability). The custom operator must be handled in the non-generic lowering pass. Often, the custom operator affects deeply nested code. To avoid rewriting the outer loop, we write the outer loop(s) in a buildAlgorithm public function which accepts a function as an argument. The custom code is now injected by writing a function and passing it to buildAlgorithm. The generic operation uses the same buildAlgorithm to inject its code. See LowerSelectRewrite for an example of this pattern.
coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 1446028547


Totals Coverage Status
Change from base Build 1426337740: -0.04%
Covered Lines: 3678
Relevant Lines: 4389

💛 - Coveralls
jim22k commented 2 years ago

I'm happy with the code, so feel free to review it. I need to find and fix this segfault before merging.