checkasm 1.0.1
Assembly testing and benchmarking framework
Loading...
Searching...
No Matches
checkasm.h
Go to the documentation of this file.
1/*
2 * Copyright © 2025, Niklas Haas
3 * Copyright © 2018, VideoLAN and dav1d authors
4 * Copyright © 2018, Two Orioles, LLC
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
38
39#ifndef CHECKASM_CHECKASM_H
40#define CHECKASM_CHECKASM_H
41
42#include <stdint.h>
43
44#include "checkasm/attributes.h"
45
55
72#ifndef CHECKASM_HAVE_GENERIC
73 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
74 #define CHECKASM_HAVE_GENERIC 1
75 #else
76 #define CHECKASM_HAVE_GENERIC 0
77 #endif
78#endif
79 /* end of config group */
81
88typedef uint64_t CheckasmCpu;
89
96typedef uintptr_t CheckasmKey;
97
105typedef struct CheckasmCpuInfo {
106 const char *name;
107 const char *suffix;
110
117typedef struct CheckasmTest {
118 const char *name;
119 void (*func)(void);
121
136
158typedef struct CheckasmConfig {
169
177
187
198 void (*set_cpu_flags)(CheckasmCpu new_flags);
199
206 const char *test_pattern;
207
215 const char *function_pattern;
216
223 int bench;
224
234 unsigned bench_usec;
235
238
247
254 unsigned seed;
255
263 unsigned repeat;
264
271
277 unsigned cpu_affinity;
279
293
304
315
330
347
383CHECKASM_API int checkasm_main(CheckasmConfig *config, int argc, const char *argv[]);
384
385#endif /* CHECKASM_CHECKASM_H */
Platform and compiler attribute macros.
#define CHECKASM_API
Symbol visibility attribute for public API functions.
Definition attributes.h:88
uint64_t CheckasmCpu
Opaque type representing a set of CPU feature flags.
Definition checkasm.h:88
CHECKASM_API void checkasm_list_tests(const CheckasmConfig *config)
Print available tests.
uintptr_t CheckasmKey
Opaque type used to identify function implementations.
Definition checkasm.h:96
CHECKASM_API void checkasm_list_functions(const CheckasmConfig *config)
Print available functions within tests.
CheckasmFormat
Output format for benchmark results.
Definition checkasm.h:129
@ CHECKASM_FORMAT_PRETTY
Definition checkasm.h:130
@ CHECKASM_FORMAT_TSV
Definition checkasm.h:132
@ CHECKASM_FORMAT_HTML
Definition checkasm.h:134
@ CHECKASM_FORMAT_CSV
Definition checkasm.h:131
@ CHECKASM_FORMAT_JSON
Definition checkasm.h:133
CHECKASM_API int checkasm_run(const CheckasmConfig *config)
Run all tests and benchmarks matching the specified patterns.
CHECKASM_API void checkasm_list_cpu_flags(const CheckasmConfig *config)
Print available CPU flags to stdout.
CHECKASM_API CheckasmCpu checkasm_get_cpu_flags(void)
Get the current active set of CPU flags.
CHECKASM_API int checkasm_main(CheckasmConfig *config, int argc, const char *argv[])
Main entry point for checkasm test programs.
Configuration structure for the checkasm test suite.
Definition checkasm.h:158
int cpu_affinity_set
Enable process pinning via cpu_affinity.
Definition checkasm.h:270
int verbose
Enable verbose output.
Definition checkasm.h:246
const char * test_pattern
Pattern for filtering which tests to run.
Definition checkasm.h:206
unsigned cpu_affinity
CPU core ID for process pinning.
Definition checkasm.h:277
unsigned repeat
Number of times to repeat tests.
Definition checkasm.h:263
unsigned bench_usec
Target benchmark duration in microseconds.
Definition checkasm.h:234
CheckasmFormat format
Output format for benchmark results.
Definition checkasm.h:237
int bench
Enable benchmarking.
Definition checkasm.h:223
void(* set_cpu_flags)(CheckasmCpu new_flags)
Callback invoked when active CPU flags change.
Definition checkasm.h:198
const CheckasmCpuInfo * cpu_flags
List of CPU flags understood by the implementation.
Definition checkasm.h:168
const char * function_pattern
Pattern for filtering which functions within tests to run.
Definition checkasm.h:215
unsigned seed
Random number generator seed.
Definition checkasm.h:254
CheckasmCpu cpu
Detected CPU flags for the current system.
Definition checkasm.h:186
const CheckasmTest * tests
Array of test functions to execute.
Definition checkasm.h:176
Describes a CPU feature flag/capability.
Definition checkasm.h:105
CheckasmCpu flag
Definition checkasm.h:108
const char * suffix
Definition checkasm.h:107
const char * name
Definition checkasm.h:106
Describes a single test function.
Definition checkasm.h:117
void(* func)(void)
Definition checkasm.h:119
const char * name
Definition checkasm.h:118