EVOLUTION-MANAGER
Edit File: detectCores.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Detect the Number of CPU Cores</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for detectCores {parallel}"><tr><td>detectCores {parallel}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Detect the Number of CPU Cores</h2> <h3>Description</h3> <p>Attempt to detect the number of CPU cores on the current host. </p> <h3>Usage</h3> <pre> detectCores(all.tests = FALSE, logical = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>all.tests</code></td> <td> <p>Logical: if true apply all known tests.</p> </td></tr> <tr valign="top"><td><code>logical</code></td> <td> <p>Logical: if possible, use the number of physical CPUs/cores (if <code>FALSE</code>) or logical CPUs (if <code>TRUE</code>). Currently this is honoured only on macOS, Solaris and Windows.</p> </td></tr> </table> <h3>Details</h3> <p>This attempts to detect the number of available CPU cores. </p> <p>It has methods to do so for Linux, macOS, FreeBSD, OpenBSD, Solaris, Irix and Windows. <code>detectCores(TRUE)</code> could be tried on other Unix-alike systems. </p> <h3>Value</h3> <p>An integer, <code>NA</code> if the answer is unknown. </p> <p>Exactly what this represents is OS-dependent: where possible by default it counts logical (e.g., hyperthreaded) CPUs and not physical cores or packages. </p> <p>Under macOS there is a further distinction between ‘available in the current power management mode’ and ‘could be available this boot’, and this function returns the first. </p> <p>On Sparc Solaris <code>logical = FALSE</code> returns the number of physical cores and <code>logical = TRUE</code> returns the number of available hardware threads. (Some Sparc CPUs have multiple cores per CPU, others have multiple threads per core and some have both.) For example, the UltraSparc T2 CPU in the former CRAN check server was a single physical CPU with 8 cores, and each core supports 8 hardware threads. So <code>detectCores(logical = FALSE)</code> returns 8, and <code>detectCores(logical = TRUE)</code> returns 64. </p> <p>Where virtual machines are in use, one would hope that the result for <code>logical = TRUE</code> represents the number of CPUs available (or potentially available) to that particular VM. </p> <h3>Note</h3> <p>This is not suitable for use directly for the <code>mc.cores</code> argument of <code>mclapply</code> nor specifying the number of cores in <code>makeCluster</code>. First because it may return <code>NA</code>, second because it does not give the number of <em>allowed</em> cores, and third because on Sparc Solaris and some Windows boxes it is not reasonable to try to use all the logical CPUs at once. </p> <h3>Author(s)</h3> <p>Simon Urbanek and Brian Ripley </p> <h3>Examples</h3> <pre> detectCores() detectCores(logical = FALSE) </pre> <hr /><div style="text-align: center;">[Package <em>parallel</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>