38#include <gtest/gtest.h>
69 constexpr size_t size = 16;
71 auto tile = mat.
asTile<uint8_t>(0);
74 for (
auto i = 0;
i < size;
i++) {
75 for (
auto j = 0; j < size; j++) {
84 for (
auto i = 0;
i < size;
i++) {
85 for (
auto j = 0; j < size; j++) {
86 ASSERT_EQ(tile[
i][j], 0);
93 constexpr size_t size = 16;
95 auto byte_tile = mat.
asTile<uint8_t>(0);
98 for (
auto i = 0;
i < size;
i++) {
99 for (
auto j = 0; j < size; j++) {
100 byte_tile[
i][j] = 0xAA;
105 auto half_word_tile = mat.
asTile<uint16_t>(0);
106 half_word_tile.zero();
109 for (
auto i = 0;
i < size / 2;
i++) {
110 for (
auto j = 0; j < size / 2; j++) {
111 ASSERT_EQ(half_word_tile[
i][j], 0);
117 half_word_tile = mat.
asTile<uint16_t>(1);
118 for (
auto i = 0;
i < size / 2;
i++) {
119 for (
auto j = 0; j < size / 2; j++) {
120 ASSERT_EQ(half_word_tile[
i][j], 0xAAAA);
125 for (
auto i = 0;
i < size;
i += 2) {
126 for (
auto j = 0; j < size; j++) {
127 ASSERT_EQ(byte_tile[
i][j], 0);
132 for (
auto i = 1;
i < size;
i += 2) {
133 for (
auto j = 0; j < size; j++) {
134 ASSERT_EQ(byte_tile[
i][j], 0xAA);
141 constexpr size_t size = 16;
143 auto byte_tile = mat.
asTile<uint8_t>(0);
146 for (
auto i = 0;
i < size;
i++) {
147 for (
auto j = 0; j < size; j++) {
148 byte_tile[
i][j] = 0xAA;
153 auto half_word_tile = mat.
asTile<uint16_t>(0);
154 auto row = half_word_tile.asHSlice(0);
158 for (
auto i = 0;
i < size / 2;
i++) {
159 ASSERT_EQ(row[
i], 0);
163 row = half_word_tile.asHSlice(1);
164 for (
auto i = 0;
i < size / 2;
i++) {
165 ASSERT_EQ(row[
i], 0xAAAA);
170 for (
auto i = 0;
i < size;
i++) {
171 for (
auto j = 0; j < size; j++) {
173 ASSERT_EQ(byte_tile[
i][j], 0);
175 ASSERT_EQ(byte_tile[
i][j], 0xAA);
183 constexpr size_t size = 16;
185 auto byte_tile = mat.
asTile<uint8_t>(0);
188 for (
auto i = 0;
i < size;
i++) {
189 for (
auto j = 0; j < size; j++) {
190 byte_tile[
i][j] = 0xAA;
195 auto half_word_tile = mat.
asTile<uint16_t>(0);
196 auto col = half_word_tile.asVSlice(0);
200 for (
auto i = 0;
i < size / 2;
i++) {
201 ASSERT_EQ(col[
i], 0);
205 col = half_word_tile.asVSlice(1);
206 for (
auto i = 0;
i < size / 2;
i++) {
207 ASSERT_EQ(col[
i], 0xAAAA);
212 for (
auto i = 0;
i < size;
i++) {
213 for (
auto j = 0; j < size; j++) {
214 if (
i % 2 == 0 && (j == 0 || j == 1)) {
215 ASSERT_EQ(byte_tile[
i][j], 0);
217 ASSERT_EQ(byte_tile[
i][j], 0xAA);
225 constexpr size_t size = 16;
227 auto byte_tile = mat.
asTile<uint8_t>(0);
230 for (
auto i = 0;
i < size;
i++) {
231 for (
auto j = 0; j < size; j++) {
232 byte_tile[
i][j] = 0xAA;
238 auto row = mat.
asHSlice<uint32_t>(4);
242 for (
auto i = 0;
i < size / 4;
i++) {
243 ASSERT_EQ(row[
i], 0);
248 for (
auto i = 0;
i < size;
i++) {
249 for (
auto j = 0; j < size; j++) {
251 ASSERT_EQ(byte_tile[
i][j], 0);
253 ASSERT_EQ(byte_tile[
i][j], 0xAA);
261 constexpr size_t size = 16;
263 auto byte_tile = mat.
asTile<uint8_t>(0);
266 for (
auto i = 0;
i < size;
i++) {
267 for (
auto j = 0; j < size; j++) {
268 byte_tile[
i][j] = 0xAA;
273 auto col = mat.
asVSlice<uint8_t>(4);
277 for (
auto i = 0;
i < size;
i++) {
278 ASSERT_EQ(col[
i], 0);
283 for (
auto i = 0;
i < size;
i++) {
284 for (
auto j = 0; j < size; j++) {
286 ASSERT_EQ(byte_tile[
i][j], 0);
288 ASSERT_EQ(byte_tile[
i][j], 0xAA);
295 for (
auto i = 0;
i < size;
i++) {
296 for (
auto j = 0; j < size; j++) {
297 byte_tile[
i][j] = 0xAA;
302 auto wide_col = mat.
asVSlice<uint32_t>(1);
306 for (
auto i = 0;
i < size;
i++) {
307 ASSERT_EQ(wide_col[
i], 0);
312 for (
auto i = 0;
i < size;
i++) {
313 for (
auto j = 0; j < size; j++) {
314 if (j >= 4 && j <= 7) {
315 ASSERT_EQ(byte_tile[
i][j], 0);
317 ASSERT_EQ(byte_tile[
i][j], 0xAA);
326 static constexpr size_t size = 4;
338 for (
auto i = 0;
i <
size;
i++) {
339 for (
auto j = 0; j <
size; j++) {
345 for (
auto i = 0;
i <
size;
i++) {
346 for (
auto j = 0; j <
size; j++) {
359 auto tile2 = mat2.asTile<uint8_t>(0);
362 for (
auto i = 0;
i < size;
i++) {
363 for (
auto j = 0; j < size; j++) {
364 ASSERT_EQ(tile2[
i][j], 0xAA);
373 ASSERT_TRUE(mat1 == mat1);
374 ASSERT_TRUE(mat2 == mat2);
375 ASSERT_FALSE(mat1 == mat2);
382 ASSERT_FALSE(mat1 != mat1);
383 ASSERT_FALSE(mat2 != mat2);
384 ASSERT_TRUE(mat1 != mat2);
391 std::ostringstream stream;
393 ASSERT_EQ(stream.str(),
"[aaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa]");
397 std::ostringstream stream;
399 ASSERT_EQ(stream.str(),
"[00000000_00000000_00000000_00000000]");
408 parser.parse(
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", mat1);
409 parser.parse(
"cccccccccccccccccccccccccccccccc", mat2);
411 for (
auto i = 0;
i < size;
i++) {
412 for (
auto j = 0; j < size; j++) {
413 ASSERT_EQ(mat1.asTile<uint8_t>(0)[
i][j], 0xbb);
414 ASSERT_EQ(mat2.asTile<uint8_t>(0)[
i][j], 0xcc);
425 EXPECT_ANY_THROW(parser.parse(
"b", mat1));
434 EXPECT_ANY_THROW(parser.parse(
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", mat1));
443 std::stringstream
ss;
445 ASSERT_EQ(
ss.str(),
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
449 std::stringstream
ss;
450 parser.show(
ss, mat2);
451 ASSERT_EQ(
ss.str(),
"00000000000000000000000000000000");
MatStore< size, size > mat1
MatStore< size, size > mat2
static constexpr size_t size
Backing store for matrices.
auto asTile(size_t index)
auto asVSlice(size_t col_idx)
static constexpr size_t linearSize()
auto asHSlice(size_t row_idx)
Matrix Register Specification.
TEST_F(TwoDifferentMatRegs, Assignment)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
constexpr unsigned MaxMatRegRowLenInBytes
constexpr unsigned MaxMatRegRows
static void show(std::ostream &os, const T &value)