blob: 618a6d037a63f0544d2c5bf1131d098c2135a153 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
add_library(
libc_diff_test_utils STATIC
Timer.cpp
Timer.h
)
target_include_directories(
libc_diff_test_utils
PRIVATE
${LIBC_SOURCE_DIR}
)
add_dependencies(
libc_diff_test_utils
libc.src.__support.macros.config
)
# A convenience target to build all performance tests.
add_custom_target(libc-math-performance-tests)
function(add_perf_binary target_name)
cmake_parse_arguments(
"PERF"
"" # No optional arguments
"SUITE;CXX_STANDARD" # Single value arguments
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_LIBRARIES" # Multi-value arguments
${ARGN}
)
if(NOT PERF_SRCS)
message(FATAL_ERROR "'add_perf_binary' target requires a SRCS list of .cpp "
"files.")
endif()
if(NOT PERF_DEPENDS)
message(FATAL_ERROR "'add_perf_binary' target requires a DEPENDS list of "
"'add_entrypoint_object' targets.")
endif()
get_fq_target_name(${target_name} fq_target_name)
get_fq_deps_list(fq_deps_list ${PERF_DEPENDS})
get_object_files_for_test(
link_object_files skipped_entrypoints_list ${fq_deps_list})
if(skipped_entrypoints_list)
if(LIBC_CMAKE_VERBOSE_LOGGING)
set(msg "Will not build ${fq_target_name} as it has missing deps: "
"${skipped_entrypoints_list}.")
message(STATUS ${msg})
endif()
return()
endif()
add_executable(
${fq_target_name}
EXCLUDE_FROM_ALL
${PERF_SRCS}
${PERF_HDRS}
)
target_include_directories(
${fq_target_name}
PRIVATE
${LIBC_SOURCE_DIR}
)
if(PERF_COMPILE_OPTIONS)
target_compile_options(
${fq_target_name}
PRIVATE ${PERF_COMPILE_OPTIONS}
)
endif()
set(link_libraries ${link_object_files})
foreach(lib IN LISTS PERF_LINK_LIBRARIES)
list(APPEND link_libraries ${lib}.unit)
endforeach()
target_link_libraries(
${fq_target_name}
PRIVATE ${link_libraries} libc_diff_test_utils)
set_target_properties(${fq_target_name}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(PERF_CXX_STANDARD)
set_target_properties(
${fq_target_name}
PROPERTIES
CXX_STANDARD ${PERF_CXX_STANDARD}
)
endif()
add_dependencies(
${fq_target_name}
libc.src.__support.FPUtil.fp_bits
${fq_deps_list}
)
add_dependencies(libc-math-performance-tests ${fq_target_name})
endfunction()
add_header_library(
perf_test
HDRS
PerfTest.h
DEPENDS
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
add_perf_binary(
sinf_perf
SRCS
sinf_perf.cpp
DEPENDS
.perf_test
libc.src.math.sinf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
cosf_perf
SRCS
cosf_perf.cpp
DEPENDS
.perf_test
libc.src.math.cosf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
expm1f_perf
SRCS
expm1f_perf.cpp
DEPENDS
.perf_test
libc.src.math.expm1f
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
ceilf_perf
SRCS
ceilf_perf.cpp
DEPENDS
.perf_test
libc.src.math.ceilf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
exp10f16_perf
SRCS
exp10f16_perf.cpp
DEPENDS
.perf_test
libc.src.math.exp10f16
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
exp2f_perf
SRCS
exp2f_perf.cpp
DEPENDS
.perf_test
libc.src.math.exp2f
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
exp2f16_perf
SRCS
exp2f16_perf.cpp
DEPENDS
.perf_test
libc.src.math.exp2f16
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
expf_perf
SRCS
expf_perf.cpp
DEPENDS
.perf_test
libc.src.math.expf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
expf16_perf
SRCS
expf16_perf.cpp
DEPENDS
.perf_test
libc.src.math.expf16
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fabsf_perf
SRCS
fabsf_perf.cpp
DEPENDS
.perf_test
libc.src.math.fabsf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
floorf_perf
SRCS
floorf_perf.cpp
DEPENDS
.perf_test
libc.src.math.floorf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
log10f_perf
SRCS
log10f_perf.cpp
DEPENDS
.perf_test
libc.src.math.log10f
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
log1pf_perf
SRCS
log1pf_perf.cpp
DEPENDS
.perf_test
libc.src.math.log1pf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
log2f_perf
SRCS
log2f_perf.cpp
DEPENDS
.perf_test
libc.src.math.log2f
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
logf_perf
SRCS
logf_perf.cpp
DEPENDS
.perf_test
libc.src.math.logf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
logbf_perf
SRCS
logbf_perf.cpp
DEPENDS
.perf_test
libc.src.math.logbf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
nearbyintf_perf
SRCS
nearbyintf_perf.cpp
DEPENDS
.perf_test
libc.src.math.nearbyintf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
rintf_perf
SRCS
rintf_perf.cpp
DEPENDS
.perf_test
libc.src.math.rintf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
roundf_perf
SRCS
roundf_perf.cpp
DEPENDS
.perf_test
libc.src.math.roundf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
sqrtf_perf
SRCS
sqrtf_perf.cpp
DEPENDS
.perf_test
libc.src.math.sqrtf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
truncf_perf
SRCS
truncf_perf.cpp
DEPENDS
.perf_test
libc.src.math.truncf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
hypotf16_perf
SRCS
hypotf16_perf.cpp
DEPENDS
.perf_test
libc.src.math.hypotf16
libc.src.__support.FPUtil.fp_bits
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
hypotf_perf
SRCS
hypotf_perf.cpp
DEPENDS
.perf_test
libc.src.math.hypotf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
hypot_perf
SRCS
hypot_perf.cpp
DEPENDS
.perf_test
libc.src.math.hypot
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmodf_perf
SRCS
fmodf_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmodf
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmod_perf
SRCS
fmod_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmod
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmodl_perf
SRCS
fmodl_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmodl
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmodf16_perf
SRCS
fmodf16_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmodf16
libc.src.__support.FPUtil.generic.fmod
libc.src.__support.macros.properties.types
)
add_perf_binary(
fmodf128_perf
SRCS
fmodf128_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmodf128
libc.src.__support.macros.properties.types
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
nearest_integer_funcs_perf
SRCS
nearest_integer_funcs_perf.cpp
DEPENDS
libc.src.math.ceilf
libc.src.math.ceilf16
libc.src.math.floorf
libc.src.math.floorf16
libc.src.math.rintf
libc.src.math.rintf16
libc.src.math.roundf
libc.src.math.roundf16
libc.src.math.roundevenf
libc.src.math.roundevenf16
libc.src.math.truncf
libc.src.math.truncf16
COMPILE_OPTIONS
-fno-builtin
LINK_LIBRARIES
LibcFPTestHelpers
)
add_perf_binary(
misc_basic_ops_perf
SRCS
misc_basic_ops_perf.cpp
DEPENDS
.perf_test
libc.src.math.copysignf
libc.src.math.copysignf16
libc.src.math.fabsf
libc.src.math.fabsf16
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
max_min_funcs_perf
SRCS
max_min_funcs_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmaxf
libc.src.math.fmaxf16
libc.src.math.fmaximumf
libc.src.math.fmaximumf16
libc.src.math.fmaximum_numf
libc.src.math.fmaximum_numf16
libc.src.math.fminf
libc.src.math.fminf16
libc.src.math.fminimumf
libc.src.math.fminimumf16
libc.src.math.fminimum_numf
libc.src.math.fminimum_numf16
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmul_perf
SRCS
fmul_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmul
libc.src.__support.FPUtil.generic.mul
libc.src.__support.FPUtil.fp_bits
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
fmull_perf
SRCS
fmull_perf.cpp
DEPENDS
.perf_test
libc.src.math.fmull
COMPILE_OPTIONS
-fno-builtin
)
add_perf_binary(
sqrtf128_perf
SRCS
sqrtf128_perf.cpp
DEPENDS
.perf_test
libc.src.math.sqrtf128
)
|