Skip to content

Commit

Permalink
Changed type of SO template parameter of RegisterMatrix from bool to …
Browse files Browse the repository at this point in the history
…StorageOrder and fixed benchmarks
  • Loading branch information
mkatliar committed Nov 6, 2024
1 parent 06ae6a4 commit bed7392
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 116 deletions.
9 changes: 4 additions & 5 deletions bench/blast/math/simd/Ger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@

namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_ger_nt(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;
using ET = ElementType_t<Kernel>;
size_t constexpr K = 100;

DynamicPanelMatrix<ET> a(Traits::rows, K);
DynamicPanelMatrix<ET> b(Traits::columns, K);
DynamicPanelMatrix<ET> c(Traits::rows, Traits::columns);
DynamicPanelMatrix<ET> a(Kernel::rows(), K);
DynamicPanelMatrix<ET> b(Kernel::columns(), K);
DynamicPanelMatrix<ET> c(Kernel::rows(), Kernel::columns());

randomize(a);
randomize(b);
Expand Down
23 changes: 6 additions & 17 deletions bench/blast/math/simd/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@

#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/Math.h>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_load_dynamic_panel(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

DynamicPanelMatrix<double> c(ker.rows(), ker.columns());
randomize(c);
Expand All @@ -37,13 +32,10 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_load_dynamic_dense(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

DynamicMatrix<double, SO> c(ker.rows(), ker.columns());
randomize(c);
Expand All @@ -58,13 +50,10 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_load_static_dense(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

StaticMatrix<double, M, N, SO> c;
randomize(c);
Expand Down
11 changes: 5 additions & 6 deletions bench/blast/math/simd/PartialGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
#include <blast/math/DynamicPanelMatrix.hpp>
#include <blast/math/RegisterMatrix.hpp>
#include <blast/math/dense/StaticMatrixPointer.hpp>
#include <blast/math/dense/StaticMatrix.hpp>

#include <bench/Benchmark.hpp>

#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/math/StaticMatrix.h>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO, size_t MM, size_t NN>
template <typename T, size_t M, size_t N, StorageOrder SO, size_t MM, size_t NN>
static void BM_RegisterMatrix_partialGemm_static(State& state)
{
size_t constexpr K = 5;

blaze::StaticMatrix<T, M, K, SO> A;
blaze::StaticMatrix<T, K, N, SO> B;
blaze::StaticMatrix<T, M, N, SO> C, D;
StaticMatrix<T, M, K, SO> A;
StaticMatrix<T, K, N, SO> B;
StaticMatrix<T, M, N, SO> C, D;

randomize(A);
randomize(B);
Expand Down
5 changes: 2 additions & 3 deletions bench/blast/math/simd/PartialLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
#include <blast/math/DynamicPanelMatrix.hpp>
#include <blast/math/RegisterMatrix.hpp>
#include <blast/math/dense/StaticMatrixPointer.hpp>
#include <blast/math/dense/StaticMatrix.hpp>

#include <bench/Benchmark.hpp>

#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/Math.h>

#include <functional>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_partialLoad_static_dense(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
Expand Down
11 changes: 5 additions & 6 deletions bench/blast/math/simd/PartialStore.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright (c) 2019-2020 Mikhail Katliar All rights reserved.
// Copyright (c) 2019-2024 Mikhail Katliar All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include <blast/math/DynamicPanelMatrix.hpp>
#include <blast/math/RegisterMatrix.hpp>
#include <blast/math/dense/StaticMatrixPointer.hpp>
#include <blast/math/dense/StaticMatrix.hpp>

#include <bench/Benchmark.hpp>

#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/math/StaticMatrix.h>

#include <functional>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_partialStore_panel(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
Expand All @@ -44,7 +43,7 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_partialStore(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
Expand All @@ -71,7 +70,7 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO, size_t MM, size_t NN>
template <typename T, size_t M, size_t N, StorageOrder SO, size_t MM, size_t NN>
static void BM_RegisterMatrix_partialStore_static(State& state)
{
RegisterMatrix<T, M, N, SO> ker;
Expand Down
15 changes: 5 additions & 10 deletions bench/blast/math/simd/Potrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@

namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_potrf(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;
size_t constexpr m = Traits::rows;
size_t constexpr n = Traits::columns;

DynamicPanelMatrix<T> a(m, n);
DynamicPanelMatrix<T> a(M, N);
randomize(a);

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;
ker.load(ptr(a));

for (auto _ : state)
Expand All @@ -34,8 +29,8 @@ namespace blast :: benchmark
DoNotOptimize(ker);
}

if (m >= n)
setCounters(state.counters, complexityPotrf(m, n));
if (M >= N)
setCounters(state.counters, complexityPotrf(M, N));
}


Expand Down
23 changes: 6 additions & 17 deletions bench/blast/math/simd/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@

#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/Math.h>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_store_dynamic_panel(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

DynamicPanelMatrix<double> c(ker.rows(), ker.columns()), d(ker.rows(), ker.columns());
randomize(c);
Expand All @@ -39,13 +34,10 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_store_dynamic_dense(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

DynamicMatrix<double, SO> c(ker.rows(), ker.columns()), d(ker.rows(), ker.columns());
randomize(c);
Expand All @@ -62,13 +54,10 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_store_static_dense(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

StaticMatrix<double, M, N, SO> c, d;
randomize(c);
Expand Down
21 changes: 9 additions & 12 deletions bench/blast/math/simd/Trmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@

#include <blast/math/Matrix.hpp>
#include <blast/math/RegisterMatrix.hpp>
#include <blast/math/dense/StaticMatrix.hpp>

#include <bench/Benchmark.hpp>

#include <blast/math/algorithm/Randomize.hpp>

#include <blast/blaze/Math.hpp>


namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO, UpLo UPLO>
template <typename T, size_t M, size_t N, StorageOrder SO, UpLo UPLO>
static void BM_RegisterMatrix_trmmLeft(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
size_t constexpr K = 100;

blaze::StaticMatrix<T, Kernel::rows(), Kernel::rows(), SO> A;
blaze::StaticMatrix<T, Kernel::rows(), Kernel::columns(), columnMajor> B;
StaticMatrix<T, M, M, SO> A;
StaticMatrix<T, M, N, columnMajor> B;

randomize(A);
randomize(B);

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

for (auto _ : state)
{
Expand All @@ -38,19 +36,18 @@ namespace blast :: benchmark
}


template <typename T, size_t M, size_t N, bool SO, UpLo UPLO>
template <typename T, size_t M, size_t N, StorageOrder SO, UpLo UPLO>
static void BM_RegisterMatrix_trmmRight(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
size_t constexpr K = 100;

blaze::StaticMatrix<T, Kernel::columns(), Kernel::columns(), SO> A;
blaze::StaticMatrix<T, Kernel::rows(), Kernel::columns(), columnMajor> B;
StaticMatrix<T, N, N, SO> A;
StaticMatrix<T, M, N, columnMajor> B;

randomize(A);
randomize(B);

Kernel ker;
RegisterMatrix<T, M, N, SO> ker;

for (auto _ : state)
{
Expand Down
11 changes: 4 additions & 7 deletions bench/blast/math/simd/Trsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@

namespace blast :: benchmark
{
template <typename T, size_t M, size_t N, bool SO>
template <typename T, size_t M, size_t N, StorageOrder SO>
static void BM_RegisterMatrix_trsm(State& state)
{
using Kernel = RegisterMatrix<T, M, N, SO>;
using Traits = RegisterMatrixTraits<Kernel>;
size_t constexpr m = Traits::rows;
size_t constexpr n = Traits::columns;

StaticPanelMatrix<double, m, n, columnMajor> L;
StaticPanelMatrix<double, M, N, columnMajor> L;
randomize(L);

StaticPanelMatrix<double, m, n, columnMajor> A;
StaticPanelMatrix<double, M, N, columnMajor> A;
randomize(A);

Kernel ker;
Expand All @@ -36,7 +33,7 @@ namespace blast :: benchmark
DoNotOptimize(ker);
}

setCounters(state.counters, complexity(trsmTag, false, m, n));
setCounters(state.counters, complexity(trsmTag, false, M, N));
}


Expand Down
Loading

0 comments on commit bed7392

Please sign in to comment.