MultiThreading: Handling Multi-Core and GPU environments

MultiThreadingR Documentation

Handling Multi-Core and GPU environments

Description

Check whether session supports multi-core and/or GPU evaluation and utilities about their activation

Usage

handleMultiCore(cores)

canUseTorch(optimizeForSpeed, deviceStr)

Arguments

cores

the number of cores asked for

optimizeForSpeed

A Boolean to indicate whether to try to use the faster torch library

deviceStr

The name of the device to be used by torch

Details

handleMultiCore() uses parallelly::supportsMulticore() and parallelly::availableCores() to actually check whether the session supports multi-core evaluation. Provides an effective upper bound to the number of cores.

canUseTorch() is an internal function to handle the torch library: it returns whether torch is ready to be used. It obeys the opt-out flag set via the COTAN.UseTorch option

Value

handleMultiCore() returns the maximum sensible number of cores to use

canUseTorch() returns a list with 2 elements:

  • "useTorch": a Boolean indicating whether the torch library can be used

  • "deviceStr": the updated name of the device to be used: if no cuda GPU is available it will fallback to CPU calculations

See Also

the help page of parallelly::supportsMulticore() about the flags influencing the multi-core support; e.g. the usage of R option parallelly.fork.enable.

torch::install_torch() and torch::torch_is_installed() for installation. Note the torch::torch_set_num_threads() has effect also on the Rfast package methods


seriph78/COTAN documentation built on Nov. 15, 2024, 7:09 a.m.