-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathoptions.cpp
More file actions
35 lines (25 loc) · 794 Bytes
/
options.cpp
File metadata and controls
35 lines (25 loc) · 794 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
32
33
34
35
#include <RcppParallel.h>
#include <Rinternals.h>
#if RCPP_PARALLEL_USE_TBB // TBB support turned on
#include <string>
#include <exception>
#include <tbb/tbb.h>
#include <tbb/global_control.h>
#include <tbb/scalable_allocator.h>
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