Eigen Version 3.3.90
gcc Версия 5.4.0
В настоящее время я пытаюсь добавить поддержку многопоточности в свой проект Eigen Tensor, и у меня возникла проблема с созданием ThreadPoolDevice, необходимого для оценки тензорных операций.
Пример минимального кода, который приводит к ошибке, показан ниже. Это основано на примерах , показанных здесь в Eigen Docs.
#include <iostream>
#define EIGEN_USE_THREADS
#include <unsupported/Eigen/CXX11/Tensor>
#include <unsupported/Eigen/CXX11/ThreadPool>
int main()
{
std::cout << "Eigen Version " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << std::endl;
// Create the Eigen ThreadPoolDevice.
Eigen::ThreadPoolDevice my_device(4 /* number of threads to use */);
Eigen::Tensor<float, 2> a(40, 40);
Eigen::Tensor<float, 2> b(40, 40);
// Now just use the device when evaluating expressions.
Eigen::array<Eigen::IndexPair<int>, 1> product_dims = { Eigen::IndexPair<int>(1, 0) };
Eigen::Tensor<float, 2> c;
c.device(my_device) = a.contract(b, product_dims);
std::cout << "Result was " << c << std::endl;
return 0;
}
Появляется сообщение об ошибке, показанное ниже:
thread_pool_tests.cpp: In function ‘int main()’:
thread_pool_tests.cpp:12:68: error: no matching function for call to ‘Eigen::ThreadPoolDevice::ThreadPoolDevice(int)’
Eigen::ThreadPoolDevice my_device(4 /* number of threads to use */);
^
In file included from /usr/local/include/unsupported/Eigen/CXX11/Tensor:103:0,
from thread_pool_tests.cpp:4:
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:55:3: note: candidate: Eigen::ThreadPoolDevice::ThreadPoolDevice(Eigen::ThreadPoolInterface*, int, Eigen::Allocator*)
ThreadPoolDevice(ThreadPoolInterface* pool, int num_cores, Allocator* allocator = NULL)
^
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:55:3: note: candidate expects 3 arguments, 1 provided
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:53:8: note: candidate: constexpr Eigen::ThreadPoolDevice::ThreadPoolDevice(const Eigen::ThreadPoolDevice&)
struct ThreadPoolDevice {
^
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:53:8: note: no known conversion for argument 1 from ‘int’ to ‘const Eigen::ThreadPoolDevice&’
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:53:8: note: candidate: constexpr Eigen::ThreadPoolDevice::ThreadPoolDevice(Eigen::ThreadPoolDevice&&)
/usr/local/include/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:53:8: note: no known conversion for argument 1 from ‘int’ to ‘Eigen::ThreadPoolDevice&&’
Похоже, что конструктор ThreadPoolDevice в этой версии также ожидает указатель на объект, производный от ThreadPoolInterface. Но я не могу найти никаких примеров этой формы. Кто-нибудь знает, как я могу решить эту проблему и начать работать с ThreadPoolDevices в моем приложении.
Спасибо.