profiling to console

This commit is contained in:
Marcel Lütke Dreimann
2025-06-27 13:44:45 +02:00
parent 9791bfbd38
commit f63168342e

View File

@@ -439,14 +439,13 @@ int main(int argc, char **argv)
double tInt = (tInt2.tv_sec - tInt1.tv_sec) * 1000 + (tInt2.tv_usec - tInt1.tv_usec) / (float)1000; double tInt = (tInt2.tv_sec - tInt1.tv_sec) * 1000 + (tInt2.tv_usec - tInt1.tv_usec) / (float)1000;
float *idata = (float *)img.ptr<float>(0); float *idata = (float *)img.ptr<float>(0);
FILE *fp = fopen("cpu_imgdata.dat", "w"); printf("cpu_imgdata.dat:\n");
for (int i = 0; i < height; i++) for (int i = 0; i < height; i++)
{ {
for (int j = 0; j < width; j++) for (int j = 0; j < width; j++)
fprintf(fp, "%f\t", *idata++); printf("%f\t", *idata++);
fprintf(fp, "\n"); printf("\n");
} }
fclose(fp);
#ifndef OCV #ifndef OCV
free(intImgHost.data); free(intImgHost.data);
#endif // OCV #endif // OCV
@@ -485,15 +484,14 @@ int main(int argc, char **argv)
#ifdef profile #ifdef profile
int N = imgSize; int N = imgSize;
FILE *hin = fopen("in.dat", "w"); printf("in.dat:\n");
for (int i = 0; i < height; i++) for (int i = 0; i < height; i++)
{ {
for (int j = 0; j < width; j++) for (int j = 0; j < width; j++)
fprintf(hin, "%f\t", data[i * width + j]); printf("%f\t", data[i * width + j]);
fprintf(hin, "\n"); printf("\n");
} }
fclose(hin);
#endif #endif
// RowIntegral kernel: First Compute prefix sum in rows of the source image // RowIntegral kernel: First Compute prefix sum in rows of the source image
@@ -539,15 +537,14 @@ int main(int argc, char **argv)
ciErrNum = clEnqueueReadBuffer(clqueue, d_Output, CL_TRUE, 0, N * sizeof(float), h_OutputGPU, 0, NULL, NULL); ciErrNum = clEnqueueReadBuffer(clqueue, d_Output, CL_TRUE, 0, N * sizeof(float), h_OutputGPU, 0, NULL, NULL);
// oclCheckError(ciErrNum, CL_SUCCESS); // oclCheckError(ciErrNum, CL_SUCCESS);
FILE *rowout = fopen("Rout.dat", "w"); printf("Rout.dat");
for (int i = 0; i < height; i++) for (int i = 0; i < height; i++)
{ {
for (int j = 0; j < width; j++) for (int j = 0; j < width; j++)
fprintf(rowout, "%f\t", h_OutputGPU[i * width + j]); printf("%f\t", h_OutputGPU[i * width + j]);
fprintf(rowout, "\n"); printf("\n");
} }
fclose(rowout);
free(h_OutputGPU); free(h_OutputGPU);
#endif #endif
@@ -591,17 +588,15 @@ int main(int argc, char **argv)
ciErrNum = clEnqueueReadBuffer(clqueue, intImage, CL_TRUE, 0, N * sizeof(float), h_ImgputGPU, 0, NULL, NULL); ciErrNum = clEnqueueReadBuffer(clqueue, intImage, CL_TRUE, 0, N * sizeof(float), h_ImgputGPU, 0, NULL, NULL);
// oclCheckError(ciErrNum, CL_SUCCESS); // oclCheckError(ciErrNum, CL_SUCCESS);
FILE *imgout = fopen("intImage.dat", "w"); printf("intImage.dat:\n");
for (int i = 0; i < height; i++) for (int i = 0; i < height; i++)
{ {
for (int j = 0; j < width; j++) for (int j = 0; j < width; j++)
fprintf(imgout, "%f\t", h_ImgputGPU[i * width + j]); printf("%f\t", h_ImgputGPU[i * width + j]);
fprintf(imgout, "\n"); printf("\n");
} }
fclose(imgout);
free(h_ImgputGPU); free(h_ImgputGPU);
#endif #endif
// BuildResponeselayer kernel: Calculate DoH responses for the layers // BuildResponeselayer kernel: Calculate DoH responses for the layers
@@ -665,25 +660,28 @@ int main(int argc, char **argv)
10 * h * w * sizeof(cl_float), (float *)hostLaplacian, 0, NULL, NULL); 10 * h * w * sizeof(cl_float), (float *)hostLaplacian, 0, NULL, NULL);
SHOWERR(clEnqueueReadBuffer\t\thostLaplacian < -- -laplacian); SHOWERR(clEnqueueReadBuffer\t\thostLaplacian < -- -laplacian);
FILE *resfp = fopen("responses.dat", "w"); printf("responses.dat:\n");
FILE *lapfp = fopen("laplacian.dat", "w");
for (int dptr = 0; dptr < 10 * h * w; dptr++) for (int dptr = 0; dptr < 10 * h * w; dptr++)
{ {
if (dptr % 10 == 0 && dptr != 0) if (dptr % 10 == 0 && dptr != 0)
{ {
fprintf(resfp, "\n"); printf("\n");
fprintf(lapfp, "\n");
} }
fprintf(resfp, "%f ", hostResponses[dptr]); printf("%f ", hostResponses[dptr]);
fprintf(lapfp, "%f ", hostLaplacian[dptr]); }
printf("laplacian.dat:\n");
for (int dptr = 0; dptr < 10 * h * w; dptr++)
{
if (dptr % 10 == 0 && dptr != 0)
{
printf("\n");
}
printf("%f ", hostLaplacian[dptr]);
} }
fclose(lapfp);
fclose(resfp);
free(hostResponses); free(hostResponses);
free(hostLaplacian); free(hostLaplacian);
#endif #endif
// IsExtremum kernel: Non Maximal Suppression function // IsExtremum kernel: Non Maximal Suppression function
@@ -770,13 +768,12 @@ int main(int argc, char **argv)
//clWaitForEvents(1, &WriteOut); //clWaitForEvents(1, &WriteOut);
cOut = executionTime(WriteOut); cOut = executionTime(WriteOut);
FILE *pExtfpi = fopen("extre.dat", "w"); printf("extre.dat:\n");
for (int pi = 0; pi < 8 * w * h; pi++) for (int pi = 0; pi < 8 * w * h; pi++)
{ {
fprintf(pExtfpi, "%d\t%d\t%.6f\t%d\n", hostExtLocation[pi].x, hostExtLocation[pi].y, printf("%d\t%d\t%.6f\t%d\n", hostExtLocation[pi].x, hostExtLocation[pi].y,
hostExtLocation[pi].scale, hostExtLocation[pi].lap); hostExtLocation[pi].scale, hostExtLocation[pi].lap);
} }
fclose(pExtfpi);
free(hostExtLocation); free(hostExtLocation);
@@ -838,16 +835,15 @@ int main(int argc, char **argv)
ciErrNum = clEnqueueReadBuffer(clqueue, orientation, CL_TRUE, 0, cmn * sizeof(float), (float *)hostOri, 0, NULL, NULL); ciErrNum = clEnqueueReadBuffer(clqueue, orientation, CL_TRUE, 0, cmn * sizeof(float), (float *)hostOri, 0, NULL, NULL);
SHOWERR(clEnqueueReadBuffer\t\thostOri < -- -ori test); SHOWERR(clEnqueueReadBuffer\t\thostOri < -- -ori test);
FILE *orifp = fopen("ori.dat", "w"); printf("ori.dat:\n");
for (int ori = 0; ori < cmn; ori++) for (int ori = 0; ori < cmn; ori++)
{ {
if (ori % 10 == 0 && ori != 0) if (ori % 10 == 0 && ori != 0)
{ {
fprintf(orifp, "\n"); printf("\n");
} }
fprintf(orifp, "%.6f ", hostOri[ori]); printf("%.6f ", hostOri[ori]);
} }
fclose(orifp);
free(hostOri); free(hostOri);
/* /*
@@ -919,30 +915,40 @@ int main(int argc, char **argv)
ciErrNum = clEnqueueReadBuffer(clqueue, gauss_s2, CL_TRUE, 0, 16 * cmn * sizeof(float), (float *)hostGau, 0, NULL, NULL); ciErrNum = clEnqueueReadBuffer(clqueue, gauss_s2, CL_TRUE, 0, 16 * cmn * sizeof(float), (float *)hostGau, 0, NULL, NULL);
SHOWERR(clEnqueueReadBuffer\t\thostDes < -- -Xs Ys gauss_s2); SHOWERR(clEnqueueReadBuffer\t\thostDes < -- -Xs Ys gauss_s2);
FILE *Xsfp = fopen("xs.dat", "w"); printf("xs.dat:\n");
FILE *Ysfp = fopen("ys.dat", "w");
FILE *Gaufp = fopen("gauss.dat", "w");
int sc; int sc;
for (sc = 0; sc < 16 * cmn; sc++) for (sc = 0; sc < 16 * cmn; sc++)
{ {
if (sc % 8 == 0 && sc != 0) if (sc % 8 == 0 && sc != 0)
{ {
fprintf(Xsfp, "\n"); printf("\n");
fprintf(Ysfp, "\n");
fprintf(Gaufp, "\n");
} }
fprintf(Xsfp, "%d\t", hostXs[sc]); printf("%d\t", hostXs[sc]);
fprintf(Ysfp, "%d\t", hostYs[sc]); }
fprintf(Gaufp, "%.6f\t", hostGau[sc]);
printf("ys.dat:\n");
for (sc = 0; sc < 16 * cmn; sc++)
{
if (sc % 8 == 0 && sc != 0)
{
printf("\n");
}
printf("%d\t", hostYs[sc]);
}
printf("gauss.dat:\n");
for (sc = 0; sc < 16 * cmn; sc++)
{
if (sc % 8 == 0 && sc != 0)
{
printf("\n");
}
printf("%.6f\t", hostGau[sc]);
} }
fclose(Xsfp);
fclose(Ysfp);
fclose(Gaufp);
free(hostXs); free(hostXs);
free(hostYs); free(hostYs);
free(hostGau); free(hostGau);
#endif #endif
// GetDescriptor kernel: Calculate descriptor for the interest points // GetDescriptor kernel: Calculate descriptor for the interest points
@@ -1042,20 +1048,17 @@ int main(int argc, char **argv)
ciErrNum = clEnqueueReadBuffer(clqueue, des, CL_TRUE, 0, 64 * cmn * sizeof(float), (float *)hostDes, 0, NULL, NULL); ciErrNum = clEnqueueReadBuffer(clqueue, des, CL_TRUE, 0, 64 * cmn * sizeof(float), (float *)hostDes, 0, NULL, NULL);
SHOWERR(clEnqueueReadBuffer\t\thostDes < -- -des); SHOWERR(clEnqueueReadBuffer\t\thostDes < -- -des);
FILE *Desfp = fopen("des.dat", "w"); printf("des.dat:\n");
int desc; int desc;
for (desc = 0; desc < 64 * cmn; desc++) for (desc = 0; desc < 64 * cmn; desc++)
{ {
if (desc % 8 == 0 && desc != 0) if (desc % 8 == 0 && desc != 0)
{ {
fprintf(Desfp, "\n"); printf("\n");
} }
fprintf(Desfp, "%.6f\t", hostDes[desc]); printf("%.6f\t", hostDes[desc]);
} }
fclose(Desfp);
free(hostDes); free(hostDes);
#endif #endif
// cknormalDes kernel: normalize descriptors // cknormalDes kernel: normalize descriptors
@@ -1102,18 +1105,16 @@ mid = clCreateBuffer(context,
64 * cmn * sizeof(float), (float *)hostnDes, 0, NULL, NULL); 64 * cmn * sizeof(float), (float *)hostnDes, 0, NULL, NULL);
SHOWERR(clEnqueueReadBuffer\t\thostnDes < -- -ndes); SHOWERR(clEnqueueReadBuffer\t\thostnDes < -- -ndes);
FILE *nDesfp = fopen("ndes.dat", "w"); printf("ndes.dat:\n");
int ndesc; int ndesc;
for (ndesc = 0; ndesc < 64 * cmn; ndesc++) for (ndesc = 0; ndesc < 64 * cmn; ndesc++)
{ {
if (ndesc % 8 == 0 && ndesc != 0) if (ndesc % 8 == 0 && ndesc != 0)
{ {
fprintf(nDesfp, "\n"); printf("\n");
} }
fprintf(nDesfp, "%.6f\t", hostnDes[ndesc]); printf("%.6f\t", hostnDes[ndesc]);
} }
fclose(nDesfp);
free(hostnDes); free(hostnDes);
#endif #endif