1
1
2
2
# ' Get the Path to a TBB Library
3
- # '
3
+ # '
4
4
# ' Retrieve the path to a TBB library. This can be useful for \R packages
5
5
# ' using RcppParallel that wish to use, or re-use, the version of TBB that
6
6
# ' RcppParallel has been configured to use.
7
- # '
7
+ # '
8
8
# ' @param name
9
9
# ' The name of the TBB library to be resolved. Normally, this is one of
10
10
# ' `tbb`, `tbbmalloc`, or `tbbmalloc_proxy`. When `NULL`, the library
11
11
# ' path containing the TBB libraries is returned instead.
12
- # '
12
+ # '
13
13
# ' @export
14
14
tbbLibraryPath <- function (name = NULL ) {
15
-
15
+
16
16
# library paths for different OSes
17
17
sysname <- Sys.info()[[" sysname" ]]
18
-
18
+
19
19
# find root for TBB install
20
20
tbbRoot <- Sys.getenv(" TBB_LIB" , unset = tbbRoot())
21
21
if (is.null(name ))
22
22
return (tbbRoot )
23
-
23
+
24
24
# form library names
25
25
tbbLibNames <- list (
26
26
" Darwin" = paste0(" lib" , name , " .dylib" ),
27
27
" Windows" = paste0( name , " .dll" ),
28
28
" SunOS" = paste0(" lib" , name , " .so" ),
29
29
" Linux" = paste0(" lib" , name , c(" .so.2" , " .so" ))
30
30
)
31
-
31
+
32
32
# skip systems that we know not to be compatible
33
33
isCompatible <- ! is_sparc() && ! is.null(tbbLibNames [[sysname ]])
34
34
if (! isCompatible )
35
35
return (NULL )
36
-
36
+
37
37
# find the request library (if any)
38
38
libNames <- tbbLibNames [[sysname ]]
39
39
for (libName in libNames ) {
@@ -49,12 +49,12 @@ tbbLibraryPath <- function(name = NULL) {
49
49
return (tbbName )
50
50
51
51
}
52
-
52
+
53
53
}
54
54
55
55
tbbCxxFlags <- function () {
56
-
57
- if (! TBB_ENABLED )
56
+
57
+ if (! TBB_ENABLED )
58
58
return (" -DRCPP_PARALLEL_USE_TBB=0" )
59
59
60
60
flags <- c(" -DRCPP_PARALLEL_USE_TBB=1" )
@@ -66,7 +66,7 @@ tbbCxxFlags <- function() {
66
66
flags <- c(flags , " -DTBB_USE_GCC_BUILTINS" )
67
67
}
68
68
}
69
-
69
+
70
70
# if TBB_INC is set, apply those library paths
71
71
tbbInc <- Sys.getenv(" TBB_INC" , unset = TBB_INC )
72
72
if (! file.exists(tbbInc )) {
@@ -86,10 +86,10 @@ tbbCxxFlags <- function() {
86
86
flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
87
87
88
88
}
89
-
89
+
90
90
# return flags as string
91
91
paste(flags , collapse = " " )
92
-
92
+
93
93
}
94
94
95
95
# Return the linker flags required for TBB on this platform
@@ -120,20 +120,20 @@ tbbLdFlags <- function() {
120
120
fmt <- " -L%s -l%s -l%s"
121
121
return (sprintf(fmt , asBuildPath(tbbLibraryPath()), TBB_NAME , TBB_MALLOC_NAME ))
122
122
}
123
-
123
+
124
124
# nothing required on other platforms
125
125
" "
126
-
126
+
127
127
}
128
128
129
129
tbbRoot <- function () {
130
-
130
+
131
131
if (nzchar(TBB_LIB ))
132
132
return (TBB_LIB )
133
-
133
+
134
134
rArch <- .Platform $ r_arch
135
135
parts <- c(" lib" , if (nzchar(rArch )) rArch )
136
136
libDir <- paste(parts , collapse = " /" )
137
137
system.file(libDir , package = " RcppParallel" )
138
-
138
+
139
139
}
0 commit comments