Skip to content

Commit 0899ed0

Browse files
authored
adapt thread affinity to possibly restricted CPU set (#62)
* don't set affinity * check allowed cores first * only use ptthread in guarded sections * bump version * make minor version
1 parent abe3710 commit 0899ed0

34 files changed

+609
-96
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: RcppThread
22
Title: R-Friendly Threading in C++
3-
Version: 2.0.2
3+
Version: 2.1.0
44
Authors@R: c(
55
person("Thomas", "Nagler",, "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-1855-0046"))

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
YEAR: 2021
1+
YEAR: 2022
22
COPYRIGHT HOLDER: Thomas Nagler

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22
=====================
33

4-
Copyright © 2021 Thomas Nagler.
4+
Copyright © 2022 Thomas Nagler.
55

66
Permission is hereby granted, free of charge, to any person
77
obtaining a copy of this software and associated documentation

NEWS.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# RcppThread 2.1.0
2+
3+
NEW FEATURE
4+
5+
* safe printing to the R error stream with `RcppThread::Rcerr` (#60, thanks to
6+
@appelmar).
7+
8+
BUG FIX
9+
10+
* adapt thread affinity to possibly restricted CPU set (#61).
11+
12+
113
# RcppThread 2.0.1
214

315
BUG FIX

docs/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = RcppThread
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.0.0
41+
PROJECT_NUMBER = 2.1.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

docs/annotated.html

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ <h1>Classes</h1>
5858
<li>class <a href="classRcppThread_1_1ProgressBar.html" class="m-doc">ProgressBar</a> <span class="m-doc">A progress bar showing progress in percent.</span></li>
5959
<li>class <a href="classRcppThread_1_1ProgressCounter.html" class="m-doc">ProgressCounter</a> <span class="m-doc">A counter showing progress in percent.</span></li>
6060
<li>class <a href="classRcppThread_1_1ProgressPrinter.html" class="m-doc">ProgressPrinter</a> <span class="m-doc">Abstract class for printing progress.</span></li>
61+
<li>class <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a> <span class="m-doc">Safely printing to the R console from threaded code.</span></li>
6162
<li>class <a href="classRcppThread_1_1RMonitor.html" class="m-doc">RMonitor</a> <span class="m-doc">Singleton class for tracking threads and safe communication.</span></li>
6263
<li>class <a href="classRcppThread_1_1RPrinter.html" class="m-doc">RPrinter</a> <span class="m-doc">Safely printing to the R console from threaded code.</span></li>
6364
<li>class <a href="classRcppThread_1_1Thread.html" class="m-doc">Thread</a> <span class="m-doc">R-friendly version of <code>std::thread</code>.</span></li>
+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>RcppThread::RErrPrinter class | RcppThread R-friendly
6+
threading
7+
in
8+
C++</title>
9+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
10+
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
11+
<link rel="icon" href="favicon-dark.png" type="image/png" />
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
13+
<meta name="theme-color" content="#22272e" />
14+
</head>
15+
<body>
16+
<header><nav id="navigation">
17+
<div class="m-container">
18+
<div class="m-row">
19+
<span id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">
20+
<a href="https://github.com/tnagler/RcppThread">RcppThread</a> <span class="m-breadcrumb">|</span> <a href="index.html" class="m-thin">R-friendly
21+
threading
22+
in
23+
C++</a>
24+
</span>
25+
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
26+
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
27+
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
28+
</svg></a>
29+
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
30+
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
31+
</div>
32+
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
33+
<div class="m-row">
34+
<ol class="m-col-t-6 m-col-m-none">
35+
<li><a href="namespaceRcppThread.html">RcppThread</a></li>
36+
<li><a href="overrides.html">Automatic overrides</a></li>
37+
</ol>
38+
<ol class="m-col-t-6 m-col-m-none" start="3">
39+
<li><a href="https://github.com/tnagler/RcppThread">GitHub</a></li>
40+
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
41+
<use href="#m-doc-search-icon-path" />
42+
</svg></a></li>
43+
</ol>
44+
</div>
45+
</div>
46+
</div>
47+
</div>
48+
</nav></header>
49+
<main><article>
50+
<div class="m-container m-container-inflatable">
51+
<div class="m-row">
52+
<div class="m-col-l-10 m-push-l-1">
53+
<h1>
54+
<span class="m-breadcrumb"><a href="namespaceRcppThread.html">RcppThread</a>::<wbr/></span>RErrPrinter <span class="m-thin">class</span>
55+
</h1>
56+
<p>Safely printing to the R console from threaded code.</p>
57+
<div class="m-block m-default">
58+
<h3>Contents</h3>
59+
<ul>
60+
<li>
61+
Reference
62+
<ul>
63+
<li><a href="#pub-methods">Public functions</a></li>
64+
</ul>
65+
</li>
66+
</ul>
67+
</div>
68+
<section id="pub-methods">
69+
<h2><a href="#pub-methods">Public functions</a></h2>
70+
<dl class="m-doc">
71+
<dt>
72+
<div class="m-doc-template">template&lt;class T&gt;</div>
73+
<span class="m-doc-wrap-bumper">auto <a href="#adeee1773d69206c2e0c806dbc72ce8e1" class="m-doc">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">T&amp; object) -&gt; <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp;</span>
74+
</dt>
75+
<dd></dd>
76+
<dt>
77+
<div class="m-doc-template">template&lt;class T&gt;</div>
78+
<span class="m-doc-wrap-bumper">auto <a href="#a04842e0c5c9bcb6b13f49623896067e7" class="m-doc">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">const T&amp; object) -&gt; <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp;</span>
79+
</dt>
80+
<dd></dd>
81+
<dt>
82+
<span class="m-doc-wrap-bumper">auto <a href="#a679a95fb8a26668c8e224cb4467598d8" class="m-doc">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">std::ostream&amp;(*)(std::ostream&amp;) object) -&gt; <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp;</span>
83+
</dt>
84+
<dd></dd>
85+
</dl>
86+
</section>
87+
<section>
88+
<h2>Function documentation</h2>
89+
<section class="m-doc-details" id="adeee1773d69206c2e0c806dbc72ce8e1"><div>
90+
<h3>
91+
<div class="m-doc-template">
92+
template&lt;class T&gt;
93+
</div>
94+
<span class="m-doc-wrap-bumper"><a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp; RcppThread::<wbr />RErrPrinter::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#adeee1773d69206c2e0c806dbc72ce8e1" class="m-doc-self">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">T&amp; object)</span></span>
95+
</h3>
96+
<table class="m-table m-fullwidth m-flat">
97+
<thead>
98+
<tr><th colspan="2">Parameters</th></tr>
99+
</thead>
100+
<tbody>
101+
<tr>
102+
<td style="width: 1%">object</td>
103+
<td>a string (or coercible object) to print.</td>
104+
</tr>
105+
</tbody>
106+
</table>
107+
<p>prints <code>object</code> to R error stream íf called from main thread; otherwise adds a printable version of <code>object</code> to a buffer for deferred printing.
108+
Declared as a friend in <code>RMonitor</code>.</p>
109+
</div></section>
110+
<section class="m-doc-details" id="a04842e0c5c9bcb6b13f49623896067e7"><div>
111+
<h3>
112+
<div class="m-doc-template">
113+
template&lt;class T&gt;
114+
</div>
115+
<span class="m-doc-wrap-bumper"><a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp; RcppThread::<wbr />RErrPrinter::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a04842e0c5c9bcb6b13f49623896067e7" class="m-doc-self">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">const T&amp; object)</span></span>
116+
</h3>
117+
<table class="m-table m-fullwidth m-flat">
118+
<thead>
119+
<tr><th colspan="2">Parameters</th></tr>
120+
</thead>
121+
<tbody>
122+
<tr>
123+
<td style="width: 1%">object</td>
124+
<td>a string (or coercible object) to print.</td>
125+
</tr>
126+
</tbody>
127+
</table>
128+
<p>prints <code>object</code> to R error stream íf called from main thread; otherwise adds a printable version of <code>object</code> to a buffer for deferred printing.
129+
Declared as a friend in <code>RMonitor</code>.</p>
130+
</div></section>
131+
<section class="m-doc-details" id="a679a95fb8a26668c8e224cb4467598d8"><div>
132+
<h3>
133+
<span class="m-doc-wrap-bumper"><a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>&amp; RcppThread::<wbr />RErrPrinter::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a679a95fb8a26668c8e224cb4467598d8" class="m-doc-self">operator&lt;&lt;</a>(</span><span class="m-doc-wrap">std::ostream&amp;(*)(std::ostream&amp;) object)</span></span>
134+
</h3>
135+
<table class="m-table m-fullwidth m-flat">
136+
<thead>
137+
<tr><th colspan="2">Parameters</th></tr>
138+
</thead>
139+
<tbody>
140+
<tr>
141+
<td style="width: 1%">object</td>
142+
<td>a string (or coercible object) to print.</td>
143+
</tr>
144+
</tbody>
145+
</table>
146+
<p>prints <code>object</code> to R error stream íf called from main thread; otherwise adds a printable version of <code>object</code> to a buffer for deferred printing.
147+
Declared as a friend in <code>RMonitor</code>.</p>
148+
</div></section>
149+
</section>
150+
</div>
151+
</div>
152+
</div>
153+
</article></main>
154+
<div class="m-doc-search" id="search">
155+
<a href="#!" onclick="return hideSearch()"></a>
156+
<div class="m-container">
157+
<div class="m-row">
158+
<div class="m-col-m-8 m-push-m-2">
159+
<div class="m-doc-search-header m-text m-small">
160+
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
161+
<div id="search-symbolcount">&hellip;</div>
162+
</div>
163+
<div class="m-doc-search-content">
164+
<form>
165+
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
166+
</form>
167+
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
168+
<div id="search-help" class="m-text m-dim m-text-center">
169+
<p class="m-noindent">Search for symbols, directories, files, pages, OpenGL, GLSL, Vulkan and OpenAL APIs. You can omit any prefix from the symbol or file path; adding a <code>:</code> or <code>/</code> suffix lists all members of given symbol or directory.</p> <p class="m-noindent">Use <span class="m-label m-dim">&darr;</span> / <span class="m-label m-dim">&uarr;</span> to navigate through the list, <span class="m-label m-dim">Enter</span> to go. <span class="m-label m-dim">Tab</span> autocompletes common prefix, you can copy a link to the result using <span class="m-label m-dim"></span> <span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span> <span class="m-label m-dim">M</span> produces a Markdown link.</p>
170+
</div>
171+
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
172+
<ul id="search-results"></ul>
173+
</div>
174+
</div>
175+
</div>
176+
</div>
177+
</div>
178+
<script src="search-v1.js"></script>
179+
<script src="searchdata-v1.js" async="async"></script>
180+
<footer><nav>
181+
<div class="m-container">
182+
<div class="m-row">
183+
<div class="m-col-l-10 m-push-l-1">
184+
<p>RcppThread docs. copyright © <a href="http://tnagler.com/">Thomas Nagler</a> 2021.<br />Generated by <a href="https://doxygen.org/">Doxygen</a> 1.8.17 and <a href="https://mcss.mosra.cz/">m.css</a>. Contact the author via <a href="https://github.com/tnagler/RcppThread">GitHub</a> or <a href="mailto:[email protected]">e-mail</a>
185+
</div>
186+
</div>
187+
</div>
188+
</nav></footer>
189+
</body>
190+
</html>

docs/classRcppThread_1_1RMonitor.html

+25
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ <h2><a href="#pro-methods">Protected functions</a></h2>
124124
<span class="m-doc-wrap-bumper">void <a href="#a98b81ed3996a37a51b5cdb8dbed89712" class="m-doc">safelyPrint</a>(</span><span class="m-doc-wrap">const T&amp; object)</span>
125125
</dt>
126126
<dd></dd>
127+
<dt>
128+
<div class="m-doc-template">template&lt;class T&gt;</div>
129+
<span class="m-doc-wrap-bumper">void <a href="#aca4da9d515e3366af9e8185a7d2b866a" class="m-doc">safelyPrintErr</a>(</span><span class="m-doc-wrap">const T&amp; object)</span>
130+
</dt>
131+
<dd></dd>
127132
</dl>
128133
</section>
129134
<section id="friends">
@@ -172,6 +177,26 @@ <h3>
172177
</tbody>
173178
</table>
174179
<p>prints <code>object</code> to R console íf called from main thread; otherwise adds a printable version of <code>object</code> to a buffer for deferred printing.</p>
180+
</div></section>
181+
<section class="m-doc-details" id="aca4da9d515e3366af9e8185a7d2b866a"><div>
182+
<h3>
183+
<div class="m-doc-template">
184+
template&lt;class T&gt;
185+
</div>
186+
<span class="m-doc-wrap-bumper">void RcppThread::<wbr />RMonitor::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#aca4da9d515e3366af9e8185a7d2b866a" class="m-doc-self">safelyPrintErr</a>(</span><span class="m-doc-wrap">const T&amp; object) <span class="m-label m-warning">protected</span></span></span>
187+
</h3>
188+
<table class="m-table m-fullwidth m-flat">
189+
<thead>
190+
<tr><th colspan="2">Parameters</th></tr>
191+
</thead>
192+
<tbody>
193+
<tr>
194+
<td style="width: 1%">object</td>
195+
<td>a string or coercible object to print.</td>
196+
</tr>
197+
</tbody>
198+
</table>
199+
<p>prints <code>object</code> to R error stream íf called from main thread; otherwise adds a printable version of <code>object</code> to a buffer for deferred printing.</p>
175200
</div></section>
176201
<section class="m-doc-details" id="ad81d4d6402e7bfe7f254b2d5388fb97b"><div>
177202
<h3>

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<h1>
5454
RcppThread: R-friendly threading in C++
5555
</h1>
56-
<aside class="m-note m-default"><h4>Authors</h4><p>Thomas Nagler</p></aside><p>This is the API documentation for the RcppThread C++ library. For a more high-level overview see the <a href="https://doi.org/10.18637/jss.v097.c01">vignette</a> and <a href="https://github.com/tnagler/RcppThread/blob/main/README.md">README</a>.</p><section id="license"><h2><a href="#license">License</a></h2><p>The MIT License (MIT)</p><p>Copyright © 2021 Thomas Nagler</p><p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p></section>
56+
<aside class="m-note m-default"><h4>Authors</h4><p>Thomas Nagler</p></aside><p>This is the API documentation for the RcppThread C++ library. For a more high-level overview see the <a href="https://doi.org/10.18637/jss.v097.c01">vignette</a> and <a href="https://github.com/tnagler/RcppThread/blob/main/README.md">README</a>.</p><section id="license"><h2><a href="#license">License</a></h2><p>The MIT License (MIT)</p><p>Copyright © 2022 Thomas Nagler</p><p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p></section>
5757
</div>
5858
</div>
5959
</div>

docs/namespaceRcppThread.html

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ <h2><a href="#nested-classes">Classes</a></h2>
8282
class <a href="classRcppThread_1_1ProgressPrinter.html" class="m-doc">ProgressPrinter</a>
8383
</dt>
8484
<dd>Abstract class for printing progress.</dd>
85+
<dt>
86+
class <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a>
87+
</dt>
88+
<dd>Safely printing to the R console from threaded code.</dd>
8589
<dt>
8690
class <a href="classRcppThread_1_1RMonitor.html" class="m-doc">RMonitor</a>
8791
</dt>
@@ -159,6 +163,10 @@ <h2><a href="#func-members">Functions</a></h2>
159163
<section id="var-members">
160164
<h2><a href="#var-members">Variables</a></h2>
161165
<dl class="m-doc">
166+
<dt id="a8393ba347760237abf9d823000af775e">
167+
static <a href="classRcppThread_1_1RErrPrinter.html" class="m-doc">RErrPrinter</a> <a href="#a8393ba347760237abf9d823000af775e" class="m-doc-self">Rcerr</a>
168+
</dt>
169+
<dd>global <code>RPrinter</code> instance called &#x27;Rcerr&#x27; (as in Rcpp).</dd>
162170
<dt id="a314d0d8e34b9799f4dda1b4d5da36ed0">
163171
static <a href="classRcppThread_1_1RPrinter.html" class="m-doc">RPrinter</a> <a href="#a314d0d8e34b9799f4dda1b4d5da36ed0" class="m-doc-self">Rcout</a>
164172
</dt>

docs/searchdata-v1.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)