Skip to content

Commit

Permalink
Add pthreadpool
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed May 29, 2022
1 parent 6a07058 commit 387eccd
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
10 changes: 10 additions & 0 deletions recipes/pthreadpool/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir build
cd build
cmake ${CMAKE_ARGS} \
-DCMAKE_BUILD_TYPE=Release \
-DPTHREADPOOL_BUILD_TESTS=OFF \
-DPTHREADPOOL_BUILD_BENCHMARKS=OFF \
-DPTHREADPOOL_LIBRARY_TYPE=shared \
..
make -j${CPU_COUNT}
make install
63 changes: 63 additions & 0 deletions recipes/pthreadpool/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# To generate the version number
{%- if false %}
git clone [email protected]:Maratyszcza/pthreadpool.git
cd pthreadpool
git pull
echo 0.0.0.$(date +%Y%m%d -d "$(git show -s --format=%ci HEAD)").$(git rev-list HEAD --count).$(git rev-parse --short HEAD)
# Get the git sha
git rev-parse HEAD
wget --quiet https://github.com/Maratyszcza/pthreadpool/archive/$(git rev-parse HEAD).tar.gz
openssl sha256 $(git rev-parse HEAD).tar.gz
{%- endif %}

{% set gitrev = "1787867f6183f056420e532eec640cba25efafea" %}
{% set version = "0.0.0.20210507.141.1787867" %}


package:
name: pthreadpool
version: {{ version }}

source:
url: https://github.com/Maratyszcza/pthreadpool/archive/{{ gitrev}}.tar.gz
sha256: da016ef48f1cdad7d9503a1ef4712a50eaf28b95d90ee67419577d40573f76c9
patches:
- shared_libs.patch

build:
# You can probably build this for windows
skip: true # [win]
number: 0
run_exports:
# 0 guarantees because they beleive in not creating real releases...
# https://github.com/pytorch/qnnpack/issues/84
- {{ pin_subpackage('pthreadpool', max_pin='x.x.x.x.x') }}

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- make # [unix]
host:
# header only libraries below
- fxdiv

test:
commands:
- test -f ${PREFIX}/include/pthreadpool.h
- test -f ${PREFIX}/lib/libpthreadpool${SHLIB_EXT}

about:
home: https://github.com/Maratyszcza/pthreadpool
summary: portable and efficient thread pool implementation
description: |
It provides similar functionality to pragma omp parallel for, but with
additional features.
license: BSD-2-Clause
license_family: BSD
license_file: LICENSE

extra:
recipe-maintainers:
- hmaarrfk
38 changes: 38 additions & 0 deletions recipes/pthreadpool/shared_libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1cba55..525427d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,16 +36,6 @@ MACRO(PTHREADPOOL_TARGET_ENABLE_CXX11 target)
ENDMACRO()

# ---[ Download deps
-IF(NOT DEFINED FXDIV_SOURCE_DIR)
- 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}" .
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
- EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
- 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)
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")
@@ -149,15 +139,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
TARGET_COMPILE_DEFINITIONS(pthreadpool PRIVATE _GNU_SOURCE=1)
ENDIF()

-# ---[ Configure FXdiv
-IF(NOT TARGET fxdiv)
- 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}

0 comments on commit 387eccd

Please sign in to comment.