Skip to content

Commit

Permalink
disable reordering flag for distributed benchmarks
Browse files Browse the repository at this point in the history
Co-authored-by: Yuhsiang M. Tsai <yhmtsai@gmail.com>
  • Loading branch information
upsj and yhmtsai committed Oct 10, 2023
1 parent 046dd58 commit 558ec16
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions benchmark/blas/distributed/multi_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>


#define GKO_BENCHMARK_DISTRIBUTED


#include "benchmark/blas/blas_common.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/generator.hpp"
Expand Down
3 changes: 3 additions & 0 deletions benchmark/solver/distributed/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <set>


#define GKO_BENCHMARK_DISTRIBUTED


#include "benchmark/solver/solver_common.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
Expand Down
3 changes: 1 addition & 2 deletions benchmark/solver/solver_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ struct SolverBenchmark : Benchmark<solver_benchmark_state<Generator>> {
state.x = generator.initialize({0.0}, exec);
} else {
auto data = generator.generate_matrix_data(test_case);
auto permutation =
reorder(data, test_case, generator.is_distributed());
auto permutation = reorder(data, test_case);

state.system_matrix = generator.generate_matrix_with_format(
exec, test_case["optimal"]["spmv"].get<std::string>(), data);
Expand Down
3 changes: 3 additions & 0 deletions benchmark/spmv/distributed/spmv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <typeinfo>


#define GKO_BENCHMARK_DISTRIBUTED


#include "benchmark/spmv/spmv_common.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/spmv/spmv_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct SpmvBenchmark : Benchmark<spmv_benchmark_state<Generator>> {
{
spmv_benchmark_state<Generator> state;
state.data = generator.generate_matrix_data(test_case);
reorder(state.data, test_case, generator.is_distributed());
reorder(state.data, test_case);

auto nrhs = FLAGS_nrhs;
state.b = generator.create_multi_vector_random(
Expand Down
17 changes: 13 additions & 4 deletions benchmark/utils/general_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,27 @@ std::string reordering_algorithm_desc =
#if GKO_HAVE_METIS
" nd - Nested Dissection reordering algorithm\n"
#endif
" rcm - Reverse Cuthill-McKee reordering algorithm";
" rcm - Reverse Cuthill-McKee reordering algorithm\n"
"This is a preprocessing step whose runtime will not be included\n"
"in the measurements.";


DEFINE_string(input_matrix, "",
"Filename of a matrix to be used as the single input. Overwrites "
"the value of the -input flag");


#ifndef GKO_BENCHMARK_DISTRIBUTED
DEFINE_string(reorder, "none", reordering_algorithm_desc.c_str());
#endif


template <typename ValueType, typename IndexType>
std::unique_ptr<gko::matrix::Permutation<IndexType>> reorder(
gko::matrix_data<ValueType, IndexType>& data, json& test_case,
bool is_distributed = false)
gko::matrix_data<ValueType, IndexType>& data, json& test_case)
{
if (FLAGS_reorder == "none" || is_distributed) {
#ifndef GKO_BENCHMARK_DISTRIBUTED
if (FLAGS_reorder == "none") {
return nullptr;
}
using Csr = gko::matrix::Csr<ValueType, IndexType>;
Expand Down Expand Up @@ -100,6 +105,10 @@ std::unique_ptr<gko::matrix::Permutation<IndexType>> reorder(
gko::as<Csr>(mtx->permute(&perm_arr))->write(data);
test_case["reordered"] = FLAGS_reorder;
return perm;
#else
// no reordering for distributed benchmarks
return nullptr;
#endif
}


Expand Down
4 changes: 0 additions & 4 deletions benchmark/utils/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ struct DefaultSystemGenerator {
using value_type = ValueType;
using Vec = vec<ValueType>;

static bool is_distributed() { return false; }

static gko::matrix_data<ValueType, IndexType> generate_matrix_data(
const json& config)
{
Expand Down Expand Up @@ -193,8 +191,6 @@ struct DistributedDefaultSystemGenerator {
using Mtx = dist_mtx<value_type, local_index_type, index_type>;
using Vec = dist_vec<value_type>;

static bool is_distributed() { return true; }

gko::matrix_data<value_type, index_type> generate_matrix_data(
const json& config) const
{
Expand Down

0 comments on commit 558ec16

Please sign in to comment.