1
2 #include "pf_conv_dispatcher.h"
3
4 #if 0
5 #include <stdio.h>
6
7 #define DPRINT(...) fprintf(stderr, __VA_ARGS__)
8
9 #else
10 #define DPRINT(...) do { } while (0)
11 #endif
12
13
14 #define N_DEFAULT_ARCHES 2
15 // 0 is "none"
16 // 1 "dflt"
17
get_all_conv_arch_ptrs(int * p_num_arch)18 ptr_to_conv_f_ptrs * get_all_conv_arch_ptrs(int * p_num_arch)
19 {
20 static ptr_to_conv_f_ptrs * all_arches = nullptr;
21 static int n_arch = 0;
22 if (!all_arches)
23 {
24 n_arch = N_DEFAULT_ARCHES;
25 // @TODO: runtime check if actual CPU supports specific architecture
26 #if defined(CONV_ARCH_GCC_AMD64)
27 static const conv_f_ptrs *conv_arch_ptrs[N_DEFAULT_ARCHES+4] = {0};
28 DPRINT("CONV_ARCH_GCC_AMD64: sse3, sse4, avx, avx2\n");
29 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, sse3)();
30 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, sse4)();
31 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, avx) ();
32 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, avx2)();
33 #elif defined(CONV_ARCH_MSVC_AMD64)
34 static const conv_f_ptrs *conv_arch_ptrs[N_DEFAULT_ARCHES+3] = {0};
35 DPRINT("CONV_ARCH_MSVC_AMD64: sse2, avx, avx2\n");
36 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, sse2)();
37 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, avx) ();
38 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, avx2)();
39 #elif defined(CONV_ARCH_GCC_ARM32NEON)
40 static const conv_f_ptrs *conv_arch_ptrs[N_DEFAULT_ARCHES+3] = {0};
41 DPRINT("CONV_ARCH_GCC_ARM32NEON: neon_vfpv4, neon_rpi3_a53\n");
42 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, neon_vfpv4)();
43 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, neon_rpi3_a53)();
44 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, neon_rpi4_a72)();
45 #elif defined(CONV_ARCH_GCC_AARCH64)
46 static const conv_f_ptrs *conv_arch_ptrs[N_DEFAULT_ARCHES+1] = {0};
47 DPRINT("CONV_ARCH_GCC_AARCH64: -\n");
48 conv_arch_ptrs[n_arch++] = CONV_FN_ARCH(conv_ptrs, armv8a)();
49 #else
50 static const conv_f_ptrs *conv_arch_ptrs[N_DEFAULT_ARCHES] = {0};
51 DPRINT("unknown CONV_ARCH: -\n");
52 #endif
53 conv_arch_ptrs[0] = CONV_FN_ARCH(conv_ptrs, none)();
54 conv_arch_ptrs[1] = CONV_FN_ARCH(conv_ptrs, dflt)();
55 all_arches = conv_arch_ptrs;
56 }
57 if (p_num_arch)
58 *p_num_arch = n_arch;
59 return all_arches;
60 }
61
62