diff --git a/benchmark/sparse_blas/operations.cpp b/benchmark/sparse_blas/operations.cpp index 6a817a67c0d..66e5707c559 100644 --- a/benchmark/sparse_blas/operations.cpp +++ b/benchmark/sparse_blas/operations.cpp @@ -695,6 +695,105 @@ class SymbolicCholeskyOperation : public BenchmarkOperation { }; +class ReorderRcmOperation : public BenchmarkOperation { + using reorder_type = gko::reorder::Rcm; + +public: + explicit ReorderRcmOperation(const Mtx* mtx) + : mtx_{mtx->clone()}, + factory_{reorder_type::build().on(mtx->get_executor())} + {} + + std::pair validate() const override + { + // validating RCM correctness is hard, let's leave it out for now + return {true, 0.0}; + } + + gko::size_type get_flops() const override { return 0; } + + gko::size_type get_memory() const override { return 0; } + + void prepare() override {} + + void run() override { reorder_ = factory_->generate(mtx_); } + +private: + std::shared_ptr mtx_; + std::unique_ptr factory_; + std::unique_ptr reorder_; +}; + + +#if GKO_HAVE_METIS + + +class ReorderNestedDissectionOperation : public BenchmarkOperation { + using factory_type = + gko::experimental::reorder::NestedDissection; + using reorder_type = gko::matrix::Permutation; + +public: + explicit ReorderNestedDissectionOperation(const Mtx* mtx) + : mtx_{mtx->clone()}, + factory_{factory_type::build().on(mtx->get_executor())} + {} + + std::pair validate() const override + { + // validating ND correctness is hard, let's leave it out for now + return {true, 0.0}; + } + + gko::size_type get_flops() const override { return 0; } + + gko::size_type get_memory() const override { return 0; } + + void prepare() override {} + + void run() override { reorder_ = factory_->generate(mtx_); } + +private: + std::shared_ptr mtx_; + std::unique_ptr factory_; + std::unique_ptr reorder_; +}; + + +#endif + + +class ReorderApproxMinDegOperation : public BenchmarkOperation { + using factory_type = gko::experimental::reorder::Amd; + using reorder_type = gko::matrix::Permutation; + +public: + explicit ReorderApproxMinDegOperation(const Mtx* mtx) + : mtx_{mtx->clone()}, + factory_{factory_type::build().on(mtx->get_executor())} + {} + + std::pair validate() const override + { + // validating AMD correctness is hard, let's leave it out for now + return {true, 0.0}; + } + + gko::size_type get_flops() const override { return 0; } + + gko::size_type get_memory() const override { return 0; } + + void prepare() override {} + + void run() override { reorder_ = factory_->generate(mtx_); } + +private: + std::shared_ptr mtx_; + std::unique_ptr factory_; + std::unique_ptr reorder_; +}; + + const std::map(const Mtx*)>> operation_map{ @@ -726,8 +825,25 @@ const std::map(mtx, false); }}, - {"symbolic_cholesky_symmetric", [](const Mtx* mtx) { + {"symbolic_cholesky_symmetric", + [](const Mtx* mtx) { return std::make_unique(mtx, true); + }}, + {"reorder_rcm", + [](const Mtx* mtx) { + return std::make_unique(mtx); + }}, + {"reorder_amd", + [](const Mtx* mtx) { + return std::make_unique(mtx); + }}, + {"reorder_nd", + [](const Mtx* mtx) -> std::unique_ptr { +#if GKO_HAVE_METIS + return std::make_unique(mtx); +#else + GKO_NOT_COMPILED(METIS); +#endif }}}; diff --git a/benchmark/sparse_blas/sparse_blas.cpp b/benchmark/sparse_blas/sparse_blas.cpp index 4fb06d2a4a0..3b0ce26db5f 100644 --- a/benchmark/sparse_blas/sparse_blas.cpp +++ b/benchmark/sparse_blas/sparse_blas.cpp @@ -57,11 +57,17 @@ const auto benchmark_name = "sparse_blas"; using mat_data = gko::matrix_data; -DEFINE_string( - operations, "spgemm,spgeam,transpose", +const char* operations_string = "Comma-separated list of operations to be benchmarked. Can be " "spgemm, spgeam, transpose, sort, is_sorted, generate_lookup, " - "lookup, symbolic_lu, symbolic_cholesky, symbolic_cholesky_symmetric"); + "lookup, symbolic_lu, symbolic_cholesky, " + "symbolic_cholesky_symmetric, reorder_rcm, " +#if GKO_HAVE_METIS + "reorder_nd, " +#endif + "reorder_amd"; + +DEFINE_string(operations, "spgemm,spgeam,transpose", operations_string); DEFINE_bool(validate, false, "Check for correct sparsity pattern and compute the L2 norm "