Hi all,
I would like to apply acc routine at this time, but it give “call to cuStreamSynchronize returned error 700: Illegal address during kernel execution” error.
What I am trying to do is just converting image(int*) to integral image(int*).
My codes are followings:
#include <opencv2/opencv.hpp>
#include <boost/filesystem.hpp>
using namespace cv;
using namespace std;
const int I_WIDTH = 5;
const int I_HEIGHT = 5;
const int I_LENGTH = 25;
const int II_WIDTH = 6;
const int II_HEIGHT = 6;
const int II_LENGTH = 36;
const int NUM_IMG = 3;
void Mat2Arr(Mat in, int* &img_data, int img_length)
{
uchar* temp = in.data;
for (int i = 0; i < img_length; i++)
{
img_data[i] = (int) temp[i];
// cout << img_data[i] << " ";
}
// cout << endl;
}
#pragma void routine seq
void Img2II(int* img, int* &ii, int ii_width, int ii_height)
{
#pragma acc loop seq
for (int i = 0; i < ii_height; i++)
{
for (int j = 0; j < ii_width; j++)
{
if (i == 0 || j == 0)
{
ii[ii_width * i + j] = 0;
}
else
{
int val = img[(ii_width - 1) * (i - 1) + (j - 1)];
ii[ii_width * i + j] = val + ii[ii_width * (i - 1) + j]
+ ii[ii_width * i + (j - 1)]
- ii[ii_width * (i - 1) + (j - 1)];
}
// cout << ii[ii_width * i + j] << " ";
}
// cout << endl;
}
}
void MatSet2Arr(string dir, int** &imgs, int num_img, int img_length)
{
}
int main(void)
{
Mat img1 = imread("/home/dongyoung/Desktop/test1.jpg",
CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread("/home/dongyoung/Desktop/test2.jpg",
CV_LOAD_IMAGE_GRAYSCALE);
Mat img3 = imread("/home/dongyoung/Desktop/test3.jpg",
CV_LOAD_IMAGE_GRAYSCALE);
int** imgs = (int**) malloc(sizeof(int*) * NUM_IMG);
for (int i = 0; i < NUM_IMG; i++)
{
imgs[i] = (int*) malloc(sizeof(int) * I_LENGTH);
stringstream ss;
ss << "/home/dongyoung/Desktop/test" << i << ".jpg";
string filename = ss.str();
Mat temp = imread(filename, CV_LOAD_IMAGE_GRAYSCALE);
Mat2Arr(temp, imgs[i], I_LENGTH);
}
int** iis = (int**) malloc(sizeof(int*) * NUM_IMG);
for (int i = 0; i < NUM_IMG; i++)
{
iis[i] = (int*) malloc(sizeof(int) * II_LENGTH);
}
#pragma acc parallel loop
for (int i = 0; i < NUM_IMG; i++)
{
Img2II(imgs[i], iis[i], II_WIDTH, II_HEIGHT);
}
//Test
for(int i = 0; i<NUM_IMG; i++)
{
int* curII = iis[i];
for(int j = 0; j<II_HEIGHT; j++)
{
for(int k = 0; k<II_WIDTH; k++)
{
cout<<curII[II_WIDTH*j+k]<<" ";
}
cout<<endl;
}
cout<<endl;
}
}
The output:
call to cuStreamSynchronize returned error 700: Illegal address during kernel execution
Please someone insight me to solve this problem.
Thanks in advance,
DK