|
|
|
@ -18,8 +18,7 @@
|
|
|
|
|
// http://msdn.microsoft.com/en-us/library/dd504870.aspx
|
|
|
|
|
#if NV_OS_WIN32 && _MSC_VER >= 1600
|
|
|
|
|
#define HAVE_PPL 1
|
|
|
|
|
#include <array>
|
|
|
|
|
//#include <ppl.h>
|
|
|
|
|
#include <ppl.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Intel Thread Building Blocks (TBB).
|
|
|
|
@ -92,24 +91,9 @@ namespace nvtt {
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_PPL)
|
|
|
|
|
|
|
|
|
|
class CountingIterator
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CountingIterator() : i(0) {}
|
|
|
|
|
CountingIterator(const CountingIterator & rhs) : i(0) {}
|
|
|
|
|
explicit CountingIterator(int x) : i(x) {}
|
|
|
|
|
|
|
|
|
|
const int & operator*() const { return i; }
|
|
|
|
|
CountingIterator & operator++() { i++; return *this; }
|
|
|
|
|
CountingIterator & operator--() { i--; return *this; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int i;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TaskFunctor {
|
|
|
|
|
TaskFunctor(Task * task, void * context) : task(task), context(context) {}
|
|
|
|
|
void operator()(int & n) const {
|
|
|
|
|
void operator()(int n) const {
|
|
|
|
|
task(context, n);
|
|
|
|
|
}
|
|
|
|
|
Task * task;
|
|
|
|
@ -121,12 +105,8 @@ namespace nvtt {
|
|
|
|
|
{
|
|
|
|
|
virtual void dispatch(Task * task, void * context, int count)
|
|
|
|
|
{
|
|
|
|
|
CountingIterator begin(0);
|
|
|
|
|
CountingIterator end((int)count);
|
|
|
|
|
TaskFunctor func(task, context);
|
|
|
|
|
|
|
|
|
|
std::for_each(begin, end, func);
|
|
|
|
|
//parallel_for_each(begin, end, func);
|
|
|
|
|
Concurrency::parallel_for(0, count, func);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|