Skip to main content
GameDev.net gamedev.net
🔒 Locked

linux get Cpu Count?

Started by Makaan Mar 30, 2010 at 10:49 AM 4 replies 2.6k views
Original Post
Makaan
Makaan
How do i get the physical Cpu count in linux? Thanks, Raxvan
Wolfdog
Wolfdog
You can read /proc/cpuinfo. This will have one entry for each core. If the processor has Hyper Threading you will see two for each core. Although I think the file has values that could be used to determine actual physical processors.
aryx
aryx
OpenMP also has the omp_get_num_procs function, if OpenMP were an option.
cache_hit
cache_hit
boost also has boost::thread::get_hardware_concurrency() or boost::thread::hardware_concurrency() or something like that
gumpy
gumpy
sysconf(_SC_NPROCESSORS_ONLN)
This space for rent.
Makaan
Makaan
gumpy Thanks , i just found the same solution on another forum.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.