vector_array_macros.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 2017 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_DETAIL_VECTOR_ARRAY_MACROS_H
  7. #define LIBSIMDPP_SIMDPP_DETAIL_VECTOR_ARRAY_MACROS_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #define SIMDPP_VEC_ARRAY_IMPL1(RTYPE, OP, V1) \
  13. RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \
  14. r.vec(i) = OP((V1).vec(i)); } \
  15. return r;
  16. #define SIMDPP_VEC_ARRAY_IMPL2(RTYPE, OP, V1, V2) \
  17. RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \
  18. r.vec(i) = OP((V1).vec(i), (V2).vec(i)); } \
  19. return r;
  20. #define SIMDPP_VEC_ARRAY_IMPL2S(RTYPE, OP, V1, A2) \
  21. RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \
  22. r.vec(i) = OP((V1).vec(i), (A2)); } \
  23. return r;
  24. #define SIMDPP_VEC_ARRAY_IMPL3(RTYPE, OP, V1, V2, V3) \
  25. RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \
  26. r.vec(i) = OP((V1).vec(i), (V2).vec(i), (V3).vec(i)); \
  27. } \
  28. return r;
  29. #define SIMDPP_VEC_ARRAY_IMPL_REF1(RTYPE, OP, V1) \
  30. for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \
  31. OP((V1).vec(i)); }
  32. #define SIMDPP_VEC_ARRAY_IMPL_REF2(RTYPE, OP, V1, V2) \
  33. for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \
  34. OP((V1).vec(i), (V2).vec(i)); }
  35. #define SIMDPP_VEC_ARRAY_IMPL_REF3(RTYPE, OP, V1, V2, V3) \
  36. for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \
  37. OP((V1).vec(i), (V2).vec(i), (V3).vec(i)); }
  38. #define SIMDPP_VEC_ARRAY_IMPL_REF4(RTYPE, OP, V1, V2, V3, V4) \
  39. for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \
  40. OP((V1).vec(i), (V2).vec(i), (V3).vec(i), (V4).vec(i)); }
  41. #endif