History

checkasm: test for dcmul_add

sunyuechi committed 2 years ago

Commit ea6817d1 parent d526a341 file · +98 −43Browse files

Unified · Split

tests/checkasm/af_afir.c+98−43
@@ -33,64 +33,119 @@ do { \ · 32 unmodified lines
3333 int i; \
3434 double bmg[2], stddev = 10.0, mean = 0.0; \
3535 \
36− for (i = 0; i < LEN*2+8; i += 2) { \
36+ for (i = 0; i < BUF_SIZE; i += 2) { \
3737 av_bmg_get(&checkasm_lfg, bmg); \
3838 buf[i] = bmg[0] * stddev + mean; \
3939 buf[i + 1] = bmg[1] * stddev + mean; \
4040 } \
4141 } while(0);
4242
43−static void test_fcmul_add(const float *src0, const float *src1, const float *src2)
43+static void test_fcmul_add(AudioFIRDSPContext *fir)
4444 {
45− LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]);
46− LOCAL_ALIGNED_32(float, odst, [LEN*2+8]);
47− int i;
48−
49− declare_func(void, float *sum, const float *t, const float *c,
50− ptrdiff_t len);
51−
52− memcpy(cdst, src0, (LEN*2+8) * sizeof(float));
53− memcpy(odst, src0, (LEN*2+8) * sizeof(float));
54− call_ref(cdst, src1, src2, LEN);
55− call_new(odst, src1, src2, LEN);
56− for (i = 0; i <= LEN*2; i++) {
57− int idx = i & ~1;
58− float cre = src2[idx];
59− float cim = src2[idx + 1];
60− float tre = src1[idx];
61− float tim = src1[idx + 1];
62− double t = fabs(src0[i]) +
63− fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) +
64− fabs(tre * cre) + fabs(tim * cim) +
65− fabs(tre * cim) + fabs(tim * cre) +
66− fabs(tre * cre - tim * cim) +
67− fabs(tre * cim + tim * cre) +
68− fabs(cdst[i]) + 1.0;
69− if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {
70− fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
71− i, cdst[i], odst[i], cdst[i] - odst[i]);
72− fail();
73− break;
45+#define BUF_SIZE LEN*2+8
46+ LOCAL_ALIGNED_32(float, src0, [BUF_SIZE]);
47+ LOCAL_ALIGNED_32(float, src1, [BUF_SIZE]);
48+ LOCAL_ALIGNED_32(float, src2, [BUF_SIZE]);
49+
50+ randomize_buffer(src0);
51+ randomize_buffer(src1);
52+ randomize_buffer(src2);
53+
54+ if (check_func(fir->fcmul_add, "fcmul_add")) {
55+ LOCAL_ALIGNED_32(float, cdst, [BUF_SIZE]);
56+ LOCAL_ALIGNED_32(float, odst, [BUF_SIZE]);
57+ int i;
58+
59+ declare_func(void, float *sum, const float *t, const float *c,
60+ ptrdiff_t len);
61+
62+ memcpy(cdst, src0, (BUF_SIZE) * sizeof(float));
63+ memcpy(odst, src0, (BUF_SIZE) * sizeof(float));
64+ call_ref(cdst, src1, src2, LEN);
65+ call_new(odst, src1, src2, LEN);
66+ for (i = 0; i <= LEN*2; i++) {
67+ int idx = i & ~1;
68+ float cre = src2[idx];
69+ float cim = src2[idx + 1];
70+ float tre = src1[idx];
71+ float tim = src1[idx + 1];
72+ double t = fabs(src0[i]) +
73+ fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) +
74+ fabs(tre * cre) + fabs(tim * cim) +
75+ fabs(tre * cim) + fabs(tim * cre) +
76+ fabs(tre * cre - tim * cim) +
77+ fabs(tre * cim + tim * cre) +
78+ fabs(cdst[i]) + 1.0;
79+ if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {
80+ fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
81+ i, cdst[i], odst[i], cdst[i] - odst[i]);
82+ fail();
83+ break;
84+ }
7485 }
86+ memcpy(odst, src0, (BUF_SIZE) * sizeof(float));
87+ bench_new(odst, src1, src2, LEN);
7588 }
76− memcpy(odst, src0, (LEN*2+8) * sizeof(float));
77− bench_new(odst, src1, src2, LEN);
89+
90+ report("fcmul_add");
7891 }
7992
80−void checkasm_check_afir(void)
93+static void test_dcmul_add(AudioFIRDSPContext *fir)
8194 {
82− LOCAL_ALIGNED_32(float, src0, [LEN*2+8]);
83− LOCAL_ALIGNED_32(float, src1, [LEN*2+8]);
84− LOCAL_ALIGNED_32(float, src2, [LEN*2+8]);
85− AudioFIRDSPContext fir = { 0 };
86−
87− ff_afir_init(&fir);
95+#define BUF_SIZE LEN*2+8
96+ LOCAL_ALIGNED_32(double, src0, [BUF_SIZE]);
97+ LOCAL_ALIGNED_32(double, src1, [BUF_SIZE]);
98+ LOCAL_ALIGNED_32(double, src2, [BUF_SIZE]);
8899
89100 randomize_buffer(src0);
90101 randomize_buffer(src1);
91102 randomize_buffer(src2);
92103
93− if (check_func(fir.fcmul_add, "fcmul_add"))
94− test_fcmul_add(src0, src1, src2);
95− report("fcmul_add");
104+ if (check_func(fir->dcmul_add, "dcmul_add")) {
105+ LOCAL_ALIGNED_32(double, cdst, [BUF_SIZE]);
106+ LOCAL_ALIGNED_32(double, odst, [BUF_SIZE]);
107+ int i;
108+
109+ declare_func(void, double *sum, const double *t, const double *c,
110+ ptrdiff_t len);
111+
112+ memcpy(cdst, src0, (BUF_SIZE) * sizeof(double));
113+ memcpy(odst, src0, (BUF_SIZE) * sizeof(double));
114+ call_ref(cdst, src1, src2, LEN);
115+ call_new(odst, src1, src2, LEN);
116+ for (i = 0; i <= LEN*2; i++) {
117+ int idx = i & ~1;
118+ double cre = src2[idx];
119+ double cim = src2[idx + 1];
120+ double tre = src1[idx];
121+ double tim = src1[idx + 1];
122+ double t = fabs(src0[i]) +
123+ fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) +
124+ fabs(tre * cre) + fabs(tim * cim) +
125+ fabs(tre * cim) + fabs(tim * cre) +
126+ fabs(tre * cre - tim * cim) +
127+ fabs(tre * cim + tim * cre) +
128+ fabs(cdst[i]) + 1.0;
129+ if (!double_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {
130+ fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
131+ i, cdst[i], odst[i], cdst[i] - odst[i]);
132+ fail();
133+ break;
134+ }
135+ }
136+ memcpy(odst, src0, (BUF_SIZE) * sizeof(double));
137+ bench_new(odst, src1, src2, LEN);
138+ }
139+
140+ report("dcmul_add");
141+}
142+
143+
144+void checkasm_check_afir(void)
145+{
146+ AudioFIRDSPContext fir = { 0 };
147+
148+ ff_afir_init(&fir);
149+ test_fcmul_add(&fir);
150+ test_dcmul_add(&fir);
96151 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t