Jump to content
  • Advertisement
Sign in to follow this  
Marmin

Core 2 quad behaviour.

This topic is 3675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently purchased a Quad core machine (Q6600). Now, I've always thought that most of the time the 1st core is used and the other 3 only when the program/game/application is programmed to utilize it. When buying; another store salesman even said it was totally useless to have a quad core CPU if the software isn't programmed to utilize it.(it could be even result in less performance). After a good 3 weeks, and watching the task manager, I've noticed that even in most old programs All 4 cores are indeed utilized. Example: flight simulator 9 (from 2003) , when calculating scenery data, uses all 4 of them. When rendering not. And, even in my current project, which is one-threaded and in no way optimizeed, i see that all 4 cores are calculating. (I checked no other resources are running), and I'm running Vista 32 bit with all updates). How is this possible? Is the task manager reliable in this regard?

Share this post


Link to post
Share on other sites
Advertisement
I'd guess that either Vista is task switching your process to other cores, or there's other threads active you don't know about. If you go to the "Select Columns" option in the menu in Task Manager, and enable the number of threads column, do you only see one for your process?

Share this post


Link to post
Share on other sites
> about. If you go to the "Select Columns" option in the menu in Task Manager
I can't find this option, really. I can see only 1 process running for my (fairly simple) application. I'm running Vista home premium.
But if I run my game from the IDE, all cores are used to a certain extend, and when I stop they remain idle. And sometimes only core 4 is used to the maximum, and the first threee are only slightly calculating.

> I'd guess that either Vista is task switching your process to other cores

I didn;t even know this was possible.

Share this post


Link to post
Share on other sites
Sometimes, the operating system uses threads without your knowledge. For example asynchronous I/O under Windows works that way. nVidia display drivers are multithreaded, and while I don't know about ATI, they very likely are too. So your program may be multithreaded under the hood without you knowing.

Also, there may be other things running (like your application firewall, G-keyboard applets, indexing, various things in explorer) which the operating system will of course schedule to an idle core whenever possible.
Therefore, your spare cores are never 100% idle, and while having 4 cores doesn't make your computer 4 times faster, it certainly doesn't hurt.

Share this post


Link to post
Share on other sites
There's no rule that the OS has to prefer the first core. It can use any core it likes, and even switch which core the application runs on a hundred times per second, which will smooth out the CPU usage, giving every core a bit of usage.
Keep in mind that Task Manager only shows an average, over the last second or so. (It doesn't really make sense to talk about the CPU usage "now", because at any given clock cycle, a core is either executing instructions (which means it's running at 100%), or it's not (0%).

15% CPU usage, or any other non-extreme value, is only possible if you average the CPU activity over time.

And over time, Vista might decide to give you a bit of time on each of the four cores. (In addition to what has been said about other processes or drivers using the CPU)

Share this post


Link to post
Share on other sites
Windows will always schedule processes to run on the various cores. Even if they just run in 1 thread, they could run on each of the cores. If your application runs more than 1 thread, Windows will attempt to run these threads on the various cores so that they can indeed run simultaneously.

If you're debugging, Visual Studio will run various threads internally to monitor your application and will therefor put stress on the other cores. So it's a good thing that other cores are being stressed.

Samoth: If he doesn't use threads himself in his code, it won't be secretly threaded by the compiler.

Toolmaker

Share this post


Link to post
Share on other sites
Quote:
Original post by Marmin

How is this possible? Is the task manager reliable in this regard?


Enable the "Threads" column.

You may be surprised how many threads there actually are.

Firefox right now is running 15 threads, svchost around 130, taskmgr 3, explorer 12, and so on....

And due to scheduling, OS is free to run thread on any core.

Quote:
When buying; another store salesman even said it was totally useless to have a quad core CPU if the software isn't programmed to utilize it


For the sake of that application, that is true. If it really doesn't use extra threads (overlapped IO under windows does, for example, it just depends on how many), then the application will not run faster than it would on individual core, regardless of which one runs it.

Quote:
Example: flight simulator 9 (from 2003) , when calculating scenery data, uses all 4 of them.


Multi-threaded programming was used well before 2003, and especially in something like FS it would make sense.

Threads are not part of application, they are managed by OS. If you have multi-threaded application, it will benefit somewhat from using multiple cores.

The question is - does this mean it will scale. Generation of terrain is text-book example of algorithm which can be trivially converted to use arbitrary number of threads, or run in single one.

Asynchronous operations can also benefit multi-threading, regardless of how many physical cores there are.

But just because an application was compiled long ago, it has no effect on how threads are handled. It just comes down to OS.

Quote:
(I checked no other resources are running)


Under Windows, at any given time, you have dozens services running actively. Not up to 100%, but definitely running.

Share this post


Link to post
Share on other sites
Quote:
Original post by Toolmaker
Samoth: If he doesn't use threads himself in his code, it won't be secretly threaded by the compiler.
Read carefully, please. I was referring to display drivers and the operating system, not the compiler.

As for the nVidia display driver example, nVidia drivers are multithreaded since late 2005 or early 2006 (don't remember exactly). It is likely that ATI drivers are working the same (although I don't know for sure).
So, if you write a game that uses Direct3D or OpenGL, and you submit your vertex data, draw commands, and whatever, the further handling will run in a different thread (or several of them). Thus, under the hood, your program effectively runs on multiple cores, even if you never thought it might.

As for the example of asynchronous IO, please refer to Microsoft's support pages where it explains "the request will be handled by a limited pool of worker threads". In other words, your single-threaded application queues a request, but multiple threads are doing the work behind your back.

There are many more examples, such as 3rd party libraries. For example when you play a sound source in OpenAL, control returns to your application immediately. Nevertheless, sound can still be heard several seconds/minutes later. Therefore, playback must obviously be happening in a different thread, even though for most application writers it's sufficient to know that it "just works".

Share this post


Link to post
Share on other sites
Say you had a computer with a 1 GHz single core CPU and another computer that has a 1 GHz quad core CPU. A single threaded application should run at the same speed on both, provided the remaining hardware is equal. At least in theory.

As others have pointed out, a modern OS does a lot "under the hood". Access to the hardware may be handled asynchronous, allowing your application to continue when you'd expect it to wait. Also modern GUI applications (think .NET) usually have several threads "built-in", without you needing to know or care about it.

Another thing that happens in the background is a kind of load balancing. The OS may shift long running tasks from one core to the other in order to distribute heat dissipation evenly across the CPU (read this somewhere, don't remember the source). It will also distribute processes running at the same time to different cores. So instead of having four single threaded applications share 25% of a single core, they now each get 100% of a separate core (depends on how CPU intensive they are, of course).

~edit
Quote:

Quote:
Original post by Marmin
If you go to the "Select Columns" option in the menu in Task Manager

I can't find this option, really. I can see only 1 process running for my (fairly simple) application. I'm running Vista home premium.

Start Task Manager. Go to the Tab "Processes". No click "View > Select columns" in the menu. There should be lots of additional columns to select. Unless they removed that from Home Premium.

Otherwise, get Process Explorer from Sysinternals (now owned my MS), it's got a lot of additional "toys" ;).

Share this post


Link to post
Share on other sites
I found it :D.
My app/game runs 11 threads. It uses SDL in OpenGL mode. It must be the new NVidea graphics card inside the machine that is running the threads, then.
Thanks for the info.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!