Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing matrix filename as benchmark input #1387

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmark/conversions/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/utils/formats.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/spmv_validation.hpp"
#include "benchmark/utils/timer.hpp"
Expand Down Expand Up @@ -115,7 +115,7 @@ int main(int argc, char* argv[])
std::string header =
"A benchmark for measuring performance of Ginkgo's conversions.\n";
std::string format_str = example_config;
initialize_argument_parsing(&argc, &argv, header, format_str);
initialize_argument_parsing_matrix(&argc, &argv, header, format_str);

std::string extra_information =
std::string() + "The formats are " + FLAGS_formats + "\n";
Expand Down
4 changes: 2 additions & 2 deletions benchmark/matrix_statistics/matrix_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>


#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/spmv_validation.hpp"
#include "benchmark/utils/types.hpp"
Expand Down Expand Up @@ -173,7 +173,7 @@ int main(int argc, char* argv[])
"A utility that collects additional statistical properties of the "
"matrix.\n";
std::string format = example_config;
initialize_argument_parsing(&argc, &argv, header, format);
initialize_argument_parsing_matrix(&argc, &argv, header, format);

std::clog << gko::version_info::get() << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions benchmark/preconditioner/preconditioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/utils/formats.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/loggers.hpp"
#include "benchmark/utils/preconditioners.hpp"
Expand Down Expand Up @@ -262,7 +262,7 @@ int main(int argc, char* argv[])
std::string header =
"A benchmark for measuring preconditioner performance.\n";
std::string format = example_config;
initialize_argument_parsing(&argc, &argv, header, format);
initialize_argument_parsing_matrix(&argc, &argv, header, format);

std::string extra_information =
"Running with preconditioners: " + FLAGS_preconditioners + "\n";
Expand Down
6 changes: 4 additions & 2 deletions benchmark/solver/distributed/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/solver/solver_common.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"


Expand Down Expand Up @@ -98,7 +98,9 @@ int main(int argc, char* argv[])
"<local_format>-<non_local_format>", where both "local_format" and
"non_local_format" can be any of the recognized spmv formats.
)";
initialize_argument_parsing(&argc, &argv, header, format);
std::string additional_json = R"(,"optimal":{"spmv":"csr-csr"})";
initialize_argument_parsing_matrix(&argc, &argv, header, format,
additional_json);

const auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
const auto rank = comm.rank();
Expand Down
6 changes: 4 additions & 2 deletions benchmark/solver/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/solver/solver_common.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"


Expand All @@ -61,7 +61,9 @@ int main(int argc, char* argv[])
std::string format = example_config + R"(
"optimal":"spmv" can be one of the recognized spmv formats
)";
initialize_argument_parsing(&argc, &argv, header, format);
std::string additional_json = R"(,"optimal":{"spmv":"csr"})";
initialize_argument_parsing_matrix(&argc, &argv, header, format,
additional_json);

std::stringstream ss_rel_res_goal;
ss_rel_res_goal << std::scientific << FLAGS_rel_res_goal;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sparse_blas/sparse_blas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/sparse_blas/operations.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/spmv_validation.hpp"
#include "benchmark/utils/types.hpp"
Expand Down Expand Up @@ -161,7 +161,7 @@ int main(int argc, char* argv[])
"A benchmark for measuring performance of Ginkgo's sparse BLAS "
"operations.\n";
std::string format = example_config;
initialize_argument_parsing(&argc, &argv, header, format);
initialize_argument_parsing_matrix(&argc, &argv, header, format);

auto exec = executor_factory.at(FLAGS_executor)(FLAGS_gpu_timer);

Expand Down
4 changes: 2 additions & 2 deletions benchmark/spmv/distributed/spmv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "benchmark/spmv/spmv_common.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/timer.hpp"
#include "benchmark/utils/types.hpp"
Expand Down Expand Up @@ -102,7 +102,7 @@ int main(int argc, char* argv[])
std::string header =
"A benchmark for measuring performance of Ginkgo's spmv.\n";
std::string format = example_config;
initialize_argument_parsing(&argc, &argv, header, format);
initialize_argument_parsing_matrix(&argc, &argv, header, format);

if (rank == 0) {
std::string extra_information = "The formats are [" +
Expand Down
4 changes: 2 additions & 2 deletions benchmark/spmv/spmv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "benchmark/spmv/spmv_common.hpp"
#include "benchmark/utils/formats.hpp"
#include "benchmark/utils/general.hpp"
#include "benchmark/utils/general_matrix.hpp"
#include "benchmark/utils/generator.hpp"
#include "benchmark/utils/spmv_validation.hpp"

Expand All @@ -64,7 +64,7 @@ int main(int argc, char* argv[])
std::string header =
"A benchmark for measuring performance of Ginkgo's spmv.\n";
std::string format = example_config;
initialize_argument_parsing(&argc, &argv, header, format);
initialize_argument_parsing_matrix(&argc, &argv, header, format);

std::string extra_information = "The formats are " + FLAGS_formats +
"\nThe number of right hand sides is " +
Expand Down
12 changes: 12 additions & 0 deletions benchmark/test/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
expected_stderr="conversion.simple.stderr",
)

# input matrixfile
test_framework.compare_output(
[
"-input_matrix",
str(test_framework.matrixpath),
"-formats",
"coo,csr",
],
expected_stdout="conversion.matrix.stdout",
expected_stderr="conversion.matrix.stderr",
)

# check that all conversions work
test_framework.compare_output(
[
Expand Down
7 changes: 7 additions & 0 deletions benchmark/test/matrix_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@
expected_stdout="matrix_statistics.simple.stdout",
expected_stderr="matrix_statistics.simple.stderr",
)

# input matrix file
test_framework.compare_output(
["-input_matrix", str(test_framework.matrixpath)],
expected_stdout="matrix_statistics.matrix.stdout",
expected_stderr="matrix_statistics.matrix.stderr",
)
7 changes: 7 additions & 0 deletions benchmark/test/preconditioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
expected_stderr="preconditioner.simple.stderr",
)

# input matrix file
test_framework.compare_output(
["-input_matrix", str(test_framework.matrixpath)],
expected_stdout="preconditioner.matrix.stdout",
expected_stderr="preconditioner.matrix.stderr",
)

# profiler annotations
test_framework.compare_output(
[
Expand Down
46 changes: 46 additions & 0 deletions benchmark/test/reference/conversion.matrix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
This is Ginkgo 1.7.0 (develop)
running with core module 1.7.0 (develop)
Running on reference(0)
Running with 2 warm iterations and 10 running iterations
The random seed for right hand sides is 42
The formats are coo,csr
Benchmarking conversions.
Running test case
{
"filename": "",
"conversions": {}
}
Matrix is of size (36, 36)
Current state:
[
{
"filename": "",
"conversions": {
"coo-csr": {
"time": 1.0,
"repetitions": 10,
"completed": true
}
},
"size": 36
}
]
Current state:
[
{
"filename": "",
"conversions": {
"coo-csr": {
"time": 1.0,
"repetitions": 10,
"completed": true
},
"csr-coo": {
"time": 1.0,
"repetitions": 10,
"completed": true
}
},
"size": 36
}
]
19 changes: 19 additions & 0 deletions benchmark/test/reference/conversion.matrix.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

[
{
"filename": "",
"conversions": {
"coo-csr": {
"time": 1.0,
"repetitions": 10,
"completed": true
},
"csr-coo": {
"time": 1.0,
"repetitions": 10,
"completed": true
}
},
"size": 36
}
]
17 changes: 17 additions & 0 deletions benchmark/test/reference/distributed_solver.matrix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This is Ginkgo 1.7.0 (develop)
running with core module 1.7.0 (develop)
Running on reference(0)
Running with 2 warm iterations and 1 running iterations
The random seed for right hand sides is 42
Running cg with 1000 iterations and residual goal of 1.000000e-06
The number of right hand sides is 1
Running test case
{
"filename": "",
"optimal": {
"spmv": "csr-csr"
},
"solver": {}
}
Matrix is of size (36, 36)
Running solver: cg
57 changes: 57 additions & 0 deletions benchmark/test/reference/distributed_solver.matrix.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[
{
"filename": "",
"optimal": {
"spmv": "csr-csr"
},
"solver": {
"cg": {
"recurrent_residuals": [],
"true_residuals": [],
"implicit_residuals": [],
"iteration_timestamps": [],
"rhs_norm": 1.0,
"generate": {
"components": {
"generate(<typename>)": 1.0,
"free": 1.0,
"overhead": 1.0
},
"time": 1.0
},
"apply": {
"components": {
"apply(<typename>)": 1.0,
"iteration": 1.0,
"allocate": 1.0,
"dense::fill": 1.0,
"cg::initialize": 1.0,
"advanced_apply(<typename>)": 1.0,
"dense::row_gather": 1.0,
"csr::advanced_spmv": 1.0,
"dense::compute_squared_norm2": 1.0,
"dense::compute_sqrt": 1.0,
"copy(<typename>)": 1.0,
"dense::copy": 1.0,
"dense::compute_conj_dot_dispatch": 1.0,
"check(<typename>)": 1.0,
"residual_norm::residual_norm": 1.0,
"cg::step_1": 1.0,
"csr::spmv": 1.0,
"cg::step_2": 1.0,
"free": 1.0,
"overhead": 1.0
},
"iterations": 27,
"time": 1.0
},
"preconditioner": {},
"residual_norm": 1.0,
"repetitions": 1,
"completed": true
}
},
"size": 36
}
]
8 changes: 8 additions & 0 deletions benchmark/test/reference/matrix_statistics.matrix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This is Ginkgo 1.7.0 (develop)
running with core module 1.7.0 (develop)
Running test case
{
"filename": "",
"problem": {}
}
Matrix is of size (36, 36)
38 changes: 38 additions & 0 deletions benchmark/test/reference/matrix_statistics.matrix.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

[
{
"filename": "",
"problem": {
"rows": 36,
"columns": 36,
"nonzeros": 208,
"row_distribution": {
"min": 4,
"q1": 4.5,
"median": 6.0,
"q3": 7.0,
"max": 9,
"mean": 5.777777777777778,
"variance": 2.061728395061728,
"skewness": 0.3366362745126052,
"kurtosis": 2.0507009932231366,
"hyperskewness": 1.9165991338199193,
"hyperflatness": 6.0545648993883665
},
"col_distribution": {
"min": 4,
"q1": 4.5,
"median": 6.0,
"q3": 7.0,
"max": 9,
"mean": 5.777777777777778,
"variance": 2.061728395061728,
"skewness": 0.3366362745126052,
"kurtosis": 2.0507009932231366,
"hyperskewness": 1.9165991338199193,
"hyperflatness": 6.0545648993883665
}
},
"size": 36
}
]
Loading