I write a little raytracer and i’d like to query how many cpu cores (or virtual cpu cores if the cpu uses hyperthreading) the current computer offers, such that i can instanciate as many threads to get better parallel rendering.
How can I do that using C++?
thanks!
You can get the number of physical processors by calling
GetSystemInfoand checking thedwNumberOfProcessorsfield of theSYSTEM_INFOstructure. You can get the number of logical processors by callingGetLogicalProcessorInformation.