We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 66966

Vivado - Is there a Tcl command to give the number of available processors?


In the Vivado Tcl console, batch mode, or Vivado Tcl shell, is there a way to determine the number of processors (CPUs) available?


The Tcl procedure "::tcl_platform" which can support this functionality is available via the Tcl Wiki:


The following public domain procedure (http://stackoverflow.com/questions/29482303/how-to-find-the-number-of-cpus-in-tcl) can be used to obtain the number of CPUs available:

--- Start ----

proc numberOfCPUs {} {
# Windows puts it in an environment variable
global tcl_platform env
if {$tcl_platform(platform) eq "windows"} {

# Check for sysctl (OSX, BSD)
set sysctl [auto_execok "sysctl"]
if {[llength $sysctl]} {
if {![catch {exec {*}$sysctl -n "hw.ncpu"} cores]} {
return $cores

# Assume Linux, which has /proc/cpuinfo, but be careful
if {![catch {open "/proc/cpuinfo"} f]} {
set cores [regexp -all -line {^processor\s} [read $f]]
close $f
if {$cores > 0} {
return $cores

# No idea what the actual number of cores is; exhausted all our option...

AR# 66966
Date Created 04/05/2016
Last Updated 04/07/2016
Status Active
Type General Article
  • Vivado Design Suite