OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.

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 fora single thread in the icc & gcc compilers.

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.

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.