tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
parallelize.hpp
Go to the documentation of this file.
1#ifndef TATAMI_PARALLELIZE_HPP
2#define TATAMI_PARALLELIZE_HPP
3
4#include <vector>
5#include <cmath>
6
7#ifndef TATAMI_CUSTOM_PARALLEL
8#include "subpar/subpar.hpp"
9#endif
10
17namespace tatami {
18
41template<bool parallel_ = true, class Function_, typename Index_>
42void parallelize(Function_ fun, Index_ tasks, int threads) {
43 if constexpr(parallel_) {
44#ifdef TATAMI_CUSTOM_PARALLEL
45 TATAMI_CUSTOM_PARALLEL(fun, tasks, threads);
46#else
47 subpar::parallelize_range(threads, tasks, std::move(fun));
48#endif
49 } else {
50 fun(0, 0, tasks);
51 }
52}
53
54}
55
56#endif
void parallelize_range(int num_workers, Task_ num_tasks, Run_ run_task_range)
Flexible representations for matrix data.
Definition Extractor.hpp:15
void parallelize(Function_ fun, Index_ tasks, int threads)
Definition parallelize.hpp:42