Skip to content

Commit

Permalink
Spgemm perf test enhancements (#1664)
Browse files Browse the repository at this point in the history
* SpGEMM perf test enhancements

- SYCL, OpenMPTarget support
- Document the --checkoutput option in the help text
- When checking output, just give the max absolute error in values
  so the user can decide what's acceptable (instead of erroring out
  based on a fixed epsilon)

* spgemm perftest: fix device id for sycl/omptarget

* Fix sometimes-uninitialized warning

* SpGEMM perf test: allow Serial to be used

Pass device_id = 0 to Kokkos::initialize if no backend is requested.
That way, if the build has a GPU backend is enabled but no backend is
requested, Kokkos::initialize won't fail and Serial can be used.

* One more spgemm perftest fix

- Initialize use_openmptarget in TestParameters constructor
  (this needs to be zeroed out, otherwise it gets used as device id)
- Print out which backend is actually being run

* spgemm perftest: error out if backend not available

* Fix unused variable warning

* Finish spgemm perf test refactor

- Add check_arg_double(...) to perf test utils
- Use perf test utils for arg parsing, selecting backend
- Get rid of the ability to have distinct fast/slow memory spaces
- Merge the three files that made up the perf test into just
  KokkosSparse_spgemm.cpp
- Change some types in KokkosKernels::Experiment::Parameters to be safer
  - on/off values should be bool, not int
  - strings should be std::string, not char*
  • Loading branch information
brian-kelley authored Mar 30, 2023
1 parent a94163c commit 27ec2cd
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 736 deletions.
36 changes: 36 additions & 0 deletions perf_test/KokkosKernels_perf_test_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ void process_arg_int(char const* str_val, int& val) {
}
}

void process_arg_double(char const* str_val, double& val) {
errno = 0;
char* ptr_end;
val = std::strtod(str_val, &ptr_end);

if (str_val == ptr_end) {
std::stringstream ss;
ss << "Error: cannot convert command line argument '" << str_val
<< "' to a double.\n";
throw std::invalid_argument(ss.str());
}

if (errno == ERANGE) {
std::stringstream ss;
ss << "Error: converted value for command line argument '" << str_val
<< "' falls out of range.\n";
throw std::invalid_argument(ss.str());
}
}

bool check_arg_int(int const i, int const argc, char** argv, char const* name,
int& val) {
if (0 != Test::string_compare_no_case(argv[i], name)) {
Expand All @@ -83,6 +103,22 @@ bool check_arg_int(int const i, int const argc, char** argv, char const* name,
return true;
}

bool check_arg_double(int const i, int const argc, char** argv,
char const* name, double& val) {
if (0 != Test::string_compare_no_case(argv[i], name)) {
return false;
}

if (i < argc - 1) {
process_arg_double(argv[i + 1], val);
} else {
std::stringstream msg;
msg << name << " input argument needs to be followed by a real number";
throw std::invalid_argument(msg.str());
}
return true;
}

bool check_arg_bool(int const i, int const /*argc*/, char** argv,
char const* name, bool& val) {
if (0 != Test::string_compare_no_case(argv[i], name)) {
Expand Down
6 changes: 3 additions & 3 deletions perf_test/graph/KokkosGraph_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void run_experiment(crsGraph_t crsGraph, int num_cols, Parameters params) {
}
}

if (params.coloring_output_file != NULL) {
if (params.coloring_output_file != "") {
std::ofstream os(params.coloring_output_file, std::ofstream::out);
KokkosKernels::Impl::print_1Dview(os, colors, true, "\n");
}
Expand Down Expand Up @@ -420,7 +420,7 @@ void run_multi_mem_experiment(Parameters params) {
// typedef typename slow_graph_t::entries_type::const_type
// const_slow_cols_view_t;

char *a_mat_file = params.a_mtx_bin_file;
const char *a_mat_file = params.a_mtx_bin_file.c_str();
// char *b_mat_file = params.b_mtx_bin_file;
// char *c_mat_file = params.c_mtx_bin_file;

Expand Down Expand Up @@ -581,7 +581,7 @@ int main(int argc, char **argv) {
if (parse_inputs(params, argc, argv)) {
return 1;
}
if (params.a_mtx_bin_file == NULL) {
if (params.a_mtx_bin_file == "") {
std::cerr << "Provide a matrix file" << std::endl;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion perf_test/graph/KokkosGraph_run_triangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool is_same_graph(crsGraph_t output_mat1, crsGraph_t output_mat2) {
if (!is_identical) return false;

if (!is_identical) {
std::cout << "Incorret values" << std::endl;
std::cout << "Incorrect values" << std::endl;
}
return true;
}
Expand Down
216 changes: 0 additions & 216 deletions perf_test/sparse/KokkosSparse_multimem_spgemm.hpp

This file was deleted.

Loading

0 comments on commit 27ec2cd

Please sign in to comment.