get_cpu_cores: Get number of CPU cores

View source: R/RcppExports.R

get_cpu_coresR Documentation

Get number of CPU cores

Description

Returns the number of logical CPU cores (processors) available.

Usage

get_cpu_cores()

Details

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.

Value

Integer with number of CPU cores

Note

  • Returns logical cores (with hyperthreading), not physical cores

  • On systems with CPU pinning, may return fewer cores

  • Value reflects cores available to the process

See Also

get_total_ram

Examples


# 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)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.