opencv performance in using opencl
I'm programming in C++ using OpenCV 3.1.0. Also I'm new in OpenCV. I want to use OpenCL. Here is my code:
int _tmain(int argc, _TCHAR* argv[])
{
clock_t t1, t2;
Mat image;
image = imread("...//myPic.jpg", CV_LOAD_IMAGE_GRAYSCALE); // Read the file
UMat u = image.getUMat(ACCESS_FAST);
// calculating time with OpenCL
cv::ocl::setUseOpenCL(true);
t1 = clock();
for (int i = 0; i < 1000; i++)
{
cv::Canny(u, u, 100, 50);
}
t2 = clock();
// showing time with OpenCL
double diff = ((double)t2 - (double)t1) / CLOCKS_PER_SEC;
cout << "Running time with OpenCL: " << diff << endl;
/////////////////////////////////////////////////////
// calculating time with OpenCL
cv::ocl::setUseOpenCL(false);
t1 = clock();
for (int i = 0; i < 1000; i++)
{
cv::Canny(u, u, 100, 50);
}
t2 = clock();
// showing time with OpenCL
diff = ((double)t2 - (double)t1) / CLOCKS_PER_SEC;
cout << "Running time without OpenCL: " << diff << endl;
getchar();
return 0;
}
Here is the result of running code in my laptop.
Running time with OpenCL: 5.565
Running time without OpenCL: 2.441
As it is expected first value must be less than second one significantly but it is not. I test OpenCl technology using EmguCV 3.1 ( it is a wrapper for opencv) in C# and the result test show that it is 40 times faster than when I do not use OpenCl.
System info:
Windows 8.1
Core i7 2.2GHz (2670QM)
Amd Radeon Graphic card (HD 6700M)
8GB RAM
Why the time with OpenCL is not what It should be expected?
with your program my results are :
It is amazing! I get result like yours using EmguCV
How can I check my environmental variables are set correctly?
Did you compile OpenCV yourself or use an installer?
Maybe the OpenCL code is runned on the Intel integrated GPU, if this CPU has one?