diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h index df9cc0998..7a54f7a23 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h @@ -85,8 +85,8 @@ class TensorExecutor #ifdef EIGEN_USE_THREADS template struct EvalRange { - static void run(void* evaluator_in, const Index first, const Index last) { - Evaluator evaluator(*static_cast(evaluator_in)); + static void run(Evaluator* evaluator_in, const Index first, const Index last) { + Evaluator evaluator = *evaluator_in; eigen_assert(last >= first); for (Index i = first; i < last; ++i) { evaluator.evalScalar(i); @@ -96,10 +96,9 @@ struct EvalRange { template struct EvalRange { - static void run(void* evaluator_in, const Index first, const Index last) { - Evaluator evaluator(*static_cast(evaluator_in)); + static void run(Evaluator* evaluator_in, const Index first, const Index last) { + Evaluator evaluator = *evaluator_in; eigen_assert(last >= first); - Index i = first; const int PacketSize = unpacket_traits::size; if (last - first >= PacketSize) { @@ -123,16 +122,6 @@ struct EvalRange { } }; -// Used to make an std::function to add to the ThreadPool with less templating -// than EvalRange::Run. -// This requires that this and EvalRange takes a void* to the evaluator that can -// be downcast to the right type by the EvalRange. -template -inline void InvokeEvalRange(void (*run_fn)(void*, const Index, const Index), - void* evaluator, const Index first, const Index last) { - run_fn(evaluator, first, last); -} - template class TensorExecutor { public: @@ -163,13 +152,12 @@ class TensorExecutor { Barrier barrier(numblocks); for (int i = 0; i < numblocks; ++i) { device.enqueue_with_barrier( - &barrier, &InvokeEvalRange, - &EvalRange::run, - static_cast(&evaluator), i * blocksize, - (i + 1) * blocksize); + &barrier, &EvalRange::run, + &evaluator, i * blocksize, (i + 1) * blocksize); } if (numblocks * blocksize < size) { - EvalRange::run(&evaluator, numblocks * blocksize, size); + EvalRange::run( + &evaluator, numblocks * blocksize, size); } barrier.Wait(); }