xref: /aosp_15_r20/external/pffft/simd/pf_float.h (revision 3f1979aa0d7ad34fcf3763de7b7b8f8cd67e5bdd)
1*3f1979aaSAndroid Build Coastguard Worker 
2*3f1979aaSAndroid Build Coastguard Worker /* Copyright (c) 2013  Julien Pommier ( [email protected] )
3*3f1979aaSAndroid Build Coastguard Worker 
4*3f1979aaSAndroid Build Coastguard Worker    Redistribution and use of the Software in source and binary forms,
5*3f1979aaSAndroid Build Coastguard Worker    with or without modification, is permitted provided that the
6*3f1979aaSAndroid Build Coastguard Worker    following conditions are met:
7*3f1979aaSAndroid Build Coastguard Worker 
8*3f1979aaSAndroid Build Coastguard Worker    - Neither the names of NCAR's Computational and Information Systems
9*3f1979aaSAndroid Build Coastguard Worker    Laboratory, the University Corporation for Atmospheric Research,
10*3f1979aaSAndroid Build Coastguard Worker    nor the names of its sponsors or contributors may be used to
11*3f1979aaSAndroid Build Coastguard Worker    endorse or promote products derived from this Software without
12*3f1979aaSAndroid Build Coastguard Worker    specific prior written permission.
13*3f1979aaSAndroid Build Coastguard Worker 
14*3f1979aaSAndroid Build Coastguard Worker    - Redistributions of source code must retain the above copyright
15*3f1979aaSAndroid Build Coastguard Worker    notices, this list of conditions, and the disclaimer below.
16*3f1979aaSAndroid Build Coastguard Worker 
17*3f1979aaSAndroid Build Coastguard Worker    - Redistributions in binary form must reproduce the above copyright
18*3f1979aaSAndroid Build Coastguard Worker    notice, this list of conditions, and the disclaimer below in the
19*3f1979aaSAndroid Build Coastguard Worker    documentation and/or other materials provided with the
20*3f1979aaSAndroid Build Coastguard Worker    distribution.
21*3f1979aaSAndroid Build Coastguard Worker 
22*3f1979aaSAndroid Build Coastguard Worker    THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23*3f1979aaSAndroid Build Coastguard Worker    EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
24*3f1979aaSAndroid Build Coastguard Worker    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25*3f1979aaSAndroid Build Coastguard Worker    NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
26*3f1979aaSAndroid Build Coastguard Worker    HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
27*3f1979aaSAndroid Build Coastguard Worker    EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28*3f1979aaSAndroid Build Coastguard Worker    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29*3f1979aaSAndroid Build Coastguard Worker    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
30*3f1979aaSAndroid Build Coastguard Worker    SOFTWARE.
31*3f1979aaSAndroid Build Coastguard Worker */
32*3f1979aaSAndroid Build Coastguard Worker 
33*3f1979aaSAndroid Build Coastguard Worker #ifndef PF_FLT_H
34*3f1979aaSAndroid Build Coastguard Worker #define PF_FLT_H
35*3f1979aaSAndroid Build Coastguard Worker 
36*3f1979aaSAndroid Build Coastguard Worker #include <assert.h>
37*3f1979aaSAndroid Build Coastguard Worker #include <string.h>
38*3f1979aaSAndroid Build Coastguard Worker #include <stdint.h>
39*3f1979aaSAndroid Build Coastguard Worker 
40*3f1979aaSAndroid Build Coastguard Worker 
41*3f1979aaSAndroid Build Coastguard Worker /*
42*3f1979aaSAndroid Build Coastguard Worker  *  SIMD reference material:
43*3f1979aaSAndroid Build Coastguard Worker  *
44*3f1979aaSAndroid Build Coastguard Worker  * general SIMD introduction:
45*3f1979aaSAndroid Build Coastguard Worker  * https://www.linuxjournal.com/content/introduction-gcc-compiler-intrinsics-vector-processing
46*3f1979aaSAndroid Build Coastguard Worker  *
47*3f1979aaSAndroid Build Coastguard Worker  * SSE 1:
48*3f1979aaSAndroid Build Coastguard Worker  * https://software.intel.com/sites/landingpage/IntrinsicsGuide/
49*3f1979aaSAndroid Build Coastguard Worker  *
50*3f1979aaSAndroid Build Coastguard Worker  * ARM NEON:
51*3f1979aaSAndroid Build Coastguard Worker  * https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics
52*3f1979aaSAndroid Build Coastguard Worker  *
53*3f1979aaSAndroid Build Coastguard Worker  * Altivec:
54*3f1979aaSAndroid Build Coastguard Worker  * https://www.nxp.com/docs/en/reference-manual/ALTIVECPIM.pdf
55*3f1979aaSAndroid Build Coastguard Worker  * https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html
56*3f1979aaSAndroid Build Coastguard Worker  * better one?
57*3f1979aaSAndroid Build Coastguard Worker  *
58*3f1979aaSAndroid Build Coastguard Worker  */
59*3f1979aaSAndroid Build Coastguard Worker 
60*3f1979aaSAndroid Build Coastguard Worker typedef float vsfscalar;
61*3f1979aaSAndroid Build Coastguard Worker 
62*3f1979aaSAndroid Build Coastguard Worker #include "pf_sse1_float.h"
63*3f1979aaSAndroid Build Coastguard Worker #include "pf_neon_float.h"
64*3f1979aaSAndroid Build Coastguard Worker #include "pf_altivec_float.h"
65*3f1979aaSAndroid Build Coastguard Worker 
66*3f1979aaSAndroid Build Coastguard Worker #ifndef SIMD_SZ
67*3f1979aaSAndroid Build Coastguard Worker #  if !defined(PFFFT_SIMD_DISABLE)
68*3f1979aaSAndroid Build Coastguard Worker #    pragma message( "building float with simd disabled !" )
69*3f1979aaSAndroid Build Coastguard Worker #    define PFFFT_SIMD_DISABLE /* fallback to scalar code */
70*3f1979aaSAndroid Build Coastguard Worker #  endif
71*3f1979aaSAndroid Build Coastguard Worker #endif
72*3f1979aaSAndroid Build Coastguard Worker 
73*3f1979aaSAndroid Build Coastguard Worker #include "pf_scalar_float.h"
74*3f1979aaSAndroid Build Coastguard Worker 
75*3f1979aaSAndroid Build Coastguard Worker /* shortcuts for complex multiplcations */
76*3f1979aaSAndroid Build Coastguard Worker #define VCPLXMUL(ar,ai,br,bi) { v4sf tmp; tmp=VMUL(ar,bi); ar=VMUL(ar,br); ar=VSUB(ar,VMUL(ai,bi)); ai=VMUL(ai,br); ai=VADD(ai,tmp); }
77*3f1979aaSAndroid Build Coastguard Worker #define VCPLXMULCONJ(ar,ai,br,bi) { v4sf tmp; tmp=VMUL(ar,bi); ar=VMUL(ar,br); ar=VADD(ar,VMUL(ai,bi)); ai=VMUL(ai,br); ai=VSUB(ai,tmp); }
78*3f1979aaSAndroid Build Coastguard Worker #ifndef SVMUL
79*3f1979aaSAndroid Build Coastguard Worker /* multiply a scalar with a vector */
80*3f1979aaSAndroid Build Coastguard Worker #define SVMUL(f,v) VMUL(LD_PS1(f),v)
81*3f1979aaSAndroid Build Coastguard Worker #endif
82*3f1979aaSAndroid Build Coastguard Worker 
83*3f1979aaSAndroid Build Coastguard Worker #endif /* PF_FLT_H */
84*3f1979aaSAndroid Build Coastguard Worker 
85