tbb

TBB for a workload that keeps changing?

风格不统一 提交于 2019-12-10 11:58:10
问题 I'm sorry I don't seem to get intel's TBB it seems great & supported but I can't wrap my head around how to use it since I guess I'm not used to thinking of parallelism in terms of tasks but instead saw it as threads. My current workload has a job that sends work to a queue to keep processing(think of a recursion but instead of calling itself it sends work to a queue). The way I got this working in Java was to create a concurrent queue(non-blocking queue) and threadpoolexecutor that worked

Atomic operators, SSE/AVX, and OpenMP

本小妞迷上赌 提交于 2019-12-09 22:57:01
问题 I'm wondering if SSE/AVX operations such as addition and multiplication can be an atomic operation? The reason I ask this is that in OpenMP the atomic construct only works on a limited set of operators. It does not work on for example SSE/AVX additions. Let's assume I had a datatype float4 that corresponds to a SSE register and that the addition operator is defined for float4 to do an SSE addition. In OpenMP I could do a reduction over an array with the following code: float4 sum4 = 0.0f; /

Threaded Building Blocks (TBB) enqueue task with lambda

孤街醉人 提交于 2019-12-09 22:32:17
问题 The TBB documentation gives this example of using lambda expressions with parallel_for, but doesn't provide an example of using lambda expressions with tbb::task::enqueue . I am looking for a simple example of tbb::task::enqueue with a lambda expression. 回答1: Low-level tasks in TBB do not directly support lambda expressions. But with some extra coding you might create syntax-sugar helpers to do what you want. You'd need to create a task class that calls a given functor: template<typename F>

How do you install Intel TBB on OS X?

痞子三分冷 提交于 2019-12-08 16:23:42
问题 How do you properly install the open source version of Intel Thread Building Blocks (TBB) on OS X 10.6? The open source version doesn't seem to have a proper install script. http://www.threadingbuildingblocks.org/ver.php?fid=154 回答1: I found an easy way to install it: brew install tbb Requires Homebrew, which is highly recommended for any Mac user wanting to use various open source tools. 回答2: There is a tutorial for using TBB 2.2 on a Mac without MacPorts/Homebrew. Maybe that's of help for

c++ two tbb::parallel_for loops efficiency

北战南征 提交于 2019-12-08 11:59:41
问题 In my code I call parallel_for twice: parallel_for( do some stuff ); // I want this operation to finish first parallel_for( do some other stuff ); // then I want to do this 1) Does this approach create physical threads twice ? and makes it slower ? 2) If needed, what would be the best method to replace those two calls of parallel_for ? 回答1: 1) No, TBB has single shared pool of threads which are created lazily on demand. So lazily that completion of the first parallel_for does not guarantee

guidance with input filter for TBB Pipeline library

匆匆过客 提交于 2019-12-08 08:52:26
问题 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

TBB flow graph conditional execution

一笑奈何 提交于 2019-12-08 08:24:45
问题 It possible to control execution path in the TBB Flow Graph dynamically, using output of a node as a condition variable to determine whether another node should be launched? 回答1: There are a couple ways to dynamically control where messages go in a flow::graph: You can explicitly put messages to other nodes in the body of a node. Notice that func_body puts a message to f1 or f2 , depending on the value of its input. The nodes are not attached by make_edge() , because the flow of messages is

Intel tbb parallel_for: pass class member function with parameters?

爷,独闯天下 提交于 2019-12-08 02:34:13
问题 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> ) } 回答1: 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

Intel TBB run a function in a parallel thread?

一曲冷凌霜 提交于 2019-12-08 00:44:48
问题 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)

tbb: parallel find first element

倾然丶 夕夏残阳落幕 提交于 2019-12-07 08:23:59
问题 I have got this problem: Find the first element in a list, for which a given condition holds. Unfortunately, the list is quite long (100.000 elements), and evaluation the condition for each element takes in total about 30 seconds using one single Thread. Is there a way to cleanly parallelize this problem? I have looked through all the tbb patterns, but could not find any fitting. UPDATE : for performance reason, I want to stop as early as possible when an item is found and stop processing the