data.table (version 1.10.4-1)

setDTthreads: Set or get number of threads that data.table should use

Description

Set and get number of threads to be used in data.table functions that are parallelized with OpenMP. Default value 0 means to utilize all CPU available with an appropriate number of threads calculated by OpenMP. getDTthreads() returns the number of threads that will be used. This affects data.table only and does not change R itself or other packages using OpenMP. The most common usage expected is setDTthreads(1) to limit data.table to one thread for pre-existing explictly parallel user code; e.g. via packages parallel and foreach. Otherwise, nested parallelism may bite. As data.table becomes more parallel automatically internally, we expect explicit user parallelism to be needed less often.

Usage

setDTthreads(threads)
getDTthreads()

Arguments

threads

An integer >= 0. Default 0 means use all CPU available and leave the operating system to multi task.

Value

A length 1 integer. The old value is returned by setDTthreads so you can store that value and pass it to setDTthreads again after the section of your code where you, probably, limited to one thread.