merging data - parallel threads

Hi Forum,

I have a section of my code running in parallel using

My question is, how do I 'merge' the data from different threads into one. A simple example is below.

omp_set_num_threads(2);

#pragma omp parallel
{
// Some code to determine x1 y1 x2 y2

double gradient = findGradientOfLine( x1, y1, x2, y2);

// Merge gradient from both threads
// find intersection point if it exists

}

Thanks,
RuiQi
Bump ~
No one knows how to do it ?
What do you mean?
Non private variables can be accessed by all threads.

If the threads do not process independent parts of the data synchronization is required.

See:

https://en.wikipedia.org/wiki/OpenMP
Topic archived. No new replies allowed.