From 635470c5f3cfb6b3c9cd2a17c6a8c004d2e9eac8 Mon Sep 17 00:00:00 2001 From: Max Ren Date: Thu, 10 Aug 2023 12:29:17 -0700 Subject: [PATCH] add pthreadpool (#47) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/47 add pthreadpool submodule for XNNPACK OSS dep After adding this submodules, we can move the extension/fb/threadpool under XNNPACK and link the correct dependencies there toegheter. Reviewed By: digantdesai Differential Revision: D48176168 fbshipit-source-id: f3c5019befc0c6e92c83e0e0e85205fd775ce176 --- .gitmodules | 3 ++ backends/xnnpack/third-party/TARGETS | 3 ++ backends/xnnpack/third-party/pthreadpool | 1 + .../xnnpack/third-party/pthreadpool_defs.bzl | 39 +++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 backends/xnnpack/third-party/TARGETS create mode 160000 backends/xnnpack/third-party/pthreadpool create mode 100644 backends/xnnpack/third-party/pthreadpool_defs.bzl diff --git a/.gitmodules b/.gitmodules index ebc2c470238..daa08070f63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [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 diff --git a/backends/xnnpack/third-party/TARGETS b/backends/xnnpack/third-party/TARGETS new file mode 100644 index 00000000000..ab78dcd5059 --- /dev/null +++ b/backends/xnnpack/third-party/TARGETS @@ -0,0 +1,3 @@ +load(":pthreadpool_defs.bzl", "define_pthreadpool") + +define_pthreadpool() 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"], + )