Skip to content

Commit 2ede079

Browse files
fbarchardxnnpack-bot
authored andcommitted
Refactor pthreadpool and XNNPACK to remove FXdiv dependency.
PiperOrigin-RevId: 922670033
1 parent 0246058 commit 2ede079

14 files changed

Lines changed: 844 additions & 897 deletions

BUILD.bazel

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ cc_library(
116116
# These are NOT public headers and should not be included from other targets.
117117
textual_hdrs = INTERNAL_HDRS,
118118
visibility = ["//visibility:public"],
119-
deps = [
120-
"@FXdiv",
121-
] + select({
119+
deps = select({
122120
":linux_arm": ["@cpuinfo"],
123121
":linux_armeabi": ["@cpuinfo"],
124122
":linux_armhf": ["@cpuinfo"],

CMakeLists.txt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ IF(PTHREADPOOL_BUILD_TESTS)
7171
ENDIF()
7272

7373
# ---[ Download deps
74-
IF(NOT DEFINED FXDIV_SOURCE_DIR)
75-
MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)")
76-
CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt")
77-
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
78-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
79-
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
80-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
81-
SET(FXDIV_SOURCE_DIR "${CMAKE_BINARY_DIR}/FXdiv-source" CACHE STRING "FXdiv source directory")
82-
ENDIF()
8374

8475
IF(PTHREADPOOL_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
8576
MESSAGE(STATUS "Downloading Google Test to ${CMAKE_BINARY_DIR}/googletest-source (define GOOGLETEST_SOURCE_DIR to avoid it)")
@@ -164,15 +155,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
164155
TARGET_COMPILE_DEFINITIONS(pthreadpool PRIVATE _GNU_SOURCE=1)
165156
ENDIF()
166157

167-
# ---[ Configure FXdiv
168-
IF(NOT TARGET fxdiv)
169-
SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
170-
SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
171-
ADD_SUBDIRECTORY(
172-
"${FXDIV_SOURCE_DIR}"
173-
"${CMAKE_BINARY_DIR}/FXdiv")
174-
ENDIF()
175-
TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv)
158+
176159

177160
INSTALL(TARGETS pthreadpool
178161
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

MODULE.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ http_archive(
5151
)
5252
# LINT.ThenChange(cmake/DownloadGoogleBenchmark.cmake,WORKSPACE:benchmark)
5353

54-
# LINT.IfChange
55-
# FXdiv library, used for repeated integer division by the same factor
56-
http_archive(
57-
name = "FXdiv",
58-
sha256 = "ab7dfb08829bee33dca38405d647868fb214ac685e379ec7ef2bebcd234cd44d",
59-
strip_prefix = "FXdiv-b408327ac2a15ec3e43352421954f5b1967701d1",
60-
urls = ["https://github.com/Maratyszcza/FXdiv/archive/b408327ac2a15ec3e43352421954f5b1967701d1.zip"],
61-
)
62-
# LINT.ThenChange(cmake/DownloadFXdiv.cmake)
54+
6355

6456
# LINT.IfChange
6557
# cpuinfo library, used for detecting processor characteristics

WORKSPACE

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ http_archive(
2222
)
2323
# LINT.ThenChange(cmake/DownloadGoogleBenchmark.cmake,MODULE.bazel:benchmark)
2424

25-
# FXdiv library, used for repeated integer division by the same factor
26-
http_archive(
27-
name = "FXdiv",
28-
strip_prefix = "FXdiv-63058eff77e11aa15bf531df5dd34395ec3017c8",
29-
sha256 = "3d7b0e9c4c658a84376a1086126be02f9b7f753caa95e009d9ac38d11da444db",
30-
urls = ["https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip"],
31-
)
25+
3226

3327
# Android NDK location and version is auto-detected from $ANDROID_NDK_HOME environment variable
3428
android_ndk_repository(name = "androidndk")

cmake/DownloadFXdiv.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

configure.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66

77

88
def main(args):
9-
options = parser.parse_args(args)
10-
build = confu.Build.from_options(options)
11-
12-
build.export_cpath("include", ["pthreadpool.h"])
13-
14-
with build.options(source_dir="src", extra_include_dirs="src", deps=build.deps.fxdiv):
15-
sources = ["legacy-api.c", "portable-api.c"]
16-
if build.target.is_emscripten:
17-
sources.append("shim.c")
18-
elif build.target.is_macos:
19-
sources.append("gcd.c")
20-
elif build.target.is_windows:
21-
sources.append("windows.c")
22-
else:
23-
sources.append("pthreads.c")
24-
build.static_library("pthreadpool", [build.cc(src) for src in sources])
25-
26-
with build.options(source_dir="test", deps=[build, build.deps.googletest]):
27-
build.unittest("pthreadpool-test", build.cxx("pthreadpool.cc"))
28-
29-
with build.options(source_dir="bench", deps=[build, build.deps.googlebenchmark]):
30-
build.benchmark("latency-bench", build.cxx("latency.cc"))
31-
build.benchmark("throughput-bench", build.cxx("throughput.cc"))
32-
33-
return build
9+
options = parser.parse_args(args)
10+
build = confu.Build.from_options(options)
11+
12+
build.export_cpath("include", ["pthreadpool.h"])
13+
14+
with build.options(source_dir="src", extra_include_dirs="src"):
15+
sources = ["legacy-api.c", "portable-api.c"]
16+
if build.target.is_emscripten:
17+
sources.append("shim.c")
18+
elif build.target.is_macos:
19+
sources.append("gcd.c")
20+
elif build.target.is_windows:
21+
sources.append("windows.c")
22+
else:
23+
sources.append("pthreads.c")
24+
build.static_library("pthreadpool", [build.cc(src) for src in sources])
25+
26+
with build.options(source_dir="test", deps=[build, build.deps.googletest]):
27+
build.unittest("pthreadpool-test", build.cxx("pthreadpool.cc"))
28+
29+
with build.options(source_dir="bench", deps=[build, build.deps.googlebenchmark]):
30+
build.benchmark("latency-bench", build.cxx("latency.cc"))
31+
build.benchmark("throughput-bench", build.cxx("throughput.cc"))
32+
33+
return build
3434

3535

3636
if __name__ == "__main__":

confu.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: pthreadpool
22
title: pthread-based thread pool
33
license: Simplified BSD
44
deps:
5-
- name: fxdiv
6-
url: https://github.com/Maratyszcza/FXdiv.git
5+
76
- name: googletest
87
- name: googlebenchmark

jni/Android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ include $(CLEAR_VARS)
99
LOCAL_MODULE := pthreadpool
1010
LOCAL_SRC_FILES := src/threadpool-pthreads.c
1111
LOCAL_CFLAGS := -std=c99 -Wall
12-
LOCAL_STATIC_LIBRARIES := pthreadpool_interface fxdiv
12+
LOCAL_STATIC_LIBRARIES := pthreadpool_interface
1313
include $(BUILD_STATIC_LIBRARY)
1414

1515
$(call import-add-path,$(LOCAL_PATH)/deps)
1616

17-
$(call import-module,fxdiv/jni)
17+

0 commit comments

Comments
 (0)