From 053e7e739bd19867b4fb84f8fe95687934bb0b5b Mon Sep 17 00:00:00 2001 From: Navaneeth-Kunhi Purayil Date: Thu, 5 Dec 2024 10:05:24 +0100 Subject: [PATCH] [CMAKE] added cmake option to add top level flamingo tests [CMAKE] some minor fixes --- hw/system/spatz_cluster/Makefile | 4 +- hw/system/spatz_cluster/sw/CMakeLists.txt | 6 ++ sw/spatzBenchmarks/CMakeLists.txt | 72 ++++++++++++++++------- sw/spatzBenchmarks/dp-faxpy-cache/main.c | 9 ++- 4 files changed, 69 insertions(+), 22 deletions(-) diff --git a/hw/system/spatz_cluster/Makefile b/hw/system/spatz_cluster/Makefile index 706338eb..8767abf5 100644 --- a/hw/system/spatz_cluster/Makefile +++ b/hw/system/spatz_cluster/Makefile @@ -181,7 +181,9 @@ sw: clean.sw ## Build SW into sw/build with the LLVM toolchain (including tests) for Questasim simulator sw.vsim: clean.sw bin/spatz_cluster.vsim mkdir -p sw/build - cd sw/build && ${CMAKE} -DLLVM_PATH=${LLVM_INSTALL_DIR} -DGCC_PATH=${GCC_INSTALL_DIR} -DPYTHON=${PYTHON} -DSNITCH_SIMULATOR=../../../../../hw/system/spatz_cluster/bin/spatz_cluster.vsim -DBUILD_TESTS=ON .. && make -j8 + cd sw/build && ${CMAKE} \ + -DPRINT_CHECK=OFF -DENABLE_FLAMINGO_TESTS=OFF -DFLA_ROOT=${FLA_ROOT} \ + -DLLVM_PATH=${LLVM_INSTALL_DIR} -DGCC_PATH=${GCC_INSTALL_DIR} -DPYTHON=${PYTHON} -DSNITCH_SIMULATOR=../../../../../hw/system/spatz_cluster/bin/spatz_cluster.vsim -DBUILD_TESTS=ON .. && make -j8 ## Build SW and run all tests with Questasim simulator sw.test.vsim: sw.vsim diff --git a/hw/system/spatz_cluster/sw/CMakeLists.txt b/hw/system/spatz_cluster/sw/CMakeLists.txt index b3f53c0c..0a963a2e 100644 --- a/hw/system/spatz_cluster/sw/CMakeLists.txt +++ b/hw/system/spatz_cluster/sw/CMakeLists.txt @@ -17,3 +17,9 @@ enable_testing() add_subdirectory(${SNITCH_SOFTWARE_DIR}/snRuntime snRuntime) add_subdirectory(${SNITCH_SOFTWARE_DIR}/riscvTests riscvTests) add_subdirectory(${SNITCH_SOFTWARE_DIR}/spatzBenchmarks spatzBenchmarks) + +option(ENABLE_FLAMINGO_TESTS "Enable flamingo tests for spatz" OFF) +if (ENABLE_FLAMINGO_TESTS) + message(STATUS "Adding flamingo tests") + add_subdirectory(${FLA_ROOT}/sw/spatz/tests tests) +endif() \ No newline at end of file diff --git a/sw/spatzBenchmarks/CMakeLists.txt b/sw/spatzBenchmarks/CMakeLists.txt index f090d659..abebddae 100644 --- a/sw/spatzBenchmarks/CMakeLists.txt +++ b/sw/spatzBenchmarks/CMakeLists.txt @@ -21,27 +21,59 @@ include_directories(${SNRUNTIME_INCLUDE_DIRS}) add_compile_options(-O3 -g -ffunction-sections) +option(PRINT_CHECK "Enable Printing" OFF) + # Macro to regenerate the golden values and compile a module -macro(add_spatz_test_oneParam name file param1) - set(target_name ${name}_M${param1}) - add_snitch_test(${target_name} ${file}) - target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) - target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}.h") -endmacro() - -macro(add_spatz_test_twoParam name file param1 param2) - set(target_name ${name}_M${param1}_N${param2}) - add_snitch_test(${target_name} ${file}) - target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) - target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}.h") -endmacro() - -macro(add_spatz_test_threeParam name file param1 param2 param3) - set(target_name ${name}_M${param1}_N${param2}_K${param3}) - add_snitch_test(${target_name} ${file}) - target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) - target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}_${param3}.h") -endmacro() +if(PRINT_CHECK) + add_definitions(-DPRINT_RESULT) + macro(add_spatz_test_oneParam name file param1) + set(target_name ${name}_M${param1}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}.h" PRINT_RESULT) + endmacro() +else() + macro(add_spatz_test_oneParam name file param1) + set(target_name ${name}_M${param1}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}.h") + endmacro() +endif() + +if(PRINT_CHECK) + add_definitions(-DPRINT_RESULT) + macro(add_spatz_test_twoParam name file param1 param2) + set(target_name ${name}_M${param1}_N${param2}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}.h" PRINT_RESULT) + endmacro() +else() + macro(add_spatz_test_twoParam name file param1 param2) + set(target_name ${name}_M${param1}_N${param2}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}.h") + endmacro() +endif() + +if(PRINT_CHECK) + add_definitions(-DPRINT_RESULT) + macro(add_spatz_test_threeParam name file param1 param2 param3) + set(target_name ${name}_M${param1}_N${param2}_K${param3}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}_${param3}.h" PRINT_RESULT) + endmacro() +else() + macro(add_spatz_test_threeParam name file param1 param2 param3) + set(target_name ${name}_M${param1}_N${param2}_K${param3}) + add_snitch_test(${target_name} ${file}) + target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME}) + target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}_${param3}.h") + endmacro() +endif() # Benchmark library add_library(benchmark benchmark/benchmark.c) diff --git a/sw/spatzBenchmarks/dp-faxpy-cache/main.c b/sw/spatzBenchmarks/dp-faxpy-cache/main.c index af4fbbf0..373dae33 100644 --- a/sw/spatzBenchmarks/dp-faxpy-cache/main.c +++ b/sw/spatzBenchmarks/dp-faxpy-cache/main.c @@ -100,18 +100,21 @@ int main() { if (cid == 0) { long unsigned int performance = 1000 * 2 * dim / timer; long unsigned int utilization = performance / (2 * num_cores * 4); - +#ifdef PRINT_RESULT printf("\n----- (%d) axpy -----\n", dim); printf("The execution took %u cycles.\n", timer); printf("The performance is %ld OP/1000cycle (%ld%%o utilization).\n", performance, utilization); +#endif } if (cid == 0) { for (unsigned int i = 0; i < dim; i++) { if (fp_check(axpy_Y_dram[i], axpy_GR_dram[i])) { +#ifdef CHECK printf("Error: Index %d -> Result = %f, Expected = %f\n", i, (float)axpy_Y_dram[i], (float)axpy_GR_dram[i]); +#endif } } } @@ -119,5 +122,9 @@ int main() { // Wait for core 0 to finish displaying results snrt_cluster_hw_barrier(); + if (cid == 0) { + set_eoc(); + } + return 0; }