qsbase / qs2

16 stars 1 forks source link

Compilation failed Mac ARM #3

Open BenjaminDEMAILLE opened 1 week ago

BenjaminDEMAILLE commented 1 week ago

Hi I try to install on ARM Mac but I got an error depending on TBB

 remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB --with-simd=AVX2", force = T)
Installing 1 packages: qs2
trying URL 'https://cran.rstudio.com/src/contrib/qs2_0.1.1.tar.gz'
Content type 'application/x-gzip' length 924074 bytes (902 KB)
==================================================
downloaded 902 KB

* installing *source* package ‘qs2’ ...
** package ‘qs2’ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
C++ compiler: clang++ -arch arm64 -std=gnu++17
zstd 1.5.6 library detected -- skipping zstd compilation
Fixed blocksize
Using TBB
Does not require -latomic flag
Using AVX2
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include   -std=c++11 -fPIC  -falign-functions=64 -Wall -g -O2   -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include   -std=c++11 -fPIC  -falign-functions=64 -Wall -g -O2   -c qx_functions.cpp -o qx_functions.o
In file included from qx_functions.cpp:1:
./io/filestream_module.h:5:10: fatal error: 'io/io_common.h' file not found
    5 | #include "io/io_common.h"
      |          ^~~~~~~~~~~~~~~~
1 error generated.
make: *** [qx_functions.o] Error 1
ERROR: compilation failed for package ‘qs2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’

The downloaded source packages are in
    ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpaSecJM/downloaded_packages’
Warning message:
In i.p(...) : installation of package ‘qs2’ had non-zero exit status

How can we install with multicore on Mac ARM ?

traversc commented 1 week ago

Can you try to take out the mavx2 flag? That flag is an optimization for Intel / x86 CPU.

remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB", force = T)
BenjaminDEMAILLE commented 1 week ago

Can you try to take out the mavx2 flag? That flag is an optimization for Intel / x86 CPU.

remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB", force = T)

Same thing :/


> remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB", force = T)
Installing 1 packages: qs2
trying URL 'https://cran.rstudio.com/src/contrib/qs2_0.1.1.tar.gz'
Content type 'application/x-gzip' length 924074 bytes (902 KB)
==================================================
downloaded 902 KB

* installing *source* package ‘qs2’ ...
** package ‘qs2’ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
C++ compiler: clang++ -arch arm64 -std=gnu++17
zstd 1.5.6 library detected -- skipping zstd compilation
Fixed blocksize
Using TBB
Does not require -latomic flag
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include   -std=c++11 -fPIC  -falign-functions=64 -Wall -g -O2   -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include   -std=c++11 -fPIC  -falign-functions=64 -Wall -g -O2   -c qx_functions.cpp -o qx_functions.o
In file included from qx_functions.cpp:1:
./io/filestream_module.h:5:10: fatal error: 'io/io_common.h' file not found
    5 | #include "io/io_common.h"
      |          ^~~~~~~~~~~~~~~~
1 error generated.
make: *** [qx_functions.o] Error 1
ERROR: compilation failed for package ‘qs2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’

The downloaded source packages are in
    ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpW1FCwZ/downloaded_packages’
Warning message:
In i.p(...) : installation of package ‘qs2’ had non-zero exit status
traversc commented 1 week ago

Can you post your ~/.R/Makevars file? Your compile string looks incomplete, but the github macos arm runner installs fine so it is unclear to me.

https://github.com/qsbase/qs2/actions/runs/11043392972/job/30677585053#step:1:8

BenjaminDEMAILLE commented 1 week ago

Can you post your ~/.R/Makevars file? Your compile string looks incomplete, but the github macos arm runner installs fine so it is unclear to me.

https://github.com/qsbase/qs2/actions/runs/11043392972/job/30677585053#step:1:8

Makevars :

PKG_CPPFLAGS = -I/opt/homebrew/include
PKG_LIBS = -L/opt/homebrew/lib -lgsl -lgslcblas -lm

CXX14FLAGS=-O3 -march=native
PKG_CXXFLAGS = -std=c++11
traversc commented 1 week ago

Try adding += to your Makevars entries, otherwise it overwrites package Makevars.

E.g.:

PKG_CPPFLAGS += -I/opt/homebrew/include
PKG_LIBS += -L/opt/homebrew/lib -lgsl -lgslcblas -lm

# CXX14FLAGS=-O3 -march=native
# PKG_CXXFLAGS = -std=c++11
BenjaminDEMAILLE commented 1 week ago

Try adding += to your Makevars entries, otherwise it overwrites package Makevars.

E.g.:

PKG_CPPFLAGS += -I/opt/homebrew/include
PKG_LIBS += -L/opt/homebrew/lib -lgsl -lgslcblas -lm

# CXX14FLAGS=-O3 -march=native
# PKG_CXXFLAGS = -std=c++11

now I have :

R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from ~/.RData]

> remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB", force = T)
Installing 1 packages: qs2
trying URL 'https://cran.rstudio.com/src/contrib/qs2_0.1.1.tar.gz'
Content type 'application/x-gzip' length 924074 bytes (902 KB)
==================================================
downloaded 902 KB

* installing *source* package ‘qs2’ ...
** package ‘qs2’ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
C++ compiler: clang++ -arch arm64 -std=gnu++17
zstd 1.5.6 library detected -- skipping zstd compilation
Fixed blocksize
Using TBB
Does not require -latomic flag
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c qx_functions.cpp -o qx_functions.o
In file included from qx_functions.cpp:11:
./io/multithreaded_block_module.h:280:16: error: no template named 'source_node' in namespace 'tbb::flow'
  280 |     tbb::flow::source_node<OrderedBlock> reader_node;
      |     ~~~~~~~~~~~^
1 error generated.
make: *** [qx_functions.o] Error 1
ERROR: compilation failed for package ‘qs2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’

The downloaded source packages are in
    ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/downloaded_packages’
Warning message:
In i.p(...) : installation of package ‘qs2’ had non-zero exit status
> install.packages('tbb')
Warning in install.packages :
  package ‘tbb’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
> remotes::install_cran("qs2", type = "source", configure.args = " --with-TBB", force = T)
Installing 1 packages: qs2
trying URL 'https://cran.rstudio.com/src/contrib/qs2_0.1.1.tar.gz'
Content type 'application/x-gzip' length 924074 bytes (902 KB)
==================================================
downloaded 902 KB

* installing *source* package ‘qs2’ ...
** package ‘qs2’ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
C++ compiler: clang++ -arch arm64 -std=gnu++17
zstd 1.5.6 library detected -- skipping zstd compilation
Fixed blocksize
Using TBB
Does not require -latomic flag
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c qx_functions.cpp -o qx_functions.o
In file included from qx_functions.cpp:11:
./io/multithreaded_block_module.h:280:16: error: no template named 'source_node' in namespace 'tbb::flow'
  280 |     tbb::flow::source_node<OrderedBlock> reader_node;
      |     ~~~~~~~~~~~^
1 error generated.
make: *** [qx_functions.o] Error 1
ERROR: compilation failed for package ‘qs2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’

The downloaded source packages are in
    ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/downloaded_packages’
Warning message:
In i.p(...) : installation of package ‘qs2’ had non-zero exit status
traversc commented 1 week ago

Progress!

I'd recommend this which should be compatible with newer TBB versions:

remotes::install_github("qsbase/qs2", configure.args = "--with-TBB")

BenjaminDEMAILLE commented 1 week ago

Progress!

I'd recommend this which should be compatible with newer TBB versions:

remotes::install_github("qsbase/qs2", configure.args = "--with-TBB")

I got this error :


Downloading GitHub repo qsbase/qs2@HEAD
── R CMD build ─────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/remotes1af75eb5c460/qsbase-qs2-2bfe0c3/DESCRIPTION’ ...
─  preparing ‘qs2’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘qs2/inst’
─  building ‘qs2_0.1.2.tar.gz’

* installing *source* package ‘qs2’ ...
** using staged installation
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
C++ compiler: clang++ -arch arm64 -std=gnu++17
zstd 1.5.6 library detected -- skipping zstd compilation
Fixed blocksize
Using TBB
Does not require -latomic flag
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I../inst/include -I. -I/opt/homebrew/opt/zstd/include   -DIS_UTF8_LOCALE=1 -I/opt/homebrew/include -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/stringfish/include' -I'/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c qx_functions.cpp -o qx_functions.o
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o qs2.so RcppExports.o qx_functions.o -L. -L/opt/homebrew/opt/zstd/lib -lzstd -L/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/lib -ltbb -ltbbmalloc -L/opt/homebrew/lib -lgsl -lgslcblas -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-qs2/00new/qs2/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘qs2’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-qs2/00new/qs2/libs/qs2.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-qs2/00new/qs2/libs/qs2.so, 0x0006): symbol not found in flat namespace '__ZN3tbb6detail2r110deallocateERNS0_2d117small_object_poolEPvmRKNS2_14execution_dataE'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/qs2’
Warning messages:
1: In readLines(old_path) :
  incomplete final line found on '/Users/benjamin/.R/Makevars'
2: In i.p(...) :
  installation of package ‘/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T//RtmpYjP1YW/file1af76f6fab33/qs2_0.1.2.tar.gz’ had non-zero exit status```

i have  tbb 2021.13.0
traversc commented 1 week ago

Since linking of TBB is done entirely by RcppParallel, I don't think there's anything I can do about it from the package side.

If you have time I can help you troubleshoot.

Does the following Rcpp code run?

#include <Rcpp.h>
#include <tbb/flow_graph.h>
#include <tbb/global_control.h>

// [[Rcpp::depends(RcppParallel)]]
// [[Rcpp::export]]
void flowgraph_test() {
  tbb::global_control gc(tbb::global_control::parameter::max_allowed_parallelism, 4);
  tbb::task_group_context tgc;
  tbb::flow::graph myGraph(tgc);
  tbb::flow::function_node<int, int> my_node(myGraph, tbb::flow::unlimited, [](const int i) {
    std::cout << i << " ";
    return 0;
  });
  for(int i=0; i<1000; ++i) {
    my_node.try_put(i);
  }
  myGraph.wait_for_all();
}

/*** R
flowgraph_test()
*/

Separately, does the package still fail to install if you re-install RcppParallel with the default TBB?

BenjaminDEMAILLE commented 1 week ago

include

include <tbb/flow_graph.h>

include <tbb/global_control.h>

// [[Rcpp::depends(RcppParallel)]] // [[Rcpp::export]] void flowgraph_test() { tbb::global_control gc(tbb::global_control::parameter::max_allowed_parallelism, 4); tbb::task_group_context tgc; tbb::flow::graph myGraph(tgc); tbb::flow::function_node<int, int> my_node(myGraph, tbb::flow::unlimited, [](const int i) { std::cout << i << " "; return 0; }); for(int i=0; i<1000; ++i) { my_node.try_put(i); } myGraph.wait_for_all(); }

/** R flowgraph_test() /

I got


Error in dyn.load("/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/sourceCpp-aarch64-apple-darwin20-1.0.13/sourcecpp_1af71c1259dc/sourceCpp_2.so") : 
  unable to load shared object '/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/sourceCpp-aarch64-apple-darwin20-1.0.13/sourcecpp_1af71c1259dc/sourceCpp_2.so':
  dlopen(/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/sourceCpp-aarch64-apple-darwin20-1.0.13/sourcecpp_1af71c1259dc/sourceCpp_2.so, 0x0006): symbol not found in flat namespace '__ZN3tbb6detail2r110deallocateERNS0_2d117small_object_poolEPvmRKNS2_14execution_dataE'```
BenjaminDEMAILLE commented 1 week ago

For RcppParellel I got :

 remotes::install_github("RcppCore/RcppParallel",force = T)
Downloading GitHub repo RcppCore/RcppParallel@HEAD
── R CMD build ─────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/remotes1af7747d4b73/RcppCore-RcppParallel-b478b62/DESCRIPTION’
─  preparing ‘RcppParallel’:
✔  checking DESCRIPTION meta-information
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts (388ms)
─  checking for empty or unneeded directories
─  building ‘RcppParallel_5.1.9.9000.tar.gz’

* installing *source* package ‘RcppParallel’ ...
** using staged installation
** preparing to configure package 'RcppParallel' ...
*** configured file: 'R/tbb-autodetected.R.in' => 'R/tbb-autodetected.R'
*** configured file: 'src/Makevars.in' => 'src/Makevars'
*** configured file: 'src/install.libs.R.in' => 'src/install.libs.R'
** finished configure for package 'RcppParallel'
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
(tbb) Building TBB using bundled sources ...
OS: macos
arch=arm64
compiler=clang
runtime=cc16.0.0_os15.0.1
tbb_build_prefix=macos_arm64_clang_cc16.0.0_os15.0.1
work_dir=/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpsYKOa0/R.INSTALL34e8792fd9e1/RcppParallel/src/build/macos_arm64_clang_cc16.0.0_os15.0.1_release
Created ../build/lib_release directory
make -C "../build/lib_release"  -r -f ../../build/Makefile.tbb cfg=release
../../build/Makefile.tbb:28: CONFIG: cfg=release arch=arm64 compiler=clang target=macos runtime=cc16.0.0_os15.0.1
clang++ -arch arm64 -I../inst/include -I/opt/homebrew/include -I/opt/R/arm64/include -o concurrent_hash_map.o -c -MMD -O2 -DUSE_PTHREAD  -stdlib=libc++ -arch arm64 -mmacosx-version-min=10.11  -fPIC  -D__TBB_BUILD=1 -Wall  -falign-functions=64 -Wall -g -O2 -DTBB_NO_LEGACY=1   -I../../src -I../../src/rml/include -I../../include ../../src/tbb/concurrent_hash_map.cpp
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:25:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_config.h:440:13: warning: TBB Warning: Support for C++98/03 is deprecated. Please use the compiler that supports C++11 features at least. [-W#pragma-messages]
  440 |     #pragma message("TBB Warning: Support for C++98/03 is deprecated. Please use the compiler that supports C++11 features at least.")
      |             ^
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:27:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:58:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
   58 | inline namespace d0 {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:1: error: unknown type name 'constexpr'
  129 | constexpr std::uintptr_t number_of_bits() {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:16: error: cannot define or redeclare 'uintptr_t' here because namespace 'd0' does not enclose namespace 'std'
  129 | constexpr std::uintptr_t number_of_bits() {
      |           ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:16: warning: variable templates are a C++14 extension [-Wc++14-extensions]
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:25: error: expected ';' at end of declaration
  129 | constexpr std::uintptr_t number_of_bits() {
      |                         ^
      |                         ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:26: error: a type specifier is required for all declarations
  129 | constexpr std::uintptr_t number_of_bits() {
      |                          ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:130:19: error: use of undeclared identifier 'T'
  130 |     return sizeof(T) * CHAR_BIT;
      |                   ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:137:39: error: expected '(' for function-style cast or type construction
  137 |     return (number_of_bits<decltype(x)>() - 1) ^ gnu_builtins::clz(x);
      |                            ~~~~~~~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:137:41: error: expected expression
  137 |     return (number_of_bits<decltype(x)>() - 1) ^ gnu_builtins::clz(x);
      |                                         ^
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:31:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
   31 | inline namespace d0 {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:34:18: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
   34 | template<typename... T> void suppress_unused_warning(T&&...) {}
      |                  ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:34:55: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
   34 | template<typename... T> void suppress_unused_warning(T&&...) {}
      |                                                       ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:40:1: error: unknown type name 'constexpr'
   40 | constexpr size_t max_nfs_size = 128;
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:40:17: error: expected ';' after top level declarator
   40 | constexpr size_t max_nfs_size = 128;
      |                 ^
      |                 ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:1: error: unknown type name 'constexpr'
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:16: error: cannot define or redeclare 'size_t' here because namespace 'd0' does not enclose namespace 'std'
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      |           ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:22: error: expected ';' after top level declarator
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      |                      ^
      |                      ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:42:20: error: use of undeclared identifier 'max_nfs_size_exp'
   42 | static_assert(1 << max_nfs_size_exp == max_nfs_size, "max_nfs_size_exp must be a log2(max_nfs_size)");
      |                    ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:42:40: error: use of undeclared identifier 'max_nfs_size'
   42 | static_assert(1 << max_nfs_size_exp == max_nfs_size, "max_nfs_size_exp must be a log2(max_nfs_size)");
      |                                        ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:12: error: unknown type name 'constexpr'
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |            ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:27: error: non-friend class member 'int32_t' cannot have a qualified name
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |                      ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:34: error: expected ';' at end of declaration list
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |                                  ^
      |                                  ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:61:45: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
   61 |     atomic_backoff(const atomic_backoff&) = delete;
      |                                             ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:62:56: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
   62 |     atomic_backoff& operator=(const atomic_backoff&) = delete;
      |                                                        ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:66:22: error: use of undeclared identifier 'LOOPS_BEFORE_YIELD'
   66 |         if (count <= LOOPS_BEFORE_YIELD) {
      |                      ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:79:21: error: use of undeclared identifier 'LOOPS_BEFORE_YIELD'
   79 |         if (count < LOOPS_BEFORE_YIELD) {
      |                     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
8 warnings and 20 errors generated.
make[2]: *** [concurrent_hash_map.o] Error 1
make[1]: *** [tbb_release] Error 2
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/include  -I/opt/R/arm64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2   -c init.cpp -o init.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/include  -I/opt/R/arm64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2   -c options.cpp -o options.o
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o RcppParallel.so init.o options.o -Ltbb/build/lib_release -ltbb -Wl,-rpath,@loader_path/../lib -L/opt/homebrew/lib -lgsl -lgslcblas -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing via 'install.libs.R' to /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘RcppParallel’:
 .onLoad failed in loadNamespace() for 'RcppParallel', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so, 0x0006): symbol not found in flat namespace '__ZN3tbb10interface78internal15task_arena_base24internal_max_concurrencyEPKNS0_10task_arenaE'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel’
Warning messages:
1: In readLines(old_path) :
  incomplete final line found on '/Users/benjamin/.R/Makevars'
2: In i.p(...) :
  installation of package ‘/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T//RtmpYjP1YW/file1af74de4a6c4/RcppParallel_5.1.9.9000.tar.gz’ had non-zero exit status
> install.packages("RcppParallel")
Error in install.packages : Updating loaded packages
> install.packages("RcppParallel")
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.4/RcppParallel_5.1.9.tgz'
Content type 'application/x-gzip' length 588289 bytes (574 KB)
==================================================
downloaded 574 KB

The downloaded binary packages are in
    /var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T//RtmpYjP1YW/downloaded_packages
traversc commented 1 week ago

So it looks like your system TBB is being mixed with the RcppParallel TBB. I am not sure, something in your Makevars might be conflicting.

Bringing this up in RcppParallel issues would be more useful. You can show them the short test script and the RcppParallel installation failure.