I am trying to run 8 different threads on 8 different cores. So my CPU time is greater than my elapsed time. One of the threads is taking a very long time when compared to the other 7. These 7 threads are taking up almost the same time with a very minute difference. I have attached a screenshot of this. Can someone please tell me why this one particular thread is taking this extra time?
"One particular thread" you side is responsible for creating 7 other threads by using OpenMP* library, before running parallel task on 8 threads/cores. It will take some time to initialize - I call it "main thread". Main thread also is responsible for fork-join, then exit program.
Because whole program only ran a few minutes, it seemed that main thread was particular long. However if you use big task set, the time of main thread's will not seem long. Note that main thread also will run parallel-work, the role is same 7 other threads (beside initialize & fork-join, or threads' communication/control, maybe)
It seems that _start thread is the main thread and as Peter hinted it is performing thread spawning work.Usually on Windows creating new thread is time consuming activity.Probably creating new thread in Linux is also time consuming operation.
Could OpenMP multithreading contribute to the thread creation overhead?.As far as I understand OpenMP library threads are using at the runtime native OS threads to perform their work.
There's no reason to assume there is any overhead in these results. The main thread simply didn't execute the multi-threaded code until the 1.8s mark. I see nothing wrong with this picture. :\
I meant overhead of creating the threads,but I do not think that this operation could consume <=1.8 second.So probably _start thread was performing different tasks after spawning the threads.
> Could OpenMP multithreading contribute to the thread creation overhead?.
Absolutely, there is overhead but I think it is not high. The best performance is to access OS thread via Win Thread API or pthread directly - but OpenMP is good at programming, you know:-)