Dual-core CPUs and Multi-threading [modified]
-
Based on comments from the device driver guy in my group, I wouldn't be surprised to see a lot of driver updates. Apparently it's pretty easy for a driver to assume a single processor environment and fail to take into account multiprocessor issues. This causes everything from performance problems to random BSOD's.
John Simmons / outlaw programmer wrote:
I'm running Win2K on the system in question
I didn't think Win2K supported multiple processors out of the box. Or are you running a server version?
Software Zen:
delete this;
Gary R. Wheeler wrote:
I didn't think Win2K supported multiple processors out of the box. Or are you running a server version?
I'm using Win2k Pro. If you go into device manager, expand the tree item "Computer", double-click the sub item, and click the 2nd tab, you'll see two items listed - Single CPU, and Mulitple CPU. All I had to do was click the multiple CPU option, and reboot.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Never had any problems with dual P3 config I had, but that was years ago. In any case, you can manually force affinity to one of the cores through task manager, shouldn't that fix the problem?
Yeah, but that's a pain. :)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
AIUI the updated driver's primary fix was to a power/noise conservation feature that could underclock the two cores independently causing timers to fall out of syncronization.
Yeah, that's what I've seen when I googled it. I'm turned off "Cool-n-Quiet", so maybe I won't have issues.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
John Simmons / outlaw programmer wrote:
Now that I have a dual-core CPU, I was thinking about writing an app to compare the speed of using just one core versus using both cores to run a calculation-intensive thread. (It's fun to play with ne hardware.)
If your calculation is not mutlithreaded the result is the dual core will probably be slower considering that it is probably clocked slower than the processor it replaces.
John
Well, the new CPU is the same clock speed as the one it replaced (both are rated at 2.2ghz). What I wanted to do was create a calc thread, run that thread simultaneously on both cores, and then run two instances of the thread on the first core, and then on the 2nd core. I'm just curious to see what the results would be. I expect that dual core will be faster, followed by 2nd core, and then by first core.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Yeah, that's what I've seen when I googled it. I'm turned off "Cool-n-Quiet", so maybe I won't have issues.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
The OS allocates threads to logical processors, if they're runnable (not blocked or suspended), in order of priority. A thread will run for up to its quantum on any CPU on which it's allowed to run (you can set affinity to restrict a thread to specific logical processors) unless it's pre-empted by a higher priority thread. Windows boosts foreground apps by giving their threads a longer quantum than background apps. To take advantage of cache locality, Windows remembers which logical processor (logical HT core, physical core, physical processor) a thread last ran on, and a preferred logical processor for that thread. Each new thread in a process gets a different preferred processor from the previous one, rotating across the logical processors. If possible, it runs the thread on the last processor, or if that is not available, on the preferred processor. If neither are available it tries a nearby processor - another logical HT processor on the same core, another core in the same package, then other cores in the same memory domain (for Non-Uniform Memory Access [NUMA] systems), then finally any available core. The full details are in 'Windows Internals, 4th Edition' by Mark Russinovich and David Solomon. I'm hoping that Mark's SysInternals' acquisition by Microsoft doesn't get in the way of him updating this book!
Stability. What an interesting concept. -- Chris Maunder
Mike Dimmick wrote:
If neither are available it tries a nearby processor - another logical HT processor on the same core, another core in the same package, then other cores in the same memory domain (for Non-Uniform Memory Access [NUMA] systems), then finally any available core.
When did this kick in? I was thinking it was WinXP; i seem to remember Win2000 still having issues with seeing two HT processors as four actual processors and treating them accordingly... was this ever fixed?
---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums
-
When you have a dual core CPU, does a multi-threaded app "just know" that it can use the 2nd core, or can/must you set cpu affinity on a thread-by-thread basis in order to take advantage of the 2nd core? Now that I have a dual-core CPU, I was thinking about writing an app to compare the speed of using just one core versus using both cores to run a calculation-intensive thread. (It's fun to play with ne hardware.) -- modified at 8:33 Friday 4th August, 2006 (for spelling errors)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001Open up task manager and add the thread column. Most of the applications already have multiple threads running, so windows is already swaping out all those threads even on single processor systems. Now it just has 2 processors to run hundreds of threads on instead of just 1. Like others have said, it manages all that for you. To take advantage of it in your software all you have to do is create multiple threads and syncronize the results. Figuring out how to keep a multiprocessor system at peak CPU utilization with a realistic workload is a hard thing to do as syncronization overhead usually takes a signifigant bite. So if you have a dual processor system with a single calculation, unless you can split it up to use 2 threads without a lot of syncronization you are only going to get single thread performance out of it.
Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you. -Chris Maunder
-
Mike Dimmick wrote:
If neither are available it tries a nearby processor - another logical HT processor on the same core, another core in the same package, then other cores in the same memory domain (for Non-Uniform Memory Access [NUMA] systems), then finally any available core.
When did this kick in? I was thinking it was WinXP; i seem to remember Win2000 still having issues with seeing two HT processors as four actual processors and treating them accordingly... was this ever fixed?
---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums
I believe the HT thing was fixed in Windows XP; using a core/processor in the same memory domain was added in Windows Server 2003 (and XP x64, which uses the Server 2003 SP1 kernel).
Stability. What an interesting concept. -- Chris Maunder
-
When you have a dual core CPU, does a multi-threaded app "just know" that it can use the 2nd core, or can/must you set cpu affinity on a thread-by-thread basis in order to take advantage of the 2nd core? Now that I have a dual-core CPU, I was thinking about writing an app to compare the speed of using just one core versus using both cores to run a calculation-intensive thread. (It's fun to play with ne hardware.) -- modified at 8:33 Friday 4th August, 2006 (for spelling errors)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001You can set CPU affinity for a thread with
SetThreadAffinityMask()
but as others have said, in normal situations (ie, not benchmarking) it's better to let the OS thread scheduler handle it.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Based on comments from the device driver guy in my group, I wouldn't be surprised to see a lot of driver updates. Apparently it's pretty easy for a driver to assume a single processor environment and fail to take into account multiprocessor issues. This causes everything from performance problems to random BSOD's.
John Simmons / outlaw programmer wrote:
I'm running Win2K on the system in question
I didn't think Win2K supported multiple processors out of the box. Or are you running a server version?
Software Zen:
delete this;
My first, and last, dual processor was a dual P2-400 box ... it was running NT 4.0 ... and used to BSOD all the time due the video drivers. NT 4.0 supported dual processor out of the box .. it's just if you upgraded from single to dual processor you had to re-install a different kernel. Yeah, those were the days ... dual-processor was hard-core back then .. now a days, it dont mean a thing :-(
Rocket science is more fun when you actually have rockets - US Navy ad
-
> Apparently there are "issues" with multiple cores under Windows with several apps (mostly games The only problem I've seen with a game when I swapped my Athlon64 3200 with a 4800 was GTA San Andreas. The timing was *way* off, eg, the in-game clock and traffic moved as fast as the machine could make it (which was interesting in its own right) :-D My quick solution was to reinstall the game on top of itself (fortunately the installer was smart enough to realize it didn't actually have to transfer any files back from the media on the hard drive), so that took less than 30 seconds. I haven't encountered any other problem whatsoever, and I simply dropped the new CPU in without reinstalling anything. At some later point I stumbled upon AMD's newer driver and installed it, but I can't even comment whether that made any difference or not...
Dual core appears to the OS as dual CPU, there is a procedure for changing the OS setting to support this feature (unless it was installed on a dual cpu or HT system with HT enabled), but the best way is to re-instyall the OS. Any way the application should work well without special regard accept writing the code in threades (and not to many opening and closing) and using sync features such as mutex and semaphores. Good luck:-D NS
-
Don't get too envious yet. Apparently there are "issues" with multiple cores under Windows with several apps (mostly games, but I don't own any of the ones I've seen mentioned), and this is such a problem that AMD has issued a new driver, and MS has issued a patch to address it. I'm running Win2K on the system in question, and I haven't noticed any problems (yet), but if I do, I haven't found anything about whether or not the driver/patch combo will work on Win2K. I'm not sure what I need to do about it yet, either. -- modified at 8:31 Friday 4th August, 2006
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001The important thing is that they will fix it. So let's not linger on the software issue and just build 10xcore CPUs faster! :D
---------- Siderite