You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

intrin_sse.h 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #define V_SIMD 128
  2. #define V_SIMD_F64 1
  3. /***************************
  4. * Data Type
  5. ***************************/
  6. typedef __m128 v_f32;
  7. #define v_nlanes_f32 4
  8. /***************************
  9. * Arithmetic
  10. ***************************/
  11. #define v_add_f32 _mm_add_ps
  12. #define v_mul_f32 _mm_mul_ps
  13. #ifdef HAVE_FMA3
  14. // multiply and add, a*b + c
  15. #define v_muladd_f32 _mm_fmadd_ps
  16. #elif defined(HAVE_FMA4)
  17. // multiply and add, a*b + c
  18. #define v_muladd_f32 _mm_macc_ps
  19. #else
  20. // multiply and add, a*b + c
  21. BLAS_FINLINE v_f32 v_muladd_f32(v_f32 a, v_f32 b, v_f32 c)
  22. { return v_add_f32(v_mul_f32(a, b), c); }
  23. #endif // HAVE_FMA3
  24. // Horizontal add: Calculates the sum of all vector elements.
  25. BLAS_FINLINE float v_sum_f32(__m128 a)
  26. {
  27. #ifdef HAVE_SSE3
  28. __m128 sum_halves = _mm_hadd_ps(a, a);
  29. return _mm_cvtss_f32(_mm_hadd_ps(sum_halves, sum_halves));
  30. #else
  31. __m128 t1 = _mm_movehl_ps(a, a);
  32. __m128 t2 = _mm_add_ps(a, t1);
  33. __m128 t3 = _mm_shuffle_ps(t2, t2, 1);
  34. __m128 t4 = _mm_add_ss(t2, t3);
  35. return _mm_cvtss_f32(t4);
  36. #endif
  37. }
  38. /***************************
  39. * memory
  40. ***************************/
  41. // unaligned load
  42. #define v_loadu_f32 _mm_loadu_ps
  43. #define v_storeu_f32 _mm_storeu_ps
  44. #define v_setall_f32(VAL) _mm_set1_ps(VAL)
  45. #define v_zero_f32 _mm_setzero_ps