summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2021-07-29 14:25:17 +0200
committerLudovic Courtès <ludo@gnu.org>2021-07-29 21:54:54 +0200
commit18d04fef0fea2c604b42c465782f3be647c2b947 (patch)
tree933be4774429dda5e0d7fbbe4c1cafc66b574cd3
parenta9bc8a25eb9a5851062167a3475622ba6b1a8b9a (diff)
gnu: Add pthreadpool.
* gnu/packages/parallel.scm (pthreadpool): New variable. * gnu/packages/patches/pthreadpool-system-libraries.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/parallel.scm35
-rw-r--r--gnu/packages/patches/pthreadpool-system-libraries.patch79
3 files changed, 114 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index e6a2e4023f..488ef3716d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1537,6 +1537,7 @@ dist_patch_DATA = \
%D%/packages/patches/pciutils-hurd-fix.patch \
%D%/packages/patches/plasma-framework-fix-KF5PlasmaMacros.cmake.patch \
%D%/packages/patches/ppsspp-disable-upgrade-and-gold.patch \
+ %D%/packages/patches/pthreadpool-system-libraries.patch \
%D%/packages/patches/samba-fix-fcntl-hint-detection.patch \
%D%/packages/patches/sdcc-disable-non-free-code.patch \
%D%/packages/patches/sdl-pango-api_additions.patch \
diff --git a/gnu/packages/parallel.scm b/gnu/packages/parallel.scm
index 42826f49d6..79387e5552 100644
--- a/gnu/packages/parallel.scm
+++ b/gnu/packages/parallel.scm
@@ -9,7 +9,7 @@
;;; Copyright © 2017, 2018 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
-;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Roel Janssen <roel@gnu.org>
;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
;;;
@@ -44,6 +44,7 @@
#:use-module (gnu packages flex)
#:use-module (gnu packages freeipmi)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages maths)
#:use-module (gnu packages mpi)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
@@ -378,3 +379,35 @@ and output captured in the notebook. Whatever arguments are accepted by a
SLURM command line executable are also accepted by the corresponding magic
command---e.g., @code{%salloc}, @code{%sbatch}, etc.")
(license license:bsd-3))))
+
+(define-public pthreadpool
+ ;; This repository has only one tag, 0.1, which is older than what users
+ ;; such as XNNPACK expect.
+ (let ((commit "1787867f6183f056420e532eec640cba25efafea")
+ (version "0.1")
+ (revision "1"))
+ (package
+ (name "pthreadpool")
+ (version (git-version version revision commit))
+ (home-page "https://github.com/Maratyszcza/pthreadpool")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "02hdvxfn5krw8zivkgjx3b4rk9p02yr4mpdjlp75lsv6z1xf5yrx"))
+ (patches (search-patches "pthreadpool-system-libraries.patch"))))
+ (build-system cmake-build-system)
+ (arguments '(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
+ (inputs
+ `(("googletest" ,googletest)
+ ("googlebenchmark" ,googlebenchmark)
+ ("fxdiv" ,fxdiv)))
+ (synopsis "Efficient thread pool implementation")
+ (description
+ "The pthreadpool library implements an efficient and portable thread
+pool, similar to those implemented by OpenMP run-time support libraries for
+constructs such as @code{#pragma omp parallel for}, with additional
+features.")
+ (license license:bsd-2))))
diff --git a/gnu/packages/patches/pthreadpool-system-libraries.patch b/gnu/packages/patches/pthreadpool-system-libraries.patch
new file mode 100644
index 0000000000..3cfe9c1af6
--- /dev/null
+++ b/gnu/packages/patches/pthreadpool-system-libraries.patch
@@ -0,0 +1,79 @@
+This patch allows the build process to use the provided dependencies instead
+of adding their source as CMake sub-directories (in which case "make install"
+would install googletest's and googlebenchmark's libraries and headers).
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c1cba55..627550f 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -36,7 +36,7 @@ MACRO(PTHREADPOOL_TARGET_ENABLE_CXX11 target)
+ ENDMACRO()
+
+ # ---[ Download deps
+-IF(NOT DEFINED FXDIV_SOURCE_DIR)
++IF(FALSE)
+ MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)")
+ CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt")
+ EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
+@@ -46,7 +46,7 @@ IF(NOT DEFINED FXDIV_SOURCE_DIR)
+ SET(FXDIV_SOURCE_DIR "${CMAKE_BINARY_DIR}/FXdiv-source" CACHE STRING "FXdiv source directory")
+ ENDIF()
+
+-IF(PTHREADPOOL_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
++IF(FALSE)
+ MESSAGE(STATUS "Downloading Google Test to ${CMAKE_BINARY_DIR}/googletest-source (define GOOGLETEST_SOURCE_DIR to avoid it)")
+ CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt")
+ EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
+@@ -56,7 +56,7 @@ IF(PTHREADPOOL_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
+ SET(GOOGLETEST_SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-source" CACHE STRING "Google Test source directory")
+ ENDIF()
+
+-IF(PTHREADPOOL_BUILD_BENCHMARKS AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR)
++IF(FALSE)
+ MESSAGE(STATUS "Downloading Google Benchmark to ${CMAKE_BINARY_DIR}/googlebenchmark-source (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)")
+ CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CMAKE_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt")
+ EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
+@@ -150,27 +150,18 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ ENDIF()
+
+ # ---[ Configure FXdiv
+-IF(NOT TARGET fxdiv)
++IF(FALSE)
+ SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
+ SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
+ ADD_SUBDIRECTORY(
+ "${FXDIV_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/FXdiv")
+ ENDIF()
+-TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv)
+-
+ INSTALL(TARGETS pthreadpool
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+ IF(PTHREADPOOL_BUILD_TESTS)
+- # ---[ Build google test
+- IF(NOT TARGET gtest)
+- SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+- ADD_SUBDIRECTORY(
+- "${GOOGLETEST_SOURCE_DIR}"
+- "${CMAKE_BINARY_DIR}/googletest")
+- ENDIF()
+
+ ADD_EXECUTABLE(pthreadpool-test test/pthreadpool.cc)
+ SET_TARGET_PROPERTIES(pthreadpool-test PROPERTIES
+@@ -188,14 +179,6 @@ IF(PTHREADPOOL_BUILD_TESTS)
+ ENDIF()
+
+ IF(PTHREADPOOL_BUILD_BENCHMARKS)
+- # ---[ Build google benchmark
+- IF(NOT TARGET benchmark)
+- SET(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "")
+- ADD_SUBDIRECTORY(
+- "${GOOGLEBENCHMARK_SOURCE_DIR}"
+- "${CMAKE_BINARY_DIR}/googlebenchmark")
+- ENDIF()
+-
+ ADD_EXECUTABLE(latency-bench bench/latency.cc)
+ SET_TARGET_PROPERTIES(latency-bench PROPERTIES
+ CXX_STANDARD 11