Is there way to get which core is used by the thread?
for example
printf("..., Core: %2d\n", coreN);
Is there way to get which core is used by the thread?
for example
printf("..., Core: %2d\n", coreN);
If you're using Linux based systems you can use
sched_getcpu()
to print the current CPU/core number on which the thread is running
cout << "Thread running on Core " << sched_getcpu() <<endl
C++ does not provide a function or anything for achieving this, since there is no notion of core in the language.
You could run a Linux command via a system call to check that out: How can I see which CPU core a thread is running in?