Controlling the Task Cutoff for OpenMP programs

General OpenMP discussion

Controlling the Task Cutoff for OpenMP programs

Postby pghosh » Fri Oct 26, 2012 10:31 am


I have a piece of code where I would like to enforce the creation of tasks even for 1 thread.
Can I perform this in any way within the code or is there an environment variable I can set to make sure that tasks are created even for
a single thread in the icc & gcc compilers.

I have tried the following technique which does not seem to work:

Code: Select all
#pragma omp parallel firstprivate(a, gap, waves) private(temp, wave, ii, i) shared(np, mp, elements)
    num_threads= omp_get_num_threads();
    #pragma omp master
      for loop
      -- do something --

     #pragma omp task firstprivate(ii, np, mp, chunk, elements) if((num_th >= 1))     
         for loop
            --- do something ---
    #pragma omp taskwait


This is a performance test I wish to conduct for I want to judge the performance of the above code using just 1 thread.
Currently the icc and gcc compilers by default do not generate tasks when the code is running on a single thread.
Is there a way I can disable that and force it to create tasks even when operating on 1 thread as well.

Posts: 1
Joined: Tue Oct 16, 2012 12:33 pm

Re: Controlling the Task Cutoff for OpenMP programs

Postby MarkB » Thu Nov 01, 2012 5:24 am

I'm not quite sure what you are asking for here, or what you are trying to measure: the tasks will get created on one thread (in the sense that the data environment including the firstprivate copies of variables will be set up), but the tasks may be executed straight away rather than being queued up, which is a perfectly reasonable thing for an implementation to do. I doubt there is any way of enforcing the queuing as this would serve no useful purpose.

In general, the cost of enqueuing an dequeuing tasks is not independent of the number of threads, so trying to measure the overhead on a single thread may not be very meaningful.

Hope that helps,
Posts: 455
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Return to Using OpenMP

Who is online

Users browsing this forum: Delais, Google [Bot], Yahoo [Bot] and 6 guests