set_num_threads: Set the number of OpenMP threads used by the functions of...

Description Usage Arguments Value See Also Examples

Description

This function sets the value of the global variable stored in options()$cgenpp.threads to the assigned integer. Note: The assigned value may exceed the number of physical cores present but that might lead to dramatical decrease in performance.

Usage

1

Arguments

x

Integer scalar that specifies the number of threads to be used by cgenpp-functions

silent

boolean, controls whether to print a message

Value

Changes the global variable cgenpp.threads to the value in x

See Also

get_num_threads, get_max_threads, check_openmp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Control the number of threads being used in an R-session:

# set the number of threads to 1
## Not run: 
set_num_threads(1)

#### Use a parallelized cgenpp-function

# generate random data
rand_data(500,5000)

# check single-threaded performance
system.time(W <- M%c%t(M))

# set number of threads to the value reported by get_max_threads()

n_threads <- get_max_threads()
set_num_threads(n_threads)

# check multi-threaded performance
system.time(W <- M%c%t(M))

## End(Not run)

cgenpp documentation built on May 2, 2019, 5:56 p.m.