Created
October 25, 2012 10:51
-
-
Save syoyo/3951980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __arm__ | |
typedef float32x4_t float4; | |
typedef int32x4_t int4; | |
typedef uint32x4_t uint4; | |
#else | |
typedef __m128 float4; | |
typedef __m128i int4; | |
#if defined(__AVX__) | |
typedef __m256 float8; | |
typedef __m256d double4; | |
#endif | |
#endif | |
#ifdef __arm__ | |
#define vadd_f4(a, b) vaddq_f32((a), (b)) | |
#define vdot_f4(ax, ay, az, bx, by, bz) ( \ | |
vaddq_f32(vmulq_f32((ax), (bx)), \ | |
vaddq_f32(vmulq_f32((ay), (by)), \ | |
vmulq_f32((az), (bz)))) ) | |
#else // sse | |
#define vadd_f4(a, b) _mm_add_ps((a), (b)) | |
#define vdot_f4(ax, ay, az, bx, by, bz) ( \ | |
_mm_add_ps(_mm_mul_ps((ax), (bx)), \ | |
_mm_add_ps(_mm_mul_ps((ay), (by)), \ | |
_mm_mul_ps((az), (bz)))) ) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment