upg onetbb

This commit is contained in:
joborun linux 2023-03-23 13:32:27 +02:00
parent 5fab31b8f9
commit c9a357ed06
4 changed files with 94 additions and 10 deletions

View File

@ -7,7 +7,7 @@
pkgname=onetbb
pkgver=2021.8.0
pkgrel=01
pkgrel=02
pkgdesc='High level abstract threading library (oneAPI Threading Building Blocks)'
url='https://oneapi-src.github.io/oneTBB/'
depends=('gcc-libs' 'hwloc')
@ -15,8 +15,15 @@ makedepends=('cmake' 'inetutils' 'ninja' 'python' 'swig')
conflicts=('intel-tbb' 'tbb')
provides=("intel-tbb=$pkgver" "tbb=$pkgver")
replaces=('intel-tbb' 'tbb')
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz
retry-pthread_create.patch::https://github.com/oneapi-src/oneTBB/pull/824.patch)
prepare() {
cd oneTBB-$pkgver
# FS#77894
patch -p1 -i ../retry-pthread_create.patch
}
build() {
cd oneTBB-$pkgver
cmake -G Ninja -D CMAKE_INSTALL_PREFIX=/usr -D TBB_STRICT=OFF -D TBB4PY_BUILD=ON .
@ -39,7 +46,11 @@ arch=(x86_64)
license=('Apache')
sha256sums=(eee380323bb7ce864355ed9431f85c43955faaae9e9bce35c62b372d7ffd9f8b) # onetbb-2021.8.0.tar.gz
sha512sums=('72f68730dfd89409796f9548d3c302111787712089688a7c77092ed1b3a7bf4e7444fe4b58015d2c78b7b71259852526789b2483bf1e71bea8146c4b4676e7b4'
'717d3f78b29ce9e2104cbf962b4ced8a4414dcb8af7259ba12dd62adbacfd59e064ae1771c217cbac46d691ab6bfd52aee90113a5aeb9a1f91379295d16e639a')
## 0561b89bff09d607f3d893927750ec793d519ff1fc08df590b148e44058260ee onetbb-2021.8.0-01-x86_64.pkg.tar.lz
sha256sums=(eee380323bb7ce864355ed9431f85c43955faaae9e9bce35c62b372d7ffd9f8b # onetbb-2021.8.0.tar.gz
5a8806497ecb3d5ee8c824658615ef08b940a3708ab98a5eb8c47a2db250652e) # retry-pthread_create.patch
## 46712eb755b307a0449d8e040aaf7e7848275e0dc670fd4002f7c0c28fb665fe onetbb-2021.8.0-02-x86_64.pkg.tar.lz

View File

@ -7,7 +7,7 @@
pkgname=onetbb
pkgver=2021.8.0
pkgrel=1
pkgrel=2
pkgdesc='High level abstract threading library (oneAPI Threading Building Blocks)'
arch=('x86_64')
url='https://oneapi-src.github.io/oneTBB/'
@ -17,8 +17,16 @@ makedepends=('cmake' 'inetutils' 'ninja' 'python' 'swig')
conflicts=('intel-tbb' 'tbb')
provides=("intel-tbb=$pkgver" "tbb=$pkgver")
replaces=('intel-tbb' 'tbb')
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('72f68730dfd89409796f9548d3c302111787712089688a7c77092ed1b3a7bf4e7444fe4b58015d2c78b7b71259852526789b2483bf1e71bea8146c4b4676e7b4')
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz
retry-pthread_create.patch::https://github.com/oneapi-src/oneTBB/pull/824.patch)
sha512sums=('72f68730dfd89409796f9548d3c302111787712089688a7c77092ed1b3a7bf4e7444fe4b58015d2c78b7b71259852526789b2483bf1e71bea8146c4b4676e7b4'
'717d3f78b29ce9e2104cbf962b4ced8a4414dcb8af7259ba12dd62adbacfd59e064ae1771c217cbac46d691ab6bfd52aee90113a5aeb9a1f91379295d16e639a')
prepare() {
cd oneTBB-$pkgver
# FS#77894
patch -p1 -i ../retry-pthread_create.patch
}
build() {
cd oneTBB-$pkgver

View File

@ -0,0 +1,64 @@
From 7e9474594c775efa70b852f0c0c5089e5980722d Mon Sep 17 00:00:00 2001
From: Rui Ueyama <ruiu@cs.stanford.edu>
Date: Sat, 7 May 2022 19:55:24 +0800
Subject: [PATCH] Retry if pthread_create fails with EAGAIN
On many Unix-like systems, pthread_create can fail spuriously even if
the running machine has enough resources to spawn a new thread.
Therefore, if EAGAIN is returned from pthread_create, we actually have
to try again.
I observed this issue when running the mold linker
(https://github.com/rui314/mold) under a heavy load. mold uses OneTBB
for parallelization.
As another data point, Go has the same logic to retry on EAGAIN:
https://go-review.googlesource.com/c/go/+/33894/
nanosleep is defined in POSIX 2001, so I believe that all Unix-like
systems support it.
Signed-off-by: Rui Ueyama <ruiu@cs.stanford.edu>
---
src/tbb/rml_thread_monitor.h | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/tbb/rml_thread_monitor.h b/src/tbb/rml_thread_monitor.h
index 13b556380f..57e9c30b07 100644
--- a/src/tbb/rml_thread_monitor.h
+++ b/src/tbb/rml_thread_monitor.h
@@ -31,6 +31,7 @@
#include <pthread.h>
#include <cstring>
#include <cstdlib>
+#include <time.h>
#else
#error Unsupported platform
#endif
@@ -191,8 +192,25 @@ inline thread_monitor::handle_type thread_monitor::launch( void* (*thread_routin
check(pthread_attr_init( &s ), "pthread_attr_init has failed");
if( stack_size>0 )
check(pthread_attr_setstacksize( &s, stack_size ), "pthread_attr_setstack_size has failed" );
+
+ // pthread_create(2) can spuriously fail with EAGAIN. We retry
+ // max_num_tries times with progressively longer wait times.
pthread_t handle;
- check( pthread_create( &handle, &s, thread_routine, arg ), "pthread_create has failed" );
+ const int max_num_tries = 20;
+ int error = EAGAIN;
+
+ for (int i = 0; i < max_num_tries && error == EAGAIN; i++) {
+ if (i != 0) {
+ // Wait i milliseconds
+ struct timespec ts = {0, i * 1000 * 1000};
+ nanosleep(&ts, NULL);
+ }
+ error = pthread_create(&handle, &s, thread_routine, arg);
+ }
+
+ if (error)
+ handle_perror(error, "pthread_create has failed");
+
check( pthread_attr_destroy( &s ), "pthread_attr_destroy has failed" );
return handle;
}

View File

@ -1,5 +1,6 @@
real 21m31.203s
user 79m54.533s
sys 2m54.154s
real 19m5.590s
user 74m27.817s
sys 1m32.222s