107#ifndef __ARCH_ARM_MATRIX_HH__
108#define __ARCH_ARM_MATRIX_HH__
114#include <type_traits>
128template <
size_t X,
size_t Y>
130template <
typename ElemType,
typename Container>
133template <
size_t X,
size_t Y>
150template <
typename ElemType,
typename Container,
bool FromTile>
154 template <
typename,
typename>
friend class Tile;
170 startElts(_startBytes / sizeof(ElemType)),
177 assert (_startBytes %
sizeof(ElemType) == 0);
178 assert (_strideBytes %
sizeof(ElemType) == 0);
180 if constexpr (!FromTile) {
183 assert(_strideBytes ==
container->xSize());
187 assert(_strideBytes /
container->xSize() ==
sizeof(ElemType));
195 assert(elem_idx <
xElems);
197 return container->template rawPtr<ElemType>()[linear_index];
204 (*this)[
i] = (ElemType)0;
223template <
typename ElemType,
typename Container,
bool FromTile>
227 template <
typename,
typename>
friend class Tile;
238 VerticalSlice(Container& cnt,
size_t _startBytes,
size_t _strideBytes,
size_t idx)
242 startElts(_startBytes / sizeof(ElemType)),
249 assert (_startBytes %
sizeof(ElemType) == 0);
250 assert (_strideBytes %
sizeof(ElemType) == 0);
252 if constexpr (!FromTile) {
255 assert(_strideBytes ==
container->xSize());
259 assert(_strideBytes /
container->xSize() ==
sizeof(ElemType));
267 assert(elem_idx <
yElems);
269 return container->template rawPtr<ElemType>()[linear_index];
276 (*this)[
i] = (ElemType)0;
294template <
typename ElemType,
typename Container>
309 Tile(Container& cnt,
size_t idx)
334 assert(row_idx < container->ySize() /
NUM_TILES);
344 assert(col_idx < container->xSize());
379template <
size_t X,
size_t Y>
382 static_assert(X > 0,
"X size cannot be 0");
383 static_assert(Y > 0,
"Y size cannot be 0");
391 static constexpr inline size_t xSize() {
return X; };
392 static constexpr inline size_t ySize() {
return Y; };
429 template<
size_t X2,
size_t Y2>
433 return X == X2 && Y == Y2 &&
440 template<
size_t X2,
size_t Y2>
449 template <
typename ElemType>
452 return reinterpret_cast<const ElemType*
>(
container.data());
455 template <
typename ElemType>
459 template <
typename ElemType>
466 template <
typename ElemType>
473 template <
typename ElemType>
486 for (
auto&
b:
v.container) {
509template <
size_t X,
size_t Y>
516 "Matrix register value overflow at unserialize");
518 "Matrix register value underflow at unserialize");
520 for (
int i = 0;
i < X * Y;
i++) {
522 if (2 *
i < str.size())
523 b = stoul(str.substr(
i * 2, 2),
nullptr, 16);
524 value.template rawPtr<uint8_t>()[
i] =
b;
530template <
size_t X,
size_t Y>
562static_assert(
sizeof(DummyMatRegContainer) ==
sizeof(
RegVal));
563static inline std::ostream &
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Provides a view of a horizontal slice of either a MatStore or a Tile.
HorizontalSlice(Container &cnt, size_t _startBytes, size_t _strideBytes, size_t idx)
ElemType & operator[](size_t elem_idx)
Backing store for matrices.
bool operator!=(const MatStore< X2, Y2 > &that) const
Inequality operator.
friend std::ostream & operator<<(std::ostream &os, const MatStore< X, Y > &v)
auto asTile(size_t index)
MatStore(const MatStore &)=default
static constexpr size_t LINEAR_SIZE
auto asVSlice(size_t col_idx)
static constexpr size_t linearSize()
MyClass & operator=(const MyClass &that)
Assignment operators.
friend class HorizontalSlice
const ElemType * rawPtr() const
Get pointer to the raw data.
auto asHSlice(size_t row_idx)
friend class VerticalSlice
std::array< uint8_t, LINEAR_SIZE > Container
static constexpr size_t xSize()
bool operator==(const MatStore< X2, Y2 > &that) const
Equality operator.
static constexpr size_t ySize()
Provides a view of a matrix that is row-interleaved onto a MatStore.
auto operator[](size_t idx)
Container * getContainer()
auto asVSlice(size_t col_idx)
Tile(Container &cnt, size_t idx)
static constexpr size_t NUM_TILES
auto asHSlice(size_t row_idx)
Provides a view of a vertical slice of either a MatStore or a Tile.
VerticalSlice(Container &cnt, size_t _startBytes, size_t _strideBytes, size_t idx)
ElemType & operator[](size_t elem_idx)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define gem5_assert(cond,...)
The assert macro will function like a normal assert, but will use panic instead of straight abort().
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
constexpr unsigned MaxMatRegRowLenInBytes
constexpr unsigned MaxMatRegRows
static std::ostream & operator<<(std::ostream &os, const DummyMatRegContainer &d)
void ccprintf(cp::Print &print)
Dummy type aliases and constants for architectures that do not implement matrix registers.
bool operator!=(const DummyMatRegContainer &d) const
bool operator==(const DummyMatRegContainer &d) const
static bool parse(const std::string &s, DummyMatRegContainer &value)
static bool parse(const std::string &str, MatStore< X, Y > &value)
static void show(std::ostream &os, const MatStore< X, Y > &value)