Search code examples
c++multithreadingc++11winapihpc

How to find on which CPU&Core my thread is running


I have an app that use HPC, and it automatically assign each thread to specific CPU and Cores on the HPC. I would like to know to which CPU and Core my thread is assigned to.

GetCurrentProcessorNumber return the Core ID which my thread is run on, and I wish to know on which CPU it runs as well.

My HPC has at least 2 CPU's and 10 cores on each CPU

How can I do that?

Thanks!


Solution

  • You might want to check the GetCurrentProcessorNumber API (or GetCurrentProcessorNumberEx if you have more than 64 logical processors).