Skip to content

Commit 8421b6e

Browse files
author
Germain Haugou
committed
Several modifications to be able to use magia-sdk in gvsoc ci:
- Added possibility to specify cmake build folder.This is useful to compile all tests for different tile sizes and then run all the tests to be able to run them in parallel. - Added testset for running all tests on gvsoc for tiles 2, 4 and 8
1 parent 085b747 commit 8421b6e

3 files changed

Lines changed: 82 additions & 14 deletions

File tree

Makefile

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2025 ETH Zurich and University of Bologna
22
#
3-
# Licensed under the Solderpad Hardware License, Version 0.51
4-
# (the "License"); you may not use this file except in compliance
3+
# Licensed under the Solderpad Hardware License, Version 0.51
4+
# (the "License"); you may not use this file except in compliance
55
# with the License. You may obtain a copy of the License at
66
#
77
# http://www.apache.org/licenses/LICENSE-2.0
@@ -15,17 +15,18 @@
1515
#
1616
# Authors: Victor Isachi <victor.isachi@unibo.it>
1717
# Alberto Dequino <alberto.dequino@unibo.it>
18-
#
18+
#
1919
# Magia-sdk Makefile
2020

2121
SHELL := /bin/bash
2222

23+
CMAKE_BUILDDIR ?= build
2324
BUILD_DIR ?= ../sw/tests/$(test)
2425
MAGIA_DIR ?= ../
2526
GVSOC_DIR ?= ./gvsoc
2627
CURR_DIR ?= $(shell pwd)
2728
GVSOC_ABS_PATH ?= $(CURR_DIR)/gvsoc
28-
BIN_ABS_PATH ?= $(CURR_DIR)/build/bin
29+
BIN_ABS_PATH ?= $(CURR_DIR)/$(CMAKE_BUILDDIR)/bin
2930
BIN ?= $(BUILD_DIR)/build/verif
3031
build_mode ?= update
3132
fsync_mode ?= stall
@@ -51,7 +52,10 @@ tiles_2 := $(shell echo $$(( $(tiles) * $(tiles) )))
5152
tiles_log := $(shell awk 'BEGIN { printf "%.0f", log($(tiles_2))/log(2) }')
5253
tiles_log_real := $(shell awk 'BEGIN { printf "%.0f", log($(tiles))/log(2) }')
5354

54-
.PHONY: gvsoc
55+
GVRUN ?= $(GVSOC_DIR)/install/bin/gvrun
56+
GVRUN_ARGS ?= --work-dir $(GVSOC_ABS_PATH)/Documents/test --attr magia/n_tiles_x=$(tiles) --attr magia/n_tiles_y=$(tiles)
57+
58+
.PHONY: gvsoc build
5559

5660
clean:
5761
rm -rf build/
@@ -79,13 +83,13 @@ ifeq ($(compiler), GCC_MULTILIB)
7983
sed -i -E 's/^#add_subdirectory\(flatatt\)/add_subdirectory\(flatatt\)/' ./tests/magia/mesh/CMakeLists.txt
8084
sed -i -E 's/^\/\/#include "utils\/attention_utils.h"/#include "utils\/attention_utils.h"/' ./targets/$(target_platform)/include/tile.h
8185
endif
82-
cmake -DTARGET_PLATFORM=$(target_platform) -DEVAL=$(eval) -DSTALLING=$(stalling) -DFSYNC_MM=$(fsync_mm) -DIDMA_MM=$(idma_mm) -DREDMULE_MM=$(redmule_mm) -DCOMPILER=$(compiler) -DPROFILE_CMP=$(profile_cmp) -DPROFILE_CMI=$(profile_cmi) -DPROFILE_CMO=$(profile_cmo) -DPROFILE_SNC=$(profile_snc) -B build --trace-expand
83-
cmake --build build --verbose
86+
cmake -DTARGET_PLATFORM=$(target_platform) -DEVAL=$(eval) -DSTALLING=$(stalling) -DFSYNC_MM=$(fsync_mm) -DIDMA_MM=$(idma_mm) -DREDMULE_MM=$(redmule_mm) -DCOMPILER=$(compiler) -DPROFILE_CMP=$(profile_cmp) -DPROFILE_CMI=$(profile_cmi) -DPROFILE_CMO=$(profile_cmo) -DPROFILE_SNC=$(profile_snc) -B $(CMAKE_BUILDDIR) --trace-expand
87+
cmake --build $(CMAKE_BUILDDIR) --verbose
8488

8589
set_mesh:
8690
ifeq ($(tiles), 1)
8791
$(eval mesh_dv=0)
88-
endif
92+
endif
8993

9094
run: set_mesh
9195
@echo 'Magia is available at https://github.com/pulp-platform/MAGIA.git'
@@ -94,23 +98,23 @@ run: set_mesh
9498
ifndef test
9599
$(error Proper formatting is: make run test=<test_name> platform=rtl|gvsoc)
96100
endif
97-
ifeq (,$(wildcard ./build/bin/$(test)))
101+
ifeq (,$(wildcard $(CMAKE_BUILDDIR)/bin/$(test)))
98102
$(error No test found with name: $(test))
99103
endif
100104
ifndef platform
101105
$(error Proper formatting is: make run test=<test_name> platform=rtl|gvsoc)
102106
endif
103107
ifeq ($(platform), gvsoc)
104-
$(GVSOC_DIR)/install/bin/gvrun --target magia_v2 --work-dir $(GVSOC_ABS_PATH)/Documents/test --param binary=$(BIN_ABS_PATH)/$(test) run --attr magia/n_tiles_x=$(tiles) --attr magia/n_tiles_y=$(tiles)
108+
$(GVRUN) --target magia_v2 --param binary=$(BIN_ABS_PATH)/$(test) run $(GVRUN_ARGS)
105109
else ifeq ($(platform), rtl)
106110
mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && mkdir -p build
107111
cp ./build/bin/$(test) $(BUILD_DIR)/build/verif
108112
objcopy --srec-len 1 --output-target=srec $(BIN) $(BIN).s19
109113
scripts/parse_s19.pl $(BIN).s19 > $(BIN).txt
110-
python3 scripts/s19tomem.py $(BIN).txt $(BUILD_DIR)/build/stim_instr.txt $(BUILD_DIR)/build/stim_data.txt
114+
python3 scripts/s19tomem.py $(BIN).txt $(BUILD_DIR)/build/stim_instr.txt $(BUILD_DIR)/build/stim_data.txt
111115
cd $(BUILD_DIR) && \
112116
cp -sf ../../../sim/modelsim.ini modelsim.ini && \
113-
ln -sfn ../../../sim/work work
117+
ln -sfn ../../../sim/work work
114118
riscv32-unknown-elf-objdump -d -S -Mmarch=$(ISA) $(BIN) > $(BIN).dump
115119
riscv32-unknown-elf-objdump -d -l -s -Mmarch=$(ISA) $(BIN) > $(BIN).objdump
116120
python3 scripts/objdump2itb.py $(BIN).objdump > $(BIN).itb
@@ -175,5 +179,3 @@ gvsoc_init:
175179
git checkout lz/magia-v2-core && \
176180
cd ../pulp && \
177181
git checkout lz/magia-v2-pulp
178-
179-

gvtest.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
targets:
2+
magia:

testset.cfg

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from gvtest.testsuite import *
2+
from functools import partial
3+
4+
# This script can be used to run all the tests for different tile sizes on gvsoc
5+
# First compile all the tests for all the tiles with:
6+
# make build compiler=GCC_PULP tiles=2 CMAKE_BUILDDIR=$PWD/build/tile2
7+
# make build compiler=GCC_PULP tiles=4 CMAKE_BUILDDIR=$PWD/build/tile4
8+
# make build compiler=GCC_PULP tiles=8 CMAKE_BUILDDIR=$PWD/build/tile8
9+
# Then execute:
10+
# gvtest
11+
# Available tests can be obtained with:
12+
# gvtest tests
13+
# Single test can be run with:
14+
# gvtest --test magia-sdk:tile8:test_float --stdout
15+
16+
def tests_build(tile_name, nb_tile, testset):
17+
18+
tests = [
19+
"test_helloworld",
20+
"test_fsync_levels",
21+
"test_fsync_diag",
22+
"test_mm_is",
23+
"test_fsync_sync",
24+
"test_mm_os",
25+
"test_idma",
26+
"test_fsync_rc",
27+
"test_float",
28+
"test_cemm_global",
29+
"test_mm_is_nb",
30+
"test_mm_is_2",
31+
"test_mm_ws_2",
32+
"test_mm_ws",
33+
"test_amo",
34+
"test_mm_ws_nb",
35+
"test_brah",
36+
"test_mm_os_2",
37+
]
38+
39+
skipped_tests = {
40+
'tile2': ['test_mm_is_nb', 'test_mm_ws_2', 'test_brah', 'test_mm_os_2'],
41+
'tile4': ['test_cemm_global', 'test_mm_is_nb', 'test_mm_is_2', 'test_brah', 'test_mm_os_2'],
42+
'tile8': ['test_mm_ws', 'test_amo', 'test_mm_ws_nb', 'test_brah', 'test_mm_os_2'],
43+
}
44+
45+
for test_name in tests:
46+
test = testset.new_test(test_name)
47+
cwd = testset.get_path()
48+
work_dir = f'{cwd}/build/{tile_name}/work/{test_name}'
49+
test.add_command(Shell('run', f'make run platform=gvsoc CMAKE_BUILDDIR={cwd}/build/{tile_name} GVRUN=gvrun test={test_name} GVRUN_ARGS="--work-dir {work_dir}'
50+
f' --attr magia/n_tiles_x={nb_tile} --attr magia/n_tiles_y={nb_tile}"'))
51+
52+
if skipped_tests.get(tile_name) is not None and test_name in skipped_tests.get(tile_name):
53+
print(f"\033[31mSkipping Magia test {test_name} for tile {tile_name}\033")
54+
test.skip('Failing, to be fixed')
55+
56+
57+
def testset_build(testset):
58+
59+
testset.set_name('magia-sdk')
60+
61+
for tile in [2, 4, 8]:
62+
name = f'tile{tile}'
63+
tile_testset = testset.new_testset(name)
64+
tile_testset.add_testset(callback=partial(tests_build, name, tile))

0 commit comments

Comments
 (0)