cpu_dotprod.cpp 527 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. #if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
  3. #include "arm_neon.h"
  4. int test()
  5. {
  6. const unsigned int src[] = { 0, 0, 0, 0 };
  7. unsigned int dst[4];
  8. uint32x4_t v_src = *(uint32x4_t*)src;
  9. uint8x16_t v_m0 = *(uint8x16_t*)src;
  10. uint8x16_t v_m1 = *(uint8x16_t*)src;
  11. uint32x4_t v_dst = vdotq_u32(v_src, v_m0, v_m1);
  12. *(uint32x4_t*)dst = v_dst;
  13. return (int)dst[0];
  14. }
  15. #else
  16. #error "DOTPROD is not supported"
  17. #endif
  18. int main()
  19. {
  20. printf("%d\n", test());
  21. return 0;
  22. }