R-Friendly Multi-Threading in C++

Dublin Core

Title

R-Friendly Multi-Threading in C++

Subject

R, C++, parallel, thread, concurrency

Description

Calling multi-threaded C++ code from R has its perils. Since the R interpreter is
single-threaded, one must not check for user interruptions or print to the R console from
multiple threads. One can, however, synchronize with R from the main thread. The
R package RcppThread (current version 1.0.0) contains a header only C++ library for
thread safe communication with R that exploits this fact. It includes C++ classes for
threads, a thread pool, and parallel loops that routinely synchronize with R. This article
explains the package’s functionality and gives examples of its usage. The synchronization
mechanism may also apply to other threading frameworks. Benchmarks suggest that,
although synchronization causes overhead, the parallel abstractions of RcppThread are
competitive with other popular libraries in typical scenarios encountered in statistical
computing.

Creator

Thomas Nagler

Source

https://www.jstatsoft.org/article/view/v097c01

Publisher

Leiden University

Date

Januari 2021

Contributor

Fajar Bagus w

Format

PDF

Language

Inggris

Type

Text

Files

Citation

Thomas Nagler, “R-Friendly Multi-Threading in C++,” Repository Horizon University Indonesia, accessed March 12, 2025, https://repository.horizon.ac.id/items/show/8186.