Escolar Documentos
Profissional Documentos
Cultura Documentos
This Would yield Cpu and Gpu time for doing same operation of sobel edge detection on
same pic.
# include <time.h>
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <math.h>
# include <cuda.h>
# include <cutil.h>
# include <ctime>
-2, 0, 2,
-1, 0, 1 };
int Gy[3][3] = { 1 ,2 ,1 ,
0,0,0,
-1,-2,-1 };
sumX = sumY = 0;
}
int sum = abs(sumY) + abs(sumX);
return sum;}
offset += width;}
__global__ void d_EdgeDetect(unsigned char *org, unsigned char *result, int width, int height) {
if (row < 2 || col < 2 || row >= height - 3 || col >= width - 3)
return;
-2, 0, 2,
-1, 0, 1 };
int Gy[3][3] = { 1 ,2 ,1 ,
0,0,0,
-1,-2,-1 };
sumX = sumY = 0;
starttime = clock();
h_EdgeDetect(h_pixels, h_resultPixels);
endtime = clock();
cutCreateTimer(&timer);
cutStartTimer(timer);
cudaThreadSynchronize();
cutStopTimer(timer);
getchar();