|
-
October 6th, 2008, 10:50 PM
#1
Proof of core utilization in a program
Hi,
Basically, I wanted to display to an audience how an application having multiple tasks executing in multiple threads pans out across multiple cores.
Basically, imagine that I have two for loops running from 0 to 10,00 and printing some data in the loop. Now, I implement two threads (native threads) in which I run the loops.
Now, I want to show the audience that the two threads are running on separate cores (I have a Centrino Duo machine) instead of timesharing on the same core.
Now, is it possible to provide any visual proof of this fact on Windows - programatically on using the Windows Task Manager (Performance) window ?
Basically, wanted a simple implementation and proof because this is for an introduction to beginners in the world of multicore and parallel programming.
Thanks.
-
October 7th, 2008, 02:45 AM
#2
Re: Proof of core utilization in a program
You can see in the task manager that PC with 2 cores will have 2 CPU utilization graphs and PC with 4 cores will have 4 CPU graphs. You can show that the all the CPUs are fully utilized if the graphs are all at 100% utilization.
But from 0 to 1000 loop, I dun think you can utilize the CPUs to 100%.
-
October 7th, 2008, 08:55 AM
#3
Re: Proof of core utilization in a program
The best approach would be to do a parallelizable math-heavy algorithm. And spare the IO----that just slows things down.
-
October 9th, 2008, 07:11 AM
#4
Re: Proof of core utilization in a program
I think i have a question related to that but my question is:
If i have two functions, running "same time" how can i make that each function to run on separate cores?
Can i do that, or the OS is responsable for that. I think they have to be some API's in order to do that.
-
October 9th, 2008, 04:02 PM
#5
Re: Proof of core utilization in a program
I forget the function calls, but search for "processor affinity" on the MSDN.
Viggy
-
October 9th, 2008, 06:54 PM
#6
Re: Proof of core utilization in a program
 Originally Posted by coricori
Can i do that, or the OS is responsable for that. I think they have to be some API's in order to do that.
You CAN do that (as MrViggy suggested) by calling SetThreadAffinityMask for each thread.
However, you SHOUD let OS decide what core to run your stuff on.
I am pretty sure that if the cores are available, the OS will use as many as there are concurrent threads running at the time.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
October 11th, 2008, 08:13 AM
#7
Re: Proof of core utilization in a program
 Originally Posted by MrViggy
I forget the function calls, but search for "processor affinity" on the MSDN.
Viggy
How do you guys use MSDN? Did you had to solve this kind of problem, or how did u know that keyword to use( and now to recommend me )?
I tried the online version of MSDN, and I really dislike it. I couldn't imagine how to use it in a proper and productive way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|