tbb

TBB with fixed number of threads for one task, and default for others

依然范特西╮ 提交于 2019-12-07 06:02:55
问题 I want to execute a for-loop in parallel (using TBB) over a set of blocks, where each block will be processed using a user-supplied function. Normally, I would do this using tbb::parallel_for() . For various reasons, I want to be able to limit the number of threads processing the blocks to a prescribed number, call it j . Normally, I would do this using tbb::task_scheduler_init(j) . However, I would like the user to have the option to use TBB and, specifically, let the user-supplied function

How do I build OpenCV with TBB?

不想你离开。 提交于 2019-12-06 19:41:55
问题 I'm trying and failing to make opencv_traincascade use multiple threads. The only documentation I can find says to "build OpenCV with TBB". I'm not sure if I'm failing to successfully build OpenCV with TBB, or whether there's some flag I need to set for opencv_traincascade . I've downloaded the OpenCV version 2.3.1 windows superpack and tbb40_20111003oss_win.zip , which I extracted to C:\tbb40_20111003oss . I then generated VC8 .sln and .proj files using CMake, setting WITH_TBB: ON TBB

A parallel algorithm for order-preserving selection from an index table

空扰寡人 提交于 2019-12-06 16:46:30
Order-preserving selection from an index table is trivial in serial code, but in multi-threading is less straightforward, in particular if one wants to retain efficiency (the whole point of multi-threading) by avoiding linked lists. Consider the serial code template<typename T> std::vector<T> select_in_order( std::vector<std::size_t> const&keys, // permutation of 0 ... key.size()-1 std::vector<T> const&data) // anything copyable { // select data[keys[i]] allowing keys.size() >= data.size() std::vector<T> result; for(auto key:keys) if(key<data.size()) result.push_back(data[key]); return result;

guidance with input filter for TBB Pipeline library

雨燕双飞 提交于 2019-12-06 16:27:30
In my previous question, I implemented a TBB Pipeline using C++ (Linux) with Input, Transform and Output filters: incorrect output with TBB pipeline The Input filter was reading data (C structure) from text files and was passing to Transform filter. The Transform filter was updating data and passing it to Output filter. The Output filter was storing it back on the disc. A simple read and write application. Now, I am looking to create a MAIN application. The MAIN application will create a TBB Pipeline with three filters in the start: InputFilter : Receive data/C structure from the main

Intel tbb parallel_for: pass class member function with parameters?

試著忘記壹切 提交于 2019-12-06 09:16:28
Is it possible to pass a class member function (with parameters) to parallel_for? Something along the lines: void classT::A(const tbb::blocked_range<std::size_t>& r,b) {} void classT::B(e,f,g) { tbb::parallel_for( blocked_range<size_t>(0,n), <need to call A with parameter b, along with r> ) } Look at this example . They create a class and suply the class with a all the parameters needed. In that class is also a operator() which does an oppertion on the data. The parallel_for is then called with a instance of that class. parallel_for(blocked_range<int>(0, nElements, 100), ArraySummer( p_A, p_B,

using TBB for non-parallel tasks

我们两清 提交于 2019-12-06 06:45:47
问题 I want to get a thread-pool behavior using TBB. But whenever I read documents about TBB they always talk about parallel-for, parallel-dowhile etc. In contrast what I need is a main thread to assign tasks to a thread pool so those tasks will be executed 'on their own' - execute tasks asynchronously. Tasks here can be event handling for a GUI. Is the TBB task scheduler appropriate for such behavior? The impression I got from task scheduler is that it's only beneficial if I have tasks that can

Intel TBB run a function in a parallel thread?

断了今生、忘了曾经 提交于 2019-12-06 05:30:29
Basically I am developing an opencv application. I have built OpenCV with_tbb option in cmake . I would like to use intel tbb to run a parallel thread that at some intervals updates some global variables. Something like: vector<int> mySharedVar; void secondaryThreadFunction() { while(true) { Do some operations And update mySharedVar if necessarily usleep(1000); } } int main() { run in parallel secondaryThreadFunction; in the master Thread keep doing something based on mySharedVar while(true) { do something; } } How can I run secondaryThreadFunction() on another thread ? Intel TBB is not meant

tbb parallel_for example c++ without lambda

萝らか妹 提交于 2019-12-06 04:41:48
Can you give me an example on tbb "parallel_for" without using lambda expression? Because I can't run lambda expression under Ubuntu system's C++ compiler, and I don't why. to be brief: turn this for loop into parallel_for please. void print(int n) { cout<<n<<endl; } for(int i=0; i<100; i++) { print(i); } by the way, if who can tell me how to run C++ lambda expression in linux system, that would be better for me. Thanks. parallel_for will take any functor, which can be a lambda, a functor class or a plain old function; the following should work just fine too: #include "tbb/tbb.h" using

Matlab limits TBB but not OpenMP

拜拜、爱过 提交于 2019-12-05 16:42:10
I'm only asking this to try to understand what I've spent 24 hours trying to fix. My system: Ubuntu 12.04.2, Matlab R2011a, both of them 64-bit, Intel Xeon processor based on Nehalem. The problem is simply, Matlab allows OpenMP based programs to utilize all CPU cores with hyper-threading enabled but does not allow the same for TBB. When running TBB, I can launch only 4 threads, even when I change the maxNumCompThreads to 8. While with OpenMP I can use all the threads I want. Without Hyper-threading, both TBB and OpenMP utilize all 4 cores of course. I understand Hyper-threading and that its

TBB with fixed number of threads for one task, and default for others

喜欢而已 提交于 2019-12-05 09:16:57
I want to execute a for-loop in parallel (using TBB) over a set of blocks, where each block will be processed using a user-supplied function. Normally, I would do this using tbb::parallel_for() . For various reasons, I want to be able to limit the number of threads processing the blocks to a prescribed number, call it j . Normally, I would do this using tbb::task_scheduler_init(j) . However, I would like the user to have the option to use TBB and, specifically, let the user-supplied function use however many cores remain. So I think tbb::task_scheduler_init() is out. The only solution I can