tatami bindings for arbitrary R matrices.
template<class Function_ , class Index_ >
void tatami_r::parallelize |
( |
Function_ | fun, |
|
|
Index_ | ntasks, |
|
|
int | nthreads ) |
- Template Parameters
-
Function_ | Function to be executed. |
Index_ | Integer type for the task indices. |
- Parameters
-
fun | Function to run in each thread. This is a lambda that should accept three arguments:
- Integer containing the thread ID.
- Integer specifying the index of the first task to be executed in a thread.
- Integer specifying the number of tasks to be executed in a thread.
|
ntasks | Number of tasks to be executed. |
nthreads | Number of threads to parallelize over. |
This function is a drop-in replacement for tatami::parallelize()
. The series of integers from [0, ntasks)
is split into nthreads
contiguous ranges. Each range is used as input to a call to fun
within a thread created by the standard <thread>
library. Serialization can be achieved via <mutex>
in most cases, or manticore::Executor::run()
if the task must be performed on the main thread (see executor()
).
This function is only available if TATAMI_R_PARALLELIZE_UNKNOWN
is defined.