forked from pulp-platform/snitch_cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bump] Adjust Snitch cluster for TCASAI kernels
- Loading branch information
viv-eth
committed
Oct 12, 2024
1 parent
7439705
commit cc1c68f
Showing
18 changed files
with
919 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2023 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Luca Colagrande <colluca@iis.ee.ethz.ch> | ||
|
||
# Usage of absolute paths is required to externally include this Makefile | ||
MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
DATA_DIR := $(realpath $(MK_DIR)/data) | ||
SRC_DIR := $(realpath $(MK_DIR)/src) | ||
|
||
SECTION ?= | ||
|
||
APP ?= ata | ||
SRCS ?= $(SRC_DIR)/main.c | ||
INCDIRS += $(DATA_DIR) $(SRC_DIR) | ||
|
||
DATAGEN_PY = $(DATA_DIR)/datagen.py | ||
DATA_H = $(DATA_DIR)/data.h | ||
DATA_CFG ?= $(DATA_DIR)/params.hjson | ||
|
||
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | ||
$< -c $(DATA_CFG) --section="$(SECTION)" $@ | ||
|
||
.PHONY: clean-data clean | ||
|
||
clean-data: | ||
rm -f $(DATA_H) | ||
|
||
clean: clean-data | ||
|
||
debug_app: | ||
@echo "MK_DIR: $(MK_DIR)" | ||
@echo "DATA_DIR: $(DATA_DIR)" | ||
@echo "SRC_DIR: $(SRC_DIR)" | ||
@echo "SECTION: $(SECTION)" | ||
@echo "APP: $(APP)" | ||
@echo "SRCS: $(SRCS)" | ||
@echo "INCDIRS: $(INCDIRS)" | ||
@echo "DATAGEN_PY: $(DATAGEN_PY)" | ||
@echo "DATA_H: $(DATA_H)" | ||
@echo "DATA_CFG: $(DATA_CFG)" | ||
@echo "$(DATAGEN_PY) -c $(DATA_CFG) --section=\"$(SECTION)\" $(DATA_H)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
|
||
double A[64] = { | ||
-0.36, | ||
-0.14, | ||
-0.38, | ||
-1.96, | ||
-1.34, | ||
-1.45, | ||
0.61, | ||
-0.34, | ||
-0.63, | ||
-1.98, | ||
-1.19, | ||
0.64, | ||
-1.38, | ||
0.65, | ||
0.13, | ||
0.91, | ||
-1.79, | ||
-1.08, | ||
0.92, | ||
-1.25, | ||
0.18, | ||
0.66, | ||
-0.59, | ||
-1.98, | ||
0.87, | ||
0.64, | ||
-1.05, | ||
-0.56, | ||
-0.54, | ||
-0.49, | ||
-1.74, | ||
0.69, | ||
-0.87, | ||
-0.6, | ||
-0.59, | ||
-0.48, | ||
0.68, | ||
0.14, | ||
-1.85, | ||
-1.57, | ||
-0.03, | ||
0.13, | ||
0.34, | ||
-1.2, | ||
-0.83, | ||
-1.26, | ||
-0.15, | ||
0.79, | ||
-0.44, | ||
0.14, | ||
-1.26, | ||
-0.81, | ||
-0.86, | ||
0.74, | ||
-0.49, | ||
-0.07, | ||
0.49, | ||
-0.15, | ||
-0.94, | ||
0.52, | ||
0.33, | ||
-0.04, | ||
0.31, | ||
0.37, | ||
}; | ||
|
||
double B[256]; | ||
|
||
ata_args_t args = { | ||
.m = 16, | ||
.n = 4, | ||
.a = A, | ||
.b = B, | ||
.m_tiles = 2, | ||
.funcptr = ata_opt | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Author: Luca Colagrande <colluca@iis.ee.ethz.ch> | ||
|
||
import numpy as np | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../../util/sim/")) | ||
|
||
from data_utils import format_array_definition, format_array_declaration, \ | ||
format_struct_definition, DataGen, validate_tcdm_footprint | ||
|
||
|
||
DOUBLE_BUFFER = True | ||
|
||
class AtaDataGen(DataGen): | ||
|
||
# Function pointers to alternative implementations | ||
FUNCPTRS = ["ata_baseline", "ata_opt"] | ||
|
||
def golden_model(self, A): | ||
return np.matmul(A, A.transpose()) | ||
|
||
def validate(self, **kwargs): | ||
assert (kwargs['m'] % kwargs['m_tiles']) == 0, "m must be an integer multiple of m_tiles" | ||
m_frac = kwargs['m'] / kwargs['m_tiles'] | ||
assert (m_frac % 8) == 0, "m_frac must be an integer multiple of the number of cores" | ||
assert (m_frac % 4) == 0, "m_frac must be an integer multiple of the unroll factor 4" | ||
assert kwargs['funcptr'] in self.FUNCPTRS, f"Function pointer must be among {self.FUNCPTRS}" | ||
|
||
# Calculate total TCDM occupation | ||
a_tile_size = m_frac * kwargs['n'] * 8 | ||
b_tile_size = m_frac * m_frac * 8 | ||
total_size = 2 * a_tile_size + b_tile_size | ||
if DOUBLE_BUFFER: | ||
total_size *= 2 | ||
validate_tcdm_footprint(total_size) | ||
|
||
def emit_header(self, **kwargs): | ||
header = [super().emit_header()] | ||
|
||
self.validate(**kwargs) | ||
|
||
A = np.random.randint(-200, 100, size=(kwargs['m'], kwargs['n']))/100 | ||
B = self.golden_model(A) | ||
|
||
A = A.flatten() | ||
B = B.flatten() | ||
|
||
A_uid = 'A' | ||
B_uid = 'B' | ||
|
||
cfg = { | ||
'm': kwargs['m'], | ||
'n': kwargs['n'], | ||
'a': A_uid, | ||
'b': B_uid, | ||
'm_tiles': kwargs['m_tiles'], | ||
'funcptr': kwargs['funcptr'] | ||
} | ||
|
||
header += [format_array_definition('double', A_uid, A)] | ||
header += [format_array_declaration('double', B_uid, B.shape)] | ||
header += [format_struct_definition('ata_args_t', 'args', cfg)] | ||
header = '\n\n'.join(header) | ||
|
||
return header | ||
|
||
|
||
if __name__ == '__main__': | ||
AtaDataGen().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
{ | ||
"m": 16, | ||
"n": 4, | ||
"m_tiles": 2, | ||
"funcptr": "ata_opt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Author: Luca Colagrande <colluca@iis.ee.ethz.ch> | ||
|
||
#pragma once | ||
#include <stdint.h> | ||
|
||
typedef void (*ata_fp_t)(uint32_t m, uint32_t n, double *a, double *at,double *b); | ||
|
||
typedef struct { | ||
uint32_t m; | ||
uint32_t n; | ||
double *a; | ||
double *b; | ||
uint32_t m_tiles; | ||
ata_fp_t funcptr; | ||
} ata_args_t; |
Oops, something went wrong.