Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench/blast/math/dense/DynamicGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// license that can be found in the LICENSE file.

#include <blast/math/dense/Gemm.hpp>
#include <blast/math/Matrix.hpp>
#include <blast/blaze/Math.hpp>

#include <bench/Gemm.hpp>

#include <blaze/math/DynamicMatrix.h>

#include <test/Randomize.hpp>


Expand Down
4 changes: 2 additions & 2 deletions bench/blast/math/dense/StaticGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// license that can be found in the LICENSE file.

#include <blast/math/dense/Gemm.hpp>
#include <blast/math/Matrix.hpp>
#include <blast/blaze/Math.hpp>

#include <bench/Gemm.hpp>

#include <blaze/math/StaticMatrix.h>

#include <test/Randomize.hpp>


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

#include <blast/math/dense/Iamax.hpp>

#include <blaze/math/DynamicVector.h>
#include <blast/blaze/Math.hpp>

#include <bench/Iamax.hpp>
#include <bench/Complexity.hpp>
Expand Down
7 changes: 2 additions & 5 deletions bench/blast/math/dense/StaticTrmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
// license that can be found in the LICENSE file.

#include <blast/math/dense/Trmm.hpp>

#include <blaze/math/StaticMatrix.h>
#include <blast/math/Matrix.hpp>
#include <blast/blaze/Math.hpp>

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

#include <random>
#include <memory>


namespace blast :: benchmark
{
Expand Down
2 changes: 2 additions & 0 deletions bench/blast/math/panel/StaticGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// license that can be found in the LICENSE file.

#include <blast/math/StaticPanelMatrix.hpp>
#include <blast/math/Matrix.hpp>
#include <blast/math/panel/Gemm.hpp>
#include <blast/blaze/Math.hpp>

#include <bench/Gemm.hpp>

Expand Down
6 changes: 3 additions & 3 deletions bench/blast/math/simd/Trmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

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

#include <bench/Benchmark.hpp>

#include <test/Randomize.hpp>

#include <blaze/math/StaticMatrix.h>
#include <blast/blaze/Math.hpp>


namespace blast :: benchmark
Expand Down Expand Up @@ -81,4 +81,4 @@ namespace blast :: benchmark
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trmmRightLower, float, 24, 4, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trmmRightLower, float, 16, 5, columnMajor);
BENCHMARK_TEMPLATE(BM_RegisterMatrix_trmmRightLower, float, 16, 6, columnMajor);
}
}
10 changes: 10 additions & 0 deletions include/blast/blaze/Math.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 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 <blast/blaze/math/Vector.hpp>
#include <blast/blaze/math/TypeTraits.hpp>

#include <blaze/Math.h>
12 changes: 12 additions & 0 deletions include/blast/blaze/math/TypeTraits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 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 <blast/blaze/math/typetraits/IsContiguous.hpp>
#include <blast/blaze/math/typetraits/IsStatic.hpp>
#include <blast/blaze/math/typetraits/IsStaticallySpaced.hpp>
#include <blast/blaze/math/typetraits/IsDenseVector.hpp>
#include <blast/blaze/math/typetraits/IsDenseMatrix.hpp>
#include <blast/blaze/math/typetraits/Spacing.hpp>
38 changes: 38 additions & 0 deletions include/blast/blaze/math/Vector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 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 <blast/blaze/math/typetraits/IsContiguous.hpp>

#include <blaze/math/typetraits/IsDenseVector.h>
#include <blaze/math/typetraits/IsView.h>


namespace blaze
{
/**
* @brief Memory distance between consecutive elements of a dense Blaze vector
*
* NOTE: The function is declared in blaze namespace s.t. it can be found by ADL.
*
* @tparam VT vector type
*
* @param v vector
*
* @return memory distance between consecutive elements of @a v
*/
template <typename VT>
requires blaze::IsDenseVector_v<VT>
inline size_t spacing(VT const& v) noexcept
{
if constexpr (IsContiguous_v<VT>)
return 1;
else
if constexpr (blaze::IsView_v<VT>)
return spacing(v.operand());
else
static_assert(false, "Spacing is not defined for a type which is not a view and is not contiguous");
}
}
41 changes: 41 additions & 0 deletions include/blast/blaze/math/typetraits/IsContiguous.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 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 <blast/math/typetraits/IsContiguous.hpp>

#include <blaze/math/Aliases.h>
#include <blaze/math/typetraits/IsContiguous.h>
#include <blaze/math/typetraits/IsVector.h>
#include <blaze/math/typetraits/IsTransExpr.h>

#include <type_traits>


namespace blast
{
/**
* @brief Specialization for Blaze vectors which are not transpose expressions
*
* @tparam T type
*/
template <typename T>
requires blaze::IsVector_v<T> && (!blaze::IsTransExpr_v<T>)
struct IsContiguous<T> : blaze::IsContiguous<T> {};


/**
* @brief Specialization for Blaze vector transpose expressions
*
* The trasnposed vector expression is contiguous iff its operand is contiguous.
*
* This specialization is required to fix this Blaze bug: https://bitbucket.org/blaze-lib/blaze/issues/474
*
* @tparam T type
*/
template <typename T>
requires blaze::IsVector_v<T> && blaze::IsTransExpr_v<T>
struct IsContiguous<T> : IsContiguous<std::remove_reference_t<blaze::Operand_t<T>>> {};
}
23 changes: 23 additions & 0 deletions include/blast/blaze/math/typetraits/IsDenseMatrix.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2019-2020 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 <blast/math/typetraits/IsDenseMatrix.hpp>

#include <blaze/math/typetraits/IsDenseMatrix.h>
#include <blaze/math/typetraits/IsMatrix.h>


namespace blast
{
/**
* @brief Specialization for Blaze matrices
*
* @tparam T matrix type
*/
template <typename T>
requires blaze::IsMatrix_v<T>
struct IsDenseMatrix<T> : blaze::IsDenseMatrix<T> {};
}
23 changes: 23 additions & 0 deletions include/blast/blaze/math/typetraits/IsDenseVector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2019-2020 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 <blast/math/typetraits/IsDenseVector.hpp>

#include <blaze/math/typetraits/IsDenseVector.h>
#include <blaze/math/typetraits/IsVector.h>


namespace blast
{
/**
* @brief Specialization for Blaze vectors
*
* @tparam T vector type
*/
template <typename T>
requires blaze::IsVector_v<T>
struct IsDenseVector<T> : blaze::IsDenseVector<T> {};
}
24 changes: 24 additions & 0 deletions include/blast/blaze/math/typetraits/IsStatic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 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 <blast/math/typetraits/IsStatic.hpp>

#include <blaze/math/typetraits/IsVector.h>
#include <blaze/math/typetraits/IsMatrix.h>
#include <blaze/math/typetraits/IsStatic.h>


namespace blast
{
/**
* @brief Specialization for Blaze matrix and vector types
*
* @tparam T matrix or vector type
*/
template <typename T>
requires blaze::IsVector_v<T> || blaze::IsMatrix_v<T>
struct IsStatic<T> : blaze::IsStatic<T> {};
}
44 changes: 44 additions & 0 deletions include/blast/blaze/math/typetraits/IsStaticallySpaced.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 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 <blast/math/typetraits/IsStaticallySpaced.hpp>
#include <blast/math/typetraits/IsContiguous.hpp>

#include <blaze/math/typetraits/IsVector.h>
#include <blaze/math/typetraits/IsView.h>
#include <blaze/math/typetraits/IsStatic.h>
#include <blaze/math/Aliases.h>


namespace blast
{
/**
* @brief Specialization for Blaze vectors which are not views
*
* Blaze vectors which are not views are statically spaced iff they are contiguous
*
* @tparam VT vector type
*/
template <typename VT>
requires blaze::IsVector_v<VT> && (!blaze::IsView_v<VT>)
struct IsStaticallySpaced<VT> : IsContiguous<VT> {};


/**
* @brief Specialization for Blaze vectors which are views
*
* Blaze vectors which are views are statically spaced iff they are contiguous or their viewed type is static
*
* @tparam VT vector type
*/
template <typename VT>
requires blaze::IsVector_v<VT> && blaze::IsView_v<VT>
struct IsStaticallySpaced<VT>
: std::integral_constant<bool,
IsContiguous_v<VT> || blaze::IsStatic_v<blaze::ViewedType_t<VT>>
>
{};
}
59 changes: 59 additions & 0 deletions include/blast/blaze/math/typetraits/Spacing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2019-2020 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 <blast/math/typetraits/Spacing.hpp>
#include <blast/blaze/math/typetraits/IsContiguous.hpp>

#include <blaze/math/Aliases.h>
#include <blaze/math/typetraits/IsDenseVector.h>
#include <blaze/math/typetraits/IsDenseMatrix.h>
#include <blaze/math/typetraits/IsTransExpr.h>
#include <blaze/math/typetraits/IsView.h>

#include <type_traits>


namespace blast
{
/**
* @brief Specialization for Blaze dense matrices which are not transpose expressions
*
* @tparam MT matrix type
*/
template <typename MT>
requires blaze::IsDenseMatrix_v<MT> && (!blaze::IsTransExpr_v<MT>)
struct Spacing<MT> : std::integral_constant<size_t, MT::spacing()> {};


/**
* @brief Specialization for Blaze dense matrix transpose expressions
*
* @tparam MT matrix type
*/
template <typename MT>
requires blaze::IsDenseMatrix_v<MT> && blaze::IsTransExpr_v<MT>
struct Spacing<MT> : Spacing<std::remove_reference_t<blaze::Operand_t<MT>>> {};


/**
* @brief Specialization for contiguous dense Blaze vectors
*
* @tparam VT vector type
*/
template <typename VT>
requires blaze::IsDenseVector_v<VT> && IsContiguous_v<VT>
struct Spacing<VT> : std::integral_constant<size_t, 1> {};


/**
* @brief Specialization for non-contiguous dense Blaze vector views
*
* @tparam VT vector type
*/
template <typename VT>
requires blaze::IsDenseVector_v<VT> && (!IsContiguous_v<VT>) && blaze::IsView_v<VT>
struct Spacing<VT> : Spacing<blaze::ViewedType_t<VT>> {};
}
Loading