Skip to content

Commit

Permalink
Standardize benchmark names (#437)
Browse files Browse the repository at this point in the history
This PR moves the get_name function in the benchmarks to a common location, ensuring that different backends can obtain uniform benchmark names.

---------

Co-authored-by: Alejandro Acosta <[email protected]>
  • Loading branch information
aacostadiaz and aacostadiaz authored Jul 10, 2023
1 parent c0018d9 commit 0355a58
Show file tree
Hide file tree
Showing 110 changed files with 1,176 additions and 1,080 deletions.
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/asum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Asum<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::asum;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -140,8 +135,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
20 changes: 9 additions & 11 deletions benchmark/cublas/blas1/axpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Axpy<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::axpy;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand All @@ -50,8 +45,8 @@ void run(benchmark::State& state, cublasHandle_t* cuda_handle_ptr, index_t size,
blas_benchmark::utils::set_benchmark_label<scalar_t>(state);

// init Google-benchmark counters.
blas_benchmark::utils::init_level_1_counters<
blas_benchmark::utils::Level1Op::axpy, scalar_t>(state, size);
blas_benchmark::utils::init_level_1_counters<benchmark_op, scalar_t>(state,
size);

cublasHandle_t& cuda_handle = *cuda_handle_ptr;

Expand Down Expand Up @@ -139,8 +134,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Dot<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::dot;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -141,8 +136,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/iamax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
#include "../utils.hpp"
#include "common/common_utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Iamax<" << blas_benchmark::utils::get_type_name<scalar_t>();
str << ">/" << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::iamax;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -147,8 +142,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/iamin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
#include "../utils.hpp"
#include "common/common_utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Iamin<" << blas_benchmark::utils::get_type_name<scalar_t>();
str << ">/" << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::iamin;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -146,8 +141,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/nrm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
#include "../utils.hpp"
#include <type_traits>

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Nrm2<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::nrm2;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -141,8 +136,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
15 changes: 7 additions & 8 deletions benchmark/cublas/blas1/rotg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name() {
std::ostringstream str{};
str << "BM_Rotg<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::rotg;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -158,8 +154,11 @@ void register_benchmark(blas_benchmark::Args& args,
bool* success) {
run<scalar_t>(st, cuda_handle_ptr, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>().c_str(), BM_lambda,
cuda_handle_ptr, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, success)
->UseRealTime();
}

Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/rotm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Rotm<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::rotm;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -160,8 +155,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/rotmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
#include "../utils.hpp"
#include "common/float_comparison.hpp"

template <typename scalar_t>
std::string get_name() {
std::ostringstream str{};
str << "BM_Rotmg<" << blas_benchmark::utils::get_type_name<scalar_t>()
<< ">/";
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::rotmg;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -164,8 +159,11 @@ void register_benchmark(blas_benchmark::Args& args,
bool* success) {
run<scalar_t>(st, cuda_handle_ptr, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>().c_str(), BM_lambda,
cuda_handle_ptr, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, success)
->UseRealTime();
}

Expand Down
16 changes: 7 additions & 9 deletions benchmark/cublas/blas1/scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(int size) {
std::ostringstream str{};
str << "BM_Scal<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/";
str << size;
return str.str();
}
constexpr blas_benchmark::utils::Level1Op benchmark_op =
blas_benchmark::utils::Level1Op::scal;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -138,8 +133,11 @@ void register_benchmark(blas_benchmark::Args& args,
index_t size, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, size, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(size).c_str(), BM_lambda,
cuda_handle_ptr, size, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
size, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, size, success)
->UseRealTime();
}
}
Expand Down
17 changes: 7 additions & 10 deletions benchmark/cublas/blas2/gbmv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(std::string t, int m, int n, int kl, int ku) {
std::ostringstream str{};
str << "BM_Gbmv<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/"
<< t << "/" << m << "/" << n << "/" << kl << "/" << ku;
return str.str();
}
constexpr blas_benchmark::utils::Level2Op benchmark_op =
blas_benchmark::utils::Level2Op::gbmv;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -166,9 +161,11 @@ void register_benchmark(blas_benchmark::Args& args,
scalar_t alpha, scalar_t beta, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, t, m, n, kl, ku, alpha, beta, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(ts, m, n, kl, ku).c_str(),
BM_lambda, cuda_handle_ptr, t, m, n, kl, ku,
alpha, beta, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
ts, m, n, kl, ku, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, t, m, n, kl, ku, alpha, beta, success)
->UseRealTime();
}
}
Expand Down
17 changes: 7 additions & 10 deletions benchmark/cublas/blas2/gemv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@

#include "../utils.hpp"

template <typename scalar_t>
std::string get_name(std::string t, int m, int n) {
std::ostringstream str{};
str << "BM_Gemv<" << blas_benchmark::utils::get_type_name<scalar_t>() << ">/"
<< t << "/" << m << "/" << n;
return str.str();
}
constexpr blas_benchmark::utils::Level2Op benchmark_op =
blas_benchmark::utils::Level2Op::gemv;

template <typename scalar_t, typename... args_t>
static inline void cublas_routine(args_t&&... args) {
Expand Down Expand Up @@ -164,9 +159,11 @@ void register_benchmark(blas_benchmark::Args& args,
scalar_t beta, bool* success) {
run<scalar_t>(st, cuda_handle_ptr, t, m, n, alpha, beta, success);
};
benchmark::RegisterBenchmark(get_name<scalar_t>(ts, m, n).c_str(),
BM_lambda, cuda_handle_ptr, t, m, n, alpha,
beta, success)
benchmark::RegisterBenchmark(
blas_benchmark::utils::get_name<benchmark_op, scalar_t>(
ts, m, n, blas_benchmark::utils::MEM_TYPE_USM)
.c_str(),
BM_lambda, cuda_handle_ptr, t, m, n, alpha, beta, success)
->UseRealTime();
}
}
Expand Down
Loading

0 comments on commit 0355a58

Please sign in to comment.