title: How to determine which logical cores share the same physical core?
body: <p>I am working on a tool to allow students to self-evaluate their programming assignment's performance. In particular, the program they're writing is multi-threaded and I have no direct way of influencing the number of threads created. I would like to compare the performance of their programs given a different number of cores (and ideally, their programs should speed up roughly proportionally to how many cores it is allowed to use).</p>
  
  <p>We can pass a bitmask to Process.SetAffinity to control which cores the program uses.</p>
  
  <p>This is problematic on i5 and i7 machines that use hyper-threading and split each physical core in to two logical ones. I want the program to run on two/four distinct physical cores. On my i7 machine, a process with affinity set to 3 (cores 0&amp;1) will run roughly as fast as the program on a single core (indicating these logical cores share the same physical core), but with affinity set to 5 (cores 0&amp;3) it will run much faster (indicating these cores are using different physical cores). However, I haven't found a reliable way (other than trial-and-error) to determine this.</p>
  
  <p>How can I (without experimentation) determine which logical cores share the same physical core?</p>
  
  <p>(/proc/cpuinfo has the information I need but that is not available on Windows machines.)</p>