- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
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?
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Peter
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. :\
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> 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:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Completely agree.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page