11
22# ' Get the Path to a TBB Library
3- # '
3+ # '
44# ' Retrieve the path to a TBB library. This can be useful for \R packages
55# ' using RcppParallel that wish to use, or re-use, the version of TBB that
66# ' RcppParallel has been configured to use.
7- # '
7+ # '
88# ' @param name
99# ' The name of the TBB library to be resolved. Normally, this is one of
1010# ' `tbb`, `tbbmalloc`, or `tbbmalloc_proxy`. When `NULL`, the library
1111# ' path containing the TBB libraries is returned instead.
12- # '
12+ # '
1313# ' @export
1414tbbLibraryPath <- function (name = NULL ) {
15-
15+
1616 # library paths for different OSes
1717 sysname <- Sys.info()[[" sysname" ]]
18-
18+
1919 # find root for TBB install
2020 tbbRoot <- Sys.getenv(" TBB_LIB" , unset = tbbRoot())
2121 if (is.null(name ))
2222 return (tbbRoot )
23-
23+
2424 # form library names
2525 tbbLibNames <- list (
2626 " Darwin" = paste0(" lib" , name , " .dylib" ),
2727 " Windows" = paste0( name , " .dll" ),
2828 " SunOS" = paste0(" lib" , name , " .so" ),
2929 " Linux" = paste0(" lib" , name , c(" .so.2" , " .so" ))
3030 )
31-
31+
3232 # skip systems that we know not to be compatible
3333 isCompatible <- ! is_sparc() && ! is.null(tbbLibNames [[sysname ]])
3434 if (! isCompatible )
3535 return (NULL )
36-
36+
3737 # find the request library (if any)
3838 libNames <- tbbLibNames [[sysname ]]
3939 for (libName in libNames ) {
@@ -49,12 +49,12 @@ tbbLibraryPath <- function(name = NULL) {
4949 return (tbbName )
5050
5151 }
52-
52+
5353}
5454
5555tbbCxxFlags <- function () {
56-
57- if (! TBB_ENABLED )
56+
57+ if (! TBB_ENABLED )
5858 return (" -DRCPP_PARALLEL_USE_TBB=0" )
5959
6060 flags <- c(" -DRCPP_PARALLEL_USE_TBB=1" )
@@ -66,7 +66,7 @@ tbbCxxFlags <- function() {
6666 flags <- c(flags , " -DTBB_USE_GCC_BUILTINS" )
6767 }
6868 }
69-
69+
7070 # if TBB_INC is set, apply those library paths
7171 tbbInc <- Sys.getenv(" TBB_INC" , unset = TBB_INC )
7272 if (! file.exists(tbbInc )) {
@@ -86,10 +86,10 @@ tbbCxxFlags <- function() {
8686 flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
8787
8888 }
89-
89+
9090 # return flags as string
9191 paste(flags , collapse = " " )
92-
92+
9393}
9494
9595# Return the linker flags required for TBB on this platform
@@ -120,20 +120,20 @@ tbbLdFlags <- function() {
120120 fmt <- " -L%s -l%s -l%s"
121121 return (sprintf(fmt , asBuildPath(tbbLibraryPath()), TBB_NAME , TBB_MALLOC_NAME ))
122122 }
123-
123+
124124 # nothing required on other platforms
125125 " "
126-
126+
127127}
128128
129129tbbRoot <- function () {
130-
130+
131131 if (nzchar(TBB_LIB ))
132132 return (TBB_LIB )
133-
133+
134134 rArch <- .Platform $ r_arch
135135 parts <- c(" lib" , if (nzchar(rArch )) rArch )
136136 libDir <- paste(parts , collapse = " /" )
137137 system.file(libDir , package = " RcppParallel" )
138-
138+
139139}
0 commit comments