gem5 v24.0.0.0
Loading...
Searching...
No Matches
matrix.hh File Reference

Matrix Register Specification. More...

#include <array>
#include <cassert>
#include <cstring>
#include <iostream>
#include <type_traits>
#include "base/cprintf.hh"
#include "base/logging.hh"
#include "base/types.hh"
#include "sim/serialize_handlers.hh"

Go to the source code of this file.

Classes

class  gem5::HorizontalSlice< ElemType, Container, FromTile >
 Provides a view of a horizontal slice of either a MatStore or a Tile. More...
 
class  gem5::VerticalSlice< ElemType, Container, FromTile >
 Provides a view of a vertical slice of either a MatStore or a Tile. More...
 
class  gem5::Tile< ElemType, Container >
 Provides a view of a matrix that is row-interleaved onto a MatStore. More...
 
class  gem5::MatStore< X, Y >
 Backing store for matrices. More...
 
struct  gem5::ParseParam< MatStore< X, Y > >
 Calls required for serialization/deserialization. More...
 
struct  gem5::ShowParam< MatStore< X, Y > >
 
struct  gem5::DummyMatRegContainer
 Dummy type aliases and constants for architectures that do not implement matrix registers. More...
 
struct  gem5::ParseParam< DummyMatRegContainer >
 

Namespaces

namespace  gem5
 Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
 

Functions

static std::ostream & gem5::operator<< (std::ostream &os, const DummyMatRegContainer &d)
 

Variables

constexpr unsigned gem5::MaxMatRegRowLenInBytes = 256
 
constexpr unsigned gem5::MaxMatRegRows = 256
 

Detailed Description

Matrix Register Specification.

In this file we add three new classes which are used to provide both the backing storage for matrix registers (MatStore) and for accessing them using a set of views onto the backing store (Tile, TileSlice).

The MatStore provides the backing store for the matrix, handles the serialisation/unserialisation, and provides interfaces to obtain views of the matrix. The underlying element for the MatStore is a byte, and it uses two templated parameters, X and Y, to set the overall size of the matrix. The common use case will be that X and Y are the same size, yielding a square matrix, but this is not a requirement - it is possible to create non-square matricies too if such a thing is desired.

The Tile provides a view on top of the MatStore which is intended to preserve the original aspect ratio of the underlying MatStore as the element size scales. It does so by row-wise interleaving one or more sub-matrices on top of the MatStore, where the number of sub-matrices is governed by the element size (in bytes) itself. As an example, if the elements are half-words, i.e. 2 bytes wide, then there are two interleaved matrices with even rows belonging to sub-matrix 0 and odd rows belonging to sub-matrix 1. However, each of these sub-matricies maintains the original aspect ratio of the MatStore - the element size has doubled (bytes => half words), hence each row contains half the original number of elements, and each sub-matrix contains half of the number of rows themselves.

The TileSlice class provides a view of either a row or a column of a matrix, and can be generated from either the MatStore directly, or from the Tile. In the former case this allows a matrix to be viewed as a set of rows or columns, and in the latter this same approach is applied to the Tile. In both cases this is achieved by adjusting the striding through the backing store accordingly.

The intended usage of the views is as follows:

// declare an 8x8 matrix of bytes using Mat8x8 = MatStore<8, 8>;

// Create a matrix and make sure that it is zeroed Mat8x8 mat; mat.zero();

// Interleave four tiles of int32_t onto the 8x8 matrix, and get // tile 0. (Each of these tiles will be a 2x2 matrix) auto mat0 = mat.asTile<int32_t>(0);

// Set both elements of row 0 to 10 for (auto i = 0; i < 2; ++i) { mat0[0][i] = 10; }

// Sum both elements of row 1 int32_t sum = 0; auto row = mat0.asHSlice(1); for (auto i = 0; i < 2; ++i) { sum += row[i]; }

// print column 1 of the whole MatStore when viewed as uint16_t col = mat.asVSlice<uint16_t>(1); for (auto i = 0; i < 4; ++i) { std::cout << col[i] << std::endl; }

Definition in file matrix.hh.


Generated on Tue Jun 18 2024 16:24:08 for gem5 by doxygen 1.11.0