if

General OpenMP discussion

if

Postby chameleon » Thu May 17, 2012 1:13 pm

I want to add 2 big vectors. Vector addition is at most a memory operation.
I use this code:
Code: Select all
#define OPENMP_PART 1000000
#pragma omp parallel for if (total > OPENMP_PART)
for (size_t z = 0; z < total; z++)
   elements[z] += m[z];

So, I use OpenMP when add at least 1000000 element, to avoid thread creation/destruction overheat.
Is my think correct or not?
chameleon
 
Posts: 8
Joined: Mon Jan 23, 2012 6:37 pm

Re: if

Postby MarkB » Fri May 18, 2012 1:57 am

chameleon wrote:So, I use OpenMP when add at least 1000000 element, to avoid thread creation/destruction overheat.
Is my think correct or not?


Yes, that's a very sensible strategy.
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests