From 0abedafadbed693592804f23482a9447d81b2dbf Mon Sep 17 00:00:00 2001 From: Vivek Chengalvala Date: Wed, 1 Mar 2017 16:02:05 -0500 Subject: allocate canny variables from stack The file scope of canny_ctx(CL_DEVICE_TYPE_ACCELERATOR) OpenCL context object resulted in constructor for Context called during g_module_open (g_plugin.c) of "/usr/lib/gstreamer-1.0/libgstdsp66.so", leading to OpenCL device initialization and subsequent CMEM error (when CMEM is not installed). The fix is to create the Context object on the stack, along the lines of oclconv_imgproc --- src/kernels/oclconv/oclconv.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kernels/oclconv/oclconv.cpp b/src/kernels/oclconv/oclconv.cpp index 2c99bf3..05f884c 100644 --- a/src/kernels/oclconv/oclconv.cpp +++ b/src/kernels/oclconv/oclconv.cpp @@ -93,13 +93,6 @@ static int oclconv_imgproc(char *kernelName, unsigned char *data_in, unsigned ch #endif return 0; } -/*----------------------------------------------------------------------------------------------------------------------*/ -static bool canny_first_call = true; -static Context canny_ctx(CL_DEVICE_TYPE_ACCELERATOR); -static CommandQueue *canny_Q; -static Buffer *canny_gradX, *canny_gradY, *canny_mag, *canny_scratch, *canny_numItems; -static Kernel *canny_K; -static Buffer *canny_input, *canny_output; /****************************************************************************** * Canny Edge Detection - called on ARM, but algorithm dispatched to 1 DSP @@ -113,9 +106,16 @@ static Buffer *canny_input, *canny_output; *****************************************************************************/ static int ocl_canny(unsigned char *data_in, unsigned char *data_out, unsigned short height, unsigned short width) { - int numelem = (int)height*(int)width; + int numelem = (int)height*(int)width; + static bool canny_first_call = true; + CommandQueue *canny_Q; + Buffer *canny_gradX, *canny_gradY, *canny_mag, *canny_scratch, *canny_numItems; + Kernel *canny_K; + Buffer *canny_input, *canny_output; + try { + Context canny_ctx(CL_DEVICE_TYPE_ACCELERATOR); Event canny_ev, canny_ev1, canny_ev2; /*--------------------------------------------------------------------- * Cache as much OpenCL plumbing on the first call, so the cost is not -- cgit v1.2.3-54-g00ecf