Fix for TimeTBB not compiling on linux
parent
314c44b0ad
commit
b4942110bc
|
@ -47,14 +47,11 @@ struct ResultWithThreads
|
|||
typedef map<int, ResultWithThreads> Results;
|
||||
|
||||
/* ************************************************************************* */
|
||||
map<int, double> testWithoutMemoryAllocation()
|
||||
struct WorkerWithoutAllocation
|
||||
{
|
||||
// A function to do some matrix operations without allocating any memory
|
||||
struct Worker
|
||||
{
|
||||
vector<double>& results;
|
||||
|
||||
Worker(vector<double>& results) : results(results) {}
|
||||
WorkerWithoutAllocation(vector<double>& results) : results(results) {}
|
||||
|
||||
void operator()(const tbb::blocked_range<size_t>& r) const
|
||||
{
|
||||
|
@ -66,7 +63,12 @@ map<int, double> testWithoutMemoryAllocation()
|
|||
results[i] = prod.norm();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/* ************************************************************************* */
|
||||
map<int, double> testWithoutMemoryAllocation()
|
||||
{
|
||||
// A function to do some matrix operations without allocating any memory
|
||||
|
||||
// Now call it
|
||||
vector<double> results(numberOfProblems);
|
||||
|
@ -76,7 +78,7 @@ map<int, double> testWithoutMemoryAllocation()
|
|||
BOOST_FOREACH(size_t grainSize, grainSizes)
|
||||
{
|
||||
tbb::tick_count t0 = tbb::tick_count::now();
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), Worker(results));
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), WorkerWithoutAllocation(results));
|
||||
tbb::tick_count t1 = tbb::tick_count::now();
|
||||
cout << "Without memory allocation, grain size = " << grainSize << ", time = " << (t1 - t0).seconds() << endl;
|
||||
timingResults[grainSize] = (t1 - t0).seconds();
|
||||
|
@ -86,14 +88,11 @@ map<int, double> testWithoutMemoryAllocation()
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
map<int, double> testWithMemoryAllocation()
|
||||
struct WorkerWithAllocation
|
||||
{
|
||||
// A function to do some matrix operations with allocating memory
|
||||
struct Worker
|
||||
{
|
||||
vector<double>& results;
|
||||
|
||||
Worker(vector<double>& results) : results(results) {}
|
||||
WorkerWithAllocation(vector<double>& results) : results(results) {}
|
||||
|
||||
void operator()(const tbb::blocked_range<size_t>& r) const
|
||||
{
|
||||
|
@ -117,7 +116,12 @@ map<int, double> testWithMemoryAllocation()
|
|||
allocator.deallocate(proddata, problemSize * problemSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/* ************************************************************************* */
|
||||
map<int, double> testWithMemoryAllocation()
|
||||
{
|
||||
// A function to do some matrix operations with allocating memory
|
||||
|
||||
// Now call it
|
||||
vector<double> results(numberOfProblems);
|
||||
|
@ -127,7 +131,7 @@ map<int, double> testWithMemoryAllocation()
|
|||
BOOST_FOREACH(size_t grainSize, grainSizes)
|
||||
{
|
||||
tbb::tick_count t0 = tbb::tick_count::now();
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), Worker(results));
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), WorkerWithAllocation(results));
|
||||
tbb::tick_count t1 = tbb::tick_count::now();
|
||||
cout << "With memory allocation, grain size = " << grainSize << ", time = " << (t1 - t0).seconds() << endl;
|
||||
timingResults[grainSize] = (t1 - t0).seconds();
|
||||
|
|
Loading…
Reference in New Issue