diff --git a/.gitmodules b/.gitmodules index ebc2c470238..c3d1e7b3ebb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,9 @@ [submodule "third-party/gflags"] path = third-party/gflags url = https://github.com/gflags/gflags.git +[submodule "backends/xnnpack/third-party/pthreadpool"] + path = backends/xnnpack/third-party/pthreadpool + url = https://github.com/Maratyszcza/pthreadpool.git +[submodule "backends/xnnpack/third-party/cpuinfo"] + path = backends/xnnpack/third-party/cpuinfo + url = https://github.com/pytorch/cpuinfo.git diff --git a/backends/xnnpack/third-party/TARGETS b/backends/xnnpack/third-party/TARGETS new file mode 100644 index 00000000000..77cd696d253 --- /dev/null +++ b/backends/xnnpack/third-party/TARGETS @@ -0,0 +1,6 @@ +load(":pthreadpool_defs.bzl", "define_pthreadpool") +load(":cpuinfo_defs.bzl", "define_cpuinfo_and_clog") + +define_pthreadpool() + +define_cpuinfo_and_clog() diff --git a/backends/xnnpack/third-party/cpuinfo b/backends/xnnpack/third-party/cpuinfo new file mode 160000 index 00000000000..6481e8bef08 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo @@ -0,0 +1 @@ +Subproject commit 6481e8bef08f606ddd627e4d3be89f64d62e1b8a diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/api.c b/backends/xnnpack/third-party/cpuinfo-wrappers/api.c new file mode 100644 index 00000000000..efd8e45ed94 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/api.c @@ -0,0 +1,7 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#include diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/android/properties.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/android/properties.c new file mode 100644 index 00000000000..02dc2354432 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/android/properties.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/cache.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/cache.c new file mode 100644 index 00000000000..1a7180d32bb --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/cache.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch32-isa.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch32-isa.c new file mode 100644 index 00000000000..7b76cf544b0 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch32-isa.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__arm__) && defined(__linux__) +#include +#endif /* defined(__arm__) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch64-isa.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch64-isa.c new file mode 100644 index 00000000000..6e88e68a3ae --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/aarch64-isa.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__aarch64__) && defined(__linux__) +#include +#endif /* defined(__aarch64__) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/chipset.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/chipset.c new file mode 100644 index 00000000000..32e5eeaacec --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/chipset.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/clusters.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/clusters.c new file mode 100644 index 00000000000..9ddc9930a42 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/clusters.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/cpuinfo.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/cpuinfo.c new file mode 100644 index 00000000000..f49c33970d5 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/cpuinfo.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/hwcap.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/hwcap.c new file mode 100644 index 00000000000..9b7b317323a --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/hwcap.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/init.c new file mode 100644 index 00000000000..c273f699e8f --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/midr.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/midr.c new file mode 100644 index 00000000000..2fe2afd7159 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/linux/midr.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/mach/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/mach/init.c new file mode 100644 index 00000000000..47a71a6ba72 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/mach/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/tlb.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/tlb.c new file mode 100644 index 00000000000..b3c1f82f2aa --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/tlb.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/arm/uarch.c b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/uarch.c new file mode 100644 index 00000000000..cbabd52a9c8 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/arm/uarch.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) +#include +#endif /* (defined(__arm__) || defined(__aarch64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/cache.c b/backends/xnnpack/third-party/cpuinfo-wrappers/cache.c new file mode 100644 index 00000000000..1711f6e3716 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/cache.c @@ -0,0 +1,7 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#include diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/init.c new file mode 100644 index 00000000000..9b01d09b6bb --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/init.c @@ -0,0 +1,7 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#include diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/linux/cpulist.c b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/cpulist.c new file mode 100644 index 00000000000..5366dfd8f17 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/cpulist.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__linux__) +#include +#endif /* defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/linux/mockfile.c b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/mockfile.c new file mode 100644 index 00000000000..a5506e98e20 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/mockfile.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__linux__) +#include +#endif /* defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/linux/multiline.c b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/multiline.c new file mode 100644 index 00000000000..773ad78da7a --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/multiline.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__linux__) +#include +#endif /* defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/linux/processors.c b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/processors.c new file mode 100644 index 00000000000..3e49452e71c --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/processors.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__linux__) +#include +#endif /* defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/linux/smallfile.c b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/smallfile.c new file mode 100644 index 00000000000..b6b7fb0a180 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/linux/smallfile.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__linux__) +#include +#endif /* defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/mach/topology.c b/backends/xnnpack/third-party/cpuinfo-wrappers/mach/topology.c new file mode 100644 index 00000000000..285427e111b --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/mach/topology.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__MACH__) && defined(__APPLE__) +#include +#endif /* defined(__MACH__) && defined(__APPLE__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/descriptor.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/descriptor.c new file mode 100644 index 00000000000..662f4817150 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/descriptor.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/deterministic.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/deterministic.c new file mode 100644 index 00000000000..1d16bc397d3 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/deterministic.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/init.c new file mode 100644 index 00000000000..9fb27f2f285 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/cache/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/info.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/info.c new file mode 100644 index 00000000000..6c49fb13f25 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/info.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/init.c new file mode 100644 index 00000000000..166725960f5 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/isa.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/isa.c new file mode 100644 index 00000000000..fb07179c1dd --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/isa.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/cpuinfo.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/cpuinfo.c new file mode 100644 index 00000000000..651f8f5c7b8 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/cpuinfo.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__linux__) +#include +#endif /* (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/init.c new file mode 100644 index 00000000000..5ac2cae0a4c --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/linux/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__linux__) +#include +#endif /* (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__linux__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mach/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mach/init.c new file mode 100644 index 00000000000..d0ff8379552 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mach/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__MACH__) && defined(__APPLE__) +#include +#endif /* (defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__MACH__) && defined(__APPLE__) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mockcpuid.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mockcpuid.c new file mode 100644 index 00000000000..b5ffcc43f61 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/mockcpuid.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/name.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/name.c new file mode 100644 index 00000000000..e9331cd9186 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/name.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/topology.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/topology.c new file mode 100644 index 00000000000..864aa8757da --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/topology.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/uarch.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/uarch.c new file mode 100644 index 00000000000..ac51c0dff14 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/uarch.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/vendor.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/vendor.c new file mode 100644 index 00000000000..6d5e122e313 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/vendor.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) +#include +#endif /* defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo-wrappers/x86/windows/init.c b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/windows/init.c new file mode 100644 index 00000000000..8a8bc24dd46 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo-wrappers/x86/windows/init.c @@ -0,0 +1,9 @@ +/* Auto-generated by generate-wrappers.py script. Do not modify */ + +#ifdef __APPLE__ + #include +#endif /* __APPLE__ */ + +#if defined(_WIN32) +#include +#endif /* defined(_WIN32) */ diff --git a/backends/xnnpack/third-party/cpuinfo_defs.bzl b/backends/xnnpack/third-party/cpuinfo_defs.bzl new file mode 100644 index 00000000000..95ee3767885 --- /dev/null +++ b/backends/xnnpack/third-party/cpuinfo_defs.bzl @@ -0,0 +1,72 @@ +def define_cpuinfo_and_clog(): + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. + native.cxx_library( + name = "cpuinfo", + srcs = [ + "cpuinfo-wrappers/api.c", + "cpuinfo-wrappers/arm/android/properties.c", + "cpuinfo-wrappers/arm/cache.c", + "cpuinfo-wrappers/arm/linux/aarch32-isa.c", + "cpuinfo-wrappers/arm/linux/aarch64-isa.c", + "cpuinfo-wrappers/arm/linux/chipset.c", + "cpuinfo-wrappers/arm/linux/clusters.c", + "cpuinfo-wrappers/arm/linux/cpuinfo.c", + "cpuinfo-wrappers/arm/linux/hwcap.c", + "cpuinfo-wrappers/arm/linux/init.c", + "cpuinfo-wrappers/arm/linux/midr.c", + "cpuinfo-wrappers/arm/mach/init.c", + "cpuinfo-wrappers/arm/uarch.c", + "cpuinfo-wrappers/cache.c", + "cpuinfo-wrappers/init.c", + "cpuinfo-wrappers/linux/cpulist.c", + "cpuinfo-wrappers/linux/multiline.c", + "cpuinfo-wrappers/linux/processors.c", + "cpuinfo-wrappers/linux/smallfile.c", + "cpuinfo-wrappers/mach/topology.c", + "cpuinfo-wrappers/x86/cache/descriptor.c", + "cpuinfo-wrappers/x86/cache/deterministic.c", + "cpuinfo-wrappers/x86/cache/init.c", + "cpuinfo-wrappers/x86/info.c", + "cpuinfo-wrappers/x86/init.c", + "cpuinfo-wrappers/x86/isa.c", + "cpuinfo-wrappers/x86/linux/cpuinfo.c", + "cpuinfo-wrappers/x86/linux/init.c", + "cpuinfo-wrappers/x86/mach/init.c", + "cpuinfo-wrappers/x86/name.c", + "cpuinfo-wrappers/x86/topology.c", + "cpuinfo-wrappers/x86/uarch.c", + "cpuinfo-wrappers/x86/vendor.c", + "cpuinfo-wrappers/x86/windows/init.c", + ], + include_directories = ["cpuinfo/src"], + public_include_directories = ["cpuinfo/include"], + raw_headers = native.glob([ + "cpuinfo/src/**/*.h", + "cpuinfo/src/**/*.c", + ]), + preferred_linkage = "static", + preprocessor_flags = [ + "-DCPUINFO_LOG_LEVEL=2", + "-D_GNU_SOURCE=1", + ], + visibility = ["PUBLIC"], + deps = [ + ":clog", + ], + ) + + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. + native.cxx_library( + name = "clog", + srcs = [ + "cpuinfo/deps/clog/src/clog.c", + ], + raw_headers = native.glob([ + "cpuinfo/deps/clog/include/*.h", + ]), + public_include_directories = [ + "cpuinfo/deps/clog/include/", + ], + force_static = True, + visibility = ["PUBLIC"], + ) diff --git a/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py b/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py new file mode 100644 index 00000000000..4d5f2a1dce4 --- /dev/null +++ b/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + +from __future__ import print_function +import os + + +CPUINFO_SOURCES = { + None: [ + "init.c", + "api.c", + "cache.c", + ], + "defined(__linux__)": [ + "linux/multiline.c", + "linux/cpulist.c", + "linux/mockfile.c", + "linux/smallfile.c", + "linux/processors.c", + ], + "defined(__MACH__) && defined(__APPLE__)": [ + "mach/topology.c", + ], + "defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(_WIN32)": [ + "x86/cache/init.c", + "x86/cache/deterministic.c", + "x86/cache/descriptor.c", + "x86/info.c", + "x86/mockcpuid.c", + "x86/isa.c", + "x86/topology.c", + "x86/name.c", + "x86/init.c", + "x86/uarch.c", + "x86/vendor.c", + ], + "(defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__linux__)": [ + "x86/linux/init.c", + "x86/linux/cpuinfo.c", + ], + "(defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && defined(__MACH__) && defined(__APPLE__)": [ + "x86/mach/init.c", + ], + "defined(_WIN32)": [ + "x86/windows/init.c", + ], + "(defined(__arm__) || defined(__aarch64__)) && defined(__linux__)": [ + "arm/linux/cpuinfo.c", + "arm/linux/hwcap.c", + "arm/linux/init.c", + "arm/linux/clusters.c", + "arm/linux/midr.c", + "arm/linux/chipset.c", + "arm/tlb.c", + "arm/uarch.c", + "arm/cache.c", + ], + "defined(__arm__) && defined(__linux__)": [ + "arm/linux/aarch32-isa.c", + ], + "defined(__aarch64__) && defined(__linux__)": [ + "arm/linux/aarch64-isa.c", + ], + "(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)": [ + "arm/android/properties.c", + ], + "(defined(__arm__) || defined(__aarch64__)) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE": [ + "arm/mach/init.c", + ],} + + +if __name__ == "__main__": + for condition, filenames in CPUINFO_SOURCES.items(): + for filename in filenames: + filepath = os.path.join("cpuinfo-wrappers", filename) + if not os.path.exists(os.path.dirname(filepath)): + print(filepath) + os.makedirs(os.path.dirname(filepath)) + with open(filepath, "w") as wrapper: + print("/* Auto-generated by generate-wrappers.py script. Do not modify */", file=wrapper) + print(file=wrapper) + print("#ifdef __APPLE__", file=wrapper) + print("\t#include ", file=wrapper) + print("#endif /* __APPLE__ */", file=wrapper) + print(file=wrapper) + + if not condition: + print("#include <%s>" % filename, file=wrapper) + else: + # Include source file only if condition is satisfied + print("#if %s" % condition, file=wrapper) + print("#include <%s>" % filename, file=wrapper) + print("#endif /* %s */" % condition, file=wrapper) diff --git a/backends/xnnpack/third-party/pthreadpool b/backends/xnnpack/third-party/pthreadpool new file mode 160000 index 00000000000..a134dd5d4ce --- /dev/null +++ b/backends/xnnpack/third-party/pthreadpool @@ -0,0 +1 @@ +Subproject commit a134dd5d4cee80cce15db81a72e7f929d71dd413 diff --git a/backends/xnnpack/third-party/pthreadpool_defs.bzl b/backends/xnnpack/third-party/pthreadpool_defs.bzl new file mode 100644 index 00000000000..353754f47e4 --- /dev/null +++ b/backends/xnnpack/third-party/pthreadpool_defs.bzl @@ -0,0 +1,39 @@ +def define_pthreadpool(): + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. + native.cxx_library( + name = "pthreadpool", + srcs = ["pthreadpool/src/legacy-api.c", "pthreadpool/src/memory.c", "pthreadpool/src/portable-api.c", "pthreadpool/src/pthreads.c"], + deps = [ + ":FXdiv", + ], + exported_deps = [ + ":pthreadpool_header", + ], + compiler_flags = [ + "-w", + "-Os", + "-fstack-protector-strong", + "-fno-delete-null-pointer-checks", + ], + headers = { + "threadpool-atomics.h": "pthreadpool/src/threadpool-atomics.h", + "threadpool-common.h": "pthreadpool/src/threadpool-common.h", + "threadpool-object.h": "pthreadpool/src/threadpool-object.h", + "threadpool-utils.h": "pthreadpool/src/threadpool-utils.h", + }, + header_namespace = "", + preferred_linkage = "static", + platform_preprocessor_flags = [["windows", ["-D_WINDOWS", "-D_WIN32", "-DWIN32", "-DNOMINMAX", "-D_CRT_SECURE_NO_WARNINGS", "-D_USE_MATH_DEFINES"]], ["windows.*64$", ["-D_WIN64"]]], + preprocessor_flags = ["-DPTHREADPOOL_USE_FUTEX=0", "-DPTHREADPOOL_USE_GCD=0"], + visibility = ["PUBLIC"], + ) + + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. + native.cxx_library( + name = "pthreadpool_header", + header_namespace = "", + exported_headers = { + "pthreadpool.h": "pthreadpool/include/pthreadpool.h", + }, + visibility = ["PUBLIC"], + )