Jump to content
Sign in to follow this  
BWBriscoe

Affinity mask: word not allowed's guide

Recommended Posts

7 hours ago, G MIDY said:

This tweak controls which CPU cores Prepar3D can use. However, Prepar3D cannot utilize multiple cores for a task and so it executes code in a singular way across single cores. A more modern approach would be to perform a single task across multiple cores so that the load is spread. You can see this in the task manager, if you load up Prepar3D and have a lot of AI, autogen etc then one of the cores will likely be getting hit 100%, the others however will barely be doing anything.

If you set an AM then Prepar3D will only be able to execute code on certain cores based upon that setting but the fundamental behaviour is still the same. Think of it as this, if you set AM to use 6 CPU cores then you have 6 people available to do any particular job. However, it still remains a problem that you cannot ask 2 people to help each other to do the same job so in reality the tweak will make no difference at all.

The default behaviour is that Prepar3D has all cores available so you are most likely to get maximum performance by leaving the tweak out. The only benefit I can see is setting an AM may help stability if you have lots of other things running in the background. For example you may wish to prevent Prepar3D from using a core to enable other applications to use that core.

The P3D Affinity Mask controls which logical processors P3D can use, not which cores per se--a "core" is a physical processor, and on intel CPUs with hyperthreading enabled (or AMD CPUs with SMT) each physical core supports two virtual, or "logical" processors that are separately considered when applying the AM mask.  Second, P3D does split off a considerable amount of its work into separate processes, called threads.  Those threads can, in turn, be assigned to any free LP by the OS (provided it's not masked out by the AM).  The main thread...the "heartbeat' of the simulation that directs everything else, runs in one big and very busy thread on the first LP available to the program.

In a CPU with HT or SMT enabled, each pair of LPs share a physical processing core and its L3 cache memory.  If you run with HT/SMT enabled, it's important to at least mask off one of the two LPs on the core that runs the main thread (P3D loads the main thread onto the first LP available to it), because you don't want that main thread competing for resources (processing time or available L3 cache) with other P3D threads that could be assigned by the OS to that core's shared LP.  If HT/SMT is disabled, an LP is synonymous with a physical core...and to make matters even more complex, on 10th/11th gen intel CPUs you can selectively turn HT on/off for individual cores.

Also, it's possible to have "too many cooks in the kitchen" where having threads assigned across too many LPs starts causing issues with thread scheduling and synchronization.  My experience suggests that 10 LPs is something of a sweet spot, or point of diminishing returns for P3D at present...so with a 10-core CPU I leave HT off and don't assign an AM, allowing the program to use all 10 physical cores.  When I ran P3D on a quad-core i7-7700K, however, HT on worked better--but only with an AM that blocked one LP on core 0 to prevent a lot of microstuttering.  In that use case, the tweak made a clear difference in performance.

 

 

  • Upvote 2

Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

System1 (P3Dv5/v4): i9-13900KS @ 6.0GHz, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@30Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU, 1.2Gbps internet
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys2 (MSFS/XPlane): i9-10900K @ 5.1GHz, 32GB 3600/15, nVidia RTX4090FE, Alienware AW3821DW 38" 21:9 GSync, EVGA 1000P2
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, 2x TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Portable Sys3 (P3Dv4/FSX/DCS): i9-9900K @ 5.0 Ghz, Noctua NH-D15, 32GB 3200/16, EVGA RTX3090, Dell S2417DG 24" GSync
Corsair RM850x PSU, TM TCA Officer Pack, Saitek combat pedals, TM Warthog HOTAS, Coolermaster HAF XB case

Share this post


Link to post
49 minutes ago, w6kd said:

When I ran P3D on a quad-core i7-7700K, however, HT on worked better--but only with an AM that blocked one LP on core 0 to prevent a lot of microstuttering.  In that use case, the tweak made a clear difference in performance.

I think this is a key element for people who aren't using AffinityMask to consider:

Considering the sim uses LP0 much more than any other LP, it's important to (at the very least) get the sim off of LP1 (the second LP of core 0). You don't want to be potentially taking resources from LP0 which for most people is the bottleneck to performance. 

Every binary AM setting used in P3D should end with 01. After that, we can debate HT/noHT for the other cores all day long. 

And from my experience (at least in 4.5), leaving out LP0 in any way completely breaks the sim. It performs great as long as you fly, but nothing will ever load beyond the initial loading phase, resulting in severe blurries. 

  • Upvote 1

Share this post


Link to post
7 minutes ago, DChockey08 said:

Every binary AM setting used in P3D should end with 01. After that, we can debate HT/noHT for the other cores all day long.

If you have 8 or 10 cores yes, less than that you may need to double one or two up, especially if you need to keep cores free for 3rd party apps.


Kevin Firth - i9 10850K @5.2; Asus Maximus XII Hero; 32Gb Cas16 3600 DDR4; RTX3090; AutoFPS; FG mod

Beta tester for: UK2000; JustFlight; VoxATC; FSReborn; //42

xaP1VAU.png

Share this post


Link to post
25 minutes ago, kevinfirth said:

If you have 8 or 10 cores yes, less than that you may need to double one or two up, especially if you need to keep cores free for 3rd party apps.

Agreed, but to be clear I was referring only to core 0, which comes at the end of the binary string - so LP0 on and LP1 off.

What settings should be used on other cores depends on many things. But anyone with at least a quad-core HT-enabled CPU should be turning off LP1. 

Share this post


Link to post

So, based on 

7 hours ago, w6kd said:

When I ran P3D on a quad-core i7-7700K, however, HT on worked better--but only with an AM that blocked one LP on core 0 to prevent a lot of microstuttering.  In that use case, the tweak made a clear difference in performance.

what would be the affinity mask entry for an Intel Core i7-8700K CPU (6 cores with 12 LPs) with HT on?

In the Prepar3D.cfg file, I would have...

[JOBSCHEDULER]
AffinityMask=???


dv

Win 10 Pro || i7-8700K ||  32GB || ASUS Z370-P MB || NVIDIA GeForce GTX 1080 Ti 11Gb || 2 960 PRO 1TB, 840 EVO

My Files in the AVSIM Library

Share this post


Link to post
11 hours ago, kevinfirth said:

How can you be sure that the main thread stays on core 2 for the duration?

Check the screen pics, see core #3 and that big gap between the red (kernal code) and green (user code), that's the main thread at work and it's always on #3 because that is where the affinity mask placed it. 

And then all we are then doing is saying - hey also use Core 0 & 1.

Check, check and away we go.

Cheers


Ryzen 5800X clocked to 4.7 Ghz (SMT off), 32 GB ram, Samsung 1 x 1 TB NVMe 970, 2 x 1 TB SSD 850 Pro raided, Asus Tuf 3080Ti

P3D 4.5.14, Orbx Global, Vector and more, lotsa planes too.

Catch my vids on Oz Sim Pilot, catch my screen pics @ Screenshots and Prepar3D

Share this post


Link to post
28 minutes ago, David Vega said:

what would be the affinity mask entry for an Intel Core i7-8700K CPU (6 cores with 12 LPs) with HT on?

In the Prepar3D.cfg file, I would have...

[JOBSCHEDULER]
AffinityMask=???

Check the link provided in this post

The cacluator will generate the value based on the boxes you've ticked.

Couldn't be any easier, HT/SMT on or off or just straight cores with no HT/SMT.

You'd probably want to put P3D on the cores and not the threads.

But hey it's only a few lines of text in the Prepar3d.cfg - do feel free to experiment for what would work best for yourself.

Cheers


Ryzen 5800X clocked to 4.7 Ghz (SMT off), 32 GB ram, Samsung 1 x 1 TB NVMe 970, 2 x 1 TB SSD 850 Pro raided, Asus Tuf 3080Ti

P3D 4.5.14, Orbx Global, Vector and more, lotsa planes too.

Catch my vids on Oz Sim Pilot, catch my screen pics @ Screenshots and Prepar3D

Share this post


Link to post

On clean install of W11 Insider preview with P3D 5.2. AffinityMask is redundant. OS spreads the load over more cores by default. Running on 11900k. Not sure what Ryzen or 10th Gen down would look like.

Edited by 40track
Word now allowed fixed

Share this post


Link to post
On 8/27/2021 at 9:30 PM, 40track said:

On clean install of W11 Insider preview with P3D 5.2. AffinityMask is redundant. OS spreads the load over more cores by default. Running on 11900k. Not sure what Ryzen or 10th Gen down would look like.

I think you have a misconception of what AM is supposed to do--its purpose is to *limit* the LPs to which P3D threads can be assigned, not to improve tasking across the available LPs.

  • Like 2

Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

System1 (P3Dv5/v4): i9-13900KS @ 6.0GHz, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@30Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU, 1.2Gbps internet
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys2 (MSFS/XPlane): i9-10900K @ 5.1GHz, 32GB 3600/15, nVidia RTX4090FE, Alienware AW3821DW 38" 21:9 GSync, EVGA 1000P2
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, 2x TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Portable Sys3 (P3Dv4/FSX/DCS): i9-9900K @ 5.0 Ghz, Noctua NH-D15, 32GB 3200/16, EVGA RTX3090, Dell S2417DG 24" GSync
Corsair RM850x PSU, TM TCA Officer Pack, Saitek combat pedals, TM Warthog HOTAS, Coolermaster HAF XB case

Share this post


Link to post
2 hours ago, w6kd said:

I think you have a misconception of what AM is supposed to do--its purpose is to *limit* the LPs to which P3D threads can be assigned, not to improve tasking across the available LPs.

Yes was thinking wrong about it. Good call.

Edited by 40track

Share this post


Link to post
On 8/27/2021 at 1:29 PM, kevinfirth said:

I have found through trial and error that my system works best with HT on (so 20 virtual cores), and an AM set of 00000101010101010101.

Kevin, did you play with something like 00001111111101010101?

1111010101010101 seemed to work a tad better on my i9 9900K  or it was something else  ))

Thanks.

Share this post


Link to post
5 hours ago, Dirk98 said:

Kevin, did you play with something like 00001111111101010101?

1111010101010101 seemed to work a tad better on my i9 9900K  or it was something else  ))

Thanks.

I've found about 8 logical/physical cores appears to be the sweet spot for maximum performance without overloading the main rendering thread.  The 10 core 10850K permits 8 physical cores to be used by P3D, one thread per each, leaving 2 physical/4 virtual cores for other add-ons.  All is peachy for me 🙂


Kevin Firth - i9 10850K @5.2; Asus Maximus XII Hero; 32Gb Cas16 3600 DDR4; RTX3090; AutoFPS; FG mod

Beta tester for: UK2000; JustFlight; VoxATC; FSReborn; //42

xaP1VAU.png

Share this post


Link to post

I'm wondering how many AM threads do exist in this forum. Since I have a 8 core machine, I keep hyperthreading off and leave AM out of the game. That turned out to be the best for my system and P3D/MSFS experience. YMMV.


- Harry 

i9-13900K (HT off, 5.5 GHz, Z690) - 32 GB RAM (DDR5 6400, CAS 34), RTX 3090Windows 11 Pro (1TB M.2) - MSFS 2020 (MS Store, on separate 4TB M.2).

 

 

 

Share this post


Link to post
2 hours ago, kevinfirth said:

I've found about 8 logical/physical cores appears to be the sweet spot for maximum performance without overloading the main rendering thread.  The 10 core 10850K permits 8 physical cores to be used by P3D, one thread per each, leaving 2 physical/4 virtual cores for other add-ons.  All is peachy for me 🙂

4 first threads (including the main one, of course) per 1 physical core each (0-3) for Prepar3D.exe is common knowleadge. My question question was about mixing further threads on cores 4-7, but never mind.

Do I read you right your 10 core 10850K permits only 8 physical cores to be used by P3D or did I miss something with the latest 10K CPUs? Must be all 10 should you want it (hex 55555 and I know all 10 cores for Prepar3D.exe may work counterproductive).

Edited by Dirk98

Share this post


Link to post
6 minutes ago, Dirk98 said:

4 first threads (including the main one, of course) per 1 physical core each (0-3) for Prepar3D.exe is common knowleadge. My question question was about mixing further threads on cores 4-7, but never mind.

Do I read you right your 10 core 10850K permits only 8 physical cores to be used by P3D or did I miss something with the latest 10K CPUs? Must be all 10 should you want it (hex 55555 and I know all 10 cores for Prepar3D.exe may work counterproductive).

Sorry I'll be more specific!

Yes I tried mixing further threads but didn't perceive much if any improvement.

I choose only to use 8 of the 10 cores for P3D, could use all 10, but 8 gives my great performance and leaves 2 cores free for other apps.

  • Like 1

Kevin Firth - i9 10850K @5.2; Asus Maximus XII Hero; 32Gb Cas16 3600 DDR4; RTX3090; AutoFPS; FG mod

Beta tester for: UK2000; JustFlight; VoxATC; FSReborn; //42

xaP1VAU.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...