FS2004 Affinity Tool for MULTI-core computers.

All things Military AI that don't fit anywhere else.
MIKE JG
MAIW Veteran
MAIW Veteran
Posts: 10976
Joined: 12 Aug 2006, 02:25
Version: MSFS

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by MIKE JG »

Sweet!!!!!!!!!!!!! :smt003
-Mike G.

Recovering flight sim addict, constant lurker.

Check out my real life RV-8 build here: RV-8 Builder Log
hgschnell
First Lieutenant
First Lieutenant
Posts: 111
Joined: 12 Feb 2011, 08:36
Version: FS9

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by hgschnell »

here is a Turkish discussion about the creation of fs2004 affinity tool :
http://www.sanalpilot.com/forum/topic.a ... hichpage=1

there are also parts of source code included (page 2 and later), perhaps anyone can find out how it works?

Code: Select all

;start loop
While 1
	$pMsg = ProcessExists ( "fs9.exe" )
	$pMsg2 = ProcessExists ( "fs9.exe" )
	$pMsg3 = $pMsg + $pMsg2
	if $pMsg3 and $dcsRunning = 0 Then; disables all but exit, cpu and save controls
		GUICtrlSetState ( $SinglePlayerButton, $GUI_DISABLE )
		$dcsRunning = 1
		GUISetState ( @SW_MINIMIZE )
	ElseIf $dcsRunning = 1 and $pMsg3 = 0 Then; reenable all controls
		GUICtrlSetState ( $SinglePlayerButton, $GUI_ENABLE )
		$dcsRunning = 0
		GUISetState ( @SW_RESTORE )
	EndIf
	$affcheck = ProcessSetAffinity($pMsg, 255);get current fs9.exe affinity
	if $pMsg AND $affcheck <> $cpuType then; check affinity versus settings
		sleep(10)
		ProcessSetAffinity($pMsg, 255);set affinity
		sleep(10)
		SplashOff ()
		EndIF
	sleep(10)
WEnd
;endloop
Guenther
User avatar
Firebird
MAIW Admin
MAIW Admin
Posts: 12399
Joined: 11 Aug 2006, 21:04
Version: FS9
Location: EGLL

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Firebird »

Hmmm, 3 weeks ago I finally let my Amiga 3000T go.
Steve
_______________________________________________________
Image
Quid Si Coelum Ruat
_______________________________________________________
MIKE JG
MAIW Veteran
MAIW Veteran
Posts: 10976
Joined: 12 Aug 2006, 02:25
Version: MSFS

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by MIKE JG »

Watch it! :smt062


:mrgreen:
-Mike G.

Recovering flight sim addict, constant lurker.

Check out my real life RV-8 build here: RV-8 Builder Log
fishlips

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by fishlips »

I'm still using a Dell 3.2ghz single core even though I have a new quad core desk PC and a duel core laptop.
There's just something about the single core. I guess it assures me of good frame rates for other peoples PC's when developing scenery models.

Mark G
User avatar
petebramley
MAIW Developer
MAIW Developer
Posts: 1545
Joined: 17 Jun 2007, 16:05
Version: P3D
Location: EGBG

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by petebramley »

Firebird wrote:Hmmm, 3 weeks ago I finally let my Amiga 3000T go.

I still have a Commodore C64 in the loft somewhere

:D :D :D
Pete B
Retired and busier than ever !!
hgschnell
First Lieutenant
First Lieutenant
Posts: 111
Joined: 12 Feb 2011, 08:36
Version: FS9

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by hgschnell »

I have an old windmill ...

but please gentlemen, back to topic ....

:roll:
Guenther
User avatar
Weescotty
MAIW Developer
MAIW Developer
Posts: 2787
Joined: 11 Aug 2006, 22:15
Version: P3D
Location: Sydney

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Weescotty »

Can help with the code - First it is not the complete code.

Appears to be written with AutoIt.
Anything beginning with a $ sign is a variable.
The code 'snippet' calls a function (subroutine) called ProcessSetAffinity passing two variables to the function (
$pMsg (fs9 process Id) and 255).

First two lines check if the fs9 executable is running (ProcessExists). If it is, it sets the variable to the ProcessID (PID) of fs9.exe, if not it returns 0.
Third line adds the two results together.

Gets tricky from then on as it introduces other variables ($dcsRunning, $cpuType etc) and the code doesn't show what they are supposed to represent.

The stuff beginning with GUI are all to do with changing a button called $SinglePlayerButton to either be enabled or disabled on the GUI. (usable or greyed out)

Sleep 10 - tells the program to wait 10 milliseconds before proceding.
SplashOff() - Turns off a previously visible 'message screen' - SplashOn() (not in this bit of code)

Wish I knew what dcsRunning was for.
hgschnell
First Lieutenant
First Lieutenant
Posts: 111
Joined: 12 Feb 2011, 08:36
Version: FS9

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by hgschnell »

thanks a lot,

there is a new version (one for all kinds of Multicore CPUs) available.

(to big for attachment)

http://airbustakeoffsetings.blogspot.com/
Guenther
User avatar
Weescotty
MAIW Developer
MAIW Developer
Posts: 2787
Joined: 11 Aug 2006, 22:15
Version: P3D
Location: Sydney

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Weescotty »

If you use Vista or above -

In the shortcut to FS9 replace the Target entry with -

C:\Windows\System32\cmd.exe /C start/affinity <NUM> fs9.exe

Replace <NUM> with - hexadecimal based on -

Core0 = 1
Core1 = 2
Core2 = 4
Core3 = 8
Core4 = 16
Core5 = 32
NOTE - cores start from 0

To allow cores 0, 2 and 3 = 1 + 4 + 8 = 13 = D in hex.

Probably most useful would be to prevent FS9 running on core 0 (OS core)
So for -
hexes use - 2 + 4 + 8 + 16 + 32 = 62 = 3E in hex
quads use - 2 + 4 + 8 = 12 = 14 = E in hex
Tris use - 2 + 4 = 6 = 6 in hex
Duals use - 2 = 2 = 2 in hex

I do know that whetever that program does it does NOT force FS9 to use all cores (or 1 big virtual core), AMD and Intel have both been trying to find a way to make single core apps utilise multi-core for years, WITHOUT success.

NOTE - THIS WILL NOT WORK ON XP

[edit] I am going to try C (12) which will limit FS9 to cores 2 and 3, leaving cores 0 and 1 for the OS etc
hgschnell
First Lieutenant
First Lieutenant
Posts: 111
Joined: 12 Feb 2011, 08:36
Version: FS9

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by hgschnell »

Weescotty wrote:...

I do know that whetever that program does it does NOT force FS9 to use all cores (or 1 big virtual core), AMD and Intel have both been trying to find a way to make single core apps utilise multi-core for years, WITHOUT success.
...
everything looks like the program is setting every 10 ms a new cpu affinity.

this has 2 effects:
- the taskmanager displays 2 cpus at 50 percent at a 2 core cpu

- fs9 feels "smoother" because it has to leave control more often for steering inputs ...

the only question for me is: why does it continue working, if I close down the program when fs9 is running???
Guenther
User avatar
Weescotty
MAIW Developer
MAIW Developer
Posts: 2787
Joined: 11 Aug 2006, 22:15
Version: P3D
Location: Sydney

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Weescotty »

hgschnell wrote:
Weescotty wrote:...

I do know that whetever that program does it does NOT force FS9 to use all cores (or 1 big virtual core), AMD and Intel have both been trying to find a way to make single core apps utilise multi-core for years, WITHOUT success.
...
everything looks like the program is setting every 10 ms a new cpu affinity.

this has 2 effects:
- the taskmanager displays 2 cpus at 50 percent at a 2 core cpu

- fs9 feels "smoother" because it has to leave control more often for steering inputs ...

the only question for me is: why does it continue working, if I close down the program when fs9 is running???
Interesting.
In which case I would guess the taskmanager display can't keep up with the change in load on each core.
I'll hazard a guess - The feeling it is smoother, is just that 'a feeling'. Swapping a program from one core to another
will not affect the overall load, however it may be switching to a core (albeit not for long) that isn't as heavily loaded as the one it was on.
Therefore if you lock it to that lightly loaded core, you should see the same results.
1st Shirt

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by 1st Shirt »

So are you saying that this might be a case of "smoke and mirrors"? Is it actually running on multiple cores or is it just switching from one to another every so many micro-seconds?
MIKE JG
MAIW Veteran
MAIW Veteran
Posts: 10976
Joined: 12 Aug 2006, 02:25
Version: MSFS

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by MIKE JG »

My brain hurts after reading all that.....
-Mike G.

Recovering flight sim addict, constant lurker.

Check out my real life RV-8 build here: RV-8 Builder Log
User avatar
btaylo24
MAIW Staff
MAIW Staff
Posts: 2747
Joined: 07 Sep 2006, 10:57
Version: P3D

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by btaylo24 »

Process SetAffinity function is in task manager anyway, just right click in processes and you can set affinity to cores.
In resource monitor I cant see any difference in CPU usage from using this or not.
Barry
hgschnell
First Lieutenant
First Lieutenant
Posts: 111
Joined: 12 Feb 2011, 08:36
Version: FS9

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by hgschnell »

1st Shirt wrote:So are you saying that this might be a case of "smoke and mirrors"? Is it actually running on multiple cores or is it just switching from one to another every so many micro-seconds?
it is switching in my opinion, but with a positive side effect of smoothing fs2004 ...

:smt021

(the smiley is for Mike)
Guenther
User avatar
Weescotty
MAIW Developer
MAIW Developer
Posts: 2787
Joined: 11 Aug 2006, 22:15
Version: P3D
Location: Sydney

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Weescotty »

1st Shirt wrote:So are you saying that this might be a case of "smoke and mirrors"? Is it actually running on multiple cores or is it just switching from one to another every so many micro-seconds?
NOT running on multiple cores.
Applications have to be specifically written to take advantage of multiple CPUs or cores.
No amount of switching affinity or anything else can make a single CPU app run on anything more than a single CPU / core at any point in time. AMD and Intel have been trying to find a way of doing it since multi cores first came out.
I think what we are seeing is the inability of the task manager display keep up with FS9 being rapidly switched between cores, so maybe it displays the load on one core as an average across all the cores it is being switched to.

Not 100% sure to be honest, but as I have said, it is impossible to make a single core app run on multiple cores.

What would be useful on a quad core -
OS - core 0
FS9 - Core other, say 1
FS9 addons (REX etc) - Core other, say 2
Core 3 free for anything else
1st Shirt

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by 1st Shirt »

Thanks for the clarification Weescotty, it's a shame it can't be done but there you are. I guess setting each core as you describe is the best we're going to get.
User avatar
Firebird
MAIW Admin
MAIW Admin
Posts: 12399
Joined: 11 Aug 2006, 21:04
Version: FS9
Location: EGLL

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by Firebird »

When I got my Quad core thingy, some years ago, and I tried to set it so that FS9 only ran in one core and everything else ran in the other three, as I thought that this would cure a lot of issues. It actually made it worse. A lot of stuttering and white objects when new scenery was being loaded. It seemed to work fine for initial loading but once a followed aircraft got airborne it got quite bad. I abandoned the idea.
My conclusion was that the one core assigned to FS9 was waiting for ancillary tasks to complete before it could resume. Still if it works for some people, go for it.
Steve
_______________________________________________________
Image
Quid Si Coelum Ruat
_______________________________________________________
1st Shirt

Re: FS2004 Affinity Tool for MULTI-core computers.

Post by 1st Shirt »

Don't get me wrong, I don't have doubts about what this app provides, I still use it and still find that the impression, effect, feeling, whatever you want to call it is still one of a "smoother" ride than before. I was only showing a little disappointment at what Weescotty showed as being a sequential switching of cores as opposed to all cores being used simultaneously which obviously would be the preferred option.

As with everything concerned with FS, it all comes down to each person's idea of what matches reality as they perceive it; whether it be scenery, AI, user A/C or utilities and add-on software. What I find incredible about FS is its versatility and almost endless capacity to be tweaked and the abilities of all the talented folks who add to it for the benefit of the talent-challenged users out there like me :D

I'll probably continue to use this add-on (like all others that I've installed) until something better comes along or I find that it conflicts with something I can't live without in my FS world.
Post Reply