Intel® Threading Building Blocks

Alternative Termination for parallel_do

Flush with success at my first parallel_for, I'm on to bigger and more complex. I now have a problem in which I have a stochastic process that is used to fill a data structure. The process can result in 0,1 or several additions to the data structure. I need to terminate when the data structure is full. The serial code is a simple do{StochasticProcess();}while (!dataStructure.isFull()); It takes 10's of thousands of calls to StochasticProcess to fill the dataStructure, and they are independent, so it's a great thing to parallelize.

Atomic floats, is this implementation safe?

I made an atomic float, and it's probably not blazingly fast (that's ok), but its faster than wrapping a lock around a float, and it works, but I'm not sure if this is because of my good luck, or if this is actually thread safe. I think it is... but you never know, so I came to ask the experts :)

struct AtomicFloat: public tbb::atomic

{

float compare_and_swap(float value, float compare)

{

size_t value_ = tbb::atomic::compare_and_swap((size_t&)value,(size_t&)compare);

return reinterpret_cast(value_);

}

TBB allocators in Win32++

I'm using a small GUI called Win32++.

http://users.bigpond.net.au/programming/

In my applicationwhen usingSTL template containers I always supply a TBB allocator.Win32++on the other hand usesthe default allocator throughout. Win32++ is based on include files only so it would be fairly easy I think to make it use some other allocator by the specification of a parameter.

Problem compiling the sample program with the tbb distribution

I have just downloaded the src package and foolowed the getting strted tutorial but have the following error

g++ -O2 -DNDEBUG -o sub_string_finder sub_string_finder.cpp -ltbb
/usr/bin/ld: cannot find -ltbb
collect2: ld returned 1 exit status
make: *** [release] Error 1

I sourced the .sh file it created and am not sure what i am missing.

-Mitchelle.

VC++ language CLR windows form with TBB? (error C2695)

I meet a question. When I write a TBB program in console mode. It is running normally.But when I write a TBB program in clr windows form(this program is the same code under clr windows form and console mode). The compiler appear in the wrong information(error C2695).

" \Program Files\Intel\TBB\2.1\include\tbb\parallel_for.h(59) : error C2695
function1' overriding virtual function differs from 'function2' only by calling convention".
Where function1 is 'start_for::note_affinity' and function2 is 'tbb::task::note_affinity'.

Link Error 1107

I'm just creating my first TBB enabled app. I got past all of the trivial mistakes, and now I'm getting the following link error:

>C:\Program Files\Intel\TBB\2.0\ia32\vc9\bin\tbb_debug.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x308

I'm using VC9 in debug. I'm linking with the /MDd switch. The only thing I can figure is that I'm using .net for the GUI and the .dll file is incompatible with /clr. Does anyone have a better suggestion? (i.e. one that does not involve relearning MFC and rewriting my whole GUI) TIA

Can use reference pointer of managed code in class of TBB?

I have a problem. I want to use reference pointer(as array^) in parallel_for.

for example:

class ApplyFoo {
char *const my_a;
public:
void operator( )( const blocked_range& r ) const {
char *a = my_a;
for( size_t i=r.begin(); i!=r.end( ); ++i )
Foo(a[i]);
}
ApplyFoo( char a[] ) :my_a(a){}
};

void ParallelApplyFoo( char a[], size_t n ) {
parallel_for(blocked_range(0,n,YouPickAGrainSize), ApplyFoo(a) );
}

I want to replace char* with array^. How should I do?

Thanks.

Suscribirse a Intel® Threading Building Blocks