Learn R Programming

TPmsm (version 1.2.12)

setThreadsTP: Set the number of threads

Description

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

Usage

setThreadsTP(num_threads=NULL)

Value

Invisibly returns the previous number of threads.

Arguments

num_threads

the number of threads to use.

Author

Artur Araújo, Javier Roca-Pardiñas and Luís Meira-Machado

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

Araújo A, Meira-Machado L, Roca-Pardiñas J (2014). TPmsm: Estimation of the Transition Probabilities in 3-State Models. Journal of Statistical Software, 62(4), 1-29. tools:::Rd_expr_doi("10.18637/jss.v062.i04")

OpenMP Architecture Review Board, OpenMP Application Program Interface Version 3.0, May 2008, p110. https://www.openmp.org/wp-content/uploads/spec30.pdf

“Runtime Library Routines”, Summary of OpenMP 3.0 C/C++ Syntax, p5. https://www.openmp.org/wp-content/uploads/OpenMP3.0-SummarySpec.pdf

Examples

Run this code
# Set the number of threads
nth <- setThreadsTP(2);

# Restore the number of threads
setThreadsTP(nth);

Run the code above in your browser using DataLab