| get_cpu_cores | R Documentation |
Returns the number of logical CPU cores (processors) available.
get_cpu_cores()
This function returns the number of logical processors, which includes cores from hyperthreading/SMT. Useful for configuring parallel processing.
Typical values:
4-core CPU without hyperthreading: 4
4-core CPU with hyperthreading: 8
8-core CPU with hyperthreading: 16
Usage for parallelization: Don't blindly use all cores. A common practice is to use 80-90 percent of available cores to leave room for the OS and other processes.
Integer with number of CPU cores
Returns logical cores (with hyperthreading), not physical cores
On systems with CPU pinning, may return fewer cores
Value reflects cores available to the process
get_total_ram
# Get CPU cores
cores <- get_cpu_cores()
cat("System has", cores, "CPU cores\n")
# Configure parallel processing (use 80 percent of cores)
threads <- max(1, floor(cores * 0.8))
options(BigDataStatMeth.threads = threads)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.