|
TECA
The Toolkit for Extreme Climate Analysis
|
A class to manage a fixed size pool of threads that dispatch work. More...
#include <teca_cpu_thread_pool.h>
Public Member Functions | |
| teca_cpu_thread_pool (MPI_Comm comm, int n, bool bind, bool verbose) | |
| teca_cpu_thread_pool (const teca_cpu_thread_pool &src)=delete | |
| teca_cpu_thread_pool (teca_cpu_thread_pool &&src)=delete | |
| teca_cpu_thread_pool & | operator= (const teca_cpu_thread_pool &src)=delete |
| teca_cpu_thread_pool & | operator= (teca_cpu_thread_pool &&src)=delete |
| void | push_task (task_t &task) |
| template<template< typename ... > class container_t, typename ... args> | |
| void | wait_all (container_t< data_t, args ... > &data) |
| template<template< typename ... > class container_t, typename ... args> | |
| int | wait_some (long n_to_wait, long long poll_interval, container_t< data_t, args ... > &data) |
| unsigned int | size () const noexcept |
| get the number of threads More... | |
A class to manage a fixed size pool of threads that dispatch work.
| teca_cpu_thread_pool< task_t, data_t >::teca_cpu_thread_pool | ( | MPI_Comm | comm, |
| int | n, | ||
| bool | bind, | ||
| bool | verbose | ||
| ) |
construct/destruct the thread pool. arguments:
| [in] | comm | communicator over which to map threads. Use MPI_COMM_SELF for local mapping. |
| [in] | n | number of threads to create for the pool. -1 will create 1 thread per physical CPU core. all MPI ranks running on the same node are taken into account, resulting in 1 thread per core node wide. |
| [in] | bind | bind each thread to a specific core. |
| [in] | verbose | print a report of the thread to core bindings |
| void teca_cpu_thread_pool< task_t, data_t >::push_task | ( | task_t & | task | ) |
add a data request task to the queue, returns a future from which the generated dataset can be accessed.
|
inlinenoexcept |
get the number of threads
| void teca_cpu_thread_pool< task_t, data_t >::wait_all | ( | container_t< data_t, args ... > & | data | ) |
wait for all of the requests to execute and transfer datasets in the order that corresponding requests were added to the queue.
| int teca_cpu_thread_pool< task_t, data_t >::wait_some | ( | long | n_to_wait, |
| long long | poll_interval, | ||
| container_t< data_t, args ... > & | data | ||
| ) |
wait for some of the requests to execute. datasets will be returned as they become ready. n_to_wait specifies how many datasets to gather but there are three cases when the number of datasets returned differs from n_to_wait. when n_to_wait is larger than the number of tasks remaining, datasets from all of the remaining tasks is returned. when n_to_wait is smaller than the number of datasets ready, all of the currenttly ready data are returned. finally, when n_to_wait is < 1 the call blocks until all of the tasks complete and all of the data is returned.