intel parallel studio 2011 - summing in parallel -


i have serial code looks that:

sum = a; sum += b; sum += c; sum += d; 

i parallelize that:

temp1 = + b     , in same time     temp2 = c + d sum = temp1 + temp2 

how do using intel parallel studio tools?

thanks!!!

assuming variables of integral or floating point types, there absolutely no sense parallelize code (in sense of executing different threads/cores), overhead much higher benefit out of it. applicable parallelism in example @ level of multiple computation units and/or vectorization on single cpu. optimizing compilers sophisticated enough nowadays exploit automatically, without code changes; if wish may explicitly use temporary variables, in second part of question.

and if ask out of curiosity: intel parallel studio provides several ways parallelize code. example, let's use cilk keywords c++11 lambda functions:

#include <cilk/cilk.h> ... temp = cilk_spawn [=]{ return a+b; }(); sum = c+d; cilk_sync; sum += temp; 

don't expect performance out of (see above), unless use classes computational-heavy overloaded operator+.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -