diff --git a/DESCRIPTION b/DESCRIPTION index 629cf838..d8ca0105 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,18 @@ Package: RcppParallel Type: Package Title: Parallel Programming Tools for 'Rcpp' -Version: 5.0.2-9000 +Version: 5.1.0-9000 Authors@R: c( person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"), person("Romain", "Francois", role = c("aut", "cph")), person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com"), person("Gregory", "Vandenbrouck", role = "aut"), person("Marcus", "Geelnard", role = c("aut", "cph"), - comment = "TinyThread library, http://tinythreadpp.bitsnbites.eu/"), + comment = "TinyThread library, https://tinythreadpp.bitsnbites.eu/"), + person("Hamada S.", "Badr", + email = "badr@jhu.edu", + role = c("ctb"), + comment = c(ORCID = "0000-0002-9808-2344")), person(family = "RStudio", role = "cph"), person(family = "Intel", role = c("aut", "cph"), comment = "Intel TBB library, https://www.threadingbuildingblocks.org/"), @@ -24,12 +28,12 @@ Suggests: RUnit, knitr, rmarkdown -SystemRequirements: GNU make, Windows: cmd.exe and cscript.exe, Solaris: g++ is required +SystemRequirements: GNU make, Intel TBB, Windows: cmd.exe and cscript.exe, Solaris: g++ is required License: GPL (>= 2) -URL: http://rcppcore.github.io/RcppParallel, https://github.com/RcppCore/RcppParallel +URL: https://rcppcore.github.io/RcppParallel/, https://github.com/RcppCore/RcppParallel BugReports: https://github.com/RcppCore/RcppParallel/issues Biarch: TRUE -Collate: +Collate: 'build.R' 'hooks.R' 'options.R' diff --git a/R/build.R b/R/build.R index 95cbf5e8..33e393f4 100644 --- a/R/build.R +++ b/R/build.R @@ -41,13 +41,23 @@ inlineCxxPlugin <- function() { } tbbCxxFlags <- function() { - + flags <- c() - + # opt-in to TBB on Windows if (Sys.info()['sysname'] == "Windows") flags <- paste(flags, "-DRCPP_PARALLEL_USE_TBB=1") - + + if (dir.exists(Sys.getenv("TBB_INC"))) { + TBB_INC <- asBuildPath(Sys.getenv("TBB_INC")) + + if (file.exists(file.path(TBB_INC, "tbb", "version.h"))) { + flags <- paste0("-I", shQuote(TBB_INC), " -DTBB_INTERFACE_NEW") + } else { + flags <- paste0("-I", shQuote(TBB_INC)) + } + } + flags } @@ -57,6 +67,9 @@ tbbLdFlags <- function() { if ((Sys.info()['sysname'] %in% c("Windows", "SunOS")) && !isSparc()) { tbb <- tbbLibPath() paste("-L", asBuildPath(dirname(tbb)), " -ltbb -ltbbmalloc", sep = "") + } else if (dir.exists(Sys.getenv("TBB_LIB"))) { + TBB_LIB <- asBuildPath(Sys.getenv("TBB_LIB")) + paste0("-L", shQuote(TBB_LIB), " -Wl,-rpath,", TBB_LIB, " -ltbb -ltbbmalloc") } else { "" } @@ -66,19 +79,32 @@ tbbLdFlags <- function() { tbbLibPath <- function(suffix = "") { sysname <- Sys.info()['sysname'] tbbSupported <- list( - "Darwin" = paste("libtbb", suffix, ".dylib", sep = ""), - "Linux" = paste("libtbb", suffix, ".so.2", sep = ""), + "Darwin" = paste("libtbb", suffix, ".dylib", sep = ""), + "Linux" = paste("libtbb", suffix, ".so.2", sep = ""), "Windows" = paste("tbb", suffix, ".dll", sep = ""), "SunOS" = paste("libtbb", suffix, ".so", sep = "") ) - if ((sysname %in% names(tbbSupported)) && !isSparc()) { - libDir <- "lib/" - if (sysname == "Windows") - libDir <- paste(libDir, .Platform$r_arch, "/", sep="") - system.file(paste(libDir, tbbSupported[[sysname]], sep = ""), - package = "RcppParallel") + + if (dir.exists(Sys.getenv("TBB_LIB"))) { + TBB_LIB <- asBuildPath(Sys.getenv("TBB_LIB")) + asBuildPath(file.path(TBB_LIB, paste("libtbb", suffix, ".so", sep = ""))) } else { - NULL + if ((sysname %in% names(tbbSupported)) && !isSparc()) { + libDir <- "lib/" + if (sysname == "Windows") + libDir <- paste(libDir, .Platform$r_arch, "/", sep="") + + tbb_path <- system.file(paste(libDir, tbbSupported[[sysname]], sep = ""), + package = "RcppParallel") + if (sysname == "Linux" && !file.exists(tbb_path)) { + system.file(paste(libDir, "libtbb", suffix, ".so", sep =""), + package = "RcppParallel") + } else { + tbb_path + } + } else { + NULL + } } } diff --git a/inst/NEWS b/inst/NEWS index 20a22bb2..30566085 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,6 +1,13 @@ -RcppParallel 5.0.3 (UNRELEASED) +RcppParallel 5.1.0 (UNRELEASED) ------------------------------------------------------------------------ +* Added support for external TBB library via TBB_INC and/or TBB_LIB environment variables. +* Updated TBB functionality for the new interface. +* Falling back to building TBB from local source code. +* Backward TBB compatibility based on `__TBB_tbb_stddef_H`. +* Resolved conflicts between system and local TBB headers. +* Fixed URLs, used HTTPS, and minor cleanups. +* Updated package DESCRIPTION and bumped version. * setThreadOptions(...) can again be called multiple times per session. The requested number of threads will be used for invocations to parallelFor() and parallelReduce() that don't explicitly request a specific number of threads. diff --git a/inst/include/serial/tbb/parallel_for.h b/inst/include/tbb_local/serial/tbb/parallel_for.h similarity index 100% rename from inst/include/serial/tbb/parallel_for.h rename to inst/include/tbb_local/serial/tbb/parallel_for.h diff --git a/inst/include/serial/tbb/tbb_annotate.h b/inst/include/tbb_local/serial/tbb/tbb_annotate.h similarity index 100% rename from inst/include/serial/tbb/tbb_annotate.h rename to inst/include/tbb_local/serial/tbb/tbb_annotate.h diff --git a/inst/include/tbb/aggregator.h b/inst/include/tbb_local/tbb/aggregator.h similarity index 100% rename from inst/include/tbb/aggregator.h rename to inst/include/tbb_local/tbb/aggregator.h diff --git a/inst/include/tbb/aligned_space.h b/inst/include/tbb_local/tbb/aligned_space.h similarity index 100% rename from inst/include/tbb/aligned_space.h rename to inst/include/tbb_local/tbb/aligned_space.h diff --git a/inst/include/tbb/atomic.h b/inst/include/tbb_local/tbb/atomic.h similarity index 100% rename from inst/include/tbb/atomic.h rename to inst/include/tbb_local/tbb/atomic.h diff --git a/inst/include/tbb/blocked_range.h b/inst/include/tbb_local/tbb/blocked_range.h similarity index 100% rename from inst/include/tbb/blocked_range.h rename to inst/include/tbb_local/tbb/blocked_range.h diff --git a/inst/include/tbb/blocked_range2d.h b/inst/include/tbb_local/tbb/blocked_range2d.h similarity index 100% rename from inst/include/tbb/blocked_range2d.h rename to inst/include/tbb_local/tbb/blocked_range2d.h diff --git a/inst/include/tbb/blocked_range3d.h b/inst/include/tbb_local/tbb/blocked_range3d.h similarity index 100% rename from inst/include/tbb/blocked_range3d.h rename to inst/include/tbb_local/tbb/blocked_range3d.h diff --git a/inst/include/tbb/cache_aligned_allocator.h b/inst/include/tbb_local/tbb/cache_aligned_allocator.h similarity index 100% rename from inst/include/tbb/cache_aligned_allocator.h rename to inst/include/tbb_local/tbb/cache_aligned_allocator.h diff --git a/inst/include/tbb/combinable.h b/inst/include/tbb_local/tbb/combinable.h similarity index 100% rename from inst/include/tbb/combinable.h rename to inst/include/tbb_local/tbb/combinable.h diff --git a/inst/include/tbb/compat/condition_variable b/inst/include/tbb_local/tbb/compat/condition_variable similarity index 100% rename from inst/include/tbb/compat/condition_variable rename to inst/include/tbb_local/tbb/compat/condition_variable diff --git a/inst/include/tbb/compat/ppl.h b/inst/include/tbb_local/tbb/compat/ppl.h similarity index 100% rename from inst/include/tbb/compat/ppl.h rename to inst/include/tbb_local/tbb/compat/ppl.h diff --git a/inst/include/tbb/compat/thread b/inst/include/tbb_local/tbb/compat/thread similarity index 100% rename from inst/include/tbb/compat/thread rename to inst/include/tbb_local/tbb/compat/thread diff --git a/inst/include/tbb/compat/tuple b/inst/include/tbb_local/tbb/compat/tuple similarity index 100% rename from inst/include/tbb/compat/tuple rename to inst/include/tbb_local/tbb/compat/tuple diff --git a/inst/include/tbb/concurrent_hash_map.h b/inst/include/tbb_local/tbb/concurrent_hash_map.h similarity index 100% rename from inst/include/tbb/concurrent_hash_map.h rename to inst/include/tbb_local/tbb/concurrent_hash_map.h diff --git a/inst/include/tbb/concurrent_lru_cache.h b/inst/include/tbb_local/tbb/concurrent_lru_cache.h similarity index 100% rename from inst/include/tbb/concurrent_lru_cache.h rename to inst/include/tbb_local/tbb/concurrent_lru_cache.h diff --git a/inst/include/tbb/concurrent_priority_queue.h b/inst/include/tbb_local/tbb/concurrent_priority_queue.h similarity index 100% rename from inst/include/tbb/concurrent_priority_queue.h rename to inst/include/tbb_local/tbb/concurrent_priority_queue.h diff --git a/inst/include/tbb/concurrent_queue.h b/inst/include/tbb_local/tbb/concurrent_queue.h similarity index 100% rename from inst/include/tbb/concurrent_queue.h rename to inst/include/tbb_local/tbb/concurrent_queue.h diff --git a/inst/include/tbb/concurrent_unordered_map.h b/inst/include/tbb_local/tbb/concurrent_unordered_map.h similarity index 100% rename from inst/include/tbb/concurrent_unordered_map.h rename to inst/include/tbb_local/tbb/concurrent_unordered_map.h diff --git a/inst/include/tbb/concurrent_unordered_set.h b/inst/include/tbb_local/tbb/concurrent_unordered_set.h similarity index 100% rename from inst/include/tbb/concurrent_unordered_set.h rename to inst/include/tbb_local/tbb/concurrent_unordered_set.h diff --git a/inst/include/tbb/concurrent_vector.h b/inst/include/tbb_local/tbb/concurrent_vector.h similarity index 100% rename from inst/include/tbb/concurrent_vector.h rename to inst/include/tbb_local/tbb/concurrent_vector.h diff --git a/inst/include/tbb/critical_section.h b/inst/include/tbb_local/tbb/critical_section.h similarity index 100% rename from inst/include/tbb/critical_section.h rename to inst/include/tbb_local/tbb/critical_section.h diff --git a/inst/include/tbb/enumerable_thread_specific.h b/inst/include/tbb_local/tbb/enumerable_thread_specific.h similarity index 100% rename from inst/include/tbb/enumerable_thread_specific.h rename to inst/include/tbb_local/tbb/enumerable_thread_specific.h diff --git a/inst/include/tbb/flow_graph.h b/inst/include/tbb_local/tbb/flow_graph.h similarity index 100% rename from inst/include/tbb/flow_graph.h rename to inst/include/tbb_local/tbb/flow_graph.h diff --git a/inst/include/tbb/flow_graph_abstractions.h b/inst/include/tbb_local/tbb/flow_graph_abstractions.h similarity index 100% rename from inst/include/tbb/flow_graph_abstractions.h rename to inst/include/tbb_local/tbb/flow_graph_abstractions.h diff --git a/inst/include/tbb/flow_graph_opencl_node.h b/inst/include/tbb_local/tbb/flow_graph_opencl_node.h similarity index 100% rename from inst/include/tbb/flow_graph_opencl_node.h rename to inst/include/tbb_local/tbb/flow_graph_opencl_node.h diff --git a/inst/include/tbb/gfx_factory.h b/inst/include/tbb_local/tbb/gfx_factory.h similarity index 100% rename from inst/include/tbb/gfx_factory.h rename to inst/include/tbb_local/tbb/gfx_factory.h diff --git a/inst/include/tbb/global_control.h b/inst/include/tbb_local/tbb/global_control.h similarity index 100% rename from inst/include/tbb/global_control.h rename to inst/include/tbb_local/tbb/global_control.h diff --git a/inst/include/tbb/index.html b/inst/include/tbb_local/tbb/index.html similarity index 100% rename from inst/include/tbb/index.html rename to inst/include/tbb_local/tbb/index.html diff --git a/inst/include/tbb/internal/_aggregator_impl.h b/inst/include/tbb_local/tbb/internal/_aggregator_impl.h similarity index 100% rename from inst/include/tbb/internal/_aggregator_impl.h rename to inst/include/tbb_local/tbb/internal/_aggregator_impl.h diff --git a/inst/include/tbb/internal/_concurrent_queue_impl.h b/inst/include/tbb_local/tbb/internal/_concurrent_queue_impl.h similarity index 100% rename from inst/include/tbb/internal/_concurrent_queue_impl.h rename to inst/include/tbb_local/tbb/internal/_concurrent_queue_impl.h diff --git a/inst/include/tbb/internal/_concurrent_unordered_impl.h b/inst/include/tbb_local/tbb/internal/_concurrent_unordered_impl.h similarity index 100% rename from inst/include/tbb/internal/_concurrent_unordered_impl.h rename to inst/include/tbb_local/tbb/internal/_concurrent_unordered_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_async_msg_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_async_msg_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_async_msg_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_async_msg_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_body_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_body_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_body_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_body_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_cache_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_cache_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_cache_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_cache_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_indexer_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_indexer_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_indexer_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_indexer_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_item_buffer_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_item_buffer_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_item_buffer_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_item_buffer_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_join_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_join_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_join_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_join_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_node_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_node_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_node_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_node_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_streaming_node.h b/inst/include/tbb_local/tbb/internal/_flow_graph_streaming_node.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_streaming_node.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_streaming_node.h diff --git a/inst/include/tbb/internal/_flow_graph_tagged_buffer_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_tagged_buffer_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_tagged_buffer_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_tagged_buffer_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_trace_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_trace_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_trace_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_trace_impl.h diff --git a/inst/include/tbb/internal/_flow_graph_types_impl.h b/inst/include/tbb_local/tbb/internal/_flow_graph_types_impl.h similarity index 100% rename from inst/include/tbb/internal/_flow_graph_types_impl.h rename to inst/include/tbb_local/tbb/internal/_flow_graph_types_impl.h diff --git a/inst/include/tbb/internal/_mutex_padding.h b/inst/include/tbb_local/tbb/internal/_mutex_padding.h similarity index 100% rename from inst/include/tbb/internal/_mutex_padding.h rename to inst/include/tbb_local/tbb/internal/_mutex_padding.h diff --git a/inst/include/tbb/internal/_range_iterator.h b/inst/include/tbb_local/tbb/internal/_range_iterator.h similarity index 100% rename from inst/include/tbb/internal/_range_iterator.h rename to inst/include/tbb_local/tbb/internal/_range_iterator.h diff --git a/inst/include/tbb/internal/_tbb_hash_compare_impl.h b/inst/include/tbb_local/tbb/internal/_tbb_hash_compare_impl.h similarity index 100% rename from inst/include/tbb/internal/_tbb_hash_compare_impl.h rename to inst/include/tbb_local/tbb/internal/_tbb_hash_compare_impl.h diff --git a/inst/include/tbb/internal/_tbb_strings.h b/inst/include/tbb_local/tbb/internal/_tbb_strings.h similarity index 100% rename from inst/include/tbb/internal/_tbb_strings.h rename to inst/include/tbb_local/tbb/internal/_tbb_strings.h diff --git a/inst/include/tbb/internal/_tbb_trace_impl.h b/inst/include/tbb_local/tbb/internal/_tbb_trace_impl.h similarity index 100% rename from inst/include/tbb/internal/_tbb_trace_impl.h rename to inst/include/tbb_local/tbb/internal/_tbb_trace_impl.h diff --git a/inst/include/tbb/internal/_tbb_windef.h b/inst/include/tbb_local/tbb/internal/_tbb_windef.h similarity index 100% rename from inst/include/tbb/internal/_tbb_windef.h rename to inst/include/tbb_local/tbb/internal/_tbb_windef.h diff --git a/inst/include/tbb/internal/_template_helpers.h b/inst/include/tbb_local/tbb/internal/_template_helpers.h similarity index 100% rename from inst/include/tbb/internal/_template_helpers.h rename to inst/include/tbb_local/tbb/internal/_template_helpers.h diff --git a/inst/include/tbb/internal/_x86_eliding_mutex_impl.h b/inst/include/tbb_local/tbb/internal/_x86_eliding_mutex_impl.h similarity index 100% rename from inst/include/tbb/internal/_x86_eliding_mutex_impl.h rename to inst/include/tbb_local/tbb/internal/_x86_eliding_mutex_impl.h diff --git a/inst/include/tbb/internal/_x86_rtm_rw_mutex_impl.h b/inst/include/tbb_local/tbb/internal/_x86_rtm_rw_mutex_impl.h similarity index 100% rename from inst/include/tbb/internal/_x86_rtm_rw_mutex_impl.h rename to inst/include/tbb_local/tbb/internal/_x86_rtm_rw_mutex_impl.h diff --git a/inst/include/tbb/machine/gcc_armv7.h b/inst/include/tbb_local/tbb/machine/gcc_armv7.h similarity index 100% rename from inst/include/tbb/machine/gcc_armv7.h rename to inst/include/tbb_local/tbb/machine/gcc_armv7.h diff --git a/inst/include/tbb/machine/gcc_generic.h b/inst/include/tbb_local/tbb/machine/gcc_generic.h similarity index 100% rename from inst/include/tbb/machine/gcc_generic.h rename to inst/include/tbb_local/tbb/machine/gcc_generic.h diff --git a/inst/include/tbb/machine/gcc_ia32_common.h b/inst/include/tbb_local/tbb/machine/gcc_ia32_common.h similarity index 100% rename from inst/include/tbb/machine/gcc_ia32_common.h rename to inst/include/tbb_local/tbb/machine/gcc_ia32_common.h diff --git a/inst/include/tbb/machine/gcc_itsx.h b/inst/include/tbb_local/tbb/machine/gcc_itsx.h similarity index 100% rename from inst/include/tbb/machine/gcc_itsx.h rename to inst/include/tbb_local/tbb/machine/gcc_itsx.h diff --git a/inst/include/tbb/machine/ibm_aix51.h b/inst/include/tbb_local/tbb/machine/ibm_aix51.h similarity index 100% rename from inst/include/tbb/machine/ibm_aix51.h rename to inst/include/tbb_local/tbb/machine/ibm_aix51.h diff --git a/inst/include/tbb/machine/icc_generic.h b/inst/include/tbb_local/tbb/machine/icc_generic.h similarity index 100% rename from inst/include/tbb/machine/icc_generic.h rename to inst/include/tbb_local/tbb/machine/icc_generic.h diff --git a/inst/include/tbb/machine/linux_common.h b/inst/include/tbb_local/tbb/machine/linux_common.h similarity index 100% rename from inst/include/tbb/machine/linux_common.h rename to inst/include/tbb_local/tbb/machine/linux_common.h diff --git a/inst/include/tbb/machine/linux_ia32.h b/inst/include/tbb_local/tbb/machine/linux_ia32.h similarity index 100% rename from inst/include/tbb/machine/linux_ia32.h rename to inst/include/tbb_local/tbb/machine/linux_ia32.h diff --git a/inst/include/tbb/machine/linux_ia64.h b/inst/include/tbb_local/tbb/machine/linux_ia64.h similarity index 100% rename from inst/include/tbb/machine/linux_ia64.h rename to inst/include/tbb_local/tbb/machine/linux_ia64.h diff --git a/inst/include/tbb/machine/linux_intel64.h b/inst/include/tbb_local/tbb/machine/linux_intel64.h similarity index 100% rename from inst/include/tbb/machine/linux_intel64.h rename to inst/include/tbb_local/tbb/machine/linux_intel64.h diff --git a/inst/include/tbb/machine/mac_ppc.h b/inst/include/tbb_local/tbb/machine/mac_ppc.h similarity index 100% rename from inst/include/tbb/machine/mac_ppc.h rename to inst/include/tbb_local/tbb/machine/mac_ppc.h diff --git a/inst/include/tbb/machine/macos_common.h b/inst/include/tbb_local/tbb/machine/macos_common.h similarity index 100% rename from inst/include/tbb/machine/macos_common.h rename to inst/include/tbb_local/tbb/machine/macos_common.h diff --git a/inst/include/tbb/machine/mic_common.h b/inst/include/tbb_local/tbb/machine/mic_common.h similarity index 100% rename from inst/include/tbb/machine/mic_common.h rename to inst/include/tbb_local/tbb/machine/mic_common.h diff --git a/inst/include/tbb/machine/msvc_armv7.h b/inst/include/tbb_local/tbb/machine/msvc_armv7.h similarity index 100% rename from inst/include/tbb/machine/msvc_armv7.h rename to inst/include/tbb_local/tbb/machine/msvc_armv7.h diff --git a/inst/include/tbb/machine/msvc_ia32_common.h b/inst/include/tbb_local/tbb/machine/msvc_ia32_common.h similarity index 100% rename from inst/include/tbb/machine/msvc_ia32_common.h rename to inst/include/tbb_local/tbb/machine/msvc_ia32_common.h diff --git a/inst/include/tbb/machine/sunos_sparc.h b/inst/include/tbb_local/tbb/machine/sunos_sparc.h similarity index 100% rename from inst/include/tbb/machine/sunos_sparc.h rename to inst/include/tbb_local/tbb/machine/sunos_sparc.h diff --git a/inst/include/tbb/machine/windows_api.h b/inst/include/tbb_local/tbb/machine/windows_api.h similarity index 100% rename from inst/include/tbb/machine/windows_api.h rename to inst/include/tbb_local/tbb/machine/windows_api.h diff --git a/inst/include/tbb/machine/windows_ia32.h b/inst/include/tbb_local/tbb/machine/windows_ia32.h similarity index 100% rename from inst/include/tbb/machine/windows_ia32.h rename to inst/include/tbb_local/tbb/machine/windows_ia32.h diff --git a/inst/include/tbb/machine/windows_intel64.h b/inst/include/tbb_local/tbb/machine/windows_intel64.h similarity index 100% rename from inst/include/tbb/machine/windows_intel64.h rename to inst/include/tbb_local/tbb/machine/windows_intel64.h diff --git a/inst/include/tbb/machine/xbox360_ppc.h b/inst/include/tbb_local/tbb/machine/xbox360_ppc.h similarity index 100% rename from inst/include/tbb/machine/xbox360_ppc.h rename to inst/include/tbb_local/tbb/machine/xbox360_ppc.h diff --git a/inst/include/tbb/memory_pool.h b/inst/include/tbb_local/tbb/memory_pool.h similarity index 100% rename from inst/include/tbb/memory_pool.h rename to inst/include/tbb_local/tbb/memory_pool.h diff --git a/inst/include/tbb/mutex.h b/inst/include/tbb_local/tbb/mutex.h similarity index 100% rename from inst/include/tbb/mutex.h rename to inst/include/tbb_local/tbb/mutex.h diff --git a/inst/include/tbb/null_mutex.h b/inst/include/tbb_local/tbb/null_mutex.h similarity index 100% rename from inst/include/tbb/null_mutex.h rename to inst/include/tbb_local/tbb/null_mutex.h diff --git a/inst/include/tbb/null_rw_mutex.h b/inst/include/tbb_local/tbb/null_rw_mutex.h similarity index 100% rename from inst/include/tbb/null_rw_mutex.h rename to inst/include/tbb_local/tbb/null_rw_mutex.h diff --git a/inst/include/tbb/parallel_do.h b/inst/include/tbb_local/tbb/parallel_do.h similarity index 100% rename from inst/include/tbb/parallel_do.h rename to inst/include/tbb_local/tbb/parallel_do.h diff --git a/inst/include/tbb/parallel_for.h b/inst/include/tbb_local/tbb/parallel_for.h similarity index 100% rename from inst/include/tbb/parallel_for.h rename to inst/include/tbb_local/tbb/parallel_for.h diff --git a/inst/include/tbb/parallel_for_each.h b/inst/include/tbb_local/tbb/parallel_for_each.h similarity index 100% rename from inst/include/tbb/parallel_for_each.h rename to inst/include/tbb_local/tbb/parallel_for_each.h diff --git a/inst/include/tbb/parallel_invoke.h b/inst/include/tbb_local/tbb/parallel_invoke.h similarity index 100% rename from inst/include/tbb/parallel_invoke.h rename to inst/include/tbb_local/tbb/parallel_invoke.h diff --git a/inst/include/tbb/parallel_reduce.h b/inst/include/tbb_local/tbb/parallel_reduce.h similarity index 100% rename from inst/include/tbb/parallel_reduce.h rename to inst/include/tbb_local/tbb/parallel_reduce.h diff --git a/inst/include/tbb/parallel_scan.h b/inst/include/tbb_local/tbb/parallel_scan.h similarity index 100% rename from inst/include/tbb/parallel_scan.h rename to inst/include/tbb_local/tbb/parallel_scan.h diff --git a/inst/include/tbb/parallel_sort.h b/inst/include/tbb_local/tbb/parallel_sort.h similarity index 100% rename from inst/include/tbb/parallel_sort.h rename to inst/include/tbb_local/tbb/parallel_sort.h diff --git a/inst/include/tbb/parallel_while.h b/inst/include/tbb_local/tbb/parallel_while.h similarity index 100% rename from inst/include/tbb/parallel_while.h rename to inst/include/tbb_local/tbb/parallel_while.h diff --git a/inst/include/tbb/partitioner.h b/inst/include/tbb_local/tbb/partitioner.h similarity index 100% rename from inst/include/tbb/partitioner.h rename to inst/include/tbb_local/tbb/partitioner.h diff --git a/inst/include/tbb/pipeline.h b/inst/include/tbb_local/tbb/pipeline.h similarity index 100% rename from inst/include/tbb/pipeline.h rename to inst/include/tbb_local/tbb/pipeline.h diff --git a/inst/include/tbb/queuing_mutex.h b/inst/include/tbb_local/tbb/queuing_mutex.h similarity index 100% rename from inst/include/tbb/queuing_mutex.h rename to inst/include/tbb_local/tbb/queuing_mutex.h diff --git a/inst/include/tbb/queuing_rw_mutex.h b/inst/include/tbb_local/tbb/queuing_rw_mutex.h similarity index 100% rename from inst/include/tbb/queuing_rw_mutex.h rename to inst/include/tbb_local/tbb/queuing_rw_mutex.h diff --git a/inst/include/tbb/reader_writer_lock.h b/inst/include/tbb_local/tbb/reader_writer_lock.h similarity index 100% rename from inst/include/tbb/reader_writer_lock.h rename to inst/include/tbb_local/tbb/reader_writer_lock.h diff --git a/inst/include/tbb/recursive_mutex.h b/inst/include/tbb_local/tbb/recursive_mutex.h similarity index 100% rename from inst/include/tbb/recursive_mutex.h rename to inst/include/tbb_local/tbb/recursive_mutex.h diff --git a/inst/include/tbb/runtime_loader.h b/inst/include/tbb_local/tbb/runtime_loader.h similarity index 100% rename from inst/include/tbb/runtime_loader.h rename to inst/include/tbb_local/tbb/runtime_loader.h diff --git a/inst/include/tbb/scalable_allocator.h b/inst/include/tbb_local/tbb/scalable_allocator.h similarity index 100% rename from inst/include/tbb/scalable_allocator.h rename to inst/include/tbb_local/tbb/scalable_allocator.h diff --git a/inst/include/tbb/spin_mutex.h b/inst/include/tbb_local/tbb/spin_mutex.h similarity index 100% rename from inst/include/tbb/spin_mutex.h rename to inst/include/tbb_local/tbb/spin_mutex.h diff --git a/inst/include/tbb/spin_rw_mutex.h b/inst/include/tbb_local/tbb/spin_rw_mutex.h similarity index 100% rename from inst/include/tbb/spin_rw_mutex.h rename to inst/include/tbb_local/tbb/spin_rw_mutex.h diff --git a/inst/include/tbb/task.h b/inst/include/tbb_local/tbb/task.h similarity index 100% rename from inst/include/tbb/task.h rename to inst/include/tbb_local/tbb/task.h diff --git a/inst/include/tbb/task_arena.h b/inst/include/tbb_local/tbb/task_arena.h similarity index 100% rename from inst/include/tbb/task_arena.h rename to inst/include/tbb_local/tbb/task_arena.h diff --git a/inst/include/tbb/task_group.h b/inst/include/tbb_local/tbb/task_group.h similarity index 100% rename from inst/include/tbb/task_group.h rename to inst/include/tbb_local/tbb/task_group.h diff --git a/inst/include/tbb/task_scheduler_init.h b/inst/include/tbb_local/tbb/task_scheduler_init.h similarity index 100% rename from inst/include/tbb/task_scheduler_init.h rename to inst/include/tbb_local/tbb/task_scheduler_init.h diff --git a/inst/include/tbb/task_scheduler_observer.h b/inst/include/tbb_local/tbb/task_scheduler_observer.h similarity index 100% rename from inst/include/tbb/task_scheduler_observer.h rename to inst/include/tbb_local/tbb/task_scheduler_observer.h diff --git a/inst/include/tbb/tbb.h b/inst/include/tbb_local/tbb/tbb.h similarity index 100% rename from inst/include/tbb/tbb.h rename to inst/include/tbb_local/tbb/tbb.h diff --git a/inst/include/tbb/tbb_allocator.h b/inst/include/tbb_local/tbb/tbb_allocator.h similarity index 100% rename from inst/include/tbb/tbb_allocator.h rename to inst/include/tbb_local/tbb/tbb_allocator.h diff --git a/inst/include/tbb/tbb_config.h b/inst/include/tbb_local/tbb/tbb_config.h similarity index 100% rename from inst/include/tbb/tbb_config.h rename to inst/include/tbb_local/tbb/tbb_config.h diff --git a/inst/include/tbb/tbb_disable_exceptions.h b/inst/include/tbb_local/tbb/tbb_disable_exceptions.h similarity index 100% rename from inst/include/tbb/tbb_disable_exceptions.h rename to inst/include/tbb_local/tbb/tbb_disable_exceptions.h diff --git a/inst/include/tbb/tbb_exception.h b/inst/include/tbb_local/tbb/tbb_exception.h similarity index 100% rename from inst/include/tbb/tbb_exception.h rename to inst/include/tbb_local/tbb/tbb_exception.h diff --git a/inst/include/tbb/tbb_machine.h b/inst/include/tbb_local/tbb/tbb_machine.h similarity index 100% rename from inst/include/tbb/tbb_machine.h rename to inst/include/tbb_local/tbb/tbb_machine.h diff --git a/inst/include/tbb/tbb_profiling.h b/inst/include/tbb_local/tbb/tbb_profiling.h similarity index 100% rename from inst/include/tbb/tbb_profiling.h rename to inst/include/tbb_local/tbb/tbb_profiling.h diff --git a/inst/include/tbb/tbb_stddef.h b/inst/include/tbb_local/tbb/tbb_stddef.h similarity index 100% rename from inst/include/tbb/tbb_stddef.h rename to inst/include/tbb_local/tbb/tbb_stddef.h diff --git a/inst/include/tbb/tbb_thread.h b/inst/include/tbb_local/tbb/tbb_thread.h similarity index 100% rename from inst/include/tbb/tbb_thread.h rename to inst/include/tbb_local/tbb/tbb_thread.h diff --git a/inst/include/tbb/tbbmalloc_proxy.h b/inst/include/tbb_local/tbb/tbbmalloc_proxy.h similarity index 100% rename from inst/include/tbb/tbbmalloc_proxy.h rename to inst/include/tbb_local/tbb/tbbmalloc_proxy.h diff --git a/inst/include/tbb/tick_count.h b/inst/include/tbb_local/tbb/tick_count.h similarity index 100% rename from inst/include/tbb/tick_count.h rename to inst/include/tbb_local/tbb/tick_count.h diff --git a/man/RcppParallel-package.Rd b/man/RcppParallel-package.Rd index 7ebea999..ddb46d34 100644 --- a/man/RcppParallel-package.Rd +++ b/man/RcppParallel-package.Rd @@ -15,7 +15,7 @@ Blocks). On other platforms a less-performant fallback implementation based on the TinyThread library is used. - For additional documentation see the package website at: \href{http://rcppcore.github.io/RcppParallel}{http://rcppcore.github.io/RcppParallel}. + For additional documentation see the package website at: \href{https://rcppcore.github.io/RcppParallel/}{https://rcppcore.github.io/RcppParallel/}. } \author{ diff --git a/src/Makevars.in b/src/Makevars.in index 56c601ee..e7f0ad73 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,7 +1,16 @@ -PKG_CPPFLAGS = -I../inst/include PKG_CXXFLAGS = @CXX11STD@ +ifdef TBB_INC +PKG_CPPFLAGS = -I../inst/include -I$(TBB_INC) +else +PKG_CPPFLAGS = -I../inst/include +endif + +ifdef TBB_LIB +PKG_LIBS = -Wl,-L,"$(TBB_LIB)" -Wl,-rpath,"$(TBB_LIB)" -ltbb -ltbbmalloc +endif + ifeq ($(OS), Windows_NT) USE_TBB=Windows @@ -86,7 +95,21 @@ endif all: tbb $(SHLIB) tbb: +ifdef TBB_LIB + echo "Using system (Intel/OneAPI) TBB library..."; \ mkdir -p ../inst/lib/$(ARCH_DIR); \ + cp $(TBB_LIB)/libtbb.so ../inst/lib/$(ARCH_DIR)/libtbb.so 2>/dev/null || :; \ + cp $(TBB_LIB)/libtbbmalloc.so ../inst/lib/$(ARCH_DIR)/libtbbmalloc.so 2>/dev/null || :; \ + rm -Rf ../inst/include/serial/ ../inst/include/tbb/; \ + rm -Rf ../inst/include/tbb_local/; \ + mkdir -p ../inst/include; \ + cp -R $(TBB_INC)/serial ../inst/include/ 2>/dev/null || :; \ + cp -R $(TBB_INC)/tbb ../inst/include/ 2>/dev/null || : +else + echo "Building TBB library from source code..."; \ + mkdir -p ../inst/lib/$(ARCH_DIR); \ + cp -R ../inst/include/tbb_local/* ../inst/include/; \ + rm -Rf ../inst/include/tbb_local/; \ cd tbb/src; \ if [ -n "$(shell echo $(CC) | grep clang)" ]; then \ $(MAKE_CMD) stdver=@STDVER@ compiler=clang $(MAKE_ARGS); \ @@ -97,9 +120,14 @@ tbb: fi; \ cd ../..; \ cp tbb/build/lib_release/$(TBB_COPY_PATTERN) ../inst/lib/$(ARCH_DIR) +endif clean: +ifdef TBB_LIB + echo "Nothing to clean for TBB." +else (cd tbb/src; make clean) - endif + +endif diff --git a/src/options.cpp b/src/options.cpp index 8a4168dd..56b9636b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -10,7 +10,11 @@ extern "C" SEXP defaultNumThreads() { SEXP threadsSEXP = Rf_allocVector(INTSXP, 1); +#ifndef __TBB_tbb_stddef_H + INTEGER(threadsSEXP)[0] = tbb::this_task_arena::max_concurrency(); +#else INTEGER(threadsSEXP)[0] = tbb::task_scheduler_init::default_num_threads(); +#endif return threadsSEXP; }