Questions tagged [parallel-for]

Parallel.For executes a for loop in which iterations may run in parallel to each other.

Parallel.For executes a for loop in which iterations may run in parallel to each other.

References

98 questions
3
votes
3 answers

OpenMP parallel for with floating-point range

I have the following program: int main(){ double sum=0; #pragma omp parallel for reduction(+:sum) for(double x=0;x<10;x+=0.1) sum+=x*x; } When I compile it, I get the error invalid type for iteration variable ‘x’. I take this to mean…
Richard
  • 44,865
  • 24
  • 144
  • 216
3
votes
2 answers

OpenCV parallel_for not using multiple processors

I just saw in the new OpenCV 2.4.3 that they added a universal parallel_for. So following this example, I tried to implement it myself. I got it all functioning with my code, but when I timed its processing vs a similar loop done in a typical serial…
blorgggg
  • 405
  • 5
  • 15
2
votes
2 answers

allocating memory per thread in a parallel_for loop

I originally have a single-threaded loop which iterates over all pixels of an image and may do various operation with the data. The library I am using dictates that retrieving pixels from an image must be done one line at a time. To this end I…
Rotem
  • 19,723
  • 6
  • 57
  • 101
2
votes
1 answer

Fastest way of converting image to grayscale using certain coefficients

I need to convert a cv::Mat into grayscale using a custom formula. Each channel of the input matrix has to be multiplied by a certain coefficient. This is a pseudocode of the operation: Y = 0.2126*R + 0.7152*G + 0.0722*B Input matrix is CV_32FC3…
2
votes
3 answers

Adding double within a parallel loop - std::atomic

I have a parallel code that does some computation and then adds a double to an outside-the-loop double variable. I tried using std::atomic but it does not have suport for arithmetic operations on std::atomic < double > variables. double dResCross =…
Zdeny
  • 65
  • 4
2
votes
1 answer

Efficient parallelization of operations on two dimensional array operations in python

I'm trying to parallelize operations on two dimensional array using joblib library in python. Here is the code I have from joblib import Parallel, delayed import multiprocessing import numpy as np # The code below just aggregates the base_array to…
Ram
  • 55
  • 8
2
votes
2 answers

C++ How can I run three diffrent parallel_for functions at once apart from using tbb::task_group?

I have code where I have to run parallel_for (independent from each other) at once parallely. Code is something like: tbb::parallel_for(range1,func1());//first tbb::parallel_for(range2,func2());//second tbb::parallel_for(range3,func3());//third I…
Vibhor
  • 35
  • 5
2
votes
0 answers

Unidentifiable error in parallel_for

I'm trying to learn how to use a parallel_for loop for simple tasks. I am trying to use the following code: Concurrency::parallel_for(int(0), 50, [&](int i) { try { printf("%d,", i); } catch (exception e) { …
SFX
  • 139
  • 10
2
votes
2 answers

Parallel.For SendAsync to BufferBlock to Async Transform?

I am learning about the TPL Dataflow Library. So far it's exactly what I was looking for. I've created a simple class (below) that performs the following functions Upon execution of ImportPropertiesForBranch I go to a 3rd party api and get a list…
2
votes
0 answers

What's the best way to return values from parallel_for

I have simple parallel_for loop and results of every iteration I am inserting to concurrent_unordered_map. I see that inserting makes my code much slower. So what is the best way to return pairs from parallel_for to unordered_map? I was trying with…
Queen
  • 171
  • 1
  • 9
2
votes
3 answers

Parallel.For as opposed to for loop

I am experimenting with parallel programming. I have a normal loop: for (int i = 0; i < 100000; i++) { Console.WriteLine("Thread ID: {0} and i is " + i + " Time Elapsed: " + sw.Elapsed, Thread.CurrentThread.ManagedThreadId); } This…
Mage
  • 929
  • 2
  • 13
  • 23
2
votes
1 answer

Parallelization of a Genetic Algorithm in Matlab

I'm writing a parallel Genetic Algorithm in Matlab, specifically a Dual Species Genetic Algorithm (DSGA) (more information can be found in this paper here), and I'm having some trouble parallelizing part of the code. Now I'm a physics and math…
2
votes
1 answer

Could this WPF code benefit from Parallel.For and how?

I'm wondering if there is a way to convert this so it would be more performant by using a Parallel.For for example. public FrameworkElement FindIntersectingElement(Rect rectangle, UIElement activeElement) { foreach (var child in…
TimothyP
  • 18,775
  • 23
  • 88
  • 141
2
votes
1 answer

Replacing TBB parallel_for with OpenMP

I'm trying to come up with an equivalent replacement of an Intel TBB parallel_for loop that uses a tbb::blocked_range using OpenMP. Digging around online, I've only managed to find mention of one other person doing something similar; a patch…
NobodyNothing
  • 155
  • 3
  • 13
2
votes
2 answers

Converting a for loop into Task.Parallel.For

I have a procedure bool IsExistImage(int i) . the task of the procedure to detect an image and return bool whether it exist or not. i have a PDF of 100+ pages which i split and send only the file name through the method. file names are actually the…
Abdur Rahim
  • 3,599
  • 11
  • 42
  • 77