diff --git a/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/Makefile b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/Makefile new file mode 100644 index 000000000..9e75d252d --- /dev/null +++ b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/Makefile @@ -0,0 +1,26 @@ +# Copyright 2023 KU Leuven. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 +# +# Xiaoling Yi + +APP = snax-mlperf-tiny-ad01 + +INCDIRS = ../../../snax-mlir/runtime/include +INCDIRS += data + +# Include the snax-mlir prebuilt binary in the final build +RISCV_LDFLAGS += bin/snax-mlperf-tiny-ad01.o + +SRCS = src/snax-mlperf-tiny-ad01.c + +include ./data/Makefile +include ../../common.mk + + +$(DEP): $(DATA_H) + +build/snax-mlperf-tiny-ad01.part.elf: $(DEP) $(LD_SRCS) | $(BUILDDIR) + $(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRCS) -o $@ + + diff --git a/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/bin/snax-mlperf-tiny-ad01.o b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/bin/snax-mlperf-tiny-ad01.o new file mode 100755 index 000000000..dce429ef0 Binary files /dev/null and b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/bin/snax-mlperf-tiny-ad01.o differ diff --git a/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/Makefile b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/Makefile new file mode 100644 index 000000000..b5373648d --- /dev/null +++ b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/Makefile @@ -0,0 +1,7 @@ +MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) +DATA_DIR := $(realpath $(MK_DIR)) + + +DATA_H = $(DATA_DIR)/data.h + + diff --git a/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/data.h b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/data.h new file mode 100755 index 000000000..aa8f1d3bd --- /dev/null +++ b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/data/data.h @@ -0,0 +1,430 @@ +#include + +const int8_t A[5120] = { + 45, -117, 0, 13, -80, 43, 69, 24, -10, 39, -105, 56, + 65, 77, -94, 89, -60, 52, -49, 27, 124, -45, 35, 92, + 68, -9, -2, 12, -24, -2, 102, 89, -118, 37, -11, -19, + 84, 95, 34, 32, -106, -46, -38, 38, 115, 87, -25, -29, + -91, 56, -122, -15, -40, -69, -84, -51, -57, -67, -52, 101, + 89, 62, 5, -113, -39, 27, 51, 119, 13, 78, 77, -58, + -69, -70, -86, -29, 66, -61, -55, -5, 103, -2, 47, 75, + -88, -53, 107, 80, -40, 41, -26, 8, 47, 73, 96, -5, + -39, -33, -20, 18, -46, 12, 14, -27, 38, 103, 116, 109, + -102, -61, -118, 87, -50, -20, -80, -109, -55, 25, -32, -41, + -118, -100, -49, -105, 21, 24, 111, 38, -12, -119, -82, -122, + 81, -108, -58, -33, 116, 19, -89, 86, 70, -97, -119, 118, + 127, -56, -74, 72, -48, -120, 111, -92, 48, -98, 58, 95, + 65, -118, 63, 95, -45, 60, 7, 123, -28, -31, -65, -6, + 89, 40, 22, 77, 50, -3, -119, 78, 116, 3, -92, -9, + -98, -124, -65, 6, 20, 67, 81, 72, 20, -115, 76, 46, + 15, -68, -56, -97, 40, -30, -4, 57, -95, 94, 82, 36, + 66, -64, 21, -118, 78, 51, -91, 58, -53, 18, 10, 0, + 83, 86, 114, -95, 35, -75, 67, -96, 91, 24, 6, 75, + 67, -99, -100, 117, -55, -88, -21, 24, 97, -66, -6, 36, + 107, 58, -60, 127, -6, 52, -80, 76, -82, -75, 71, -13, + 44, 39, 61, 56, -59, 71, -11, -99, 89, -16, -72, -93, + 100, 5, 18, 1, 41, 30, -93, 1, -23, 80, -123, 37, + 104, 123, -45, -74, -35, -98, 31, 6, -104, -46, -89, -89, + -49, 51, 29, 105, -114, 107, -71, 117, -29, 112, 30, -110, + 114, 113, -29, -48, -6, 26, 114, 5, 50, -111, 104, -22, + 71, 12, 47, -85, 109, -80, -12, 59, 54, -119, -35, -96, + 59, 114, 29, -7, -44, 98, -16, -126, -46, -127, 104, -62, + 118, 24, 51, 104, -16, -21, -102, 42, 112, -21, -112, -70, + -23, -58, 121, -92, -70, 50, 43, -25, -80, -75, 40, -8, + 109, 47, 44, -116, 60, 65, -84, 47, 34, 92, -74, -45, + 93, 48, -36, -36, -47, -126, -94, 1, 120, -83, 65, 15, + 106, 64, -47, -28, 75, 27, 28, -74, -89, -99, -34, 13, + -52, -73, -44, -6, -21, 121, 18, 43, -64, 87, -118, -43, + -79, -55, -15, 76, 73, -32, 35, -59, -110, -121, 126, -121, + 52, -2, 118, 69, 28, -96, -101, -80, -59, -98, 40, 0, + 115, -7, -74, 117, -72, 20, 35, 4, 21, -52, -86, 77, + 116, 76, 127, -27, -100, -77, 40, 53, -91, 117, 21, 105, + 56, 88, -63, -49, -112, -107, -21, 16, -91, -31, -8, 21, + 71, 6, -6, 100, 45, 19, -65, 59, -36, 31, 32, -104, + -68, 51, -87, 80, 43, 8, -41, 14, 12, -62, -99, -10, + 18, 61, 45, -42, -72, -122, 41, -79, -93, -75, -46, -78, + 118, -32, -92, -58, 39, -62, 72, 42, -71, -44, -77, 36, + -105, -104, 116, 65, 70, -27, -33, -32, -35, 28, 42, 70, + 29, -83, 83, -33, -17, -6, -124, -127, 34, 92, -103, -14, + 88, -13, 32, 51, 15, 4, 87, -91, 118, -11, 45, 35, + 104, 26, -103, -79, -28, 82, 121, -34, -64, 122, 122, 4, + -54, 82, 97, -29, 7, 122, -8, -85, 63, -9, 3, 78, + -124, -114, 123, -15, -46, -60, -113, 104, -88, 88, 27, 22, + -84, 0, -12, 74, -31, -63, 62, 0, 106, -98, -122, -127, + -73, -119, -117, 11, 120, -108, -14, -13, -118, -25, -55, -84, + -77, 71, 123, 59, -76, 70, -97, 0, 14, -123, -35, -104, + 89, 80, -52, 60, 87, -100, -4, 3, 113, -27, -97, -6, + -102, -51, 49, -29, -39, -24, -46, -65, 95, -25, 98, 36, + -92, -114, -21, 95, -5, -110, 108, -4, 121, -20, -111, 68, + 40, 2, -72, -45, 91, -58, 50, 47, -72, 49, 17, 100, + 75, -115, 18, 21, -35, -8, 94, 82, 17, 113, -60, -77, + 75, -52, 3, 28, 22, 116, 6, -113, -36, 47, 107, -86, + -3, -115, -103, -69, 125, 81, 108, 66, -69, -14, 20, -91, + 93, -57, -106, -117, -36, 103, 110, -41, 17, -103, -56, -84, + 61, 14, -46, -23, -76, -26, -125, -116, -23, 92, 43, -125, + 60, 36, 88, -76, 2, 62, -94, -47, -75, 46, 38, -95, + -71, -30, 56, 55, -107, -26, 88, 1, 5, -105, -53, -89, + -36, 70, -60, -108, 34, 102, -81, 47, 21, 88, -26, -85, + 55, -90, 23, -12, 54, 6, 14, 57, 69, -90, -122, 61, + 10, -70, -85, 105, -22, -74, 85, -50, 63, 44, -33, -97, + 58, -76, -126, -103, -74, -2, -90, -2, -29, 6, 46, -125, + 4, 83, 18, -124, -65, -96, -58, -33, -95, -87, 53, 99, + 45, -74, 61, -20, 24, 90, -54, -114, 126, -46, 119, -15, + 120, 108, -17, -87, -54, 47, -64, -55, -74, 17, 66, -108, + -115, 0, 20, -32, 51, -25, -26, -55, -112, 17, 24, 27, + 70, -29, 102, 67, -102, 0, 19, 121, -43, 17, 36, 53, + 97, -100, -70, -60, 106, -67, 101, 109, -36, 104, 116, -66, + -96, -103, 47, -113, 80, -9, -13, -31, 32, 127, -13, -123, + -66, 47, 89, 68, 32, 4, 123, 110, -109, -110, 52, 12, + -23, 64, -98, 125, 84, -91, -51, -41, 43, -36, 69, 78, + -114, -42, 81, -6, -116, -18, -22, -18, -25, 2, -26, -52, + 20, 106, 45, 57, 123, 16, 98, -111, 39, 115, -64, 25, + -51, 79, 21, 30, -108, -80, -47, 22, -23, 58, 98, -17, + 5, -90, 120, -102, 65, -54, 50, 81, 38, 38, 23, 61, + -60, 43, 58, -6, -120, 97, 41, -9, 76, -41, 1, -10, + -75, 1, 9, 62, 102, 66, 117, -44, -73, -123, -68, 34, + 11, 93, 37, -23, -88, -105, -26, 33, 68, 2, -19, 101, + -67, -21, 31, 124, 22, -67, 28, 124, 107, 17, -6, -6, + 89, 106, -123, -57, 22, -37, -7, 86, -126, -75, -50, -96, + 42, -47, 56, -114, -93, -126, 42, -56, 72, 58, -54, 57, + 7, -61, -53, 25, 21, -85, -29, -48, -61, -73, 31, -86, + 25, 74, 64, -109, 74, 68, -18, -87, -65, 99, 97, 55, + -18, 47, -93, 80, -63, -42, -101, -116, -68, -35, -51, 39, + 81, 38, -104, -16, -71, 106, 18, -34, 78, 35, -37, 122, + -16, -60, 24, 2, 85, -60, 14, 96, 123, -121, 20, -9, + 40, 28, -119, -83, -84, -71, 40, 89, 97, -114, 121, -2, + -66, 113, 39, -103, 97, -83, -45, -60, -15, -14, -17, 83, + 44, 37, -71, 112, -108, 5, 102, -124, 96, -86, -91, 107, + 9, -103, -33, 77, -121, 103, -103, 103, 88, 21, -16, -92, + -78, 107, 124, 87, -105, -42, 101, 127, 52, 38, -61, 62, + 59, -29, 79, 70, -49, -5, 10, 88, -117, -77, 53, -84, + -53, 44, -13, -95, -7, 41, -102, -116, -35, -2, -102, -23, + -73, -28, 108, 85, -103, -78, -37, 11, 5, 89, 55, 55, + 55, -95, -7, 108, -16, 53, 38, 118, -43, 88, -2, -65, + -61, -89, 29, 127, 23, 104, -16, 3, -66, 95, 105, -2, + 30, -118, -125, -92, 26, -86, -100, 119, -95, 3, 84, -48, + 22, 30, 90, 5, 55, -85, 24, 43, 51, -96, -74, 100, + -16, 72, -76, -110, -104, 90, 47, -59, -19, 94, 21, -11, + 45, 79, 54, -52, -46, -22, -98, 23, 49, 18, -60, -65, + 86, -92, -92, -85, -66, -23, -88, -60, 2, -119, 10, 110, + 53, -110, -54, -119, 11, 124, -86, 50, 11, 51, 24, 124, + 16, -32, 4, -32, -100, -11, -81, -112, 11, -20, 91, 35, + 89, 57, 51, -40, 116, -115, -19, -68, 76, 94, -124, -88, + 18, -34, -96, 72, 60, 122, -118, 60, -62, -123, 11, 110, + -106, 92, -100, 111, -110, -68, 46, 50, -125, 72, -63, 82, + 68, 40, 6, -88, -35, -66, -107, 51, 114, -42, 42, 97, + 59, -30, 116, 64, -83, 109, 112, -84, -93, -84, 100, -41, + 35, 40, -29, 6, -39, -107, -44, -2, -94, -103, 106, -114, + 6, 59, 72, -41, 105, 121, -77, -76, -109, 116, -82, -91, + 89, 62, -123, -127, 72, 70, -84, 76, 70, -80, 76, -93, + 58, 37, -9, 70, -95, -44, -70, -1, -124, 101, 96, 54, + 120, -23, -39, 127, 85, 50, 114, -47, 61, 23, 110, 63, + -10, 55, 28, 9, 1, -43, 53, 62, -23, 63, 25, 2, + 25, -89, -119, 82, 105, 29, 73, -15, -26, -86, -85, -92, + 58, -126, 1, -7, -74, -102, 32, -36, -114, 102, -115, 41, + -63, 70, 20, -11, -104, 121, 51, -91, 12, 103, -67, 49, + 49, -114, 127, -102, 39, -87, 112, -60, -46, -20, -59, -24, + 96, -83, 30, 125, 98, 89, 46, -92, -68, -96, 10, -13, + 13, -62, 94, -97, -40, -123, 24, -98, -43, -72, 65, 114, + -57, 106, 59, -94, 78, 105, 119, 19, 33, 92, -48, -110, + 86, 99, 14, 94, 81, 114, -26, -43, -70, -32, -73, 126, + -46, 57, -74, -125, -117, 115, -71, -58, -39, 43, -80, -26, + 118, -72, 13, -28, 67, 114, -83, 19, 80, 18, -10, -76, + -44, 62, 126, -21, 62, -12, -61, 54, 15, -2, -16, -17, + -30, 121, -36, 89, -72, -69, -42, -82, -71, 47, 40, 2, + -98, -62, -88, 111, 86, -106, 76, 91, -113, 23, -17, -14, + -113, 31, 110, -74, -16, 18, 111, 99, -3, 71, 91, 82, + -48, 72, 4, 10, 98, -109, 18, -60, 51, -35, 36, 118, + 122, -84, -39, 53, -31, -44, 85, -97, 31, 50, 2, 123, + -82, -86, -76, 98, 11, -34, -39, -46, -121, 47, 117, 72, + 91, 22, -58, -72, -110, 74, 113, -20, 63, -38, 48, 109, + 46, 115, -54, 6, -5, 97, -6, -90, -11, 92, -72, -42, + 46, -54, -62, -34, 10, -99, -49, -24, 28, 108, -64, 13, + 102, 82, -31, 119, 55, -22, 91, 7, 126, 59, 120, -79, + -7, 1, 16, 7, -72, 87, -32, 62, -11, -64, -1, 64, + 42, -111, -123, -116, 105, -21, -103, -22, -60, 37, 97, -95, + -92, -33, -29, -54, -122, -103, -97, 47, -69, -11, -101, -90, + 67, 64, 21, 48, 98, 68, 37, 109, -46, -76, -26, 9, + 104, 9, 49, -85, -29, 57, -92, -45, 38, -36, 116, 28, + 23, -34, -19, -97, -44, -4, 24, 64, 85, 111, 75, -116, + 6, -40, 117, -123, 34, 33, 33, -124, -127, 20, -119, -25, + 96, -55, -109, 87, -48, 72, 90, -121, -57, -40, -27, 107, + -19, -114, 77, -51, 77, -69, -2, 38, 99, -46, 87, 6, + -80, -7, 21, -115, 47, -11, -88, 107, 116, 56, 108, 69, + -11, -63, -68, 48, 76, 43, 65, -4, 93, 3, -84, -72, + 37, 84, 107, 74, -102, 98, 7, 115, -95, 52, 61, -69, + 43, -34, -102, 60, -113, -80, -36, 98, 87, -46, -125, -62, + -99, -90, -49, -47, -107, 30, 28, -73, 83, 0, -100, 118, + -59, 78, 41, 5, -105, 55, 69, -7, 100, 85, 18, -121, + -5, -36, -85, 55, -44, 67, -99, -74, 8, 3, -39, -88, + 73, -80, 57, -19, -66, -61, 127, 59, 14, 27, 74, -32, + -122, 23, -14, 38, -127, 98, 45, -9, 9, -19, -125, -72, + 80, 45, -109, -56, 80, 58, 60, -80, 54, 0, -72, 23, + 12, 21, 62, 79, -123, 37, -90, 94, 40, 26, -63, 64, + -35, 18, -105, -97, 46, 76, 67, 45, -101, 118, -13, 5, + -53, 3, 99, -57, -75, -72, 80, -94, 111, 84, 71, -83, + 50, -98, 5, 56, 92, -19, -39, 53, -76, -84, -27, -26, + 100, -125, 18, -9, -22, -12, 64, 17, -109, -44, -89, 88, + -10, -18, 108, -81, -93, -106, -13, -75, -76, 63, -107, -90, + 31, 63, -69, -85, 54, -62, 114, -3, -69, -112, 118, -96, + 44, -16, -118, -36, -72, -56, 91, 57, 125, -90, 65, 113, + 125, 68, 76, -120, -109, -36, 109, 68, 46, -124, -68, 64, + -40, -20, 41, 64, 66, -30, 53, -104, -57, -82, -37, 104, + 107, 86, 43, -72, -74, -83, -36, -106, -79, -92, 80, 64, + -33, -3, -35, 14, -68, -55, -47, 60, -47, -70, 33, 22, + 27, -25, 46, -116, -3, -9, -62, 119, 36, -47, 12, -74, + -69, -81, 75, -53, 50, -60, -12, -54, -21, 117, 39, -66, + 74, -95, -30, 46, -83, 94, 45, -102, -114, -56, -92, -111, + -6, 60, -75, -123, -57, -120, -64, 15, -89, 35, 118, 110, + 40, 15, -34, -125, 9, 39, 0, 44, -114, 125, -62, 86, + 121, 72, 73, 8, -124, 126, 124, 81, -9, -96, -55, 121, + -68, -103, 53, -105, 123, -97, 23, 121, -30, 0, -81, -48, + -32, -32, -111, 90, -72, -83, 4, -119, -104, -45, -3, 100, + -81, 25, 21, -121, -96, -66, 123, 82, -35, 29, 74, 72, + 38, -29, 97, 85, 122, -62, 28, 90, 22, 18, -41, 67, + -64, 106, -72, -67, -9, -86, 119, 17, 114, 6, -11, -71, + 77, -47, -68, -13, 28, 126, 97, 110, 15, -121, 116, 24, + -53, -122, -1, -103, -94, 127, 113, -123, -123, -80, 56, -27, + 11, 25, 77, 109, 116, -11, -3, -78, -118, -26, 34, -40, + -22, -28, 54, -97, -41, 82, 96, -73, -97, 7, 0, 26, + -31, -124, -52, -107, -16, -75, 89, -30, -34, -43, 90, -26, + -22, 65, -78, 58, -85, -82, 31, 24, 50, 121, 70, 28, + -2, -28, -124, -98, -123, -22, 122, 34, -52, 101, -39, -12, + -42, 65, 93, -74, 16, 109, -90, -8, -117, 75, 72, 52, + -84, -38, 124, -41, -108, -84, 125, 119, -6, -9, -5, -120, + 113, 106, 65, -22, -117, -42, 0, 114, -52, -118, -126, 10, + -7, 53, 36, 55, 27, 125, -59, 1, 16, -36, -33, -44, + -124, -105, -22, -7, 102, -116, -92, 37, -108, 33, -18, 82, + -49, -9, 83, 21, -35, -64, -51, -10, 96, 26, -79, 113, + 28, 49, -25, -124, 78, 102, 3, -1, -31, 100, -97, -85, + 88, -19, -70, -62, -93, -112, 124, -107, -41, -115, -102, -91, + 4, 120, -24, -59, 22, 57, 93, 81, 76, 56, 18, -15, + -63, -110, 122, 48, 8, 119, -40, 11, -61, 122, 118, 110, + 17, 116, 74, -23, -122, -107, 105, 95, 52, -48, -22, -36, + 120, -88, 71, -84, -73, 122, -36, -64, -127, -54, -42, 32, + 16, -58, -25, 21, -112, 68, -107, 71, 74, -59, -50, -118, + 118, -63, -23, 61, 78, -11, 71, -36, 51, -12, -68, -16, + -53, -99, 110, 36, 54, 107, -94, -44, 10, -56, -44, -51, + -24, 46, -114, -109, -42, 112, 116, -14, 14, 65, 58, -53, + -96, 19, -124, 99, 105, 109, -125, 98, -75, 18, 9, 44, + 72, -59, 70, 4, -105, 122, -50, 13, -52, 31, -90, 101, + -99, -124, 99, -69, 16, -36, -107, 2, 80, -87, -63, -14, + -70, 113, -105, 1, 93, -21, 46, -88, -44, -116, 45, -103, + 117, -8, 80, 59, -29, 81, -65, -91, -62, 34, -17, -28, + -6, 41, -20, -58, 100, 12, 65, 7, 57, 48, 15, -124, + 81, -31, 85, 99, -107, -50, 93, -6, -36, -119, -30, 41, + 19, -96, 59, 61, -6, 56, -103, 34, -74, -75, -58, -99, + -34, 19, -62, -59, 92, 41, -94, -101, -111, 10, 24, 97, + -125, -82, -113, 121, -23, 123, -6, -18, 18, -74, -50, 52, + -56, 106, -3, 74, -83, -101, -60, 54, -74, -30, -10, 70, + 33, 70, -11, 34, 52, -52, 7, 8, 7, 108, 47, -2, + 107, -88, -14, -33, 3, -107, 51, -55, -55, -57, 91, 119, + 49, 21, -55, -43, 92, 118, -17, 8, 101, -61, -30, 68, + 71, 46, 84, 86, 105, -32, -81, 92, -66, -27, 3, -19, + -97, 95, 74, -60, 78, -99, -105, -25, 25, 14, -113, -43, + -32, 121, 41, -56, -22, -17, 51, -44, -29, 100, -75, 96, + 21, -39, 72, -127, -118, 104, 89, 6, -81, -123, 72, -36, + 14, -18, 47, -20, 5, -22, -61, 31, -4, 42, -82, 74, + -72, 51, -32, 84, -56, 99, -110, -120, 111, -19, 23, 22, + 109, -5, -125, 102, 40, 88, -58, 93, -34, -34, 101, 9, + -74, 113, -33, 44, 71, -85, -93, -81, -89, -13, -77, -127, + -95, -6, 72, -23, -98, 58, -10, 52, 3, 88, 109, -89, + 55, -20, -116, -38, 117, -106, 56, -53, -19, 64, 77, 116, + -54, 39, -2, 99, -21, 52, -108, -4, -117, -78, -7, -40, + -30, 83, 5, -31, -67, 122, 98, -44, -100, 12, -49, -101, + -14, -119, -2, 79, 91, 90, 20, -95, -103, -94, -21, -12, + -19, 30, 118, 71, 26, 19, -83, -30, -104, -59, 38, 45, + 18, 45, -6, -68, 4, -114, -118, -70, -88, 30, 73, 51, + 91, -81, -17, 46, -87, -13, 15, 106, -9, 17, 3, 5, + -115, 110, -87, 58, 110, -61, 10, -34, -127, 83, -91, -36, + 62, -16, 47, 18, -74, -60, 39, 36, 10, -111, -56, 67, + 15, -117, 11, 21, -126, 126, -95, 46, -108, -31, -44, 58, + -27, 7, -27, 80, 52, 35, -90, -8, -126, 88, 117, 37, + -65, 110, -87, -22, 80, 104, -80, 63, -85, -94, -94, -123, + -1, -20, 104, 114, -62, -75, 21, 115, 94, -73, 12, 78, + -35, 31, -104, 31, -90, 121, -11, -18, -10, -102, 106, -40, + -8, 78, 98, 99, 35, -66, -106, 36, -110, -24, -10, -54, + 27, 102, 77, 91, -115, -28, 58, 56, 40, 12, 97, -101, + 7, -89, -25, -9, 118, 109, -104, -105, -11, -16, 104, 77, + -30, -93, -18, 80, -5, 38, 49, -29, 126, -91, -6, -37, + -17, -101, 52, -76, 77, 8, 21, 103, -4, 102, -44, -81, + 72, -36, 56, 81, -65, 61, 66, -66, 127, 110, -121, 61, + 102, 85, 35, -80, 92, -67, 60, 123, 120, -14, -66, -23, + 57, -40, 69, 1, -109, -102, -86, 11, -114, 1, -125, 76, + -48, 97, 76, 14, 88, 108, -49, -56, 114, 12, 118, -33, + -109, 30, -68, -121, 23, -55, -10, 46, 31, 97, 1, 118, + 61, -53, 24, 31, -106, -88, 117, -112, 55, 20, 92, 42, + 57, 77, 15, 39, 25, -115, -10, -74, 54, 116, -103, 44, + -116, 47, 116, -45, -45, -89, 32, 8, -18, -27, 20, 93, + -115, 112, 93, -62, 76, -98, 83, 42, 23, -37, -87, -61, + 124, 42, 105, -13, 93, -112, 127, -35, -84, 71, 81, -49, + 34, 67, -106, 102, -29, 80, -87, 92, -27, -81, -103, 119, + -3, 33, -27, -95, -75, 35, 32, 74, -26, 94, -87, -122, + 116, 51, 117, -114, -111, 125, 30, 79, 112, 47, -31, 14, + -19, -34, -29, 8, -13, -13, -97, -70, -61, 34, -49, -53, + 59, -115, 20, -37, 90, 97, -49, -124, 63, 106, 39, 7, + -119, -47, 36, 23, -49, -61, 101, 0, 118, 73, -42, 42, + -97, 116, -12, 122, -37, -2, -119, 35, -14, 11, -91, -46, + -36, -15, -45, -52, -27, 91, -101, -81, -123, 28, -59, -88, + 9, 57, -29, -20, -80, -7, -35, -22, 89, -62, 114, 57, + -25, 65, -54, -54, 10, 70, -117, 103, 110, -39, -80, -89, + 47, -93, -34, 1, -102, 80, -112, 116, 28, -124, -55, 114, + 61, 91, -74, -102, 111, 77, 23, 95, 38, -97, 16, -104, + 44, 125, -60, -11, 84, 71, -44, -113, -39, 44, 35, -44, + -57, 127, -89, -105, 21, -97, 22, -68, 7, -28, 56, -67, + -99, 16, -50, 30, -12, -45, 107, 87, 7, 20, -8, -119, + -61, -108, 59, 6, -35, 67, 127, -124, 93, 96, -39, 4, + -25, 15, 70, -18, -26, -28, -36, 39, -4, -50, -18, -110, + 70, -49, -21, 12, -18, -75, 0, -63, -54, 38, -48, -119, + -27, -127, 31, -71, 55, 83, 5, 21, -50, -92, 82, -63, + 22, -104, -25, 70, 124, 86, 13, -94, 32, -29, -47, -31, + -46, 79, -107, -124, -92, 77, 52, -2, 110, -31, 17, -98, + 116, 61, -51, 124, 123, 57, -43, 31, 9, -6, 34, -65, + 127, 91, -23, 122, -102, 38, 84, -32, -106, -63, 8, 126, + 46, -38, 49, -116, 102, 69, 56, -23, 87, 24, -31, -48, + 17, -30, 56, -86, 26, -11, 95, 85, 111, 100, 6, 36, + -8, -115, 26, 79, 38, 39, 5, -2, 0, 32, 89, 36, + 2, 118, -54, 126, 6, 118, -68, -33, 71, 71, 56, -111, + 13, 26, -111, -47, -37, -114, 3, 73, -53, -93, -58, 78, + 124, -4, 85, -54, 55, 84, -119, -109, -49, 29, 78, -66, + -65, 36, 127, 47, -55, 103, 26, 42, 72, -7, -8, -30, + -82, 126, -65, 6, -51, -54, 35, -80, 63, -10, 43, 60, + 115, -56, 110, 43, -43, -17, 5, 68, 82, 28, 91, 11, + -103, 18, -19, 115, 83, -24, 0, -70, -122, -127, 15, 92, + 14, 7, -18, -38, -74, -3, -54, 4, -62, 20, 83, -2, + -107, 99, 53, 79, -21, 125, 61, -45, -112, -75, -21, 70, + -123, -7, -13, 59, 55, -51, -35, 5, -120, -117, 121, -110, + 93, -93, 85, 70, -93, 121, -35, 64, 34, 75, 109, -33, + 66, 69, -26, 25, -93, 72, -116, 4, -49, -101, 62, -58, + -14, 14, -68, 41, -94, 120, -13, 37, 17, -71, -38, -69, + 95, 114, 112, 50, 37, 34, 81, 56, -114, 91, -62, 25, + -85, -54, 125, 34, -125, 60, -30, 19, 8, -113, 121, -30, + 96, -8, 51, 79, 50, 43, 104, 114, -29, 39, 102, 8, + -99, 108, -52, 54, 72, 126, -97, 108, -13, 117, 126, -81, + 113, 86, -66, 113, 126, 90, -64, 117, -4, -16, -69, 0, + 43, -99, -100, 34, -4, -47, -2, -46, 34, -14, 116, 30, + 85, -69, 101, -115, -17, 66, -68, -9, 111, 45, -36, -81, + 40, 21, 49, -9, 108, 31, -29, -95, -14, 113, -113, -93, + 32, 47, 107, -12, 65, -112, 60, -40, -105, -92, -98, -3, + -21, 57, 98, 26, -14, 18, 34, 47, -19, 63, -58, 115, + -86, -127, -93, -20, 96, -118, -30, -75, -1, 79, -32, 106, + 96, 82, -32, -17, -77, -115, -44, -63, 23, 49, 64, -51, + -114, -99, 47, -9, 112, 97, -67, -54, -85, 41, 76, 19, + 17, 127, -84, -123, 76, -126, 2, -120, 72, -123, -12, 4, + 11, 87, -52, -79, 37, 114, -50, -51, -19, 79, 99, -90, + -102, 86, 87, -11, -79, -107, -37, 110, 38, 93, -67, -79, + -89, -120, 62, -18, 25, 29, 1, 83, -88, -83, 15, 52, + -87, -50, 114, -78, 43, 23, -76, -56, 45, -50, 35, -37, + 64, -20, 13, 50, 46, -121, 95, 111, -48, -120, 6, -98, + 22, 50, 113, -124, 83, -54, -38, -53, -95, -77, 65, -43, + -1, -50, -121, 107, -38, -104, 52, -62, 46, -102, -89, -8, + 24, 77, 120, -107, -113, 66, -94, 81, -115, 18, 127, -85, + -107, -69, 54, 115, 22, 43, -12, -99, 65, 6, 54, 27, + 6, -91, -109, -40, 12, 28, 29, 53, 13, 117, -53, -79, + -102, -125, 45, 67, 56, -127, -88, -25, -25, 17, -13, -118, + -28, 97, -21, -125, -98, -77, 51, -11, -82, 29, -94, -19, + 124, 90, -31, 106, -9, 40, 27, -38, 52, 28, -102, -3, + 54, -30, -10, -28, 84, 118, -27, -125, -71, 102, -37, -111, + 12, -109, -59, -27, 66, 120, -22, 99, 113, -123, -117, 39, + -127, 13, -115, -47, 70, 123, -23, 87, -37, -57, 98, 41, + -125, -89, 38, -22, 29, 24, 40, -47, -69, -61, 33, -92, + 19, 102, -5, 102, -83, -72, -94, 46, -96, -23, 27, -92, + -10, 21, -28, -127, -42, 14, 90, 93, 75, 122, -77, -118, + 12, -58, -39, 106, 100, -58, 83, 125, 24, -11, -107, 88, + -41, 121, 95, 51, 87, -25, 29, 127, 7, -121, -55, -121, + 25, -64, -109, 86, -41, 100, 26, -10, 1, 2, 25, -28, + -24, 54, -88, -97, -10, -48, 107, -83, -99, -56, -4, -73, + 0, -32, -99, 66, -106, 102, 25, -9, -27, 7, 19, -81, + 75, -121, 68, 127, -89, 65, 45, 57, -86, 33, 84, 63, + -31, -42, -82, 106, -35, -43, -73, 44, 22, 109, -127, -63, + 22, 120, 11, 105, 65, 93, 68, 83, -88, -84, 7, 120, + -9, -115, 92, 23, 72, 103, -28, 56, 111, -63, 58, 42, + -9, -43, 71, 112, -74, -13, 20, 76, 37, 100, 35, 101, + 73, -101, -77, -119, -79, 4, 115, 57, -74, -38, -25, 20, + 57, 3, -107, -119, -8, 62, 44, -101, -120, -28, -9, -77, + -73, 47, 1, 105, 52, 8, 101, 22, -43, 32, -18, -38, + 89, 114, -22, -79, 102, 54, 67, 31, 19, 101, 98, 97, + -10, -75, 13, -33, -40, 46, -112, 8, -6, -40, -9, -51, + 24, 36, -94, -69, -97, 46, 24, -23, -30, 13, 13, 8, + -106, 98, 6, 16, 79, -58, -89, -3, -81, 12, -126, 112, + 117, -90, -117, -126, -32, -55, -121, 45, -73, 92, -2, 0, + 62, -120, -121, -106, 20, 35, -25, 35, 89, 54, 39, -16, + 54, -51, -52, 50, -123, -125, -13, 118, 81, -10, -42, 102, + -24, -32, -1, -18, -56, -121, -13, -54, 82, 8, 51, -37, + 94, 15, -76, 0, -112, 109, -125, -18, -11, -35, -51, -98, + 106, -105, 30, 19, 50, 1, -118, 87, 108, -24, -12, -93, + -43, -88, 73, -28, -70, -121, 6, -110, 111, -19, -11, -37, + 54, -40, 54, 97, 123, 104, 108, 9, -53, 32, 66, 81, + -82, -125, -84, -15, -56, -48, -5, -120, 121, -65, -83, 51, + -74, -51, -22, 95, 49, -80, 59, 31, -98, -51, -37, -12, + -102, 22, -9, 64, 20, -7, 65, -81, -53, -109, -72, 126, + 50, -38, 58, -127, 11, -114, -29, -122, 45, 95, 65, -30, + 58, -35, 15, 105, 115, 109, 81, 13, -28, -22, -87, 50, + -127, 86, -83, -93, -69, -121, 47, 47, 38, -27, 51, -14, + -11, -79, -49, 52, 26, -87, -25, 91, 121, 27, 36, 56, + 23, 31, -99, -10, 86, 6, -98, -7, 119, 16, 57, -80, + 107, 64, 52, -46, -123, 102, -82, 84, 43, -90, 45, -51, + 51, -68, -1, 80, -15, -14, -65, -50, 81, -32, -79, -29, + 48, -31, 58, 3, 3, 113, 10, -117, 39, 81, 57, -1, + -42, -95, -102, -12, -120, -65, 1, -11, 75, 11, -22, -25, + 108, 13, 106, 101, -103, -34, -9, 95, 11, -63, -64, -86, + -14, 30, -10, 60, 126, -37, 26, -100, 6, 104, -120, -108, + -29, 23, -95, 40, 50, 20, 98, 2, 79, 6, -54, -59, + -104, -91, 12, -123, -9, -44, -13, -49, -69, 0, 65, 43, + 84, 101, 6, -118, -22, -122, 40, -124, 11, -35, -66, 17, + 32, 77, 74, -92, 100, 27, 93, -112, 100, 114, 47, -49, + 98, -44, -27, -20, 31, 13, 48, -116, -43, 103, 8, -85, + -93, 8, -27, 9, -24, 53, -51, -120, 124, -47, -125, -17, + 12, 30, -38, -82, 96, -127, -59, -88, 32, 88, -49, 51, + 1, 80, -5, -98, -30, -53, -97, 109, 125, 127, 73, 11, + 4, 111, 24, 11, -66, 19, 117, -97, -60, 74, -34, 109, + 17, -83, -61, 47, -15, -88, -11, 85, 74, 38, 1, -54, + -43, 31, 98, 120, -11, 1, -127, -116, 102, 99, -9, 108, + 31, 57, -98, -71, 4, -70, -118, -65, 118, -65, -100, 57, + 92, 62, -83, -79, -37, -122, -46, 18, -43, 31, -28, -10, + 104, -99, -64, 58, 32, 64, 116, -118, 15, -109, 17, 109, + 50, 79, -51, 63, 85, -121, 105, -48, -23, -107, -86, 103, + 99, 2, 21, 79, 93, 101, 99, 34, -30, -109, 26, 5, + 104, -57, -13, 17, -20, 113, -67, 101, 9, -21, 105, -56, + -120, 54, 21, -65, 94, -123, -86, -104, 64, -40, -90, -36, + -65, 42, -17, 106, 108, -42, -120, -95, 54, -15, 126, 26, + -93, 33, -105, 36, 21, -108, -29, 8, -1, -35, 31, -23, + -52, 51, 119, 103, -73, 106, -47, 7, -42, -64, 28, 101, + 101, 97, -80, -65, -91, -117, 112, 82, -91, -16, -13, 3, + -39, -112, -116, -69, 3, 5, 88, 88, 35, -112, -49, 88, + 4, -6, 104, -80, -30, 105, -97, -28, -77, -80, -37, -119, + -22, 62, -93, -6, -51, -16, -73, -21, 104, 102, -46, -24, + -124, -79, 36, -37, -81, 45, -56, 93, -104, 56, -18, 28, + -23, 8, -68, 64, 100, 6, -15, -77, 113, -50, 38, 18, + -111, -45, -59, -11, -5, 54, -94, 76, -127, -114, -19, 57, + -35, -26, 89, 105, 25, -108, -12, -3, -7, -20, -86, 39, + -119, 46, 85, -31, -31, -100, -43, -126, 82, -57, 67, 123, + 70, -11, -31, 121, -3, -22, 55, -83, -27, -95, 116, 42, + 2, -122, 120, -44, 126, 3, -116, -52, 30, -43, -84, 47, + 6, -108, -52, -76, 81, -32, -81, -111, 103, 81, 123, 109, + 121, 50, -11, 28, 41, -104, -84, -48, 23, -117, -56, -5, + -97, -51, -70, -24, -71, 53, -55, -108, -37, -111, 35, -123, + 40, -119, -66, 21, 83, -126, 101, -21, -100, 56, 4, -53, + -53, 64, -17, -4, 1, -79, -33, 68, 62, 32, 110, 87, + -3, 95, -11, -67, 26, 19, 24, 102, 107, -27, -41, 123, + -11, 10, -17, -34, -57, -13, 121, 42, -13, 65, 24, -87, + -105, -86, -93, 61, 105, 65, -37, 82, -91, 73, -103, 52, + -13, -77, 41, -87, 6, 105, -40, -68, 57, 126, 39, 107, + 10, -50, 24, 95, -90, -35, 83, -98, 75, 64, 41, 98, + 57, -100, -24, -33, 31, 51, -26, 111, 93, 30, -118, 38, + 47, 81, -1, 82, -111, 125, 89, 41, -106, -37, -111, -2, + 58, -13, -28, -100, 47, 57, 40, 93, -119, 113, 30, 31, + -71, 36, 125, 98, -117, 45, -62, -51, -91, 81, -104, -64, + -57, -59, 73, 109, 106, 122, 1, 6, -25, 17, -40, 5, + 74, 100, -90, 16, 122, 117, -16, -42, 59, 68, 64, -22, + -114, -98, 27, -22, 65, 51, 90, 83, 49, -58, -38, -74, + 100, -42, 7, 61, -126, -106, 89, 57, 79, -90, 120, 70, + 105, 68, 80, 106, -119, -111, -26, -27, 14, -122, -86, -58, + 110, -66, 18, 104, -93, -92, 81, 42, -17, -15, 16, 57, + -61, -84, 13, 34, 6, -17, -59, 95, 70, 78, 105, 70, + -9, 82, 110, -82, 20, -116, -15, 118, 112, -37, 108, -17, + -105, 56, -119, -97, -18, 110, -69, -44, 12, 32, -27, -100, + -116, 123, -38, 22, 34, -68, 119, 23, 8, -32, 61, 112, + -8, -23, 83, 63, -101, -110, 88, 113, -79, -29, -95, 90, + 72, -83, -14, -114, 112, 49, 19, 112, 55, -53, 34, 25, + -31, 83, 66, 124, -27, -110, -50, 101}; diff --git a/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/src/snax-mlperf-tiny-ad01.c b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/src/snax-mlperf-tiny-ad01.c new file mode 100644 index 000000000..5be146728 --- /dev/null +++ b/target/sim/sw/device/apps/snax/snax-mlperf-tiny-ad01/src/snax-mlperf-tiny-ad01.c @@ -0,0 +1,146 @@ +#include "stdint.h" + +#include "data.h" +#include "memref.h" +#include "snax_rt.h" + +/* + * These libraries are included from github.com/KULeuven-MICAS/snitch_cluster + * Interested users, might want to look at: + * + * /sw/snRuntime/api + * /target/snitch_cluster/sw/runtime/rtl/src + * /target/snitch_cluster/sw/runtime/common + * */ +#include + +void _mlir_ciface_run_network(TwoDMemrefI8_t *output, TwoDMemrefI8_t *input); + +void _mlir_ciface_snax_debug_gemm(int32_t _ptr_a, int32_t _ptr_b, + int32_t _ptr_c, int32_t when) { + int8_t *ptr_a, *ptr_b; + int32_t *ptr_c; + ptr_a = (int8_t *)_ptr_a; + ptr_b = (int8_t *)_ptr_b; + ptr_c = (int32_t *)_ptr_c; + + int thisc = snrt_cluster_core_idx(); + + if (thisc == 0) { + printf("Debugging GeMM at t = %d with A at %p, B at %p, C at %p\r\n", + when, ptr_a, ptr_b, ptr_c); + + for (int i = 0; i < 5; i++) { + printf("i%d -> A=%d, B=%d, C=%d\r\n", i, ptr_a[i], ptr_b[i], + ptr_c[i]); + } + } + + for (uint8_t i = 0; i < 20; i++) { + if (thisc == i) { + printf("Core %d present.\r\n", thisc); + if (snrt_is_dm_core()) { + printf("I am a dm core\r\n"); + } + } + snrt_cluster_hw_barrier(); + } +} + +void _mlir_ciface_snax_debug_bias(int32_t _ptr_a, int32_t _ptr_b, + int32_t _ptr_c, int32_t when) { + int32_t *ptr_a, *ptr_b, *ptr_c; + ptr_a = (int32_t *)_ptr_a; + ptr_b = (int32_t *)_ptr_b; + ptr_c = (int32_t *)_ptr_c; + + int thisc = snrt_cluster_core_idx(); + if (thisc == 0) { + printf("Debugging bias at t = %d with A at %p, B at %p, C at %p\r\n", + when, ptr_a, ptr_b, ptr_c); + + for (int i = 0; i < 5; i++) { + printf("i%d -> A=%d, B=%d, C=%d\r\n", i, ptr_a[i], ptr_b[i], + ptr_c[i]); + } + } + + for (uint8_t i = 0; i < 20; i++) { + if (thisc == i) { + printf("Core %d present.\r\n", thisc); + if (snrt_is_dm_core()) { + printf("I am a dm core\r\n"); + } + } + snrt_cluster_hw_barrier(); + } +} + +void _mlir_ciface_snax_debug_simd(int32_t _ptr_a, int32_t _ptr_b, + int32_t _ptr_c, int32_t when) { + int32_t *ptr_a; + int8_t *ptr_c; + ptr_a = (int32_t *)_ptr_a; + ptr_c = (int8_t *)_ptr_c; + + int thisc = snrt_cluster_core_idx(); + if (thisc == 0) { + printf("Debugging SIMD at t = %d with A at %p, C at %p\r\n", when, + ptr_a, ptr_c); + + for (int i = 0; i < 128; i++) { + printf("i%d -> A=%d, C=%d\r\n", i, ptr_a[i], ptr_c[i]); + } + } + for (uint8_t i = 0; i < 20; i++) { + if (thisc == i) { + printf("Core %d present.\r\n", thisc); + if (snrt_is_dm_core()) { + printf("I am a dm core\r\n"); + } + } + snrt_cluster_hw_barrier(); + } +} + +int main() { + if (snrt_cluster_idx() == 0) { + if (snrt_cluster_core_idx() == 0) { + printf("hello from snitch cluster! running mlperf tiny \r\n"); + } + + // Create memref objects for data stored in L3 + TwoDMemrefI8_t memrefA; + memrefA.data = &A; + memrefA.aligned_data = memrefA.data; + // Shape and Stride need to be defined for dynamic case + memrefA.shape[0] = 8; + memrefA.shape[1] = 640; + memrefA.stride[0] = 640; + memrefA.stride[1] = 1; + memrefA.offset = 0; + + TwoDMemrefI8_t memrefB; + + (void)snrt_mcycle(); + + _mlir_ciface_run_network(&memrefB, &memrefA); + + snrt_cluster_hw_barrier(); + + (void)snrt_mcycle(); + + if (snrt_cluster_core_idx() == 0) { + printf("Got result at %p: \r\n", memrefB.aligned_data); + int8_t *data = memrefB.aligned_data; + for (int i = 0; i < 640; i++) { + printf("%d ", data[i]); + } + printf("\r\n"); + } + + snrt_cluster_hw_barrier(); + + return 0; + } +} diff --git a/target/sim/sw/device/snax-mlir/runtime/include/memref.h b/target/sim/sw/device/snax-mlir/runtime/include/memref.h new file mode 100755 index 000000000..43eb75f45 --- /dev/null +++ b/target/sim/sw/device/snax-mlir/runtime/include/memref.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +struct OneDMemrefI32 { + int32_t *data; // allocated pointer: Pointer to data buffer as allocated, + // only used for deallocating the memref + int32_t *aligned_data; // aligned pointer: Pointer to properly aligned data + // that memref indexes + uint32_t offset; + uint32_t shape[1]; + uint32_t stride[1]; +}; + +struct OneDMemrefI64 { + int64_t *data; // allocated pointer: Pointer to data buffer as allocated, + // only used for deallocating the memref + int64_t *aligned_data; // aligned pointer: Pointer to properly aligned data + // that memref indexes + uint32_t offset; + uint32_t shape[1]; + uint32_t stride[1]; +}; + +struct TwoDMemrefI32 { + int32_t *data; // allocated pointer: Pointer to data buffer as allocated, + // only used for deallocating the memref + int32_t *aligned_data; // aligned pointer: Pointer to properly aligned data + // that memref indexes + uint32_t offset; + uint32_t shape[2]; + uint32_t stride[2]; +}; + +struct TwoDMemrefI8 { + int8_t *data; // allocated pointer: Pointer to data buffer as allocated, + // only used for deallocating the memref + int8_t *aligned_data; // aligned pointer: Pointer to properly aligned data + // that memref indexes + uint32_t offset; + uint32_t shape[2]; + uint32_t stride[2]; +}; + +typedef struct OneDMemrefI32 OneDMemrefI32_t; +typedef struct OneDMemrefI64 OneDMemrefI64_t; +typedef struct TwoDMemrefI8 TwoDMemrefI8_t; +typedef struct TwoDMemrefI32 TwoDMemrefI32_t; diff --git a/target/sim/sw/device/snax-mlir/runtime/include/snax_rt.h b/target/sim/sw/device/snax-mlir/runtime/include/snax_rt.h new file mode 100755 index 000000000..d5958b0de --- /dev/null +++ b/target/sim/sw/device/snax-mlir/runtime/include/snax_rt.h @@ -0,0 +1,97 @@ +#pragma once + +#include +#include + +int8_t *allocated_pointer; + +int8_t *_mlir_memref_to_llvm_alloc(uint32_t size) { + /* This calls malloc on the DMA core + * --> requires mlir opt to compile with: + * --convert-memref-to-llvm="use-generic-functions index-bitwidth=32" + * To ensure that all cores in the cluster come up with the correct + */ + if (snrt_is_dm_core()) { + allocated_pointer = (int8_t *)snrt_l1alloc(size); + } + snrt_cluster_hw_barrier(); + return allocated_pointer; +}; + +typedef struct alloc_result { + void *pointer; + void *aligned_pointer; +} alloc_result_t; + +alloc_result_t *allocated_result = (alloc_result_t *)0x10000000; + +alloc_result_t *_mlir_ciface_snax_alloc_l1(uint32_t size, uint32_t alignment) { + if (snrt_is_dm_core()) { + void *next_ptr = snrt_l1_next(); + // calculate extra size needed to allocate for correct alignment + uint32_t extra_size = alignment - ((int32_t)next_ptr % alignment); + void *allocated_pointer = snrt_l1alloc(size + extra_size); + void *aligned_pointer = + (void *)((int32_t)allocated_pointer + extra_size); + + allocated_result->pointer = allocated_pointer; + allocated_result->aligned_pointer = aligned_pointer; + } + + snrt_cluster_hw_barrier(); + + for (int i = 0; i < 3; i++) { + if (snrt_cluster_core_idx() == i) { + printf("Allocated result at %p is %p\r\n", allocated_result, + allocated_result->aligned_pointer); + } + snrt_cluster_hw_barrier(); + } + + return allocated_result; +} + +void _mlir_ciface_snax_dump_l1() { + snrt_alloc_init(); + // keep first 256 bytes free for zero wizardry + snrt_l1alloc(256); + // memset all to 0 with DMA + if (snrt_is_dm_core()) { + snrt_dma_start_2d((int32_t *)0x10000080, (int32_t *)0x10000040, 0x40, + 0x40, 0, 0x1800); + snrt_dma_wait_all(); + } + snrt_cluster_hw_barrier(); + return; +} + +void _mlir_ciface_snax_cluster_hw_barrier() { + snrt_cluster_hw_barrier(); + return; +} + +void _mlir_ciface_snax_dma_1d_transfer(size_t *source, size_t *destination, + size_t size) { + // printf("Copying %d bytes from %p to %p\n", size, (void *)source, + // (void *)destination); + snrt_dma_start_1d((void *)destination, (void *)source, size); + snrt_dma_wait_all(); + return; +} + +void _mlir_ciface_snax_dma_2d_transfer(size_t *source, size_t *destination, + size_t size, size_t src_stride, + size_t dst_stride, size_t repeat) { + // printf("Copying %d bytes from %p to %p, stridsrc %x stridedst %x rpt + // %d\n", + // size, source, destination, src_stride, dst_stride, repeat); + snrt_dma_start_2d((void *)destination, (void *)source, size, dst_stride, + src_stride, repeat); + snrt_dma_wait_all(); +} + +int _mlir_ciface_snax_is_dm_core() { return snrt_is_dm_core(); } + +int _mlir_ciface_snax_is_compute_core() { + return (snrt_cluster_core_idx() == 0); +} diff --git a/target/sim/sw/host/apps/offload/Makefile b/target/sim/sw/host/apps/offload/Makefile index 5f673626e..b5e11c728 100644 --- a/target/sim/sw/host/apps/offload/Makefile +++ b/target/sim/sw/host/apps/offload/Makefile @@ -36,6 +36,7 @@ DEVICE_APPS += snax/snax-data-reshuffler DEVICE_APPS += snax/snax-streamer-gemm-conv DEVICE_APPS += snax/snax-streamer-gemm-conv-simd DEVICE_APPS += snax/snax-test-integration +DEVICE_APPS += snax/snax-mlperf-tiny-ad01 # Dependencies INCDIRS += $(RUNTIME_DIR) INCDIRS += $(HOST_DIR)/../shared/platform/generated @@ -145,4 +146,4 @@ $(BUILDDIR)/$(APP)-%.dwarf: $(BUILDDIR)/$(APP)-%.elf | $(BUILDDIR) ifneq ($(MAKECMDGOALS),clean) -include $(DEP) -endif \ No newline at end of file +endif