CMakeLists.txt 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. cmake_minimum_required (VERSION 3.6)
  2. cmake_policy(SET CMP0077 NEW)
  3. # The tests are assuming that MATRIX_CHECK is enabled when building
  4. # CMSIS-DSP.
  5. list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)
  6. function(writeConfig path)
  7. set(output "")
  8. list(APPEND output "OPTIMIZED,HARDFP,FASTMATH,NEON,HELIUM,UNROLL,ROUNDING,PLATFORM,CORE,COMPILER,VERSION\n")
  9. if (OPTIMIZED)
  10. list(APPEND output "1")
  11. else()
  12. list(APPEND output "0")
  13. endif()
  14. if (HARDFP)
  15. list(APPEND output ",1")
  16. else()
  17. list(APPEND output ",0")
  18. endif()
  19. if (FASTMATHCOMPUTATIONS)
  20. list(APPEND output ",1")
  21. else()
  22. list(APPEND output ",0")
  23. endif()
  24. if (NEON OR NEONEXPERIMENTAL)
  25. list(APPEND output ",1")
  26. else()
  27. list(APPEND output ",0")
  28. endif()
  29. if (HELIUM OR MVEI OR MVEF)
  30. list(APPEND output ",1")
  31. else()
  32. list(APPEND output ",0")
  33. endif()
  34. if (LOOPUNROLL)
  35. list(APPEND output ",1")
  36. else()
  37. list(APPEND output ",0")
  38. endif()
  39. if (ROUNDING)
  40. list(APPEND output ",1")
  41. else()
  42. list(APPEND output ",0")
  43. endif()
  44. list(APPEND output ",${PLATFORMID}")
  45. list(APPEND output ",${COREID},")
  46. if (ARMAC6)
  47. list(APPEND output "AC6")
  48. elseif(GCC)
  49. list(APPEND output "GCC")
  50. endif()
  51. compilerVersion()
  52. list(APPEND output ",${COMPILERVERSION}")
  53. file(WRITE ${path} ${output})
  54. endfunction()
  55. option(BENCHMARK "Benchmarking compiled" OFF)
  56. option(EXTBENCH "Benchmarking with external traces" OFF)
  57. option(NN "NN Tests included" OFF)
  58. project(Testing)
  59. # Needed to find the config modules
  60. set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
  61. # Change behavior of configBoot for scatter file
  62. # We use the linker files from older test framework because bigger sections are needed.
  63. # We should migrate the linker files to this new framework.
  64. set(TESTFRAMEWORK ON)
  65. include(config)
  66. add_subdirectory(../Source bin_dsp)
  67. if (NN)
  68. add_subdirectory(${ROOT}/CMSIS/NN/Source bin_nn)
  69. endif()
  70. add_library(TestingLib STATIC)
  71. add_library(FrameworkLib STATIC)
  72. if (BENCHMARK)
  73. set (NNSRC
  74. Source/Benchmarks/FullyConnectedBench.cpp
  75. Source/Benchmarks/PoolingBench.cpp
  76. )
  77. set(TESTSRC
  78. Source/Benchmarks/BasicMathsBenchmarksF32.cpp
  79. Source/Benchmarks/BasicMathsBenchmarksQ31.cpp
  80. Source/Benchmarks/BasicMathsBenchmarksQ15.cpp
  81. Source/Benchmarks/BasicMathsBenchmarksQ7.cpp
  82. Source/Benchmarks/ComplexMathsBenchmarksF32.cpp
  83. Source/Benchmarks/ComplexMathsBenchmarksQ31.cpp
  84. Source/Benchmarks/ComplexMathsBenchmarksQ15.cpp
  85. Source/Benchmarks/FIRF32.cpp
  86. Source/Benchmarks/FIRQ31.cpp
  87. Source/Benchmarks/FIRQ15.cpp
  88. Source/Benchmarks/MISCF32.cpp
  89. Source/Benchmarks/MISCQ31.cpp
  90. Source/Benchmarks/MISCQ15.cpp
  91. Source/Benchmarks/MISCQ7.cpp
  92. Source/Benchmarks/DECIMF32.cpp
  93. Source/Benchmarks/DECIMQ31.cpp
  94. Source/Benchmarks/DECIMQ15.cpp
  95. Source/Benchmarks/BIQUADF32.cpp
  96. Source/Benchmarks/BIQUADF64.cpp
  97. Source/Benchmarks/ControllerF32.cpp
  98. Source/Benchmarks/ControllerQ31.cpp
  99. Source/Benchmarks/ControllerQ15.cpp
  100. Source/Benchmarks/FastMathF32.cpp
  101. Source/Benchmarks/FastMathQ31.cpp
  102. Source/Benchmarks/FastMathQ15.cpp
  103. Source/Benchmarks/SupportF32.cpp
  104. Source/Benchmarks/SupportBarF32.cpp
  105. Source/Benchmarks/SupportQ31.cpp
  106. Source/Benchmarks/SupportQ15.cpp
  107. Source/Benchmarks/SupportQ7.cpp
  108. Source/Benchmarks/UnaryF32.cpp
  109. Source/Benchmarks/UnaryF64.cpp
  110. Source/Benchmarks/UnaryQ31.cpp
  111. Source/Benchmarks/UnaryQ15.cpp
  112. Source/Benchmarks/BinaryF32.cpp
  113. Source/Benchmarks/BinaryQ31.cpp
  114. Source/Benchmarks/BinaryQ15.cpp
  115. Source/Benchmarks/TransformF32.cpp
  116. Source/Benchmarks/TransformQ31.cpp
  117. Source/Benchmarks/TransformQ15.cpp
  118. )
  119. target_include_directories(TestingLib PRIVATE Include/Benchmarks)
  120. else()
  121. set(NNSRC
  122. Source/Tests/NNSupport.cpp
  123. Source/Tests/Pooling.cpp
  124. Source/Tests/Softmax.cpp
  125. Source/Tests/FullyConnected.cpp
  126. )
  127. set(TESTSRC
  128. Source/Tests/BasicTestsF32.cpp
  129. Source/Tests/BasicTestsQ31.cpp
  130. Source/Tests/BasicTestsQ15.cpp
  131. Source/Tests/BasicTestsQ7.cpp
  132. Source/Tests/ComplexTestsF32.cpp
  133. Source/Tests/ComplexTestsQ31.cpp
  134. Source/Tests/ComplexTestsQ15.cpp
  135. Source/Tests/SVMF32.cpp
  136. Source/Tests/BayesF32.cpp
  137. Source/Tests/TransformCF64.cpp
  138. Source/Tests/TransformCF32.cpp
  139. Source/Tests/TransformRF64.cpp
  140. Source/Tests/TransformRF32.cpp
  141. Source/Tests/TransformCQ31.cpp
  142. Source/Tests/TransformRQ31.cpp
  143. Source/Tests/TransformCQ15.cpp
  144. Source/Tests/TransformRQ15.cpp
  145. Source/Tests/StatsTestsF32.cpp
  146. Source/Tests/StatsTestsF64.cpp
  147. Source/Tests/StatsTestsQ31.cpp
  148. Source/Tests/StatsTestsQ15.cpp
  149. Source/Tests/StatsTestsQ7.cpp
  150. Source/Tests/FastMathF32.cpp
  151. Source/Tests/FastMathQ31.cpp
  152. Source/Tests/FastMathQ15.cpp
  153. Source/Tests/SupportTestsF32.cpp
  154. Source/Tests/SupportTestsQ31.cpp
  155. Source/Tests/SupportTestsQ15.cpp
  156. Source/Tests/SupportTestsQ7.cpp
  157. Source/Tests/SupportBarTestsF32.cpp
  158. Source/Tests/DistanceTestsF32.cpp
  159. Source/Tests/DistanceTestsU32.cpp
  160. Source/Tests/UnaryTestsQ31.cpp
  161. Source/Tests/UnaryTestsQ15.cpp
  162. Source/Tests/UnaryTestsF32.cpp
  163. Source/Tests/UnaryTestsF64.cpp
  164. Source/Tests/BinaryTestsF32.cpp
  165. Source/Tests/BinaryTestsQ31.cpp
  166. Source/Tests/BinaryTestsQ15.cpp
  167. Source/Tests/DECIMF32.cpp
  168. Source/Tests/DECIMQ31.cpp
  169. Source/Tests/DECIMQ15.cpp
  170. Source/Tests/MISCF32.cpp
  171. Source/Tests/MISCQ31.cpp
  172. Source/Tests/MISCQ15.cpp
  173. Source/Tests/MISCQ7.cpp
  174. Source/Tests/FIRF32.cpp
  175. Source/Tests/FIRQ31.cpp
  176. Source/Tests/FIRQ15.cpp
  177. Source/Tests/FIRQ7.cpp
  178. Source/Tests/BIQUADF64.cpp
  179. Source/Tests/BIQUADF32.cpp
  180. Source/Tests/BIQUADQ31.cpp
  181. Source/Tests/BIQUADQ15.cpp
  182. Source/Tests/InterpolationTestsF32.cpp
  183. Source/Tests/InterpolationTestsQ31.cpp
  184. Source/Tests/InterpolationTestsQ15.cpp
  185. Source/Tests/InterpolationTestsQ7.cpp
  186. Source/Tests/ExampleCategoryF32.cpp
  187. Source/Tests/ExampleCategoryQ31.cpp
  188. Source/Tests/ExampleCategoryQ15.cpp
  189. Source/Tests/ExampleCategoryQ7.cpp
  190. )
  191. target_include_directories(TestingLib PRIVATE Include/Tests)
  192. endif()
  193. set(FRAMEWORKSRC
  194. FrameworkSource/Test.cpp
  195. FrameworkSource/Semihosting.cpp
  196. FrameworkSource/IORunner.cpp
  197. FrameworkSource/ArrayMemory.cpp
  198. FrameworkSource/Pattern.cpp
  199. FrameworkSource/PatternMgr.cpp
  200. FrameworkSource/Error.cpp
  201. FrameworkSource/FPGA.cpp
  202. FrameworkSource/Timing.cpp
  203. FrameworkSource/Generators.cpp
  204. FrameworkSource/Calibrate.cpp
  205. )
  206. # With -O2, generated code is crashing on some cycle accurate models.
  207. # (cpp part)
  208. disableOptimization(TestingLib)
  209. disableOptimization(FrameworkLib)
  210. target_sources(TestingLib PRIVATE ${TESTSRC})
  211. if(NN)
  212. target_sources(TestingLib PRIVATE ${NNSRC})
  213. endif()
  214. target_sources(TestingLib PRIVATE testmain.cpp)
  215. target_sources(TestingLib PRIVATE GeneratedSource/TestDesc.cpp)
  216. if (BENCHMARK)
  217. target_compile_definitions(TestingLib PUBLIC BENCHMARK)
  218. endif()
  219. target_sources(FrameworkLib PRIVATE ${FRAMEWORKSRC})
  220. if (EXTBENCH)
  221. target_compile_definitions(FrameworkLib PUBLIC EXTBENCH)
  222. endif()
  223. ### Includes
  224. target_link_libraries(TestingLib PRIVATE CMSISDSP)
  225. if(NN)
  226. target_link_libraries(TestingLib PRIVATE CMSISNN)
  227. endif()
  228. target_include_directories(TestingLib PRIVATE FrameworkInclude)
  229. target_include_directories(TestingLib PRIVATE GeneratedInclude)
  230. configLib(TestingLib ${ROOT})
  231. configDsp(TestingLib ${ROOT})
  232. configLib(FrameworkLib ${ROOT})
  233. target_include_directories(FrameworkLib PRIVATE FrameworkInclude)
  234. # arm_math.h is needed for q7,q15,q31 types
  235. # which are used for access to pattern files.
  236. target_include_directories(FrameworkLib PRIVATE ${ROOT}/CMSIS/DSP/Include)
  237. # Because we need access to core include for
  238. # timing features in the test framework.
  239. # So we need to identify the core
  240. # then reference the right include folder
  241. set_platform_core()
  242. core_includes(FrameworkLib)
  243. add_executable(Testing main.cpp)
  244. # With -O2, generated code is crashing on some cycle accurate models.
  245. # (cpp part)
  246. disableOptimization(Testing)
  247. configApp(Testing ${ROOT})
  248. target_link_libraries(Testing PRIVATE TestingLib)
  249. target_link_libraries(Testing PRIVATE FrameworkLib)
  250. writeConfig(${CMAKE_CURRENT_BINARY_DIR}/currentConfig.csv)