Get the number of CPU cores available on the current machine using gdalraster::get_num_cpus(),
which calls the internal GDAL C++ library function GDALGetCPUs().
Details
This method is more robust than parallel::detectCores() because it accounts for CPU
affinity, container limits, and other environmental restrictions that may cap the processing
pools actually available to the R session.
However, on a standard unconstrained desktop machine, it will return the same value as
parallel::detectCores(logical = TRUE) because both report the total logical processing channels.
Number of CPUs (GDAL):
gdalraster::get_num_cpus()queries the C++ backend to see how many logical execution slots (hardware threads) are exposed by the operating system.Number of Cores (parallel):
parallel::detectCores(logical = TRUE)targets the virtual threads generated by Hyper-Threading (Intel) or SMT (AMD). Conversely, runningparallel::detectCores(logical = FALSE)attempts to return only the count of independent physical cores on the processor.