Skip to content

Commit

Permalink
Decouple from Blaze - part 2 (#38)
Browse files Browse the repository at this point in the history
- RegisterMatrixTest.testPotrf works
- Added reference gemm() implementation
- Cleaned-up few other tests in RegisterMatrixTest
- Added DynamicMatrix class
- Functions trans(), submatrix(), randomize(), makePositiveDefinite() implemented for BLAST matrices
- Randomize.hpp moved to blast/math/algorithm.
  • Loading branch information
mkatliar authored Sep 29, 2024
1 parent 81192ce commit 85721d3
Show file tree
Hide file tree
Showing 63 changed files with 1,281 additions and 364 deletions.
2 changes: 1 addition & 1 deletion bench/blas/Gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <bench/Gemm.hpp>

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

#include <blaze/Math.h>

Expand Down
2 changes: 1 addition & 1 deletion bench/blas/Iamax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Iamax.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/DynamicGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <bench/Gemm.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/DynamicSyrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Syrk.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/StaticGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <bench/Gemm.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/StaticGetrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <bench/Complexity.hpp>
#include <bench/Getrf.hpp>

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

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/StaticPotrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Complexity.hpp>

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

#include <random>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/StaticSyrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Syrk.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/dense/StaticTrmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <blast/blaze/Math.hpp>

#include <bench/Gemm.hpp>
#include <test/Randomize.hpp>
#include <blast/math/algorithm/Randomize.hpp>


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/panel/DynamicGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <bench/Gemm.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/panel/DynamicPotrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Complexity.hpp>

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

#include <random>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/panel/StaticGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <bench/Gemm.hpp>

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


namespace blast :: benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/panel/StaticPotrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Complexity.hpp>

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

#include <random>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions bench/blast/math/simd/Ger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <bench/Benchmark.hpp>

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


namespace blast :: benchmark
Expand Down Expand Up @@ -53,4 +53,4 @@ namespace blast :: benchmark
BENCHMARK_TEMPLATE(BM_RegisterMatrix_ger_nt, float, 24, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_ger_nt, float, 16, 5, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_ger_nt, float, 16, 6, columnMajor);
}
}
2 changes: 1 addition & 1 deletion bench/blast/math/simd/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <bench/Benchmark.hpp>

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

#include <blaze/Math.h>

Expand Down
4 changes: 2 additions & 2 deletions bench/blast/math/simd/PartialGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <bench/Benchmark.hpp>

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

#include <blaze/math/StaticMatrix.h>

Expand Down Expand Up @@ -47,4 +47,4 @@ namespace blast :: benchmark
BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialGemm_static, double, 4, 4, columnMajor, 3, 4);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialGemm_static, double, 4, 4, columnMajor, 4, 4);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialGemm_static, double, 4, 4, columnMajor, 1, 1);
}
}
4 changes: 2 additions & 2 deletions bench/blast/math/simd/PartialLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <bench/Benchmark.hpp>

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

#include <blaze/Math.h>

Expand Down Expand Up @@ -121,4 +121,4 @@ namespace blast :: benchmark

// BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialStore_static, double, 4, 4, columnMajor, 1, 4);
// BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialStore_static, double, 4, 4, columnMajor, 2, 4);
}
}
4 changes: 2 additions & 2 deletions bench/blast/math/simd/PartialStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <bench/Benchmark.hpp>

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

#include <blaze/math/StaticMatrix.h>

Expand Down Expand Up @@ -171,4 +171,4 @@ namespace blast :: benchmark

BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialStore_static, double, 4, 4, columnMajor, 1, 4);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_partialStore_static, double, 4, 4, columnMajor, 2, 4);
}
}
4 changes: 2 additions & 2 deletions bench/blast/math/simd/Potrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Complexity.hpp>

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


namespace blast :: benchmark
Expand Down Expand Up @@ -46,4 +46,4 @@ namespace blast :: benchmark
BENCHMARK_TEMPLATE(BM_RegisterMatrix_potrf, float, 8, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_potrf, float, 16, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_potrf, float, 24, 4, columnMajor);
}
}
2 changes: 1 addition & 1 deletion bench/blast/math/simd/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <bench/Benchmark.hpp>

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

#include <blaze/Math.h>

Expand Down
2 changes: 1 addition & 1 deletion bench/blast/math/simd/Trmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <bench/Benchmark.hpp>

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

#include <blast/blaze/Math.hpp>

Expand Down
4 changes: 2 additions & 2 deletions bench/blast/math/simd/Trsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <bench/Benchmark.hpp>
#include <bench/Trsm.hpp>

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


namespace blast :: benchmark
Expand Down Expand Up @@ -44,4 +44,4 @@ namespace blast :: benchmark
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trsm, double, 8, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trsm, double, 12, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trsm, double, 8, 8, columnMajor);
}
}
2 changes: 1 addition & 1 deletion bench/blaze/Gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.

#include <bench/Gemm.hpp>
#include <test/Randomize.hpp>
#include <blast/math/algorithm/Randomize.hpp>

#include <blaze/Math.h>

Expand Down
1 change: 0 additions & 1 deletion bench/blaze/StaticTrmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

#include <bench/Gemm.hpp>
#include <test/Randomize.hpp>

#include <blaze/Math.h>

Expand Down
2 changes: 1 addition & 1 deletion bench/eigen/Gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <Eigen/Dense>

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

#include <bench/Gemm.hpp>

Expand Down
2 changes: 1 addition & 1 deletion bench/libxsmm/Gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <bench/Gemm.hpp>

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

#include <libxsmm.h>

Expand Down
13 changes: 0 additions & 13 deletions include/blast/math/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <iosfwd>
#include <stdexcept>
#include <random>


namespace blast
Expand Down Expand Up @@ -49,18 +48,6 @@ namespace blast
{
return ptr<IsAligned_v<MT>>(m, 0, 0);
}


template <Matrix M>
inline void randomize(M& m) noexcept
{
std::mt19937 rng;
std::uniform_real_distribution<ElementType_t<M>> dist;

for (size_t i = 0; i < rows(m); ++i)
for (size_t j = 0; j < columns(m); ++j)
m(i, j) = dist(rng);
}


template <Matrix MA, Matrix MB>
Expand Down
29 changes: 11 additions & 18 deletions include/blast/math/TransposeFlag.hpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
// Copyright 2023 Mikhail Katliar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Copyright 2023-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.

#pragma once

#include <blaze/math/TransposeFlag.h>


namespace blast
{
/**
* @brief Defines whether a vector is a row or a column
*
* The bool values match those of @a blaze::TransposeFlag
*/
enum TransposeFlag : bool
{
rowVector = blaze::rowVector,
columnVector = blaze::columnVector
rowVector = true,
columnVector = false
};


inline TransposeFlag constexpr operator!(TransposeFlag tf)
{
return tf == TransposeFlag::rowVector ? TransposeFlag::columnVector : TransposeFlag::rowVector;
}
}
}
1 change: 1 addition & 0 deletions include/blast/math/TypeTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <blast/math/typetraits/IsPadded.hpp>
#include <blast/math/typetraits/IsContiguous.hpp>
#include <blast/math/typetraits/IsStaticallySpaced.hpp>
#include <blast/math/typetraits/IsView.hpp>
#include <blast/math/typetraits/ElementType.hpp>
#include <blast/math/typetraits/StorageOrder.hpp>
#include <blast/math/typetraits/Spacing.hpp>
Expand Down
Loading

0 comments on commit 85721d3

Please sign in to comment.