- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My multi-threaded program works, but I find that running with several cores actually takes longer than does a single-thread run. Here's what is going on:
1. Several threads are started. They each go into a DO WHILE loop, waiting for a flag in an indexed variable in a named COMMON block.
2. When the flag is set, the thread starts some serious number crunching, using data taken from another indexed set of variables. When the routine finishes, it sets another flag, also in an indexed array.
3. The calling program waits until all threads have finished, checking the flags in another DO WHILE loop, and then reads out the answers from the indexed variables. Then it starts over with another set of input data, and so on.
This should run faster with several threads running in parallel, but it doesn't. Possible reasons:
1. One of the threads is in a core being used by Windows for something else. It cannot complete its task until Windows lets it run, and the calling program has to wait for that.
2. The several threads do not in fact run in parallel. If they go individually, that would also be very slow.
Is there any way to ensure that my threads get their own cores, and they all run in parallel?
1. Several threads are started. They each go into a DO WHILE loop, waiting for a flag in an indexed variable in a named COMMON block.
2. When the flag is set, the thread starts some serious number crunching, using data taken from another indexed set of variables. When the routine finishes, it sets another flag, also in an indexed array.
3. The calling program waits until all threads have finished, checking the flags in another DO WHILE loop, and then reads out the answers from the indexed variables. Then it starts over with another set of input data, and so on.
This should run faster with several threads running in parallel, but it doesn't. Possible reasons:
1. One of the threads is in a core being used by Windows for something else. It cannot complete its task until Windows lets it run, and the calling program has to wait for that.
2. The several threads do not in fact run in parallel. If they go individually, that would also be very slow.
Is there any way to ensure that my threads get their own cores, and they all run in parallel?
Link Copied
- « Previous
- Next »
43 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is more or less what I experience: too many threads slows things down. Anyway, it's time to move on. I can get a slight improvement in speed with some problems, but a decrease with others. I conclude that OpenMP is a nice idea -- but one that does not work very well for the kind of problems I have. Had to try it, and I'm glad I posted in this forum. I appreciate all of the intelligent suggestions made by the posters. But there is no simple solution that works well and reliably. I'll use the feature in the cases when it works, and not worry about it otherwise.
Thank you, everyone.
Thank you, everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> I conclude that OpenMP is a nice idea -- but one that does not work very well for the kind of problems I have. Had to try it, and I'm glad I posted in this forum.
I am glad you gave it a try.
If compute time is a serious concern, then I would suggest you have a more experienced programmer look at the application as a whole. I expect that they will see something that you have been unable to convey to us on this forum.
Jim Dempsey
I am glad you gave it a try.
If compute time is a serious concern, then I would suggest you have a more experienced programmer look at the application as a whole. I expect that they will see something that you have been unable to convey to us on this forum.
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
- Next »