blob: b3be9131df624c007c3434281feb125757bfa8b3 [file] [log] [blame]
Bill Yi4e213d52015-06-23 13:53:11 -07001/* 16-bit signed integer dot product
2 * Switch to appropriate versions
3 * Copyright 2004 Phil Karn
4 * May be used under the terms of the GNU Lesser General Public License (LGPL)
5 */
6#include <stdlib.h>
7#include "fec.h"
8
9void *initdp_port(signed short coeffs[],int len);
10long dotprod_port(void *p,signed short *b);
11void freedp_port(void *p);
12
13#ifdef __i386__
14void *initdp_mmx(signed short coeffs[],int len);
15void *initdp_sse2(signed short coeffs[],int len);
16long dotprod_mmx(void *p,signed short *b);
17long dotprod_sse2(void *p,signed short *b);
18void freedp_mmx(void *p);
19void freedp_sse2(void *p);
20#endif
21
22#ifdef __VEC__
23void *initdp_av(signed short coeffs[],int len);
24long dotprod_av(void *p,signed short *b);
25void freedp_av(void *p);
26#endif
27
28/* Create and return a descriptor for use with the dot product function */
29void *initdp(signed short coeffs[],int len){
30 find_cpu_mode();
31
32 switch(Cpu_mode){
33 case PORT:
34 default:
35 return initdp_port(coeffs,len);
36#ifdef __i386__
37 case MMX:
38 case SSE:
39 return initdp_mmx(coeffs,len);
40 case SSE2:
41 return initdp_sse2(coeffs,len);
42#endif
43
44#ifdef __VEC__
45 case ALTIVEC:
46 return initdp_av(coeffs,len);
47#endif
48 }
49}
50
51
52/* Free a dot product descriptor created earlier */
53void freedp(void *p){
54 switch(Cpu_mode){
55 case PORT:
56 default:
57#ifdef __i386__
58 case MMX:
59 case SSE:
60 return freedp_mmx(p);
61 case SSE2:
62 return freedp_sse2(p);
63#endif
64#ifdef __VEC__
65 case ALTIVEC:
66 return freedp_av(p);
67#endif
68 }
69}
70
71/* Compute a dot product given a descriptor and an input array
72 * The length is taken from the descriptor
73 */
74long dotprod(void *p,signed short a[]){
75 switch(Cpu_mode){
76 case PORT:
77 default:
78 return dotprod_port(p,a);
79#ifdef __i386__
80 case MMX:
81 case SSE:
82 return dotprod_mmx(p,a);
83 case SSE2:
84 return dotprod_sse2(p,a);
85#endif
86
87#ifdef __VEC__
88 case ALTIVEC:
89 return dotprod_av(p,a);
90#endif
91 }
92}
93
94