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"], + )