opencv/cmake/checks/cpu_neon_dotprod.cpp
Vadim Pisarevsky ba4d6c859d
added detection & dispatching of some modern NEON instructions (NEON_FP16, NEON_BF16) (#24420)
* added more or less cross-platform (based on POSIX signal() semantics) method to detect various NEON extensions, such as FP16 SIMD arithmetics, BF16 SIMD arithmetics, SIMD dotprod etc. It could be propagated to other instruction sets if necessary.

* hopefully fixed compile errors

* continue to fix CI

* another attempt to fix build on Linux aarch64

* * reverted to the original method to detect special arm neon instructions without signal()
* renamed FP16_SIMD & BF16_SIMD to NEON_FP16 and NEON_BF16, respectively

* removed extra whitespaces
2023-10-18 22:06:20 +03:00

25 lines
527 B
C++

#include <stdio.h>
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#include "arm_neon.h"
int test()
{
const unsigned int src[] = { 0, 0, 0, 0 };
unsigned int dst[4];
uint32x4_t v_src = *(uint32x4_t*)src;
uint8x16_t v_m0 = *(uint8x16_t*)src;
uint8x16_t v_m1 = *(uint8x16_t*)src;
uint32x4_t v_dst = vdotq_u32(v_src, v_m0, v_m1);
*(uint32x4_t*)dst = v_dst;
return (int)dst[0];
}
#else
#error "DOTPROD is not supported"
#endif
int main()
{
printf("%d\n", test());
return 0;
}