Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
bench/ | 23-Nov-2023 | - | 501 | 394 | ||
cmake/ | 23-Nov-2023 | - | 64 | 52 | ||
examples/ | 23-Nov-2023 | - | 49 | 37 | ||
include/ | 23-Nov-2023 | - | 1,163 | 305 | ||
src/ | 23-Nov-2023 | - | 7,289 | 5,779 | ||
test/ | 23-Nov-2023 | - | 7,399 | 6,178 | ||
.gitignore | D | 23-Nov-2023 | 268 | 28 | 25 | |
.travis.yml | D | 23-Nov-2023 | 156 | 13 | 12 | |
Android.bp | D | 23-Nov-2023 | 2 KiB | 86 | 81 | |
BUILD.bazel | D | 23-Nov-2023 | 10.4 KiB | 405 | 358 | |
CMakeLists.txt | D | 23-Nov-2023 | 8.7 KiB | 204 | 183 | |
LICENSE | D | 23-Nov-2023 | 1.3 KiB | 27 | 21 | |
METADATA | D | 23-Nov-2023 | 524 | 20 | 19 | |
MODULE_LICENSE_BSD | D | 23-Nov-2023 | 0 | |||
OWNERS | D | 23-Nov-2023 | 219 | 12 | 11 | |
README.md | D | 23-Nov-2023 | 2.1 KiB | 62 | 46 | |
TEST_MAPPING | D | 23-Nov-2023 | 70 | 8 | 7 | |
WORKSPACE | D | 23-Nov-2023 | 1.3 KiB | 39 | 31 | |
configure.py | D | 23-Nov-2023 | 1.2 KiB | 39 | 26 | |
confu.yaml | D | 23-Nov-2023 | 195 | 9 | 8 |
README.md
1# pthreadpool 2 3[](https://github.com/Maratyszcza/pthreadpool/blob/master/LICENSE) 4[](https://travis-ci.org/Maratyszcza/pthreadpool) 5 6**pthreadpool** is a portable and efficient thread pool implementation. 7It provides similar functionality to `#pragma omp parallel for`, but with additional features. 8 9## Features: 10 11* C interface (C++-compatible). 12* 1D-6D loops with step parameters. 13* Run on user-specified or auto-detected number of threads. 14* Work-stealing scheduling for efficient work balancing. 15* Wait-free synchronization of work items. 16* Compatible with Linux (including Android), macOS, iOS, Windows, Emscripten environments. 17* 100% unit tests coverage. 18* Throughput and latency microbenchmarks. 19 20## Example 21 22 The following example demonstates using the thread pool for parallel addition of two arrays: 23 24```c 25static void add_arrays(struct array_addition_context* context, size_t i) { 26 context->sum[i] = context->augend[i] + context->addend[i]; 27} 28 29#define ARRAY_SIZE 4 30 31int main() { 32 double augend[ARRAY_SIZE] = { 1.0, 2.0, 4.0, -5.0 }; 33 double addend[ARRAY_SIZE] = { 0.25, -1.75, 0.0, 0.5 }; 34 double sum[ARRAY_SIZE]; 35 36 pthreadpool_t threadpool = pthreadpool_create(0); 37 assert(threadpool != NULL); 38 39 const size_t threads_count = pthreadpool_get_threads_count(threadpool); 40 printf("Created thread pool with %zu threads\n", threads_count); 41 42 struct array_addition_context context = { augend, addend, sum }; 43 pthreadpool_parallelize_1d(threadpool, 44 (pthreadpool_task_1d_t) add_arrays, 45 (void*) &context, 46 ARRAY_SIZE, 47 PTHREADPOOL_FLAG_DISABLE_DENORMALS /* flags */); 48 49 pthreadpool_destroy(threadpool); 50 threadpool = NULL; 51 52 printf("%8s\t%.2lf\t%.2lf\t%.2lf\t%.2lf\n", "Augend", 53 augend[0], augend[1], augend[2], augend[3]); 54 printf("%8s\t%.2lf\t%.2lf\t%.2lf\t%.2lf\n", "Addend", 55 addend[0], addend[1], addend[2], addend[3]); 56 printf("%8s\t%.2lf\t%.2lf\t%.2lf\t%.2lf\n", "Sum", 57 sum[0], sum[1], sum[2], sum[3]); 58 59 return 0; 60} 61``` 62