diff --git a/sw/chainingTest/CMakeLists.txt b/sw/chainingTest/CMakeLists.txt new file mode 100644 index 0000000..59f8235 --- /dev/null +++ b/sw/chainingTest/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright 2020 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13) + +# Allow spatzBenchmarks to be built as a standalone library. +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) + set(CMAKE_TOOLCHAIN_FILE toolchain-gcc CACHE STRING "Toolchain to use") + + project(Benchmarks LANGUAGES C ASM) + include(SnitchUtilities) + + # Build the runtime. + add_subdirectory(../snRuntime snRuntime) +endif() + +add_compile_options(-O3 -g -ffunction-sections) +add_compile_options(-DELEN=64) + +include_directories(include) +include_directories(${SNRUNTIME_INCLUDE_DIRS}) +include_directories(../riscvTests/isa/macros/vector) + +# Tests +enable_testing() +set(SNITCH_TEST_PREFIX chaining-) + +add_snitch_test(test1 test1.c) diff --git a/sw/chainingTest/test1.c b/sw/chainingTest/test1.c new file mode 100644 index 0000000..5f57d99 --- /dev/null +++ b/sw/chainingTest/test1.c @@ -0,0 +1,32 @@ +// Copyright 2021 ETH Zurich and University of Bologna. +// Solderpad Hardware License, Version 0.51, see LICENSE for details. +// SPDX-License-Identifier: SHL-0.51 +// +// Author: Navaneeth Kunhi Purayil +// + +#include "vector_macros.h" + +void TEST32(void) { + VSET(32, e64, m8); + VLOAD_64(v0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + asm volatile("vadd.vi v8, v0, 1"); + VCMP_U64(1, v8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33); +} + +void TEST64(void) { + VSET(64, e64, m8); + VLOAD_64(v0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + asm volatile("vadd.vi v8, v0, 1"); + VCMP_U64(2, v8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33); +} + +int main(void) { + INIT_CHECK(); + enable_vec(); + + TEST32(); + TEST64(); + + EXIT_CHECK(); +}