Skip to content

Commit f597d4b

Browse files
authored
Merge pull request #48 from jolars/master
Update to TBB 2017 Update 7
2 parents 3b01ab8 + b0bd9e0 commit f597d4b

File tree

651 files changed

+52095
-27086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

651 files changed

+52095
-27086
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
^doc$
1111
^src/.*\.o$
1212
^gen/
13+
^appveyor\.yml$
14+
^revdep$

.travis.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
language: cpp
2-
1+
# Run Travis CI for R using https://eddelbuettel.github.io/r-travis/
2+
3+
language: c
4+
sudo: required
5+
group: edge
6+
37
before_install:
4-
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
5-
- chmod 755 ./travis-tool.sh
6-
- ./travis-tool.sh bootstrap
7-
- ./travis-tool.sh install_aptget r-cran-rcpp r-cran-bh r-cran-runit
8+
- curl -OLs https://eddelbuettel.github.io/r-travis/run.sh && chmod 0755 run.sh
9+
- ./run.sh bootstrap
10+
11+
install:
12+
- ./run.sh install_aptget r-cran-rcpp r-cran-bh r-cran-runit r-cran-knitr r-cran-rmarkdown
813

9-
script:
10-
- R CMD INSTALL .
11-
- cd tests && Rscript doRUnit.R
14+
script:
15+
- ./run.sh run_tests
16+
17+
after_failure:
18+
- ./run.sh dump_logs
1219

1320
notifications:
1421
email:
1522
on_success: change
16-
on_failure: change
17-
18-
23+
on_failure: change

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: RcppParallel
22
Type: Package
33
Title: Parallel Programming Tools for 'Rcpp'
4-
Version: 4.3.20
4+
Version: 2017.7.0
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"),
77
person("Romain", "Francois", role = c("aut", "cph")),

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ export(RcppParallelLibs)
44
export(CxxFlags)
55
export(LdFlags)
66
export(RcppParallel.package.skeleton)
7-
8-

README.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## RcppParallel Package
22

3+
[![Travis-CI Build Status](https://travis-ci.org/RcppCore/RcppParallel.svg?branch=master)](https://travis-ci.org/RcppCore/RcppParallel)
4+
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/RcppCore/RcppParallel?branch=master&svg=true)](https://ci.appveyor.com/project/RcppCore/RcppParallel)
5+
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/RcppParallel)](https://cran.r-project.org/package=RcppParallel)
6+
37
High level functions for doing parallel programming with Rcpp. For example, the `parallelFor` function can be used to convert the work of a standard serial "for" loop into a parallel one and the `parallelReduce` function can be used for accumulating aggregate or other values.
48

59
The high level interface enables safe and robust parallel programming without direct manipulation of operating system threads. On Windows, OS X, and Linux systems the underlying implementation is based on [Intel TBB](https://www.threadingbuildingblocks.org/) (Threading Building Blocks). On other platforms a less-performant fallback implementation based on the [TinyThread](http://tinythreadpp.bitsnbites.eu/) library is used.
@@ -12,20 +16,4 @@ The RcppParallel package is made available under the [GPLv2](http://www.gnu.org/
1216

1317
The TinyThread library is licensed under the [zlib/libpng](http://www.opensource.org/licenses/zlib-license.php) license as described [here](https://gitorious.org/tinythread/tinythreadpp/source/master:README.txt).
1418

15-
The Intel TBB Library is licensed under the GPLv2 (as described at https://www.threadingbuildingblocks.org/Licensing):
16-
17-
TBB and other open-source software available from this site is licensed under GPLv2 with the (libstdc++) runtime exception. Specifically, the TBB open-source license is the same license used by the GNU libstdc++ library in gcc 4.2.1 (and earlier). For a complete description of the license, please visit the official GNU website for [GPLv2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) and for the [runtime exception](https://www.threadingbuildingblocks.org/licensing#runtime-exception).
18-
19-
**Runtime Exception**
20-
21-
```
22-
As a special exception, you may use this file as part of a free software
23-
library without restriction. Specifically, if other files instantiate
24-
templates or use macros or inline functions from this file, or you compile
25-
this file and link it with other files to produce an executable, this
26-
file does not by itself cause the resulting executable to be covered by
27-
the GNU General Public License. This exception does not however
28-
invalidate any other reasons why the executable file might be covered by
29-
the GNU General Public License.
30-
```
31-
19+
The Intel TBB Library is licensed under the Apache 2.0 (as described at https://www.threadingbuildingblocks.org/faq/10).

appveyor.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# DO NOT CHANGE the "init" and "install" sections below
2+
3+
# Download script file from GitHub
4+
init:
5+
ps: |
6+
$ErrorActionPreference = "Stop"
7+
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
8+
Import-Module '..\appveyor-tool.ps1'
9+
10+
install:
11+
ps: Bootstrap
12+
13+
cache:
14+
- C:\RLibrary
15+
16+
# Adapt as necessary starting from here
17+
18+
build_script:
19+
- travis-tool.sh install_deps
20+
21+
test_script:
22+
- travis-tool.sh run_tests
23+
24+
on_failure:
25+
- 7z a failure.zip *.Rcheck\*
26+
- appveyor PushArtifact failure.zip
27+
28+
artifacts:
29+
- path: '*.Rcheck\**\*.log'
30+
name: Logs
31+
32+
- path: '*.Rcheck\**\*.out'
33+
name: Logs
34+
35+
- path: '*.Rcheck\**\*.fail'
36+
name: Logs
37+
38+
- path: '*.Rcheck\**\*.Rout'
39+
name: Logs
40+
41+
- path: '\*_*.tar.gz'
42+
name: Bits
43+
44+
- path: '\*_*.zip'
45+
name: Bits

inst/NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
RcppParallel 4.3.21 (unreleased)
1+
RcppParallel 2017.7.0 (unreleased)
22
------------------------------------------------------------------------
33

44
* Allow setting the number of threads to use via RCPP_PARALLEL_NUM_THREADS
55
environment variable.
6+
* Update to TBB 2017 Update 7.
7+
* Add native registration of compiled functions.
68

79
RcppParallel 4.3.20
810
------------------------------------------------------------------------

inst/include/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<HTML>
2+
<BODY>
3+
4+
<H2>Overview</H2>
5+
Include files for Intel&reg; Threading Building Blocks (Intel&reg; TBB).
6+
7+
<H2>Directories</H2>
8+
<DL>
9+
<DT><A HREF="tbb/index.html">tbb</A>
10+
<DD>Include files for Intel TBB classes and functions.
11+
<DT><A HREF="serial/tbb/">serial/tbb</A>
12+
<DD>Include files for a sequential implementation of the parallel_for algorithm.
13+
</DL>
14+
15+
<HR>
16+
<A HREF="../index.html">Up to parent directory</A>
17+
<p></p>
18+
Copyright &copy; 2005-2017 Intel Corporation. All Rights Reserved.
19+
<P></P>
20+
Intel is a registered trademark or trademark of Intel Corporation
21+
or its subsidiaries in the United States and other countries.
22+
<p></p>
23+
* Other names and brands may be claimed as the property of others.
24+
</BODY>
25+
</HTML>
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
/*
2+
Copyright (c) 2005-2017 Intel Corporation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
17+
18+
19+
*/
20+
21+
#ifndef __TBB_SERIAL_parallel_for_H
22+
#define __TBB_SERIAL_parallel_for_H
23+
24+
#if !TBB_USE_EXCEPTIONS && _MSC_VER
25+
// Suppress "C++ exception handler used, but unwind semantics are not enabled" warning in STL headers
26+
#pragma warning (push)
27+
#pragma warning (disable: 4530)
28+
#endif
29+
30+
#include <stdexcept>
31+
#include <string> // required to construct std exception classes
32+
33+
#if !TBB_USE_EXCEPTIONS && _MSC_VER
34+
#pragma warning (pop)
35+
#endif
36+
37+
#include "tbb_annotate.h"
38+
39+
#ifndef __TBB_NORMAL_EXECUTION
40+
#include "tbb/blocked_range.h"
41+
#include "tbb/partitioner.h"
42+
#endif
43+
44+
namespace tbb {
45+
namespace serial {
46+
namespace interface9 {
47+
48+
// parallel_for serial annotated implementation
49+
50+
template< typename Range, typename Body, typename Partitioner >
51+
class start_for : tbb::internal::no_copy {
52+
Range my_range;
53+
const Body my_body;
54+
typename Partitioner::task_partition_type my_partition;
55+
void execute();
56+
57+
//! Constructor for root task.
58+
start_for( const Range& range, const Body& body, Partitioner& partitioner ) :
59+
my_range( range ),
60+
my_body( body ),
61+
my_partition( partitioner )
62+
{
63+
}
64+
65+
//! Splitting constructor used to generate children.
66+
/** this becomes left child. Newly constructed object is right child. */
67+
start_for( start_for& parent_, typename Partitioner::split_type& split_obj ) :
68+
my_range( parent_.my_range, split_obj ),
69+
my_body( parent_.my_body ),
70+
my_partition( parent_.my_partition, split_obj )
71+
{
72+
}
73+
74+
public:
75+
static void run( const Range& range, const Body& body, Partitioner& partitioner ) {
76+
if( !range.empty() ) {
77+
ANNOTATE_SITE_BEGIN( tbb_parallel_for );
78+
{
79+
start_for a( range, body, partitioner );
80+
a.execute();
81+
}
82+
ANNOTATE_SITE_END( tbb_parallel_for );
83+
}
84+
}
85+
};
86+
87+
template< typename Range, typename Body, typename Partitioner >
88+
void start_for< Range, Body, Partitioner >::execute() {
89+
if( !my_range.is_divisible() || !my_partition.is_divisible() ) {
90+
ANNOTATE_TASK_BEGIN( tbb_parallel_for_range );
91+
{
92+
my_body( my_range );
93+
}
94+
ANNOTATE_TASK_END( tbb_parallel_for_range );
95+
} else {
96+
typename Partitioner::split_type split_obj;
97+
start_for b( *this, split_obj );
98+
this->execute(); // Execute the left interval first to keep the serial order.
99+
b.execute(); // Execute the right interval then.
100+
}
101+
}
102+
103+
//! Parallel iteration over range with default partitioner.
104+
/** @ingroup algorithms **/
105+
template<typename Range, typename Body>
106+
void parallel_for( const Range& range, const Body& body ) {
107+
serial::interface9::start_for<Range,Body,const __TBB_DEFAULT_PARTITIONER>::run(range,body,__TBB_DEFAULT_PARTITIONER());
108+
}
109+
110+
//! Parallel iteration over range with simple partitioner.
111+
/** @ingroup algorithms **/
112+
template<typename Range, typename Body>
113+
void parallel_for( const Range& range, const Body& body, const simple_partitioner& partitioner ) {
114+
serial::interface9::start_for<Range,Body,const simple_partitioner>::run(range,body,partitioner);
115+
}
116+
117+
//! Parallel iteration over range with auto_partitioner.
118+
/** @ingroup algorithms **/
119+
template<typename Range, typename Body>
120+
void parallel_for( const Range& range, const Body& body, const auto_partitioner& partitioner ) {
121+
serial::interface9::start_for<Range,Body,const auto_partitioner>::run(range,body,partitioner);
122+
}
123+
124+
//! Parallel iteration over range with static_partitioner.
125+
/** @ingroup algorithms **/
126+
template<typename Range, typename Body>
127+
void parallel_for( const Range& range, const Body& body, const static_partitioner& partitioner ) {
128+
serial::interface9::start_for<Range,Body,const static_partitioner>::run(range,body,partitioner);
129+
}
130+
131+
//! Parallel iteration over range with affinity_partitioner.
132+
/** @ingroup algorithms **/
133+
template<typename Range, typename Body>
134+
void parallel_for( const Range& range, const Body& body, affinity_partitioner& partitioner ) {
135+
serial::interface9::start_for<Range,Body,affinity_partitioner>::run(range,body,partitioner);
136+
}
137+
138+
//! Implementation of parallel iteration over stepped range of integers with explicit step and partitioner (ignored)
139+
template <typename Index, typename Function, typename Partitioner>
140+
void parallel_for_impl(Index first, Index last, Index step, const Function& f, Partitioner& ) {
141+
if (step <= 0 )
142+
throw std::invalid_argument( "nonpositive_step" );
143+
else if (last > first) {
144+
// Above "else" avoids "potential divide by zero" warning on some platforms
145+
ANNOTATE_SITE_BEGIN( tbb_parallel_for );
146+
for( Index i = first; i < last; i = i + step ) {
147+
ANNOTATE_TASK_BEGIN( tbb_parallel_for_iteration );
148+
{ f( i ); }
149+
ANNOTATE_TASK_END( tbb_parallel_for_iteration );
150+
}
151+
ANNOTATE_SITE_END( tbb_parallel_for );
152+
}
153+
}
154+
155+
//! Parallel iteration over a range of integers with explicit step and default partitioner
156+
template <typename Index, typename Function>
157+
void parallel_for(Index first, Index last, Index step, const Function& f) {
158+
parallel_for_impl<Index,Function,const auto_partitioner>(first, last, step, f, auto_partitioner());
159+
}
160+
//! Parallel iteration over a range of integers with explicit step and simple partitioner
161+
template <typename Index, typename Function>
162+
void parallel_for(Index first, Index last, Index step, const Function& f, const simple_partitioner& p) {
163+
parallel_for_impl<Index,Function,const simple_partitioner>(first, last, step, f, p);
164+
}
165+
//! Parallel iteration over a range of integers with explicit step and auto partitioner
166+
template <typename Index, typename Function>
167+
void parallel_for(Index first, Index last, Index step, const Function& f, const auto_partitioner& p) {
168+
parallel_for_impl<Index,Function,const auto_partitioner>(first, last, step, f, p);
169+
}
170+
//! Parallel iteration over a range of integers with explicit step and static partitioner
171+
template <typename Index, typename Function>
172+
void parallel_for(Index first, Index last, Index step, const Function& f, const static_partitioner& p) {
173+
parallel_for_impl<Index,Function,const static_partitioner>(first, last, step, f, p);
174+
}
175+
//! Parallel iteration over a range of integers with explicit step and affinity partitioner
176+
template <typename Index, typename Function>
177+
void parallel_for(Index first, Index last, Index step, const Function& f, affinity_partitioner& p) {
178+
parallel_for_impl(first, last, step, f, p);
179+
}
180+
181+
//! Parallel iteration over a range of integers with default step and default partitioner
182+
template <typename Index, typename Function>
183+
void parallel_for(Index first, Index last, const Function& f) {
184+
parallel_for_impl<Index,Function,const auto_partitioner>(first, last, static_cast<Index>(1), f, auto_partitioner());
185+
}
186+
//! Parallel iteration over a range of integers with default step and simple partitioner
187+
template <typename Index, typename Function>
188+
void parallel_for(Index first, Index last, const Function& f, const simple_partitioner& p) {
189+
parallel_for_impl<Index,Function,const simple_partitioner>(first, last, static_cast<Index>(1), f, p);
190+
}
191+
//! Parallel iteration over a range of integers with default step and auto partitioner
192+
template <typename Index, typename Function>
193+
void parallel_for(Index first, Index last, const Function& f, const auto_partitioner& p) {
194+
parallel_for_impl<Index,Function,const auto_partitioner>(first, last, static_cast<Index>(1), f, p);
195+
}
196+
//! Parallel iteration over a range of integers with default step and static partitioner
197+
template <typename Index, typename Function>
198+
void parallel_for(Index first, Index last, const Function& f, const static_partitioner& p) {
199+
parallel_for_impl<Index,Function,const static_partitioner>(first, last, static_cast<Index>(1), f, p);
200+
}
201+
//! Parallel iteration over a range of integers with default step and affinity_partitioner
202+
template <typename Index, typename Function>
203+
void parallel_for(Index first, Index last, const Function& f, affinity_partitioner& p) {
204+
parallel_for_impl(first, last, static_cast<Index>(1), f, p);
205+
}
206+
207+
} // namespace interfaceX
208+
209+
using interface9::parallel_for;
210+
211+
} // namespace serial
212+
213+
#ifndef __TBB_NORMAL_EXECUTION
214+
using serial::interface9::parallel_for;
215+
#endif
216+
217+
} // namespace tbb
218+
219+
#endif /* __TBB_SERIAL_parallel_for_H */

0 commit comments

Comments
 (0)