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
52typedef uint64_t CheckasmCpu;
53
60typedef uintptr_t CheckasmKey;
61
69typedef struct CheckasmCpuInfo {
70 const char *name;
71 const char *suffix;
74
81typedef struct CheckasmTest {
82 const char *name;
83 void (*func)(void);
85
100
122typedef struct CheckasmConfig {
133
141
151
162 void (*set_cpu_flags)(CheckasmCpu new_flags);
163
170 const char *test_pattern;
171
179 const char *function_pattern;
180
187 int bench;
188
198 unsigned bench_usec;
199
202
211
218 unsigned seed;
219
227 unsigned repeat;
228
235
241 unsigned cpu_affinity;
243
257
268
279
294
311
347CHECKASM_API int checkasm_main(CheckasmConfig *config, int argc, const char *argv[]);
348
349#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:52
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:60
CHECKASM_API void checkasm_list_functions(const CheckasmConfig *config)
Print available functions within tests.
CheckasmFormat
Output format for benchmark results.
Definition checkasm.h:93
@ CHECKASM_FORMAT_PRETTY
Definition checkasm.h:94
@ CHECKASM_FORMAT_TSV
Definition checkasm.h:96
@ CHECKASM_FORMAT_HTML
Definition checkasm.h:98
@ CHECKASM_FORMAT_CSV
Definition checkasm.h:95
@ CHECKASM_FORMAT_JSON
Definition checkasm.h:97
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:122
int cpu_affinity_set
Enable process pinning via cpu_affinity.
Definition checkasm.h:234
int verbose
Enable verbose output.
Definition checkasm.h:210
const char * test_pattern
Pattern for filtering which tests to run.
Definition checkasm.h:170
unsigned cpu_affinity
CPU core ID for process pinning.
Definition checkasm.h:241
unsigned repeat
Number of times to repeat tests.
Definition checkasm.h:227
unsigned bench_usec
Target benchmark duration in microseconds.
Definition checkasm.h:198
CheckasmFormat format
Output format for benchmark results.
Definition checkasm.h:201
int bench
Enable benchmarking.
Definition checkasm.h:187
void(* set_cpu_flags)(CheckasmCpu new_flags)
Callback invoked when active CPU flags change.
Definition checkasm.h:162
const CheckasmCpuInfo * cpu_flags
List of CPU flags understood by the implementation.
Definition checkasm.h:132
const char * function_pattern
Pattern for filtering which functions within tests to run.
Definition checkasm.h:179
unsigned seed
Random number generator seed.
Definition checkasm.h:218
CheckasmCpu cpu
Detected CPU flags for the current system.
Definition checkasm.h:150
const CheckasmTest * tests
Array of test functions to execute.
Definition checkasm.h:140
Describes a CPU feature flag/capability.
Definition checkasm.h:69
CheckasmCpu flag
Definition checkasm.h:72
const char * suffix
Definition checkasm.h:71
const char * name
Definition checkasm.h:70
Describes a single test function.
Definition checkasm.h:81
void(* func)(void)
Definition checkasm.h:83
const char * name
Definition checkasm.h:82