checkasm 1.0.1
Assembly testing and benchmarking framework
Loading...
Searching...
No Matches
Rectangular Buffer Helpers

Macros for creating aligned, padded 2D test buffers. More...

Macros

#define CHECKASM_ROUND(x, a)
 Round up to nearest multiple of a.
#define BUF_RECT(type, name, w, h)
 Declare an aligned, padded rectangular buffer.
#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).

Detailed Description

Macros for creating aligned, padded 2D test buffers.

These macros simplify creating properly aligned and padded rectangular buffers for testing, including automatic stride calculation and padding detection support.

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]); \
ptrdiff_t name##_stride = sizeof(type) * (CHECKASM_ROUND(w, 64) + 64); \
int name##_buf_h = (h) + 32; \
(void) checkasm_check_impl(name##_type); \
(void) name##_stride; \
(void) name##_buf_h; \
type *name = name##_buf + (CHECKASM_ROUND(w, 64) + 64) * 16 + 64
#define CHECKASM_ROUND(x, a)
Round up to nearest multiple of a.
Definition utils.h:522

Declare an aligned, padded rectangular buffer.

Creates a properly aligned rectangular buffer with padding on all sides for use with checkasm_check_rect_padded(). Sets up associated metadata (stride, height) and declares a pointer to the usable data region.

Parameters
typeElement type (e.g., uint8_t, int16_t)
nameBase name for the buffer variables
wWidth of the usable buffer region
hHeight of the usable buffer region

Creates:

  • name_buf: Full buffer array (with padding)
  • name_stride: Stride in bytes
  • name_buf_h: Total buffer height in lines (with padding)
  • name: Pointer to start of usable region
BUF_RECT(uint8_t, src, 64, 32);
BUF_RECT(uint8_t, dst, 64, 32);
// uint8_t *src, *dst; // now point to a 64x32 usable area
// ...
checkasm_call_new(dst, dst_stride, src, src_stride, 64, 32);
#define BUF_RECT(type, name, w, h)
Declare an aligned, padded rectangular buffer.
Definition utils.h:553
#define CLEAR_BUF_RECT(name)
Clear a rectangular buffer (including padding).
Definition utils.h:570
#define INITIALIZE_BUF_RECT(name)
Initialize a rectangular buffer (including padding) with pathological values.
Definition utils.h:578
#define checkasm_call_new(...)
Call the implementation being tested with validation.
Definition test.h:342

◆ checkasm_check_rect

#define checkasm_check_rect ( rect1,
... )
Value:
checkasm_check(rect1##_type, rect1, __VA_ARGS__)
#define checkasm_check(type,...)
Compare two 2D buffers and fail test if different.
Definition utils.h:480

Compare two rectangular buffers.

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

◆ checkasm_check_rect_padded

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

Compare two rectangular buffers including padding.

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

◆ checkasm_check_rect_padded_align

#define checkasm_check_rect_padded_align ( rect1,
... )
Value:
checkasm_check_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_check_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:620

◆ CHECKASM_ROUND

#define CHECKASM_ROUND ( x,
a )
Value:
(((x) + ((a) - 1)) & ~((a) - 1))

Round up to nearest multiple of a.

Parameters
xValue to round
aAlignment (must be power of 2)

◆ 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()