Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6ceb4dd
first attempt
hngenc Jun 25, 2020
87e889a
Add residual layer
hngenc Jul 7, 2020
7c5c005
fixed stride bug in resadd
hngenc Jul 12, 2020
6d8e516
Added matrix-add tests
hngenc Sep 14, 2020
51d04e7
We pass bareMetalC tests on Spike now, but not imagenet tests
hngenc Sep 16, 2020
8a9e4d0
Updated params
hngenc Sep 17, 2020
f6335a8
merged header
Sep 20, 2020
94bf285
merged header
Sep 20, 2020
0017247
merge with A_stride
Sep 22, 2020
05436ac
merging and OS works
Sep 22, 2020
f79e76d
Made resadd use mvin_scale
hngenc Oct 16, 2020
616a7d1
First attempt to add hardware FSM for matmuls
hngenc Oct 23, 2020
25ee327
Added mvin mvout full tests
hngenc Nov 4, 2020
f2faf51
Added explicit gemmini_config_st to all bareMetalC tests
hngenc Nov 5, 2020
4358df6
Added double-buffering
hngenc Nov 9, 2020
c9a3eb3
Merge branch 'fsm' of https://github.com/ucb-bar/gemmini-rocc-tests i…
hngenc Nov 9, 2020
49babf0
Allow OS tiled matmuls to proceed
hngenc Nov 13, 2020
4334b30
Added explicit store configs to baremetal tests
hngenc Nov 14, 2020
0233af8
removed stale files
hngenc Nov 14, 2020
3ab001c
Update gemmini_params.h and other updates
hngenc Nov 15, 2020
6109644
Merge branch 'fsm' of https://github.com/ucb-bar/gemmini-rocc-tests i…
hngenc Nov 15, 2020
13d5835
Merged dev and fsm together
hngenc Nov 15, 2020
bbb7b5e
Updated params to make ACC_SCALE identity function, and removed print…
hngenc Nov 19, 2020
4a38dff
Made mobilenet use the CPU dw conv when convs aren't enabled
hngenc Nov 25, 2020
2df45dc
Add test rules
jerryz123 Nov 23, 2020
d3b703b
Added test for zero stride mvin
hngenc Nov 26, 2020
820799a
Added tranpose tests
hngenc Nov 29, 2020
c92cce8
Reduced size of transpose tests
hngenc Nov 29, 2020
7e87624
Add transpose options to loop_ws command
hngenc Nov 30, 2020
ce9688c
Add FAST versions of select tests
jerryz123 Nov 30, 2020
94e7074
Merge commit '7e87624a05c84862c3bd48e12ebcfaa3dfd04fa0' into ci
jerryz123 Dec 1, 2020
06153b2
Add relu6 back into cpu matmul
hngenc Dec 2, 2020
8af9156
Add full_C option to tiled_matmul
hngenc Dec 2, 2020
3cdddd9
Remove FAST exit(0)
jerryz123 Dec 3, 2020
7d15716
Added fences around pool mvout
hngenc Dec 3, 2020
2973bee
Merge pull request #9 from ucb-bar/ci
hngenc Dec 3, 2020
6fb9a46
Add low_D option to tiled_matmul
hngenc Dec 5, 2020
89f9aef
Fix FAST tests when bias is present
hngenc Dec 7, 2020
4974847
initial tests
Apr 28, 2021
0015b1a
sparse mvin tests, dummy gcn test
May 14, 2021
2e08459
gcn dummy tests
May 14, 2021
9a6f351
merge
May 14, 2021
1fa6bcf
updated params for 16x16 systolic array
May 15, 2021
f59419d
working with segfault protection
May 27, 2021
788c7e3
merging
Jun 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ build
autom4te.cache
configure
.ipynb_checkpoints
*.swp

35 changes: 35 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
#=============================================================================
# variables
#=============================================================================
Expand All @@ -7,6 +8,7 @@ XLEN := @XLEN@
RISCVTOOLS := @RISCVTOOLS@
ROCC := examples
CATEGORIES := bareMetalC mlps imagenet
RUNNER := "spike --extension=gemmini "

#=============================================================================
# targets
Expand All @@ -30,3 +32,36 @@ clean:
$(MAKE) -C imagenet -f $(abs_top_srcdir)/imagenet/Makefile abs_top_srcdir=$(abs_top_srcdir) PREFIX=$(ROCC)-imagenet clean
$(MAKE) -C mlps -f $(abs_top_srcdir)/mlps/Makefile abs_top_srcdir=$(abs_top_srcdir) PREFIX=$(ROCC)-mlps clean

test-baremetal-bareMetalC:
make -C bareMetalC \
-f $(abs_top_srcdir)/bareMetalC/Makefile \
TARGET_MAKEFILE=$(abs_top_srcdir)/bareMetalC/Makefile \
abs_top_srcdir=$(abs_top_srcdir) \
src_dir=$(abs_top_srcdir)/bareMetalC \
XLEN=$(XLEN) \
PREFIX=$(ROCC)-bareMetalC \
RISCVTOOLS=$(RISCVTOOLS) \
RUNNER=$(RUNNER) \
run-baremetal

test-baremetal: test-baremetal-bareMetalC
make -C mlps \
-f $(abs_top_srcdir)/mlps/Makefile \
TARGET_MAKEFILE=$(abs_top_srcdir)/mlps/Makefile \
abs_top_srcdir=$(abs_top_srcdir) \
src_dir=$(abs_top_srcdir)/mlps \
XLEN=$(XLEN) \
PREFIX=$(ROCC)-mlps \
RISCVTOOLS=$(RISCVTOOLS) \
RUNNER=$(RUNNER) \
run-baremetal
make -C imagenet \
-f $(abs_top_srcdir)/imagenet/Makefile \
TARGET_MAKEFILE=$(abs_top_srcdir)/imagenet/Makefile \
abs_top_srcdir=$(abs_top_srcdir) \
src_dir=$(abs_top_srcdir)/imagenet \
XLEN=$(XLEN) \
PREFIX=$(ROCC)-imagenet \
RISCVTOOLS=$(RISCVTOOLS) \
RUNNER=$(RUNNER) \
run-baremetal
81 changes: 81 additions & 0 deletions bareMetalC/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

tests := \
mvin_mvout \
mvin_mvout_sparse \
mvin_mvout_stride \
mvin_mvout_acc \
mvin_mvout_acc_zero_stride \
mvin_mvout_acc_stride \
mvin_mvout_acc_full \
mvin_mvout_acc_full_stride \
matmul_os \
matmul_ws \
matmul \
Expand All @@ -15,9 +19,86 @@ tests := \
conv_with_pool \
tiled_matmul_os \
tiled_matmul_ws \
tiled_matmul_gcn_1 \
tiled_matmul_gcn_1b \
tiled_matmul_gcn_2 \
tiled_matmul_gcn_3 \
tiled_matmul_gcn_4 \
tiled_matmul_gcn_4b \
tiled_matmul_ws_At \
tiled_matmul_ws_Bt \
tiled_matmul_ws_full_C \
tiled_matmul_ws_low_D \
tiled_matmul_cpu \
tiled_matmul_option \
tiled_matmul_ws_perf \
transpose \
template \
gemm
matrix_add \
resadd \
template

tests_baremetal = $(tests:=-baremetal)

ifeq ($(findstring spike,$(RUNNER)),spike)
# Currently don't support conv or conv-with-pool on spike
runs_baremetal = $(addsuffix .run,$(filter-out conv-baremetal conv_with_pool-baremetal,$(tests_baremetal)))
else
# Don't run very long benchmarks for RTL sim
runs_baremetal = $(addsuffix .run,$(filter-out tiled_matmul_cpu-baremetal tiled_matmul_option-baremetal,$(tests_baremetal)))
endif

ifdef BAREMETAL_ONLY
tests_linux =
else
tests_linux = $(tests:=-linux)
endif

BENCH_COMMON = $(abs_top_srcdir)/riscv-tests/benchmarks/common
GEMMINI_HEADERS = $(abs_top_srcdir)/include/gemmini.h $(abs_top_srcdir)/include/gemmini_params.h $(abs_top_srcdir)/include/gemmini_testutils.h

CFLAGS := $(CFLAGS) \
-DPREALLOCATE=1 \
-DMULTITHREAD=1 \
-mcmodel=medany \
-std=gnu99 \
-O2 \
-ffast-math \
-fno-common \
-fno-builtin-printf \
-march=rv64gc -Wa,-march=rv64gcxhwacha \
-lm \
-lgcc \
-I$(abs_top_srcdir)/riscv-tests \
-I$(abs_top_srcdir)/riscv-tests/env \
-I$(abs_top_srcdir) \
-I$(BENCH_COMMON) \
-DID_STRING=$(ID_STRING) \

CFLAGS_BAREMETAL := \
$(CFLAGS) \
-nostdlib \
-nostartfiles \
-static \
-T $(BENCH_COMMON)/test.ld \
-DBAREMETAL=1 \

all: $(tests_baremetal) $(tests_linux)

vpath %.c $(src_dir)

%-baremetal: %.c $(GEMMINI_HEADERS)
$(CC_BAREMETAL) $(CFLAGS_BAREMETAL) $< $(LFLAGS) -o $@ \
$(wildcard $(BENCH_COMMON)/*.c) $(wildcard $(BENCH_COMMON)/*.S) $(LIBS)

%-linux: %.c $(GEMMINI_HEADERS)
$(CC_LINUX) $(CFLAGS) $< $(LFLAGS) -o $@

run-baremetal: $(runs_baremetal)

%-baremetal.run: %-baremetal
$(RUNNER)$(abs_top_srcdir)/build/bareMetalC/$^

junk += $(tests_baremetal) $(tests_linux)

1 change: 1 addition & 0 deletions bareMetalC/aligned.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int main() {
}

gemmini_config_ld(DIM * sizeof(elem_t));
gemmini_config_st(DIM * sizeof(elem_t));

// printf("Mvin\n");
gemmini_mvin(In.data, 0);
Expand Down
45 changes: 37 additions & 8 deletions bareMetalC/conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@
#define PADDING 1
#define STRIDE 2
#else
#define BATCH_SIZE 3
#ifdef FAST
#define IN_DIM 9
#define IN_CHANNELS 5
#define OUT_CHANNELS 7
#else
#define IN_DIM 23
#define IN_CHANNELS 17
#define OUT_CHANNELS 31
#endif

#define BATCH_SIZE 3
#define KERNEL_DIM 3
#define PADDING 1
#define STRIDE 2

#endif

#define NO_BIAS false
Expand Down Expand Up @@ -69,9 +77,6 @@ void conv(int batch_size, int in_channels, int in_dim,
}
}

// Shift while rounding to nearest integer (ties round to negative infinity)
result = ROUNDING_RIGHT_SHIFT(result, 0);

// Clip result
result = result > elem_t_max ? elem_t_max : (result < elem_t_min ? elem_t_min : result);

Expand Down Expand Up @@ -113,16 +118,26 @@ bool vec_is_equal(elem_t * a, elem_t * b, int len) {
}

void init_random(elem_t * buf, int len) {
elem_t i = 0;
for (elem_t * ptr = buf; ptr < buf + len; ptr++) {
// *ptr = (rand() % 32) - 16;
*ptr = (rand() % 5) - 2;
#ifdef FAST
*ptr = 1;
#else
*ptr = (rand() % 5) - 2;
#endif
}
}

void init_random_acc(acc_t * buf, int len) {
elem_t i = 0;
for (acc_t * ptr = buf; ptr < buf + len; ptr++) {
// *ptr = (rand() % 32) - 16;
*ptr = (rand() % 5) - 2;
#ifdef FAST
*ptr = 1;
#else
*ptr = (rand() % 5) - 2;
#endif
}
}

Expand Down Expand Up @@ -159,6 +174,7 @@ int main() {

printf("CPU conv...\n");
uint64_t start_cpu = read_cycles();
#ifndef FAST
conv(BATCH_SIZE, IN_CHANNELS, IN_DIM,
OUT_CHANNELS, KERNEL_DIM,
OUT_DIM,
Expand All @@ -167,6 +183,7 @@ int main() {
weights,
bias,
output);
#endif
uint64_t end_cpu = read_cycles();
printf("CPU conv took %llu cycles\n", end_cpu - start_cpu);

Expand All @@ -191,15 +208,28 @@ int main() {
NO_BIAS ? NULL : (acc_t*)bias,
(elem_t*)output_mat,

NO_ACTIVATION, 0, 0, 0, 0, 0,
NO_ACTIVATION, ACC_SCALE_IDENTITY, 0, 0, 0, 0,

WS);
uint64_t end_gemmini = read_cycles();
printf("Gemmini conv took %llu cycles\n", end_gemmini - start_gemmini);

ASSERT(sizeof(output_mat) == sizeof(output), "output_mat size");

#ifdef FAST
bool success = true;
for (int orow = 0; orow < BATCH_SIZE * OUT_DIM * OUT_DIM; orow++) {
for (int ocol = 0; ocol < OUT_CHANNELS; ocol++) {
elem_t v = output_mat[orow][ocol];
if (v != 21 && v != 31 && v != 46) {
success = false;
break;
}
}
}
#else
bool success = vec_is_equal(&output[0][0][0][0], &output_mat[0][0], sizeof(output) / sizeof(elem_t));
#endif

if (!success) {
// return 1;
Expand Down Expand Up @@ -289,4 +319,3 @@ int main() {

return 0;
}

Loading