From 8d819f3c53f4e5812cc04bffca71be59e6e1ef1c Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Mon, 1 Feb 2021 20:06:09 -0600
Subject: [PATCH] Added support to run all benchmarks in ctest

---
 hpvm/test/CMakeLists.txt                       | 3 +++
 hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hpvm/test/CMakeLists.txt b/hpvm/test/CMakeLists.txt
index 5ffc073164..654197c16c 100644
--- a/hpvm/test/CMakeLists.txt
+++ b/hpvm/test/CMakeLists.txt
@@ -161,4 +161,7 @@ add_custom_target(hpvm-check)
 add_dependencies(hpvm-check check-hpvm)
 set_target_properties(hpvm-check PROPERTIES FOLDER "Tests")
 
+# HPVM-C benchmarks uses ctest instead of LLVM's test mechanism
+# because they are compiled in a custom way
+include(CTest)
 add_subdirectory(dnn_benchmarks/hpvm-c)
diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt b/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt
index b19e62930b..4d38998191 100644
--- a/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt
+++ b/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt
@@ -23,6 +23,8 @@ function(approxhpvm_py_codegen bin_filename src_filepath codegen_target)
       -t ${codegen_target} -I ${CONFIG_INCLUDE_DIR} ${ARGV}
   )
   add_custom_target(${bin_filename} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${bin_filename})
+  add_test(NAME test_${bin_filename} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${bin_filename})
+  set_tests_properties(test_${bin_filename} PROPERTIES RUN_SERIAL TRUE)
   set(test_compile_targets ${test_compile_targets} ${bin_filename} PARENT_SCOPE)
 endfunction(approxhpvm_py_codegen)
 
@@ -44,12 +46,8 @@ foreach(dir ${entries})
     --quant-file ${dir}/data/quant_ranges_rt.txt
     --conf-file ${dir}/data/tuner_confs.txt
   )
-  # Run tensor binary
-  run_single_benchmark(run_${dirname} ${dirname})
   # Generate "cudnn"-targeted code
   approxhpvm_py_codegen(${dirname}_cudnn ${dir}/${dirname}_cudnn.cpp cudnn)
-  # Run cudnn binary
-  run_single_benchmark(run_${dirname}_cudnn ${dirname}_cudnn)
 endforeach(dir)
 
 message(STATUS "List of test dnn benchmarks: ${test_compile_targets}")
-- 
GitLab