Моя игрушечная программа вычисляет градиент изображения (простое вычитание верхней строки из нижней, масштабирование пополам и сохранение результатов).
Код: Выделить всё
#include
#include
#include
#include
Eigen::Matrix GetRandomMat(const int rows, const int cols)
{
return Eigen::Matrix::Random(rows, cols);
}
void compare(const Eigen::Matrix &grad_eig, const float *grad_simd)
{
const int rows = grad_eig.rows();
const int cols = grad_eig.cols();
for (int row = 1; row < rows - 1; ++row)
{
for (int col = 1; col < cols - 1; ++col)
{
if ((grad_eig(row, col) - grad_simd[row * cols + col]) != 0.0)
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79868320/simd-slower-than-a-single-implementation-for-toy-example[/url]
Мобильная версия