Parallel Patterns Library: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: date. | Use this bot. Report bugs. | Suggested by Abductive | Category:Threads (computing) | #UCB_Category 14/41
Syntax highlight
 
Line 2:
 
For example, this sequential loop:
<syntaxhighlight lang="cpp">
for (int x=0; x < width; ++x)
{
// Something parallelizable
}
</syntaxhighlight>
 
Can be made into a parallel loop by replacing the for with a <code>parallel_for</code>:
for (int x=0; x < width; ++x)
<syntaxhighlight lang="cpp">
{
#include <ppl.h>
//Something parallelizable
// . . }.
Concurrency::parallel_for (0, width, [=](int x)
 
{
Can be made into a parallel loop by replacing the for with a parallel_for:
// Something parallelizable
 
});
#include <ppl.h>
</syntaxhighlight>
// . . .
Concurrency::parallel_for (0, width, [=](int x)
{
//Something parallelizable
});
 
This still requires the developer to know that the loop is parallelizable, but all the other work is done by the library.