Skip to content

Commit

Permalink
Remove boost from benchmarks (#193)
Browse files Browse the repository at this point in the history
* remove boost from benchmarks

* fixing memory bugs

* allow adding multiple options separated by column

* using program_options.hpp from rocBLAS

* removing boost as a dependency

Co-authored-by: jsandham <james.sandham@amd.com>
  • Loading branch information
jsandham and jsandham authored Mar 11, 2021
1 parent e375572 commit 707faaf
Show file tree
Hide file tree
Showing 11 changed files with 488 additions and 124 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Build options
option(BUILD_SHARED_LIBS "Build rocSPARSE as a shared library" ON)
option(BUILD_CLIENTS_TESTS "Build tests (requires googletest)" OFF)
option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks (requires boost)" OFF)
option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks" OFF)
option(BUILD_CLIENTS_SAMPLES "Build examples" ON)
option(BUILD_VERBOSE "Output additional build information" OFF)
option(BUILD_CODE_COVERAGE "Build rocSPARSE with code coverage enabled" OFF)
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Optional:
* Required for tests.
* Use GTEST_ROOT to specify GTest location.
* If [GTest][] is not found, it will be downloaded and built automatically.
* [Boost][]
* Required for benchmarks.

## Quickstart rocSPARSE build and install

Expand Down Expand Up @@ -92,7 +90,6 @@ The [license file][] can be found in the main repository.
[ROCm]: https://github.com/RadeonOpenCompute/ROCm
[HIP]: https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/
[GTest]: https://github.com/google/googletest
[Boost]: https://www.boost.org/
[the issue tracker]: https://github.com/ROCmSoftwarePlatform/rocSPARSE/issues
[license file]: https://github.com/ROCmSoftwarePlatform/rocSPARSE
[here]: https://rocsparse.readthedocs.io
Expand Down
4 changes: 2 additions & 2 deletions clients/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ########################################################################
# Copyright (c) 2018-2020 Advanced Micro Devices, Inc.
# Copyright (c) 2018-2021 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -65,7 +65,7 @@ if(NOT TARGET rocsparse)
find_package(rocsparse REQUIRED CONFIG PATHS /opt/rocm/rocsparse)

option(BUILD_CLIENTS_TESTS "Build tests (requires googletest)" OFF)
option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks (requires boost)" OFF)
option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks" OFF)
option(BUILD_CLIENTS_SAMPLES "Build examples" ON)
endif()

Expand Down
15 changes: 1 addition & 14 deletions clients/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@
#
# ########################################################################

set(Boost_USE_MULTITHREADED ON)
set(Boost_DETAILED_FAILURE_MSG ON)
set(Boost_ADDITIONAL_VERSIONS 1.65.1 1.65)
set(Boost_USE_STATIC_LIBS OFF)

find_package(Boost COMPONENTS program_options)

if(NOT Boost_FOUND)
message(STATUS "Dynamic boost libraries not found. Attempting to find static libraries...")
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS program_options)
endif()

set(ROCSPARSE_BENCHMARK_SOURCES
client.cpp
)
Expand Down Expand Up @@ -130,7 +117,7 @@ target_compile_options(rocsparse-bench PRIVATE -Wno-unused-command-line-argument
target_include_directories(rocsparse-bench PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>)

# Target link libraries
target_link_libraries(rocsparse-bench PRIVATE Boost::program_options roc::rocsparse hip::host)
target_link_libraries(rocsparse-bench PRIVATE roc::rocsparse hip::host)

# Add OpenMP if available
if(OPENMP_FOUND)
Expand Down
111 changes: 56 additions & 55 deletions clients/benchmarks/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
#include "testing_sparse_to_dense_csc.hpp"
#include "testing_sparse_to_dense_csr.hpp"

#include <boost/program_options.hpp>
#include <iostream>
#include <rocsparse.h>
#include <unordered_set>

namespace po = boost::program_options;
#include "program_options.hpp"

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -142,128 +142,134 @@ int main(int argc, char* argv[])
rocsparse_int dir;
rocsparse_int order;

std::vector<rocsparse_int> laplace(3, 0);

rocsparse_int device_id;

po::options_description desc("rocsparse client command line options");
desc.add_options()("help,h", "produces this help message")
// clang-format off

options_description desc("rocsparse client command line options");
desc.add_options() ("help,h", "produces this help message")
// clang-format off
("sizem,m",
po::value<rocsparse_int>(&arg.M)->default_value(128),
value<rocsparse_int>(&arg.M)->default_value(128),
"Specific matrix size testing: sizem is only applicable to SPARSE-2 "
"& SPARSE-3: the number of rows.")

("sizen,n",
po::value<rocsparse_int>(&arg.N)->default_value(128),
value<rocsparse_int>(&arg.N)->default_value(128),
"Specific matrix/vector size testing: SPARSE-1: the length of the "
"dense vector. SPARSE-2 & SPARSE-3: the number of columns")

("sizek,k",
po::value<rocsparse_int>(&arg.K)->default_value(128),
value<rocsparse_int>(&arg.K)->default_value(128),
"Specific matrix/vector size testing: SPARSE-3: the number of columns")

("sizennz,z",
po::value<rocsparse_int>(&arg.nnz)->default_value(32),
value<rocsparse_int>(&arg.nnz)->default_value(32),
"Specific vector size testing, LEVEL-1: the number of non-zero elements "
"of the sparse vector.")

("blockdim",
po::value<rocsparse_int>(&arg.block_dim)->default_value(2),
value<rocsparse_int>(&arg.block_dim)->default_value(2),
"BSR block dimension (default: 2)")

("row-blockdimA",
po::value<rocsparse_int>(&arg.row_block_dimA)->default_value(2),
value<rocsparse_int>(&arg.row_block_dimA)->default_value(2),
"General BSR row block dimension (default: 2)")

("col-blockdimA",
po::value<rocsparse_int>(&arg.col_block_dimA)->default_value(2),
value<rocsparse_int>(&arg.col_block_dimA)->default_value(2),
"General BSR col block dimension (default: 2)")

("row-blockdimB",
po::value<rocsparse_int>(&arg.row_block_dimB)->default_value(2),
value<rocsparse_int>(&arg.row_block_dimB)->default_value(2),
"General BSR row block dimension (default: 2)")

("col-blockdimB",
po::value<rocsparse_int>(&arg.col_block_dimB)->default_value(2),
value<rocsparse_int>(&arg.col_block_dimB)->default_value(2),
"General BSR col block dimension (default: 2)")

("mtx",
po::value<std::string>(&filename)->default_value(""), "read from matrix "
value<std::string>(&filename)->default_value(""), "read from matrix "
"market (.mtx) format. This will override parameters -m, -n, and -z.")

("rocalution",
po::value<std::string>(&rocalution)->default_value(""),
value<std::string>(&rocalution)->default_value(""),
"read from rocalution matrix binary file. This will override parameter --mtx")

("laplacian-dim",
po::value<std::vector<rocsparse_int> >(&laplace)->multitoken(), "assemble "
("dimx",
value<rocsparse_int>(&arg.dimx)->default_value(0.0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")

("dimy",
value<rocsparse_int>(&arg.dimy)->default_value(0.0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")

("dimz",
value<rocsparse_int>(&arg.dimz)->default_value(0.0), "assemble "
"laplacian matrix with dimensions <dimx dimy dimz>. dimz is optional. This "
"will override parameters -m, -n, -z and --mtx.")

("alpha",
po::value<double>(&arg.alpha)->default_value(1.0), "specifies the scalar alpha")
value<double>(&arg.alpha)->default_value(1.0), "specifies the scalar alpha")

("beta",
po::value<double>(&arg.beta)->default_value(0.0), "specifies the scalar beta")
value<double>(&arg.beta)->default_value(0.0), "specifies the scalar beta")

("threshold",
po::value<double>(&arg.threshold)->default_value(1.0), "specifies the scalar threshold")
value<double>(&arg.threshold)->default_value(1.0), "specifies the scalar threshold")

("percentage",
po::value<double>(&arg.percentage)->default_value(0.0), "specifies the scalar percentage")
value<double>(&arg.percentage)->default_value(0.0), "specifies the scalar percentage")

("transposeA",
po::value<char>(&transA)->default_value('N'),
value<char>(&transA)->default_value('N'),
"N = no transpose, T = transpose, C = conjugate transpose")

("transposeB",
po::value<char>(&transB)->default_value('N'),
value<char>(&transB)->default_value('N'),
"N = no transpose, T = transpose, C = conjugate transpose, (default = N)")

("indexbaseA",
po::value<int>(&baseA)->default_value(0),
value<int>(&baseA)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")

("indexbaseB",
po::value<int>(&baseB)->default_value(0),
value<int>(&baseB)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")

("indexbaseC",
po::value<int>(&baseC)->default_value(0),
value<int>(&baseC)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")

("indexbaseD",
po::value<int>(&baseD)->default_value(0),
value<int>(&baseD)->default_value(0),
"0 = zero-based indexing, 1 = one-based indexing, (default: 0)")

("action",
po::value<int>(&action)->default_value(0),
value<int>(&action)->default_value(0),
"0 = rocsparse_action_numeric, 1 = rocsparse_action_symbolic, (default: 0)")

("hybpart",
po::value<int>(&part)->default_value(0),
value<int>(&part)->default_value(0),
"0 = rocsparse_hyb_partition_auto, 1 = rocsparse_hyb_partition_user,\n"
"2 = rocsparse_hyb_partition_max, (default: 0)")

("diag",
po::value<char>(&diag)->default_value('N'),
value<char>(&diag)->default_value('N'),
"N = non-unit diagonal, U = unit diagonal, (default = N)")

("uplo",
po::value<char>(&uplo)->default_value('L'),
value<char>(&uplo)->default_value('L'),
"L = lower fill, U = upper fill, (default = L)")

("apolicy",
po::value<char>(&apol)->default_value('R'),
value<char>(&apol)->default_value('R'),
"R = reuse meta data, F = force re-build, (default = R)")

// ("spolicy",
// po::value<char>(&spol)->default_value('A'),
// "A = auto, (default = A)")

("function,f",
po::value<std::string>(&function)->default_value("axpyi"),
value<std::string>(&function)->default_value("axpyi"),
"SPARSE function to test. Options:\n"
" Level1: axpyi, doti, dotci, gthr, gthrz, roti, sctr\n"
" Level2: bsrmv, bsrsv, coomv, coomv_aos, csrmv, csrmv_managed, csrsv, ellmv, hybmv, gebsrmv\n"
Expand All @@ -278,41 +284,41 @@ int main(int argc, char* argv[])
" Misc: identity, nnz")

("indextype",
po::value<char>(&indextype)->default_value('s'),
value<char>(&indextype)->default_value('s'),
"Specify index types to be int32_t (s), int64_t (d) or mixed (m). Options: s,d,m")

("precision,r",
po::value<char>(&precision)->default_value('s'), "Options: s,d,c,z")
value<char>(&precision)->default_value('s'), "Options: s,d,c,z")

("verify,v",
po::value<rocsparse_int>(&arg.unit_check)->default_value(0),
value<rocsparse_int>(&arg.unit_check)->default_value(0),
"Validate GPU results with CPU? 0 = No, 1 = Yes (default: No)")

("iters,i",
po::value<int>(&arg.iters)->default_value(10),
value<int>(&arg.iters)->default_value(10),
"Iterations to run inside timing loop")

("device,d",
po::value<rocsparse_int>(&device_id)->default_value(0),
value<rocsparse_int>(&device_id)->default_value(0),
"Set default device to be used for subsequent program runs")

("direction",
po::value<rocsparse_int>(&dir)->default_value(rocsparse_direction_row),
value<rocsparse_int>(&dir)->default_value(rocsparse_direction_row),
"Indicates whether a dense matrix should be parsed by rows or by columns, assuming column-major storage: row = 0, column = 1 (default: 0)")

("order",
po::value<rocsparse_int>(&order)->default_value(rocsparse_order_column),
value<rocsparse_int>(&order)->default_value(rocsparse_order_column),
"Indicates whether a dense matrix is laid out in column-major storage: 1, or row-major storage 0 (default: 1)")

("denseld",
po::value<rocsparse_int>(&arg.denseld)->default_value(128),
value<rocsparse_int>(&arg.denseld)->default_value(128),
"Indicates the leading dimension of a dense matrix >= M, assuming a column-oriented storage.");

// clang-format on

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);

if(vm.count("help"))
{
Expand Down Expand Up @@ -388,11 +394,6 @@ int main(int argc, char* argv[])
= (dir == rocsparse_direction_row) ? rocsparse_direction_row : rocsparse_direction_column;
arg.order = (order == rocsparse_order_row) ? rocsparse_order_row : rocsparse_order_column;

// Set laplace dimensions
arg.dimx = laplace[0];
arg.dimy = laplace[1];
arg.dimz = laplace[2];

// rocALUTION parameter overrides filename parameter
if(rocalution != "")
{
Expand Down
Loading

0 comments on commit 707faaf

Please sign in to comment.