如何在Windows中运行OpenACC + OpenCV with PGI?



我尝试运行下面的代码:

#include <chrono>
#include <omp.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
using namespace std;
int main()
{
std::string imgstr = "input.bmp";
cv::Mat imgmat = cv::imread(imgstr, cv::IMREAD_GRAYSCALE);
imgmat.convertTo(imgmat, CV_64FC1, 1.0 / 255.0);
double st = omp_get_wtime();
int i, j;
double res = 0.0;
#pragma acc parallel loop
for (i =0; i <= 10; i++) {
for (j =0; j <=10; j++) {
res =res+ imgmat.at<double>(i, j);
}
}
double runtime = omp_get_wtime() - st;
printf("n total: %f sn", runtime);
}

在 PGI 中pgcc -fast -ta=nvidia,managed -Minfo=accel -o runEx runEx.c -lopencv_legacy -lopencv_highgui -lopencv_core && ./runEx,但我收到一个错误说

can't find include file opencv2/opencv.hpp

但是,上面的代码在Visual Studio中成功编译并运行,而无需使用OpenACC

谁能帮忙?

很可能您需要在命令行上使用"-I/path/to/openvc/include"标志包含头文件的路径。 您还需要包含库路径(通过"-L/path/to/opencv/lib"(,以便它可以找到库。

虽然给定"pgcc"是一个C编译器,但鉴于您在代码中使用C++头文件和C++构造,您会遇到其他问题。 当前的 PGI 版本不支持 Windows 上的C++。

最新更新