• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /* Copyright (c) 2013  Julien Pommier ( pommier@modartt.com )
3 
4    Redistribution and use of the Software in source and binary forms,
5    with or without modification, is permitted provided that the
6    following conditions are met:
7 
8    - Neither the names of NCAR's Computational and Information Systems
9    Laboratory, the University Corporation for Atmospheric Research,
10    nor the names of its sponsors or contributors may be used to
11    endorse or promote products derived from this Software without
12    specific prior written permission.
13 
14    - Redistributions of source code must retain the above copyright
15    notices, this list of conditions, and the disclaimer below.
16 
17    - Redistributions in binary form must reproduce the above copyright
18    notice, this list of conditions, and the disclaimer below in the
19    documentation and/or other materials provided with the
20    distribution.
21 
22    THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23    EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
24    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25    NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
26    HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
27    EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
30    SOFTWARE.
31 */
32 
33 #ifndef PF_SSE1_FLT_H
34 #define PF_SSE1_FLT_H
35 
36 /*
37   SSE1 support macros
38 */
39 #if !defined(SIMD_SZ) && !defined(PFFFT_SIMD_DISABLE) && (defined(__x86_64__) || defined(_M_X64) || defined(i386) || defined(_M_IX86))
40 #pragma message( __FILE__ ": SSE1 float macros are defined" )
41 
42 #include <xmmintrin.h>
43 typedef __m128 v4sf;
44 
45 /* 4 floats by simd vector -- this is pretty much hardcoded in the preprocess/finalize functions
46  *  anyway so you will have to work if you want to enable AVX with its 256-bit vectors. */
47 #  define SIMD_SZ 4
48 
49 typedef union v4sf_union {
50   v4sf  v;
51   float f[SIMD_SZ];
52 } v4sf_union;
53 
54 #  define VARCH "SSE1"
55 #  define VREQUIRES_ALIGN 1
56 #  define VZERO() _mm_setzero_ps()
57 #  define VMUL(a,b) _mm_mul_ps(a,b)
58 #  define VADD(a,b) _mm_add_ps(a,b)
59 #  define VMADD(a,b,c) _mm_add_ps(_mm_mul_ps(a,b), c)
60 #  define VSUB(a,b) _mm_sub_ps(a,b)
61 #  define LD_PS1(p) _mm_set1_ps(p)
62 #  define VLOAD_UNALIGNED(ptr)  _mm_loadu_ps(ptr)
63 #  define VLOAD_ALIGNED(ptr)    _mm_load_ps(ptr)
64 
65 #  define INTERLEAVE2(in1, in2, out1, out2) { v4sf tmp__ = _mm_unpacklo_ps(in1, in2); out2 = _mm_unpackhi_ps(in1, in2); out1 = tmp__; }
66 #  define UNINTERLEAVE2(in1, in2, out1, out2) { v4sf tmp__ = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(2,0,2,0)); out2 = _mm_shuffle_ps(in1, in2, _MM_SHUFFLE(3,1,3,1)); out1 = tmp__; }
67 #  define VTRANSPOSE4(x0,x1,x2,x3) _MM_TRANSPOSE4_PS(x0,x1,x2,x3)
68 #  define VSWAPHL(a,b) _mm_shuffle_ps(b, a, _MM_SHUFFLE(3,2,1,0))
69 
70 /* reverse/flip all floats */
71 #  define VREV_S(a)    _mm_shuffle_ps(a, a, _MM_SHUFFLE(0,1,2,3))
72 /* reverse/flip complex floats */
73 #  define VREV_C(a)    _mm_shuffle_ps(a, a, _MM_SHUFFLE(1,0,3,2))
74 
75 #  define VALIGNED(ptr) ((((uintptr_t)(ptr)) & 0xF) == 0)
76 
77 #else
78 /* #pragma message( __FILE__ ": SSE1 float macros are not defined" ) */
79 #endif
80 
81 #endif /* PF_SSE1_FLT_H */
82 
83