Skip to content

Commit

Permalink
opencl: Add missing checks for OpenCL failures
Browse files Browse the repository at this point in the history
Fix also text for an existing check.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Dec 3, 2016
1 parent 3e11fc1 commit 2bb0d9a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions opencl/openclwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ PERF_COUNT_START("pixReadFromTiffKernel")

l_uint32 *pResult = (l_uint32 *)malloc(w*h * sizeof(l_uint32));
rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "composeRGBPixel", &clStatus );
CHECK_OPENCL( clStatus, "clCreateKernel");
CHECK_OPENCL( clStatus, "clCreateKernel composeRGBPixel");

//Allocate input and output OCL buffers
valuesCl = allocateZeroCopyBuffer(rEnv, tiffdata, w*h, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &clStatus);
Expand Down Expand Up @@ -1390,6 +1390,7 @@ pixDilateCL_55(l_int32 wpl, l_int32 h)
localThreads[1] = GROUPSIZE_HMORY;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "morphoDilateHor_5x5", &status );
CHECK_OPENCL(status, "clCreateKernel morphoDilateHor_5x5");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1432,6 +1433,7 @@ pixDilateCL_55(l_int32 wpl, l_int32 h)
localThreads[1] = GROUPSIZE_Y;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "morphoDilateVer_5x5", &status );
CHECK_OPENCL(status, "clCreateKernel morphoDilateVer_5x5");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1484,6 +1486,7 @@ pixErodeCL_55(l_int32 wpl, l_int32 h)
localThreads[1] = GROUPSIZE_HMORY;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "morphoErodeHor_5x5", &status );
CHECK_OPENCL(status, "clCreateKernel morphoErodeHor_5x5");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1526,6 +1529,7 @@ pixErodeCL_55(l_int32 wpl, l_int32 h)
localThreads[1] = GROUPSIZE_Y;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "morphoErodeVer_5x5", &status );
CHECK_OPENCL(status, "clCreateKernel morphoErodeVer_5x5");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1603,6 +1607,7 @@ pixDilateCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
// Generic case.
rEnv.mpkKernel =
clCreateKernel(rEnv.mpkProgram, "morphoDilateHor", &status);
CHECK_OPENCL(status, "clCreateKernel morphoDilateHor");

status = clSetKernelArg(rEnv.mpkKernel, 0, sizeof(cl_mem), &pixsCLBuffer);
status = clSetKernelArg(rEnv.mpkKernel, 1, sizeof(cl_mem), &pixdCLBuffer);
Expand All @@ -1626,6 +1631,7 @@ pixDilateCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
// Specific Horizontal pass kernel for half width < 32
rEnv.mpkKernel =
clCreateKernel(rEnv.mpkProgram, "morphoDilateHor_32word", &status);
CHECK_OPENCL(status, "clCreateKernel morphoDilateHor_32word");
isEven = (xp != xn);

status = clSetKernelArg(rEnv.mpkKernel, 0, sizeof(cl_mem), &pixsCLBuffer);
Expand All @@ -1644,12 +1650,13 @@ pixDilateCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
pixtemp = pixsCLBuffer;
pixsCLBuffer = pixdCLBuffer;
pixdCLBuffer = pixtemp;
}
}
}

if (yp > 0 || yn > 0)
{
rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "morphoDilateVer", &status );
CHECK_OPENCL(status, "clCreateKernel morphoDilateVer");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1781,6 +1788,7 @@ cl_int pixErodeCL(l_int32 hsize, l_int32 vsize, l_uint32 wpl, l_uint32 h) {
// Vertical Pass
if (yp > 0 || yn > 0) {
rEnv.mpkKernel = clCreateKernel(rEnv.mpkProgram, "morphoErodeVer", &status);
CHECK_OPENCL(status, "clCreateKernel morphoErodeVer");

status = clSetKernelArg(rEnv.mpkKernel, 0, sizeof(cl_mem), &pixsCLBuffer);
status = clSetKernelArg(rEnv.mpkKernel, 1, sizeof(cl_mem), &pixdCLBuffer);
Expand Down Expand Up @@ -1926,6 +1934,7 @@ pixORCL_work(l_uint32 wpl, l_uint32 h, cl_mem buffer1, cl_mem buffer2, cl_mem ou
globalThreads[1] = gsize;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "pixOR", &status );
CHECK_OPENCL(status, "clCreateKernel pixOR");

status = clSetKernelArg(rEnv.mpkKernel,
0,
Expand Down Expand Up @@ -1975,6 +1984,7 @@ pixANDCL_work(l_uint32 wpl, l_uint32 h, cl_mem buffer1, cl_mem buffer2, cl_mem o
globalThreads[1] = gsize;

rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "pixAND", &status );
CHECK_OPENCL(status, "clCreateKernel pixAND");

// Enqueue a kernel run call.
status = clSetKernelArg(rEnv.mpkKernel,
Expand Down Expand Up @@ -2027,10 +2037,12 @@ pixSubtractCL_work(l_uint32 wpl, l_uint32 h, cl_mem buffer1, cl_mem buffer2, cl_
if (outBuffer != nullptr)
{
rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "pixSubtract", &status );
CHECK_OPENCL(status, "clCreateKernel pixSubtract");
}
else
{
rEnv.mpkKernel = clCreateKernel( rEnv.mpkProgram, "pixSubtract_inplace", &status );
CHECK_OPENCL(status, "clCreateKernel pixSubtract_inplace");
}

// Enqueue a kernel run call.
Expand Down

0 comments on commit 2bb0d9a

Please sign in to comment.