checkasm 1.0.1
Assembly testing and benchmarking framework
Loading...
Searching...
No Matches
Internal Implementation Details

Internal functions and structures not part of the public API. More...

Collaboration diagram for Internal Implementation Details:

Data Structures

struct  CheckasmPerf

Macros

#define checkasm_clear_cpu_state()
 Clear CPU state after running a function.
#define CHECKASM_PERF_CALL4(...)
#define CHECKASM_PERF_CALL16(...)
#define CHECKASM_PERF_BENCH_SIMPLE(count, time, ...)
#define CHECKASM_PERF_BENCH_ASM(total_count, time, ...)
#define CHECKASM_PERF_BENCH(count, time, ...)
#define DECL_CHECK_FUNC(NAME, TYPE)
#define DECL_CHECKASM_CHECK_FUNC(type)
#define checkasm_check_impl2(type)
#define checkasm_check_impl(type)
#define checkasm_check1(type, ...)
#define checkasm_check2(type, ...)

Functions

CHECKASM_API CheckasmKey checkasm_check_key (CheckasmKey version, const char *name,...) CHECKASM_PRINTF(2
 Internal implementation of checkasm_check_func().
CHECKASM_API CheckasmKey CHECKASM_API void checkasm_set_signal_handler_state (int enabled)
 Enable or disable signal handling.
CHECKASM_API void checkasm_push_stack_guard (uintptr_t guard[2])
 Push stack guard values for corruption detection.
CHECKASM_API void checkasm_pop_stack_guard (void)
CHECKASM_API const CheckasmPerfcheckasm_get_perf (void)
CHECKASM_API int checkasm_bench_func (void)
 Check if current function should be benchmarked.
CHECKASM_API int checkasm_bench_runs (void)
 Get number of iterations for current benchmark run.
CHECKASM_API void checkasm_bench_update (int iterations, uint64_t cycles)
 Update benchmark statistics with timing results.
CHECKASM_API void checkasm_bench_finish (void)
 Finalize and store benchmark results.
static void checkasm_unused (void)
 Suppress unused variable warnings.
 DECL_CHECKASM_CHECK_FUNC (int)
 DECL_CHECKASM_CHECK_FUNC (int8_t)
 DECL_CHECKASM_CHECK_FUNC (int16_t)
 DECL_CHECKASM_CHECK_FUNC (int32_t)
 DECL_CHECKASM_CHECK_FUNC (unsigned)
 DECL_CHECKASM_CHECK_FUNC (uint8_t)
 DECL_CHECKASM_CHECK_FUNC (uint16_t)
 DECL_CHECKASM_CHECK_FUNC (uint32_t)
CHECKASM_API int checkasm_check_impl_float_ulp (const char *file, int line, const float *buf1, ptrdiff_t stride1, const float *buf2, ptrdiff_t stride2, int w, int h, const char *name, unsigned max_ulp, int align_w, int align_h, int padding)
 Compare float buffers with ULP tolerance.

Detailed Description

Internal functions and structures not part of the public API.

These functions and types are used internally by checkasm macros and should not be called or referenced directly by test code.

Macro Definition Documentation

◆ checkasm_check1

#define checkasm_check1 ( type,
... )
Value:
checkasm_check_impl_##type(__VA_ARGS__)

◆ checkasm_check2

#define checkasm_check2 ( type,
... )
Value:
checkasm_check1(type, __FILE__, __LINE__, __VA_ARGS__)

◆ checkasm_check_impl

#define checkasm_check_impl ( type)
Value:
checkasm_check_impl2(type)

◆ checkasm_check_impl2

#define checkasm_check_impl2 ( type)
Value:
checkasm_check_impl_##type

◆ checkasm_clear_cpu_state

#define checkasm_clear_cpu_state ( )
Value:
do { \
} while (0)

Clear CPU state after running a function.

Clears any processor state that might be left over after running a function. On x86, this typically includes running EMMS to clear MMX state.

◆ CHECKASM_PERF_BENCH

#define CHECKASM_PERF_BENCH ( count,
time,
... )
Value:
do { \
const CheckasmPerf perf = *checkasm_get_perf(); \
CHECKASM_PERF_BENCH_SIMPLE(count, time, __VA_ARGS__); \
} while (0)
Definition test.h:494

◆ CHECKASM_PERF_BENCH_ASM

#define CHECKASM_PERF_BENCH_ASM ( total_count,
time,
... )
Value:
do { \
int tcount_trim = 0; \
uint64_t tsum_trim = 0; \
for (int titer = 0; titer < total_count; titer += 32) { \
uint64_t t = CHECKASM_PERF_ASM(); \
CHECKASM_PERF_CALL16(__VA_ARGS__); \
CHECKASM_PERF_CALL16(__VA_ARGS__); \
t = CHECKASM_PERF_ASM() - t; \
if (t * tcount_trim <= tsum_trim * 4 && (titer > 0 || total_count < 1000)) { \
tsum_trim += t; \
tcount_trim++; \
} \
} \
time = tsum_trim; \
total_count = tcount_trim << 5; \
} while (0)

◆ CHECKASM_PERF_BENCH_SIMPLE

#define CHECKASM_PERF_BENCH_SIMPLE ( count,
time,
... )
Value:
do { \
time = perf.start(); \
for (int tidx = 0; tidx < count; tidx++) \
bench_func(__VA_ARGS__); \
time = perf.stop(time); \
} while (0)

◆ CHECKASM_PERF_CALL16

#define CHECKASM_PERF_CALL16 ( ...)
Value:
do { \
CHECKASM_PERF_CALL4(__VA_ARGS__); \
CHECKASM_PERF_CALL4(__VA_ARGS__); \
CHECKASM_PERF_CALL4(__VA_ARGS__); \
CHECKASM_PERF_CALL4(__VA_ARGS__); \
} while (0)

◆ CHECKASM_PERF_CALL4

#define CHECKASM_PERF_CALL4 ( ...)
Value:
do { \
int tidx = 0; \
bench_func(__VA_ARGS__); \
tidx = 1; \
bench_func(__VA_ARGS__); \
tidx = 2; \
bench_func(__VA_ARGS__); \
tidx = 3; \
bench_func(__VA_ARGS__); \
(void) tidx; \
} while (0)

◆ DECL_CHECK_FUNC

#define DECL_CHECK_FUNC ( NAME,
TYPE )
Value:
int (NAME)(const char *const file, const int line, const TYPE *const buf1, \
const ptrdiff_t stride1, const TYPE *const buf2, const ptrdiff_t stride2, \
const int w, const int h, const char *const buf_name, const int align_w, \
const int align_h, const int padding)

◆ DECL_CHECKASM_CHECK_FUNC

#define DECL_CHECKASM_CHECK_FUNC ( type)
Value:
CHECKASM_API DECL_CHECK_FUNC(checkasm_check_impl_##type, type)
#define CHECKASM_API
Symbol visibility attribute for public API functions.
Definition attributes.h:88

Function Documentation

◆ checkasm_bench_func()

CHECKASM_API int checkasm_bench_func ( void )

Check if current function should be benchmarked.

Returns
Non-zero if benchmarking is enabled for the current function

◆ checkasm_bench_runs()

CHECKASM_API int checkasm_bench_runs ( void )

Get number of iterations for current benchmark run.

Returns
Number of iterations to run, or 0 if benchmarking is complete

◆ checkasm_bench_update()

CHECKASM_API void checkasm_bench_update ( int iterations,
uint64_t cycles )

Update benchmark statistics with timing results.

Parameters
[in]iterationsNumber of iterations that were run
[in]cyclesSum of elapsed time/cycles for those iterations

◆ checkasm_check_key()

CHECKASM_API CheckasmKey checkasm_check_key ( CheckasmKey version,
const char * name,
... )

Internal implementation of checkasm_check_func().

Returns
Reference key if testing should proceed, 0 to skip

◆ checkasm_push_stack_guard()

CHECKASM_API void checkasm_push_stack_guard ( uintptr_t guard[2])

Push stack guard values for corruption detection.

Parameters
[in]guardArray of guard values to push

◆ checkasm_set_signal_handler_state()

CHECKASM_API CheckasmKey CHECKASM_API void checkasm_set_signal_handler_state ( int enabled)

Enable or disable signal handling.

Parameters
[in]enabledNon-zero to enable signal handling, 0 to disable