setting affinity for multiple cores on dual cpu system

0

1

We are using some systems with 2cpu's with 6 cores/12 threads each so 24 threads in total, for quite a lot of multitread simulations. Because the problem doesnt scale perfectly, i usualy run 4 problems in parralel, of 5 threads each. to have 4 cores left to run the 4 threads, that are starting the the simulations and pre- and postprocessing. I noticed some strange performance differences for identical simulations.

My idea was that by using affinity i could maybe regulate the performance a bit more, guiding the process not to be split over 2 cpu's, so that the problem doesnt get spread over different parts of the cache and memory, but remains fixed to a single cpu, or set of cores on the cpu.

I know how to set the affinity in the task manager, once the process is running, but i like to set it in a batch file.

for example:

start /affinity HEXNUM myprog3.exe

where HEXNUM is for example: 1F000 (the hex representation of 011111000000000000

if the aim was to run it on core:0,1,2,3,4 of cpu2

or HEXNUM 1F the hex represenation of 011111 if the aim is to run it on core 0,1,2,3,4 of cpu1.

But some how it does not seem to work, how i expect: when i start a simulation on 5 threads whithout affinity specification, the process takes 20-21% of cpu. when i start 5 treads, with affinity to 6 cores's it works also, but when i start 5 treads with affinity to 5 cores. it only takes 13% and if i look in the task manager, (windows 7 64 pro) it looks like it is only using core 1,3,5.

is there some problem using a uneven number of cores for the affinity specification? or am i doing something in the wrong way?

Are there any people that have experience using affinity specification, that managed to get some performance gains? What strategies did you use?

Sarmes

Posted 2014-10-02T11:45:37.567

Reputation: 121

No 24 logical cores are available. i run 4 simulations with 5 threads each, leaving 24-(4x5)=4 threads for the overhead. (whats with the -1?) – Sarmes – 2014-10-02T11:54:59.907

I believed the question not to be clear. Of course downvotes are anonymous for a reason. So I don't appreciate you assuming it was me. – Ramhound – 2014-10-02T13:30:17.170

Related: How does Windows processor affinity work with hyperthreaded CPUs?

– Ƭᴇcʜιᴇ007 – 2014-10-02T13:35:03.760

@Ƭᴇcʜιᴇ007, Yes its related, however that post just covers the basics on affinity specification. I was hoping for some answers/comments of users who have experience with setting affinity, on multi-threaded problems on multi-cpu configs. And also my question why 5 threads set on 5 cores performs way off, 5 threads on 6 cores, distinghuises it. – Sarmes – 2014-10-02T13:59:28.793

I mentioned it as related for those looking for related information (for similar problems, or possible answers), not suggesting it was a dupe. Carry on. ;) – Ƭᴇcʜιᴇ007 – 2014-10-02T14:01:21.913

1I have no explanation for your specific results, but I will say that generally it's best to leave affinities alone. Windows will automatically assign threads to "ideal processors" and steer them to those in order to optimize cache usage. Being too "creative" with affinities often gets you into situations where threads that are able to execute, can't for a while, because you've locked them out of the only CPUs that are available at the moment. It's generally better for compute throughput to run somewhere than nowhere. – Jamie Hanrahan – 2016-12-24T01:29:18.913

No answers