comparison peck_test.c @ 4:2d6c49fcafcb

neon2 and neon4 support
author Peter Meerwald <p.meerwald@bct-electronic.com>
date Fri, 16 Sep 2011 14:04:19 +0200
parents 723f588b82ac
children 707be088ccc3
comparison
equal deleted inserted replaced
3:3b31bd44a09f 4:2d6c49fcafcb
23 23
24 int main(int argc, char *argv[]) { 24 int main(int argc, char *argv[]) {
25 unsigned int i, j; 25 unsigned int i, j;
26 peck_fftr_cfg p, pi; 26 peck_fftr_cfg p, pi;
27 27
28 enable_runfast(); 28 // enable_runfast();
29 29
30 const unsigned int N = 256; 30 const unsigned int N = 256;
31 31
32 peck_fft_scalar in[N]; 32 peck_fft_scalar in[N];
33 peck_fft_cpx out[N/2 + 1]; 33 peck_fft_cpx out[N/2 + 1];
34 peck_fft_scalar res[N]; 34 peck_fft_scalar res[N];
35 35
36 for (i = 0; i < N; i++) { 36 for (i = 0; i < N; i++) {
37 #if USE_SIMD == SIMD_SSE2
38 in[i] = _mm_set1_ps((i % 13) / 3);
39 #elif USE_SIMD == SIMD_NEON4
40 in[i] = vdupq_n_f32((i % 13) / 3);
41 #elif USE_SIMD == SIMD_NEON2
42 in[i] = vdup_n_f32((i % 13) / 3);
43 #else
37 in[i] = (i % 13) / 3; 44 in[i] = (i % 13) / 3;
45 #endif
38 } 46 }
39 47
40 p = peck_fftr_alloc(N, 0, NULL, NULL); 48 p = peck_fftr_alloc(N, 0, NULL, NULL);
41 pi = peck_fftr_alloc(N, 1, NULL, NULL); 49 pi = peck_fftr_alloc(N, 1, NULL, NULL);
42 50
43 for (j = 0; j < 10000; j++) { 51 for (j = 0; j < 10000; j++) {
44 if (j == 0) { 52 if (j == 0) {
45 for (i = 0; i < 8; i++) 53 for (i = 0; i < 8; i++)
46 printf("%d: %f\n", i, in[i]); 54 printf("%d: %f\n", i, *(float*)&in[i]);
47 printf("----\n"); 55 printf("----\n");
48 } 56 }
49 57
50 peck_fftr(p, in, out); 58 peck_fftr(p, in, out);
51 59
52 if (j == 0) { 60 if (j == 0) {
53 for (i = 0; i < 8; i++) 61 for (i = 0; i < 8; i++)
54 printf("%d: %f %f\n", i, out[i].r, out[i].i); 62 printf("%d: %f %f\n", i, *(float*)&out[i].r, *(float*)&out[i].i);
55 printf("----\n"); 63 printf("----\n");
56 } 64 }
57 65
58 peck_fftri(pi, out, res); 66 peck_fftri(pi, out, res);
59 67
60 if (j == 0) { 68 if (j == 0) {
61 for (i = 0; i < 8; i++) 69 for (i = 0; i < 8; i++)
62 printf("%d: %f\n", i, res[i] / N); 70 printf("%d: %f\n", i, *(float*)&res[i] / N);
63 } 71 }
64 } 72 }
65 peck_fftr_free(p); 73 peck_fftr_free(p);
66 peck_fftr_free(pi); 74 peck_fftr_free(pi);
67 peck_fft_cleanup(); 75 peck_fft_cleanup();
68 76
69 for (i = 0; i < N; i++) { 77 for (i = 0; i < N; i++) {
70 if (fabs(in[i] - res[i]/N) > 0.00001) { 78 if (fabs(*(float*)&in[i] - *(float*)&res[i]/N) > 0.00001) {
71 fprintf(stderr, "!!!! ERROR !!!! at %d\n", i); 79 fprintf(stderr, "!!!! ERROR !!!! at %d\n", i);
72 exit(EXIT_FAILURE); 80 exit(EXIT_FAILURE);
73 } 81 }
74 } 82 }
75 83

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.