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

Connected Components #243

Closed paul-tqh-nguyen closed 2 years ago

paul-tqh-nguyen commented 2 years ago

This PR adds the connected components algorithm along with a few necessary changes.

These valid uses of scf.while in MLIR were not previously supported in our IR builder.

      /////////////////////////////////////////////////////////////////////////////////////
      %res = scf.while (%arg1 = %0) : (f32) -> f32 {
        %condition = arith.cmpf "one", %0, %0 : f32
        // CHECK: while before: 1.3 
        graphblas.print %0 { strings = ["while before: "] } : f32
        scf.condition(%condition) %arg1 : f32
      } do {
      ^bb0(%arg2: f32):
        // COM: This should never be run
        graphblas.print %0 { strings = ["while after: "] } : f32
        scf.yield %arg2 : f32
      }
      /////////////////////////////////////////////////////////////////////////////////////
      // COM: TODO remove these
      scf.while : () -> () {
        %condition = arith.cmpf "one", %0, %0 : f32
        // CHECK: while before: 1.3 
        graphblas.print %0 { strings = ["while before: "] } : f32
        scf.condition(%condition)
      } do {
        // COM: This should never be run
        graphblas.print %0 { strings = ["while after: "] } : f32
        scf.yield
      }
      /////////////////////////////////////////////////////////////////////////////////////
      scf.while : () -> (f32, f32) {
        %condition = arith.cmpf "one", %0, %0 : f32
        // CHECK: while before: 1.3 
        graphblas.print %0 { strings = ["while before: "] } : f32
        scf.condition(%condition) %0, %0 : f32, f32
      } do {
      ^bb0(%arg2: f32, %arg3: f32):
        // COM: This should never be run
        graphblas.print %0 { strings = ["while after: "] } : f32
        scf.yield
      }
      /////////////////////////////////////////////////////////////////////////////////////

They are now supported.

We'll need some more tests. I've put off handling that for now and will address it in https://github.com/metagraph-dev/mlir-graphblas/issues/244.

This PR also works around https://github.com/metagraph-dev/mlir-graphblas/issues/236. https://github.com/metagraph-dev/mlir-graphblas/issues/236 seems to only occur with sparse vectors where the last element is missing, e.g. [_, 10, 20, _]. For vectors where this is not the case, e.g. [_, 10, _, 20], the intermittent failures do not come up. This PR changes the test mentioned in https://github.com/metagraph-dev/mlir-graphblas/issues/236 that causes the intermittent failures. The test now succeeds consistently. It's intended that https://github.com/metagraph-dev/mlir-graphblas/issues/236 remain open until it is actually solved, this is merely a workaround to reduce the number of unimportant CI failures that might distract us. CC @jim22k

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 1545841592


Changes Missing Coverage Covered Lines Changed/Added Lines %
mlir_graphblas/ops.py 13 15 86.67%
<!-- Total: 124 126 98.41% -->
Totals Coverage Status
Change from base Build 1508136823: 0.3%
Covered Lines: 3998
Relevant Lines: 4710

💛 - Coveralls