I have to use VS 2010 which supports OpenMP 2.0 I have a large single linked list and I'd like to distribute processing of nodes for threads team using OpenMP. I found some articles about using single thread to iterate and then assigning copy of each node to every thread member from the team:
#pragma omp parallel
{
#pragma omp single default(none)
{
element *p = listHead;
while( p != NULL )
{
#pragma omp task private(p)
Process( p );
p = p->next;
}
}
}
Here 'single' directive specifies that one thread should do iteration and inside - directive 'private' specifies that each thread receives copy of 'p' variable and do processing. Though I need something else. I'd like to distribute different nodes to threads. For example if my list contains 10 nodes and I set to use 4 threads, I'd like that first thread receives 3 nodes, second 3 nodes, third 2 nodes and fourth 2 nodes. This is just approximate assumption. Basically I'd like that each thread gets different node. I was thinking to use 'single' or 'master' directive to specify that one thread should perform iteration through the list, but I don't know how to specify this nodes distribution. Any ideas?
Update: And no it is not a duplicate as @Zulan suggested cause answer from All OpenMP Tasks running on the same thread cannot be used in VS2010. 'task' directive is not supported on OpenMP 2.0 which VS2010 deploys.