Skip to content

Commit 3a2b74d

Browse files
xuxin930xiaoxiang781216
authored andcommitted
cmake:port benchmarks to CMake build for testing
Signed-off-by: xuxin19 <[email protected]>
1 parent 3fe1778 commit 3a2b74d

File tree

3 files changed

+440
-5
lines changed

3 files changed

+440
-5
lines changed
Lines changed: 331 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,331 @@
1+
# ##############################################################################
2+
# apps/benchmarks/coremark-pro/CMakeLists.txt
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
5+
# license agreements. See the NOTICE file distributed with this work for
6+
# additional information regarding copyright ownership. The ASF licenses this
7+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
8+
# use this file except in compliance with the License. You may obtain a copy of
9+
# the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations under
17+
# the License.
18+
#
19+
# ##############################################################################
20+
21+
if(CONFIG_BENCHMARK_COREMARK_PRO)
22+
23+
set(COREMARKAPP_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro)
24+
25+
if(NOT EXISTS ${COREMARKAPP_DIR})
26+
FetchContent_Declare(
27+
coremark_fetch
28+
URL https://github.com/eembc/coremark-pro/archive/refs/heads/main.zip
29+
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro BINARY_DIR
30+
${CMAKE_BINARY_DIR}/apps/benchmarks/coremark/coremark-pro
31+
DOWNLOAD_NO_PROGRESS true
32+
TIMEOUT 30)
33+
34+
FetchContent_GetProperties(coremark_fetch)
35+
if(NOT coremark_fetch_POPULATED)
36+
FetchContent_Populate(coremark_fetch)
37+
endif()
38+
endif()
39+
40+
nuttx_add_library(coremark_pro STATIC)
41+
42+
set(CSRCS
43+
coremark-pro/mith/src/md5.c
44+
coremark-pro/mith/src/mith_lib.c
45+
coremark-pro/mith/src/mith_workload.c
46+
coremark-pro/mith/src/th_bignum.c
47+
coremark-pro/mith/src/th_encode.c
48+
coremark-pro/mith/src/th_lib.c
49+
coremark-pro/mith/src/th_math.c
50+
coremark-pro/mith/src/th_rand.c)
51+
52+
file(GLOB MITH_AL_SRCS coremark-pro/mith/al/src/*.c)
53+
54+
list(APPEND CSRCS ${MITH_AL_SRCS})
55+
56+
set(CFLAGS
57+
-Wno-undef
58+
-Wno-strict-prototypes
59+
-Wno-unused-variable
60+
-Wno-pointer-sign
61+
-Wno-unused-but-set-variable
62+
-Wno-shadow
63+
-DNDEBUG
64+
-DHOST_EXAMPLE_CODE=1
65+
-DHAVE_SYS_STAT_H=1
66+
-DGCC_INLINE_MACRO=1
67+
-DMAX_CONTEXTS=100
68+
-DEE_SIZEOF_INT=4
69+
-DUSE_FP128=0)
70+
71+
set(INCDIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro/mith/include
72+
${CMAKE_CURRENT_LIST_DIR}/coremark-pro/mith/al/include)
73+
74+
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_SINGLE_CONTEXT)
75+
list(APPEND CFLAGS -DUSE_SINGLE_CONTEXT=1 -DHAVE_PTHREAD=0
76+
-DUSE_NATIVE_PTHREAD=0)
77+
else()
78+
list(APPEND CFLAGS -DUSE_SINGLE_CONTEXT=0 -DHAVE_PTHREAD=1
79+
-DUSE_NATIVE_PTHREAD=1)
80+
endif()
81+
82+
if(CONFIG_BENCHMARK_COREMARK_PRO_SMP)
83+
list(APPEND CFLAGS -DHAVE_PTHREAD_SETAFFINITY_NP=1 -DHAVE_PTHREAD_SELF=1)
84+
endif()
85+
86+
if(CONFIG_BENCHMARK_COREMARK_PRO_64BIT)
87+
list(APPEND CFLAGS -DEE_SIZEOF_PTR=8 -DEE_PTR_ALIGN=8 -DEE_SIZEOF_LONG=8)
88+
endif()
89+
90+
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
91+
92+
list(APPEND CFLAGS -DUSE_FP64=1 -DUSE_FP32=0)
93+
list(APPEND CSRCS coremark-pro/benchmarks/fp/linpack/ref/inputs_f64.c)
94+
95+
else()
96+
list(APPEND CFLAGS -DUSE_FP32=1 -DUSE_FP64=0)
97+
list(APPEND CSRCS coremark-pro/benchmarks/fp/linpack/ref/inputs_f32.c)
98+
endif()
99+
100+
if(CONFIG_BENCHMARK_COREMARK_PRO_CORE_TEST)
101+
file(GLOB CORE_TEST_SRCS coremark-pro/benchmarks/core/*.c)
102+
set(CORE_TEST_CSRCS coremark-pro/workloads/core/core.c ${CORE_TEST_SRCS})
103+
nuttx_add_application(
104+
NAME
105+
core
106+
PRIORITY
107+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
108+
STACKSIZE
109+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
110+
MODULE
111+
${CONFIG_BENCHMARK_COREMARK_PRO}
112+
COMPILE_FLAGS
113+
${CFLAGS}
114+
SRCS
115+
${CORE_TEST_CSRCS}
116+
INCLUDE_DIRECTORIES
117+
${INCDIR}
118+
DEPENDS
119+
coremark_pro)
120+
endif()
121+
122+
if(CONFIG_BENCHMARK_COREMARK_PRO_CJPEG_TEST)
123+
file(GLOB CJPEG_SRCS coremark-pro/benchmarks/consumer_v2/cjpeg/*.c)
124+
set(CJPEG_CSRCS
125+
coremark-pro/workloads/cjpeg-rose7-preset/cjpeg-rose7-preset.c
126+
coremark-pro/benchmarks/consumer_v2/cjpeg/data/Rose256_bmp.c
127+
${CJPEG_SRCS})
128+
nuttx_add_application(
129+
NAME
130+
cjpeg_rose7_preset
131+
PRIORITY
132+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
133+
STACKSIZE
134+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
135+
MODULE
136+
${CONFIG_BENCHMARK_COREMARK_PRO}
137+
COMPILE_FLAGS
138+
${CFLAGS}
139+
SRCS
140+
${CJPEG_CSRCS}
141+
INCLUDE_DIRECTORIES
142+
${INCDIR}
143+
DEPENDS
144+
coremark_pro)
145+
endif()
146+
147+
if(CONFIG_BENCHMARK_COREMARK_PRO_SHA_TEST)
148+
file(GLOB SHA_TEST_SRCS coremark-pro/benchmarks/darkmark/sha/*.c)
149+
set(SHA_TEST_CSRCS coremark-pro/workloads/sha-test/sha-test.c
150+
${SHA_TEST_SRCS})
151+
nuttx_add_application(
152+
NAME
153+
sha_test
154+
PRIORITY
155+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
156+
STACKSIZE
157+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
158+
MODULE
159+
${CONFIG_BENCHMARK_COREMARK_PRO}
160+
COMPILE_FLAGS
161+
${CFLAGS}
162+
SRCS
163+
${SHA_TEST_CSRCS}
164+
INCLUDE_DIRECTORIES
165+
${INCDIR}
166+
DEPENDS
167+
coremark_pro)
168+
endif()
169+
170+
if(CONFIG_BENCHMARK_COREMARK_PRO_ZIP_TEST)
171+
set(ZIP_TEST_CSRCS coremark-pro/workloads/zip-test/zip-test.c
172+
coremark-pro/benchmarks/darkmark/zip/zip_darkmark.c)
173+
set(ZIP_TEST_FLAGS ${CFLAGS} -Dgzclose_r=coremark_zip_gzclose_r
174+
-Dgzclose_w=coremark_zip_gzclose_w)
175+
set(ZIP_TEST_INCDIR ${INCDIR} ${NUTTX_APPS_DIR}/system/zlib/zlib)
176+
nuttx_add_application(
177+
NAME
178+
zip_test
179+
PRIORITY
180+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
181+
STACKSIZE
182+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
183+
MODULE
184+
${CONFIG_BENCHMARK_COREMARK_PRO}
185+
COMPILE_FLAGS
186+
${ZIP_TEST_FLAGS}
187+
SRCS
188+
${ZIP_TEST_CSRCS}
189+
INCLUDE_DIRECTORIES
190+
${ZIP_TEST_INCDIR}
191+
DEPENDS
192+
coremark_pro)
193+
endif()
194+
195+
if(CONFIG_BENCHMARK_COREMARK_PRO_LINEAR_ALG_MID_TEST)
196+
set(ALG_MID_CSRCS
197+
coremark-pro/workloads/linear_alg-mid-100x100-sp/linear_alg-mid-100x100-sp.c
198+
coremark-pro/benchmarks/fp/linpack/linpack.c)
199+
nuttx_add_application(
200+
NAME
201+
linear_alg_mid_100x100_sp
202+
PRIORITY
203+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
204+
STACKSIZE
205+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
206+
MODULE
207+
${CONFIG_BENCHMARK_COREMARK_PRO}
208+
COMPILE_FLAGS
209+
${CFLAGS}
210+
SRCS
211+
${ALG_MID_CSRCS}
212+
INCLUDE_DIRECTORIES
213+
${INCDIR}
214+
DEPENDS
215+
coremark_pro)
216+
endif()
217+
218+
if(CONFIG_BENCHMARK_COREMARK_PRO_RADIX_TEST)
219+
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
220+
file(GLOB RADIX_SRCS coremark-pro/benchmarks/fp/fft_radix2/ref/*.c)
221+
else()
222+
file(GLOB RADIX_SRCS coremark-pro/benchmarks/fp/fft_radix2/ref-sp/*.c)
223+
endif()
224+
225+
set(RADIX_CSRCS
226+
coremark-pro/workloads/radix2-big-64k/radix2-big-64k.c
227+
coremark-pro/benchmarks/fp/fft_radix2/fft_radix2.c ${RADIX_SRCS})
228+
nuttx_add_application(
229+
NAME
230+
radix2_big_64k
231+
PRIORITY
232+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
233+
STACKSIZE
234+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
235+
MODULE
236+
${CONFIG_BENCHMARK_COREMARK_PRO}
237+
COMPILE_FLAGS
238+
${CFLAGS}
239+
SRCS
240+
${RADIX_CSRCS}
241+
INCLUDE_DIRECTORIES
242+
${INCDIR}
243+
DEPENDS
244+
coremark_pro)
245+
endif()
246+
247+
if(CONFIG_BENCHMARK_COREMARK_PRO_LOOPS_ALL_MID_TEST)
248+
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
249+
file(GLOB MID_SRCS coremark-pro/benchmarks/fp/loops/ref/*.c)
250+
else()
251+
file(GLOB MID_SRCS coremark-pro/benchmarks/fp/loops/ref-sp/*.c)
252+
endif()
253+
254+
set(MID_CSRCS
255+
coremark-pro/workloads/loops-all-mid-10k-sp/loops-all-mid-10k-sp.c
256+
coremark-pro/benchmarks/fp/loops/loops.c ${MID_SRCS})
257+
nuttx_add_application(
258+
NAME
259+
loops_all_mid_10k_sp
260+
PRIORITY
261+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
262+
STACKSIZE
263+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
264+
MODULE
265+
${CONFIG_BENCHMARK_COREMARK_PRO}
266+
COMPILE_FLAGS
267+
${CFLAGS}
268+
SRCS
269+
${MID_CSRCS}
270+
INCLUDE_DIRECTORIES
271+
${INCDIR}
272+
DEPENDS
273+
coremark_pro)
274+
endif()
275+
276+
if(CONFIG_BENCHMARK_COREMARK_PRO_NNET_TEST)
277+
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
278+
file(GLOB NNET_SRCS coremark-pro/benchmarks/fp/nnet/ref/*.c)
279+
else()
280+
file(GLOB NNET_SRCS coremark-pro/benchmarks/fp/nnet/ref-sp/*.c)
281+
endif()
282+
file(GLOB FP_NNET_SRCS coremark-pro/benchmarks/fp/nnet/*.c)
283+
set(NNET_CSRCS coremark-pro/workloads/nnet_test/nnet_test.c ${FP_NNET_SRCS}
284+
${NNET_SRCS})
285+
nuttx_add_application(
286+
NAME
287+
nnet_test
288+
PRIORITY
289+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
290+
STACKSIZE
291+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
292+
MODULE
293+
${CONFIG_BENCHMARK_COREMARK_PRO}
294+
COMPILE_FLAGS
295+
${CFLAGS}
296+
SRCS
297+
${NNET_CSRCS}
298+
INCLUDE_DIRECTORIES
299+
${INCDIR}
300+
DEPENDS
301+
coremark_pro)
302+
endif()
303+
304+
if(CONFIG_BENCHMARK_COREMARK_PRO_PARSER_125K)
305+
file(GLOB PARSER_SRCS coremark-pro/benchmarks/darkmark/parser/*.c)
306+
set(PARSER_CSRCS coremark-pro/workloads/parser-125k/parser-125k.c
307+
${PARSER_SRCS})
308+
nuttx_add_application(
309+
NAME
310+
parser_125k
311+
PRIORITY
312+
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
313+
STACKSIZE
314+
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
315+
MODULE
316+
${CONFIG_BENCHMARK_COREMARK_PRO}
317+
COMPILE_FLAGS
318+
${CFLAGS}
319+
SRCS
320+
${PARSER_CSRCS}
321+
INCLUDE_DIRECTORIES
322+
${INCDIR}
323+
DEPENDS
324+
coremark_pro)
325+
endif()
326+
327+
target_sources(coremark_pro PRIVATE ${CSRCS})
328+
target_include_directories(coremark_pro PRIVATE ${INCDIR})
329+
target_compile_options(coremark_pro PRIVATE ${CFLAGS})
330+
331+
endif()

0 commit comments

Comments
 (0)