- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
How can I get in Intel-Fortran the optimal/maximum number of threads to use in a program on a given PC. This would be the "number cores + the number of HT cores", right? Is there a system function in Intel-Fortran that will give me this number?
Thank you
Tihomir
Link Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Win32 API routine GetSystemInfo will return the number of logical processors that Windows sees in the dwNumberOfProcessors field of the SYSTEM_INFO structure. This will include both physical processors/cores and the logical processors that HT creates.
There is, I am sure, also a way to find out how many physical processors and/or cores are on the system, but I don't know offhand what that is.
There is, I am sure, also a way to find out how many physical processors and/or cores are on the system, but I don't know offhand what that is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that the number returned by the system API may not be very helpful. For many reasons:
(1) There may be processes running that have already reserved one or more CPU's.
(2) There may be system drivers that have priority over your requests.
(3) There may be system limits set for your account that limit the number of CPU's you may be allowed to request.
(4) There may be CPU's that can't reach the memory allocated for your program.
(5) There may be "hyper" CPU's, which IMHO are mostly hype. Even in Intel's own specially crafted benchmarks, it's hard for them to show more than a few tenths of a CPU is generated by the hyper feature. And IIRC they've dropped the hyper feature on their latest CPUs.
(6) One or more CPU's may be sidelined due to some unrecoverable error, such as a double bus fault.
(7) One or more CPU's may be virtual CPU's, if your app ends up running under something like "virtual PC", or the microsoft equivalent.
In my programs I usually detect the number of CPU's by starting 1, 2, ... threads and stop adding threads when the thruput stops increasing.
(1) There may be processes running that have already reserved one or more CPU's.
(2) There may be system drivers that have priority over your requests.
(3) There may be system limits set for your account that limit the number of CPU's you may be allowed to request.
(4) There may be CPU's that can't reach the memory allocated for your program.
(5) There may be "hyper" CPU's, which IMHO are mostly hype. Even in Intel's own specially crafted benchmarks, it's hard for them to show more than a few tenths of a CPU is generated by the hyper feature. And IIRC they've dropped the hyper feature on their latest CPUs.
(6) One or more CPU's may be sidelined due to some unrecoverable error, such as a double bus fault.
(7) One or more CPU's may be virtual CPU's, if your app ends up running under something like "virtual PC", or the microsoft equivalent.
In my programs I usually detect the number of CPU's by starting 1, 2, ... threads and stop adding threads when the thruput stops increasing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The GetSystemInfo API will tell you about the processors available to the OS, which is good enough for the purpose requested. Hyper-Threading can show a benefit of up to 25% in some real applications, but I'm not going to argue that it's a replacement for a physical CPU or core.
The article I pointed to goes into a lot more detail regarding processor affinity, etc. And yes, if you're talking about non-uniform memory access (NUMA), then knowing which memory is local and which is not can be important, but in the Intel world that's for users of certain Itanium-based systems only.
The article I pointed to goes into a lot more detail regarding processor affinity, etc. And yes, if you're talking about non-uniform memory access (NUMA), then knowing which memory is local and which is not can be important, but in the Intel world that's for users of certain Itanium-based systems only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is very helpful. Thanks a lot.One morequick question. Is there an advantage of two single core procs over one dual core?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It depends. Some dual-core CPUs (such as the Intel Core 2 Duo processors) have a shared cache which can speed sharing data between threads but the total cache available tends to be less than in dual-CPU systems. So a lot depends on the application and how much communication between threads is needed. Dual-CPU systems tend to need more components on the motherboard and are more expensive. Of course, the multiple-socket strategy nowadays is to have dual-core CPUs in each socket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That link does not work for me (brings up a blank screen and gets me right back here). Is it still valid?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not any more, it would seem. I've replaced the link with a new one (this is for the article, not my Fortran sample program).
![](/skins/images/B7BA37F9CE4B52FF7CAE1FB0388839C8/responsive_peak/images/icon_anonymous_message.png)
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