Home | History | Annotate | Download | only in opencl
      1 // This file is part of OpenCV project.
      2 // It is subject to the license terms in the LICENSE file found in the top-level directory
      3 // of this distribution and at http://opencv.org/license.html.
      4 
      5 // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
      6 // Third party copyrights are property of their respective owners.
      7 
      8 #include "opencv2/core/utility.hpp"
      9 //#define CV_OPENCL_RUN_ASSERT
     10 
     11 #ifdef HAVE_OPENCL
     12 
     13 #ifdef CV_OPENCL_RUN_VERBOSE
     14 #define CV_OCL_RUN_(condition, func, ...)                                   \
     15     {                                                                       \
     16         if (cv::ocl::useOpenCL() && (condition) && func)                    \
     17         {                                                                   \
     18             printf("%s: OpenCL implementation is running\n", CV_Func);      \
     19             fflush(stdout);                                                 \
     20             CV_IMPL_ADD(CV_IMPL_OCL);                                       \
     21             return __VA_ARGS__;                                             \
     22         }                                                                   \
     23         else                                                                \
     24         {                                                                   \
     25             printf("%s: Plain implementation is running\n", CV_Func);       \
     26             fflush(stdout);                                                 \
     27         }                                                                   \
     28     }
     29 #elif defined CV_OPENCL_RUN_ASSERT
     30 #define CV_OCL_RUN_(condition, func, ...)                                   \
     31     {                                                                       \
     32         if (cv::ocl::useOpenCL() && (condition))                            \
     33         {                                                                   \
     34             if(func)                                                        \
     35             {                                                               \
     36                 CV_IMPL_ADD(CV_IMPL_OCL);                                   \
     37             }                                                               \
     38             else                                                            \
     39             {                                                               \
     40                 CV_Error(cv::Error::StsAssert, #func);                      \
     41             }                                                               \
     42             return __VA_ARGS__;                                             \
     43         }                                                                   \
     44     }
     45 #else
     46 #define CV_OCL_RUN_(condition, func, ...)                                   \
     47     if (cv::ocl::useOpenCL() && (condition) && func)                        \
     48     {                                                                       \
     49         CV_IMPL_ADD(CV_IMPL_OCL);                                           \
     50         return __VA_ARGS__;                                                 \
     51     }
     52 #endif
     53 
     54 #else
     55 #define CV_OCL_RUN_(condition, func, ...)
     56 #endif
     57 
     58 #define CV_OCL_RUN(condition, func) CV_OCL_RUN_(condition, func)
     59