0

Is there way to get which core is used by the thread?
for example

printf("..., Core: %2d\n", coreN);
HolyBlackCat
  • 63,700
  • 7
  • 105
  • 170
Ufx
  • 2,355
  • 11
  • 40
  • 74

2 Answers2

1

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
Deepak Kr Gupta
  • 6,994
  • 2
  • 21
  • 34
0

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?

gsamaras
  • 69,751
  • 39
  • 173
  • 279