Author Topic: Processor Affinity with Knossos  (Read 792 times)

0 Members and 1 Guest are viewing this topic.

Offline AV8R

  • 28
Processor Affinity with Knossos

Is there a way to set processor affinity using Knossos?

Launcher 5.5g used to use a registry setting under Volition's subkey in HKLM/Software (ProcessorAffiinty=x).

Can this be done when running an FSOpen EXE thru Knossos so it will run on a specific processor?


Offline AV8R

  • 28
Re: Processor Affinity with Knossos
Sorry to necro this thread, but it still may contain relevant information for myself and others, so here I go:

So I finally stumbled upon the Processor Affinity setting I originally asked about in this thread (-set_cpu_affinity) listed under Troubleshooting in the Knossos launcher. Unfortunately, it requires an additional value which the wiki doesn't explain clearly. Also, if selected under Troubleshooting, it places the flag in the "Full Command Line" area of the FSO Settings box where you are unable to edit - and thus you cannot add a value behind the flag even if you wanted to.

Trying to "trick" the launcher by adding the -set_cpu_affinity flag to the custom flags area ends up with it being stripped from the custom area and added back into the Full Command Line area after hitting the save button (Knossos is a little too smart for its own good sometimes).

As far as the optional values go, I'm guessing it will follow the typical Windows Affinity value scheme of 0-3 on a 4 core processor (without Hyper-Threading). Perhaps additional values may be needed if HT is involved, but I'm just speculating.

Anyway, any input on how to properly use this flag in Knossos would be appreciated.

Re: Processor Affinity with Knossos
If you're thinking of splitting FSO's workload on multiple threads... That won't work. FSO is working nearly fully on a single thread (with the exception of something, I believe it might be audio codecs?) and has no way of splitting that onto more cores without a massive code rewrite... that I know of, at least.
How do you kill a hydra?

You starve it to death.


Offline AV8R

  • 28
Re: Processor Affinity with Knossos
Actually, I simply wanted it to run FSO on a single core - the one core on my processor that runs the coolest (Sandy/Ivy Bridge processors are notorious for their cores running at wildly different temperatures due to Intel switching from welding the heat spreader over the cores to using thermal compound instead). If I stress every core of my processor, one of them runs 20F degrees cooler than the other 3, so I like to force certain processes to use that particular core when I can - but obviously only for programs that I know are strictly single core processes, like FSO.
« Last Edit: May 25, 2020, 08:42:37 am by AV8R »


Offline AV8R

  • 28
Re: Processor Affinity with Knossos (SOLVED)
So I figured how to get this to work but it took some file editing that some users wouldn't/shouldn't edit:

1) I enabled Processor Affinity under the Troubleshooting tab in the Knossos launcher for the mod. This adds the -set_cpu_affinity flag under Full Command Line.
2) Since there is no secondary flag for this to add a value under Custom Flags, I located the file where these settings are stored in the mod's folder, which was "user.json".
3) I opened "user.json" and located the command string within the file and after the flag "-set_cpu_affinity" I simply added a space and a 1 for the value (be sure that -set_cpu_affinity is the last entry of the "Full Command Line" options or the added "space 1" will be added to the wrong area of the command line).
4) I saved the "user.json" file, ran the mod from Knossos and the FSO executable was indeed running on the specific CPU core I selected with this flag.

I discovered the basic usable values for "-set_cpu_affinity" and they seemed to be (on a 4 core processor):
Value    Use actual CPU core #
0          1
1          2
2          3
3          4

It looks as if "-set_cpu_affinity" uses the same CPU numbering as Windows' CPU affinity settings (0-3 and not 1-4) so keep that in mind when trying to use a specific core.

Eventually, perhaps a secondary flag switch could be added to FSO much like the new Anti-Aliasing options:

-aa                 Enables Anti-Aliasing (appears under Full Command Line options)
-aa_preset x   Sets anti-aliasing level (set under custom flag options)

And the affinity settings could look something like this:

-set_cpu_affinity  Enables Processor Affinity (appears under Full Command Line options)
-cpu 0                 Use CPU core 0 - same as Window's CPU Affinity setting 0 (set under custom flag options)
-cpu 1                 Use CPU core 1 - same as Window's CPU Affinity setting 1 ( etc, etc, etc...)

It's just a suggestion - but you guys are the experts. Handle it however you see fit (but, like I said earlier, users who want to use this setting now will have to edit their user.json file - a kludgey/risky option at best).

« Last Edit: July 07, 2020, 11:38:05 am by AV8R »