How many cores do I have?

Possible duplicate:
Programmatically find the number of cores on a machine

I have a multithreaded C ++ program that runs on Windows, MacOS, and Linux. Is there an easy way to find out how many kernels I'm currently working on? My system works best when it has 1 thread for each core.

+3
source share
3 answers

I believe this question may contain your answer:

Programmatically find the number of cores on a machine

Edit: I just voted for ybungalobill's answer. I love you boost!

+1
source

Use boost::thread::hardware_concurrency()or std::thread::hardware_concurrency()if you have a C ++ 0x compiler.

+3

In the linux system cat / proc / cpuinfo and analyze the output in one way. Dunno if it is most effective or not.

0
source

Source: https://habr.com/ru/post/1778529/


All Articles