checkasm 1.0.1
Assembly testing and benchmarking framework
Loading...
Searching...
No Matches
Buffer Comparison Utilities

Functions and macros for comparing multi-dimensional buffers. More...

Collaboration diagram for Buffer Comparison Utilities:

Macros

#define CHECKASM_ALIGN(x)
 Declare a variable with platform-specific alignment requirements.
#define checkasm_check2d(type, ...)
 Compare two 2D buffers and fail test if different.
#define checkasm_check2d_padded(type, ...)
 Compare two 2D buffers, including padding regions (detect over-write).
#define BUF_RECT(type, name, w, h)
#define CLEAR_BUF_RECT(name)
 Clear a rectangular buffer (including padding).
#define INITIALIZE_BUF_RECT(name)
 Initialize a rectangular buffer (including padding) with pathological values.
#define RANDOMIZE_BUF_RECT(name)
 Randomize a rectangular buffer (including padding).
#define checkasm_check_rect(rect1, ...)
 Compare two rectangular buffers.
#define checkasm_check_rect_padded(rect1, ...)
 Compare two rectangular buffers including padding.
#define checkasm_check_rect_padded_align(rect1, ...)
 Compare two rectangular buffers, with custom alignment (over-write).
#define CHECK_BUF_RECT(buf1, buf2, w, h)
 Compare two rectangular buffers (convenience macro).

Detailed Description

Functions and macros for comparing multi-dimensional buffers.

These utilities compare 2D buffers (with stride support) and detect differences, including in padding regions. Used to verify that optimized implementations produce bit-identical output to reference implementations.

Macro Definition Documentation

◆ BUF_RECT

#define BUF_RECT ( type,
name,
w,
h )
Value:
DECL_CHECK_FUNC(*checkasm_check_impl_##name##_type, type) \
= checkasm_check_impl_##type; \
CHECKASM_ALIGN(type name##_buf[((h) + 32) * (CHECKASM_ROUND(w, 64) + 64) + 64]); \
const int name##_buf_w = CHECKASM_ROUND(w, 64) + 64; \
const int name##_buf_h = (h) + 32; \
ptrdiff_t name##_stride = sizeof(type) * name##_buf_w; \
(void) checkasm_check_impl(name##_type); \
(void) name##_stride; \
(void) name##_buf_h; \
type *name = name##_buf + name##_buf_w * 16 + 64

◆ CHECK_BUF_RECT

#define CHECK_BUF_RECT ( buf1,
buf2,
w,
h )
Value:
checkasm_check_rect_padded(buf1, buf1##_stride, buf2, buf2##_stride, w, h, \
#buf1 " vs " #buf2)
#define checkasm_check_rect_padded(rect1,...)
Compare two rectangular buffers including padding.
Definition utils.h:657

Compare two rectangular buffers (convenience macro).

Parameters
buf1First buffer (from BUF_RECT)
buf2Second buffer (from BUF_RECT)
wWidth of the usable buffer region
hHeight of the usable buffer region
See also
checkasm_check_rect_padded()

◆ CHECKASM_ALIGN

#define CHECKASM_ALIGN ( x)
Value:
x __attribute__((aligned(CHECKASM_ALIGNMENT)))

Declare a variable with platform-specific alignment requirements.

Parameters
xVariable declaration
Note
This must be applied to each buffer individually!
// correct
CHECKASM_ALIGN(uint8_t buf1[64*64]);
CHECKASM_ALIGN(uint8_t buf2[64*64]);
// wrong
CHECKASM_ALIGN(uint8_t buf1[64*64], buf2[64*64]);
#define CHECKASM_ALIGN(x)
Declare a variable with platform-specific alignment requirements.
Definition utils.h:408

◆ checkasm_check2d

#define checkasm_check2d ( type,
... )
Value:
checkasm_check2(type, __VA_ARGS__, 0, 0, 0)

Compare two 2D buffers and fail test if different.

Parameters
typeElement type (e.g., uint8_t, int, float)
buf1First buffer pointer to compare
stride1First buffer stride in bytes
buf2Second buffer pointer to compare
stride2Second buffer stride in bytes
wWidth of the buffers in elements
hHeight of the buffers in lines
nameName of the buffer (for error reporting)
...Extra parameters (e.g. max_ulp for checkasm_check2d(float_ulp, ...))
Note
This will automatically print a hexdump of the differing regions on failure, if verbose mode is enabled.
CHECKASM_ALIGN(uint8_t buf1[64][64]);
CHECKASM_ALIGN(uint8_t buf2[64][64]);
const ptrdiff_t stride = sizeof(buf1[0]);
for (int h = 8; h <= 64; h <<= 1) {
for (int w = 8; w <= 64; w <<= 1) {
if (checkasm_check_func(..., "myfunc_%dx%d", w, h)) {
checkasm_call_ref(buf1, strude, w, h);
checkasm_call_new(buf2, strude, w, h);
checkasm_check2d(uint8_t, buf1, stride, buf2, stride, w, h, "buffer");
}
}
#define checkasm_check2d(type,...)
Compare two 2D buffers and fail test if different.
Definition utils.h:482
#define checkasm_call_ref(...)
Call the reference implementation.
Definition test.h:327
#define checkasm_call_new(...)
Call the implementation being tested with validation.
Definition test.h:342
#define checkasm_check_func(func,...)
Check if a function should be tested and set up function references.
Definition test.h:76

◆ checkasm_check2d_padded

#define checkasm_check2d_padded ( type,
... )
Value:
checkasm_check2(type, __VA_ARGS__)

Compare two 2D buffers, including padding regions (detect over-write).

Parameters
typeElement type (e.g., uint8_t, int, float)
buf1First buffer pointer to compare
stride1First buffer stride in bytes
buf2Second buffer pointer to compare
stride2Second buffer stride in bytes
wWidth of the buffers in elements
hHeight of the buffers in lines
nameName of the buffer (for error reporting)
...Extra parameters (e.g. max_ulp for checkasm_check2d_padded(float_ulp, ...))
align_wHorizontal alignment of the allowed over-write (elements)
align_hVertical alignment of the allowed over-write (lines), or 0 to disable top/bottom overwrite checks.
paddingNumber of extra elements/lines of padding to check (past the alignment boundaries)
See also
checkasm_check2d(), checkasm_check_rect_padded()

◆ checkasm_check_rect

#define checkasm_check_rect ( rect1,
... )
Value:
checkasm_check2d(rect1##_type, rect1, __VA_ARGS__)

Compare two rectangular buffers.

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name
See also
checkasm_check2d()

◆ checkasm_check_rect_padded

#define checkasm_check_rect_padded ( rect1,
... )
Value:
checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 1, 1, 8)
#define checkasm_check2d_padded(type,...)
Compare two 2D buffers, including padding regions (detect over-write).
Definition utils.h:504

Compare two rectangular buffers including padding.

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name
See also
checkasm_check2d()

◆ checkasm_check_rect_padded_align

#define checkasm_check_rect_padded_align ( rect1,
... )
Value:
checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 8)

Compare two rectangular buffers, with custom alignment (over-write).

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name, align
See also
checkasm_check2d_padded()
// Code is allowed to over-write up to 16 elements on the right edge only
checkasm_check_rect_padded_align(src, src_stride, dst, dst_stride, w, h,
"buffer", 16, 1);
#define checkasm_check_rect_padded_align(rect1,...)
Compare two rectangular buffers, with custom alignment (over-write).
Definition utils.h:673

◆ CLEAR_BUF_RECT

#define CLEAR_BUF_RECT ( name)
Value:
CLEAR_BUF(name##_buf)
#define CLEAR_BUF(buf)
Clear a fixed size buffer (convenience macro).
Definition utils.h:254

Clear a rectangular buffer (including padding).

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_clear()

◆ INITIALIZE_BUF_RECT

#define INITIALIZE_BUF_RECT ( name)
Value:
INITIALIZE_BUF(name##_buf)
#define INITIALIZE_BUF(buf)
Fill a fixed size buffer with pathological test data (convenience macro).
Definition utils.h:269

Initialize a rectangular buffer (including padding) with pathological values.

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_init()

◆ RANDOMIZE_BUF_RECT

#define RANDOMIZE_BUF_RECT ( name)
Value:
RANDOMIZE_BUF(name##_buf)
#define RANDOMIZE_BUF(buf)
Fill a fixed size buffer wth random data (convenience macro).
Definition utils.h:261

Randomize a rectangular buffer (including padding).

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_randomize()