Skip to content

Commit

Permalink
[CMAKE] added cmake option to add top level flamingo tests
Browse files Browse the repository at this point in the history
[CMAKE] some minor fixes
  • Loading branch information
Navaneeth-KunhiPurayil committed Dec 5, 2024
1 parent 3986d9b commit 053e7e7
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 22 deletions.
4 changes: 3 additions & 1 deletion hw/system/spatz_cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions hw/system/spatz_cluster/sw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
72 changes: 52 additions & 20 deletions sw/spatzBenchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion sw/spatzBenchmarks/dp-faxpy-cache/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,31 @@ 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
}
}
}

// Wait for core 0 to finish displaying results
snrt_cluster_hw_barrier();

if (cid == 0) {
set_eoc();
}

return 0;
}

0 comments on commit 053e7e7

Please sign in to comment.