forked from RcppCore/RcppParallel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.cpp
More file actions
31 lines (22 loc) · 704 Bytes
/
options.cpp
File metadata and controls
31 lines (22 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <RcppParallel.h>
#include <Rinternals.h>
#if RCPP_PARALLEL_USE_TBB // TBB support turned on
#include <string>
#include <exception>
extern "C" SEXP defaultNumThreads() {
SEXP threadsSEXP = Rf_allocVector(INTSXP, 1);
#ifdef __TBB_task_arena_H
INTEGER(threadsSEXP)[0] = tbb::this_task_arena::max_concurrency();
#else
INTEGER(threadsSEXP)[0] = tbb::task_scheduler_init::default_num_threads();
#endif
return threadsSEXP;
}
#else // TBB support not turned on
#include <tthread/tinythread.h>
extern "C" SEXP defaultNumThreads() {
SEXP threadsSEXP = Rf_allocVector(INTSXP, 1);
INTEGER(threadsSEXP)[0] = tthread::thread::hardware_concurrency();
return threadsSEXP;
}
#endif