Anything related to processor affinity, also known as CPU pinning. The processor affinity is a propriety of a process or a thread in an OS on multi-processor or multi-core systems that influences the OS' scheduling algorithm, binding the execution of that process (or thread) to a specific processor (or core). DO NOT use this tag as a synonym for [affinetransform] tag.
Questions tagged [affinity]
330 questions
6
votes
2 answers
Setting CPU affinity using taskset
I am using the taskset tool to set CPU affinity for one of my programs. How do I set the affinity on a single CPU only - since I was not sure about this, so I was doing this:
taskset -c 2-2 tests/prog 1 2 3
...expecting, that I am scheduling the…

Sayan
- 2,662
- 10
- 41
- 56
6
votes
1 answer
How to replace --cpus-per-proc with --map-by in OpenMPI
I need to update some old codes to work with the most recent version of OpenMPI, but I'm very confused by the new --map-by system. In particular, I'm not sure how to replace --cpus-per-proc N.
Several websites have suggested using --map-by…

Kat S.
- 63
- 4
6
votes
2 answers
Identify processor (core) is used by specific thread
I would like to know if it is possible to identify physical processor (core) used by thread with specific thread-id?
For example, I have a multithreaded application that has two (2) threads (thread-id = 10 and thread-id = 20, for instance). I run…

DenisL
- 308
- 2
- 10
6
votes
1 answer
Thread affinity with Windows, MSVC, and OpenMP
I want to bind the threads in my code to each physical core.
With GCC I have successfully done this using sched_setaffinity so I no longer have to set export OMP_PROC_BIND=true. I want to do the same thing in Windows with MSVC. Windows and Linux…

Z boson
- 32,619
- 11
- 123
- 226
6
votes
5 answers
assign two MPI processes per core
How do I assign 2 MPI processes per core?
For example, if I do mpirun -np 4 ./application then it should use 2 physical cores to run 4 MPI processes (2 processes per core). I am using Open MPI 1.6. I did mpirun -np 4 -nc 2 ./application but wasn't…

codereviewanskquestions
- 13,460
- 29
- 98
- 167
6
votes
1 answer
How to set the affinity of a process from a Linux kernel mode?
How can the CPU affinity of a process be set in kernel module? In user mode there is a syscall sched_setaffinity, but I am looking for the kernel mode equivalent.
In the Linux kernel code, there is also a function called sched_setaffinity. It's…

Mike Mu
- 977
- 6
- 10
5
votes
2 answers
Deployment affinity
I have k8s cluster with 3 nodes
I would like that a sample deployment with 3 replicas as the follwing , so each pod got schduled in a different node ?
apiVersion: apps/v1 kind: Deployment metadata: name: tomcat-deployment labels:
app:…

Zamalkawy
- 59
- 1
- 4
5
votes
1 answer
Is it possible to set pthread CPU affinity in OS X?
In Linux there is a sched_setaffinity() function defined in sched.h, but I can't seem to find anything like that in Mac OS X 10.6 pthreads implementation... If it is not possible to set affinity, what is the default policy in OS X?

Ryan
- 1,451
- 2
- 27
- 36
5
votes
0 answers
Set affinity in std::thread before execution
I want to map certain threads to certain processors before the execution, in a way we do by passing pthread_attr_t in pthread_create, but with std::thread objects. I have tried the following:
std::vector threads;
for (int i = 0;…

k_kaz
- 596
- 1
- 9
- 20
5
votes
0 answers
udp_recv cpu usage increase after setting CPU affinity
I wrote a simple udp_recv test demo, and I found one strange thing
If I set the CPU affinity to cpu0, the cpu usage is 5%, but after setting affinity to other cpu, the cpu usage increased to 9%~12%,especially set to cpu20, the cpu usage is more than…

Patrick
- 51
- 1
- 2
- 6
5
votes
1 answer
Unbound workqueue's kthreads CPU affinity
Is there a way to set CPU affinity for unbound workqueue's kthreads (those that named kthread/uXX:y)? Something like cpu mask for regular workqueues.
Is it a good idea to set it for each kthread using taskset?

Filipp
- 859
- 1
- 6
- 20
5
votes
3 answers
Pthread affinity before create threads
I need to set the affinity (thread to core, eg: 1st thread to 1st core) before creating a thread. Something like KMP_AFFINITY in OpenMP. Is it possible?
edit:
I try in this way, but dont' work :/
void* DoWork(void* args)
{
int nr = (int)args;
…

JudgeDeath
- 151
- 1
- 2
- 9
5
votes
1 answer
With MSI-X device can IRQ affinity be set (Linux)?
I've set IRQ affinity in the past on Linux by setting values to the proc files. [1]
However, I noticed that when I do this on an system that uses MSI-X for the device
(PCIe) that I want to set affinity for e.g. NIC, the /proc/interrupt counters…

jonschipp
- 781
- 2
- 9
- 21
5
votes
1 answer
Compute affinity matrix from distance matrix
I used clustal omega to get a distance matrix of 500 protein sequences (they are homologous to each other).
I want to use affinity propagation to cluster these sequences.
Initially, because I observed by hand that the distance matrix only had values…

ericmjl
- 13,541
- 12
- 51
- 80
5
votes
4 answers
To set the affinity of CPUs using C#
I have created a window application in C#.Now I want to set the CPU affinity for this application.I may have 2 processors,4 processors,8 processors or may be more than 8 processors.
I want to set the cpu affinity using input from interface.
How can…

Kandpal Lalit
- 139
- 1
- 5