 |
 |

03-22-2008, 04:56 PM
|
|
Newcomer
|
|
Join Date: Sep 2006
Posts: 12
|
|
Programs launched from VB only running on one processor core
|
I'm using the Process class in VB.Net 2005 to launch multiple instances of a number-crunching Fortran program (exe file). I'm running on a dual-core Athlon with XP-64. I expected execution of the apps to be automatically spread among the two cores, but instead they all get assigned to core 1 (the second core, even though core 0 utilization is very low. A sample code fragment used to launch each instance is as follows:
Code:
Proc = New Process
Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Proc.StartInfo.FileName = "MyFortranApp.exe"
Proc.StartInfo.Arguments = MyFortranAppArgs
Proc.Start()
I've also tried adding both of the following code variants with no change:
Code:
Proc.ProcessorAffinity = 0
Proc.ProcessorAffinity = 3 ' this is the default for my dual core if not specified
Besides explicity setting the processoraffinity to a specific core for each instance launched are there other ways to get the work distributed more evenly among the cores?
Thanks,
Mark
|
|

03-22-2008, 05:17 PM
|
 |
Fabulous Florist
Forum Leader * Guru *
|
|
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
|
|
Sadly, the .NET Framework is, for the most part, not aware of multiple processing cores. Code has to be written a special way to take advantage of this feature, and even when the 2.0 CLR (which the 3.0 and 3.5 frameworks still use) was being developed, multiple-core systems were not common.
You can download the Parallel Extensions to the .NET Framework 3.5. Note that download link might be out of date; it's what I found when google searching. The extensions introduce some stuff that apparently help you get parallelism into your application.
Still, that won't get your Fortran application to magically start putting parallel tasks onto another core; even when an application claims to be using both cores I'm pretty sure it gets no benefits unless it was actually written to execute parallel tasks on different threads. I may be wrong though.
|
|

03-23-2008, 09:49 AM
|
|
Newcomer
|
|
Join Date: Sep 2006
Posts: 12
|
|
Thanks AtmaWeapon,
Actually, I'm not trying to get the applications that I launch to multiprocess, I'm just trying to get them to distribute evenly among the cores. For example, if I launch 4 instances of an application then ideally I'd like to see (example only) that the first automatically goes to core 1, the second goes to core 0, the third goes to core 1 and the fourth goes to core 0. Even if they initially all go to one core, it was my impression that the OS would automatically shuffle them among the cores to even the processor load if ProcessorAffinity is 0 or 2n-1 (3 in my case).
It seems if I manually launch the four example instances from a cmd window as follows then the OS does distribute them among the cores as I would expect.
Code:
C:\> MyFortranApp.exe Args1
C:\> MyFortranApp.exe Args2
C:\> MyFortranApp.exe Args3
C:\> MyFortranApp.exe Args4
So I remain a bit stumped and will continue to experiment...
|
|

03-24-2008, 01:36 AM
|
 |
Joseph Koss
* Guru *
|
|
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
|
|
|
If your fortran aps are distributing evenly with the 4 instances case then I can't see how your affinity assignments are being applied. Is the current F# very strict about its threading?
In any case, I would let the operating system worry about CPU allocation if and when possible. Your attempts to balance the load may interfere with the OS's attempt to balance the load.
Load balancing can be done for many reasons. Sometimes it matches the implied goal of most work in least time, whereas other times the implied goal may be to avoid or target a specific core. A core may be dedicated to servicing a high priority group of tasks. It may be being avoided do to an energy saving feature. The OS may favor foreground applications over applications without focus. This isnt generally your call.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|