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
57template<bool parallel_ = true, class Function_, typename Index_>
58int parallelize(Function_ fun, const Index_ tasks, const int workers) {
59 if constexpr(parallel_) {
60#ifdef TATAMI_CUSTOM_PARALLEL
61 return TATAMI_CUSTOM_PARALLEL(fun, tasks, workers);
62#else
63 return subpar::parallelize_range(workers, tasks, std::move(fun));
64#endif
65 } else {
66 fun(0, 0, tasks);
67 return 1;
68 }
69}
70
71}
72
73#endif
int parallelize_range(int num_workers, const Task_ num_tasks, const Run_ run_task_range)
Flexible representations for matrix data.
Definition Extractor.hpp:15
int parallelize(Function_ fun, const Index_ tasks, const int workers)
Definition parallelize.hpp:58