Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions
MemsetTest.cpp File Reference
#include "src/core/SkMemset.h"
#include "tests/Test.h"
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Macros

#define MAX_ALIGNMENT   64
 
#define MAX_COUNT   ((MAX_ALIGNMENT) * 32)
 
#define PAD   32
 
#define TOTAL   (PAD + MAX_ALIGNMENT + MAX_COUNT + PAD)
 
#define VALUE16   0x1234
 
#define VALUE32   0x12345678
 

Functions

static void set_zero (void *dst, size_t bytes)
 
static void compare16 (skiatest::Reporter *r, const uint16_t base[], uint16_t value, int count)
 
static void compare32 (skiatest::Reporter *r, const uint32_t base[], uint32_t value, int count)
 
static void test_16 (skiatest::Reporter *reporter)
 
static void test_32 (skiatest::Reporter *reporter)
 
 DEF_TEST (Memset, reporter)
 

Macro Definition Documentation

◆ MAX_ALIGNMENT

#define MAX_ALIGNMENT   64

Definition at line 21 of file MemsetTest.cpp.

◆ MAX_COUNT

#define MAX_COUNT   ((MAX_ALIGNMENT) * 32)

Definition at line 22 of file MemsetTest.cpp.

◆ PAD

#define PAD   32

Definition at line 23 of file MemsetTest.cpp.

◆ TOTAL

#define TOTAL   (PAD + MAX_ALIGNMENT + MAX_COUNT + PAD)

Definition at line 24 of file MemsetTest.cpp.

◆ VALUE16

#define VALUE16   0x1234

Definition at line 26 of file MemsetTest.cpp.

◆ VALUE32

#define VALUE32   0x12345678

Definition at line 27 of file MemsetTest.cpp.

Function Documentation

◆ compare16()

static void compare16 ( skiatest::Reporter r,
const uint16_t  base[],
uint16_t  value,
int  count 
)
static

Definition at line 29 of file MemsetTest.cpp.

30 {
31 for (int i = 0; i < count; ++i) {
32 if (base[i] != value) {
33 ERRORF(r, "[%d] expected %x found %x\n", i, value, base[i]);
34 return;
35 }
36 }
37}
int count
#define ERRORF(r,...)
Definition Test.h:293

◆ compare32()

static void compare32 ( skiatest::Reporter r,
const uint32_t  base[],
uint32_t  value,
int  count 
)
static

Definition at line 39 of file MemsetTest.cpp.

40 {
41 for (int i = 0; i < count; ++i) {
42 if (base[i] != value) {
43 ERRORF(r, "[%d] expected %x found %x\n", i, value, base[i]);
44 return;
45 }
46 }
47}

◆ DEF_TEST()

DEF_TEST ( Memset  ,
reporter   
)

Test SkOpts::memset16 and SkOpts::memset32. For performance considerations, implementations may take different paths depending on the alignment of the dst, and/or the size of the count.

Definition at line 88 of file MemsetTest.cpp.

88 {
91}
reporter
static void test_32(skiatest::Reporter *reporter)
static void test_16(skiatest::Reporter *reporter)

◆ set_zero()

static void set_zero ( void *  dst,
size_t  bytes 
)
static

Definition at line 14 of file MemsetTest.cpp.

14 {
15 char* ptr = (char*)dst;
16 for (size_t i = 0; i < bytes; ++i) {
17 ptr[i] = 0;
18 }
19}

◆ test_16()

static void test_16 ( skiatest::Reporter reporter)
static

Definition at line 49 of file MemsetTest.cpp.

49 {
50 uint16_t buffer[TOTAL];
51
52 for (int count = 0; count < MAX_COUNT; ++count) {
53 for (int alignment = 0; alignment < MAX_ALIGNMENT; ++alignment) {
54 set_zero(buffer, sizeof(buffer));
55
56 uint16_t* base = &buffer[PAD + alignment];
58
59 compare16(reporter, buffer, 0, PAD + alignment);
61 compare16(reporter, base + count, 0, TOTAL - count - PAD - alignment);
62 }
63 }
64}
#define PAD
#define MAX_ALIGNMENT
static void compare16(skiatest::Reporter *r, const uint16_t base[], uint16_t value, int count)
#define VALUE16
static void set_zero(void *dst, size_t bytes)
#define MAX_COUNT
#define TOTAL
static const uint8_t buffer[]
void(* memset16)(uint16_t[], uint16_t, int)

◆ test_32()

static void test_32 ( skiatest::Reporter reporter)
static

Definition at line 66 of file MemsetTest.cpp.

66 {
67 uint32_t buffer[TOTAL];
68
69 for (int count = 0; count < MAX_COUNT; ++count) {
70 for (int alignment = 0; alignment < MAX_ALIGNMENT; ++alignment) {
71 set_zero(buffer, sizeof(buffer));
72
73 uint32_t* base = &buffer[PAD + alignment];
75
76 compare32(reporter, buffer, 0, PAD + alignment);
78 compare32(reporter, base + count, 0, TOTAL - count - PAD - alignment);
79 }
80 }
81}
static void compare32(skiatest::Reporter *r, const uint32_t base[], uint32_t value, int count)
#define VALUE32
void(* memset32)(uint32_t[], uint32_t, int)