Note that there are some explanatory texts on larger screens.

plurals
  1. POCompile R package with TBB
    primarykey
    data
    text
    <p>I want to compile R package by using TBB (Threading Building Blocks). I used a simple example in the internet to test whether it is possible to develop R packages with TBB or not.</p> <p>I create Makevars file which include these flags for gcc:</p> <pre><code>PKG_CPPFLAGS=-I/opt/tbb41_20121003oss/include/ -O3 -g3 -Wall -c -fmessage-length=0 PKG_LIBS=-L/opt/tbb41_20121003oss/build/linux_intel64_gcc_cc4.4.6_libc2.12_kernel2.6.32_release/ </code></pre> <p>And the source code is:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;algorithm&gt; #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" using namespace tbb; using namespace std; static const size_t N = 23; class SubStringFinder { const string str; size_t *max_array; size_t *pos_array; public: void operator() ( const blocked_range&lt;size_t&gt;&amp; r ) const { for ( size_t i = r.begin(); i != r.end(); ++i ) { size_t max_size = 0, max_pos = 0; for (size_t j = 0; j &lt; str.size(); ++j) if (j != i) { size_t limit = str.size()-max(i,j); for (size_t k = 0; k &lt; limit; ++k) { if (str[i + k] != str[j + k]) break; if (k &gt; max_size) { max_size = k; max_pos = j; } } } max_array[i] = max_size; pos_array[i] = max_pos; } } SubStringFinder(string &amp;s, size_t *m, size_t *p) : str(s), max_array(m), pos_array(p) { } }; extern "C" { int test() { string str[N] = { string("a"), string("b") }; for (size_t i = 2; i &lt; N; ++i) str[i] = str[i-1]+str[i-2]; string &amp;to_scan = str[N-1]; size_t num_elem = to_scan.size(); size_t *max = new size_t[num_elem]; size_t *pos = new size_t[num_elem]; parallel_for(blocked_range&lt;size_t&gt;(0, num_elem ), SubStringFinder( to_scan, max, pos ) ); // for (size_t i = 0; i &lt; num_elem; ++i) cout &lt;&lt; " " &lt;&lt; max[i] &lt;&lt; "(" &lt;&lt; pos[i] &lt;&lt; ")" &lt;&lt; endl; delete[] pos; delete[] max; } } </code></pre> <p>When I compile the code I get this error:</p> <pre><code> library/2.14/test/libs/test.so: undefined symbol: _ZTIN3tbb4taskE </code></pre> <p>If I remove this line I can compile the program:</p> <pre><code>parallel_for(blocked_range&lt;size_t&gt;(0, num_elem ), SubStringFinder( to_scan, max, pos ) ); </code></pre> <p>Which make the TBB library useless!</p> <p>In addition I added</p> <pre><code> export /opt/tbb41_20121003oss/build/linux_intel64_gcc_cc4.4.6_libc2.12_kernel2.6.32_release/ </code></pre> <p>to the .bashrc</p> <p>I use centos.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload