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
33 int i; \33 int i; \
34 double bmg[2], stddev = 10.0, mean = 0.0; \34 double bmg[2], stddev = 10.0, mean = 0.0; \
35 \35 \
36 for (i = 0; i < LEN*2+8; i += 2) { \36 for (i = 0; i < BUF_SIZE; i += 2) { \
37 av_bmg_get(&checkasm_lfg, bmg); \37 av_bmg_get(&checkasm_lfg, bmg); \
38 buf[i] = bmg[0] * stddev + mean; \38 buf[i] = bmg[0] * stddev + mean; \
39 buf[i + 1] = bmg[1] * stddev + mean; \39 buf[i + 1] = bmg[1] * stddev + mean; \
40 } \40 } \
41} while(0);41} while(0);
42 42
43static void test_fcmul_add(const float *src0, const float *src1, const float *src2)43static void test_fcmul_add(AudioFIRDSPContext *fir)
44{44{
45 LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]);45#define BUF_SIZE LEN*2+8
46 LOCAL_ALIGNED_32(float, odst, [LEN*2+8]);46 LOCAL_ALIGNED_32(float, src0, [BUF_SIZE]);
47 int i;47 LOCAL_ALIGNED_32(float, src1, [BUF_SIZE]);
48 48 LOCAL_ALIGNED_32(float, src2, [BUF_SIZE]);
49 declare_func(void, float *sum, const float *t, const float *c,49
50 ptrdiff_t len);50 randomize_buffer(src0);
51 51 randomize_buffer(src1);
52 memcpy(cdst, src0, (LEN*2+8) * sizeof(float));52 randomize_buffer(src2);
53 memcpy(odst, src0, (LEN*2+8) * sizeof(float));53
54 call_ref(cdst, src1, src2, LEN);54 if (check_func(fir->fcmul_add, "fcmul_add")) {
55 call_new(odst, src1, src2, LEN);55 LOCAL_ALIGNED_32(float, cdst, [BUF_SIZE]);
56 for (i = 0; i <= LEN*2; i++) {56 LOCAL_ALIGNED_32(float, odst, [BUF_SIZE]);
57 int idx = i & ~1;57 int i;
58 float cre = src2[idx];58
59 float cim = src2[idx + 1];59 declare_func(void, float *sum, const float *t, const float *c,
60 float tre = src1[idx];60 ptrdiff_t len);
61 float tim = src1[idx + 1];61
62 double t = fabs(src0[i]) +62 memcpy(cdst, src0, (BUF_SIZE) * sizeof(float));
63 fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) +63 memcpy(odst, src0, (BUF_SIZE) * sizeof(float));
64 fabs(tre * cre) + fabs(tim * cim) +64 call_ref(cdst, src1, src2, LEN);
65 fabs(tre * cim) + fabs(tim * cre) +65 call_new(odst, src1, src2, LEN);
66 fabs(tre * cre - tim * cim) +66 for (i = 0; i <= LEN*2; i++) {
67 fabs(tre * cim + tim * cre) +67 int idx = i & ~1;
68 fabs(cdst[i]) + 1.0;68 float cre = src2[idx];
69 if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {69 float cim = src2[idx + 1];
70 fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",70 float tre = src1[idx];
71 i, cdst[i], odst[i], cdst[i] - odst[i]);71 float tim = src1[idx + 1];
72 fail();72 double t = fabs(src0[i]) +
73 break;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 }
74 }85 }
86 memcpy(odst, src0, (BUF_SIZE) * sizeof(float));
87 bench_new(odst, src1, src2, LEN);
75 }88 }
76 memcpy(odst, src0, (LEN*2+8) * sizeof(float));89
77 bench_new(odst, src1, src2, LEN);90 report("fcmul_add");
78}91}
79 92
80void checkasm_check_afir(void)93static void test_dcmul_add(AudioFIRDSPContext *fir)
81{94{
82 LOCAL_ALIGNED_32(float, src0, [LEN*2+8]);95#define BUF_SIZE LEN*2+8
83 LOCAL_ALIGNED_32(float, src1, [LEN*2+8]);96 LOCAL_ALIGNED_32(double, src0, [BUF_SIZE]);
84 LOCAL_ALIGNED_32(float, src2, [LEN*2+8]);97 LOCAL_ALIGNED_32(double, src1, [BUF_SIZE]);
85 AudioFIRDSPContext fir = { 0 };98 LOCAL_ALIGNED_32(double, src2, [BUF_SIZE]);
86
87 ff_afir_init(&fir);
88 99
89 randomize_buffer(src0);100 randomize_buffer(src0);
90 randomize_buffer(src1);101 randomize_buffer(src1);
91 randomize_buffer(src2);102 randomize_buffer(src2);
92 103
93 if (check_func(fir.fcmul_add, "fcmul_add"))104 if (check_func(fir->dcmul_add, "dcmul_add")) {
94 test_fcmul_add(src0, src1, src2);105 LOCAL_ALIGNED_32(double, cdst, [BUF_SIZE]);
95 report("fcmul_add");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
144void 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);
96}151}

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