Skip to content
Advertisement

Provide windows avilable cores

I use the following in my script to find how many available cores I can use.

This is for Linux:

NPROCS = $(shell grep -c 'processor' /proc/cpuinfo)

This is for Mac (darwin):

NPROCS = $(shell sysctl -n hw.ncpu)

How should it be in Windows?

Advertisement

Answer

You can use one of those commands:

c:wmic cpu get NumberOfCores, NumberOfLogicalProcessors/Format:List
NumberOfCores=6
NumberOfLogicalProcessors=12

NumberOfCores=6
NumberOfLogicalProcessors=12

(here you have two physical processors)

Or as suggested in comments:

c:echo %NUMBER_OF_PROCESSORS%
24

In Makefile the record should be something like:

NPROCS = $(shell echo %NUMBER_OF_PROCESSORS%)

P.S. And the commands you write in question are wrong! You must remove space around =

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement