Learn R Programming

TPmsm (version 1.1.0)

threadsTP: Set the number of threads

Description

Specifies the number of threads used by default in parallel sections.

Usage

threadsTP(num_threads=NULL)

Arguments

num_threads
the number of threads to use.

Value

  • Invisibly returns the previous number of threads.

encoding

UTF-8

Details

If num_threads is greater than the number of processors/cores then the number of processors/cores is used. If package TPmsm was compiled without OpenMP support then this function returns 1 regardless of the number of processors/cores available. If num_threads=NULL the number of threads is not defined. This is useful when the current number of threads is desired without defining a new thread number.

References

OpenMP Architecture Review Board, OpenMP Application Program Interface Version 3.0, May 2008, p110 (http://www.openmp.org/mp-documents/spec30.pdf) Runtime Library Routines, Summary of OpenMP 3.0 C/C++ Syntax, p5 (http://www.openmp.org/mp-documents/OpenMP3.0-SummarySpec.pdf)

Examples

Run this code
# set the number of threads
nth <- threadsTP(2)

# restore the number of threads
threadsTP(nth)

Run the code above in your browser using DataLab