40
40
//M*/
41
41
42
42
#include " precomp.hpp"
43
+
44
+ #ifndef HAVE_OPENCL
45
+ #include " ocl_disabled.impl.hpp"
46
+ #else // HAVE_OPENCL
47
+
43
48
#include < list>
44
49
#include < map>
45
50
#include < deque>
106
111
#include " opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
107
112
#include " opencv2/core/opencl/runtime/opencl_clamdfft.hpp"
108
113
109
- #ifdef HAVE_OPENCL
110
114
#include " opencv2/core/opencl/runtime/opencl_core.hpp"
111
- #else
112
- #if defined(_MSC_VER)
113
- #pragma warning(push)
114
- #pragma warning(disable : 4100)
115
- #pragma warning(disable : 4702)
116
- #elif defined(__clang__)
117
- #pragma clang diagnostic push
118
- #pragma clang diagnostic ignored "-Wunused-parameter"
119
- #elif defined(__GNUC__)
120
- #pragma GCC diagnostic push
121
- #pragma GCC diagnostic ignored "-Wunused-parameter"
122
- #endif
123
- // TODO FIXIT: This file can't be build without OPENCL
124
- #include " ocl_deprecated.hpp"
125
- #endif // HAVE_OPENCL
126
115
127
116
#ifdef HAVE_OPENCL_SVM
128
117
#include " opencv2/core/opencl/runtime/opencl_svm_20.hpp"
@@ -147,31 +136,6 @@ cv::utils::AllocatorStatisticsInterface& getOpenCLAllocatorStatistics()
147
136
return opencl_allocator_stats;
148
137
}
149
138
150
- #ifndef HAVE_OPENCL
151
- #define CV_OPENCL_NO_SUPPORT () CV_Error(cv::Error::OpenCLApiCallError, " OpenCV build without OpenCL support" )
152
- namespace {
153
- struct DummyImpl
154
- {
155
- DummyImpl () { CV_OPENCL_NO_SUPPORT (); }
156
- ~DummyImpl () { /* do not throw in desctructors */ }
157
- IMPLEMENT_REFCOUNTABLE ();
158
- };
159
- } // namespace
160
-
161
- // TODO Replace to empty body (without HAVE_OPENCL)
162
- #define CV_OCL_TRACE_CHECK_RESULT (status, message ) /* nothing */
163
- #define CV_OCL_API_ERROR_MSG (check_result, msg ) cv::String()
164
- #define CV_OCL_CHECK_RESULT (check_result, msg ) (void )check_result
165
- #define CV_OCL_CHECK_ (expr, check_result ) expr; (void )check_result
166
- #define CV_OCL_CHECK (expr ) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT (__cl_result, #expr); } while (0 )
167
- #define CV_OCL_DBG_CHECK_RESULT (check_result, msg ) (void )check_result
168
- #define CV_OCL_DBG_CHECK_ (expr, check_result ) expr; (void )check_result
169
- #define CV_OCL_DBG_CHECK (expr ) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT (__cl_result, #expr); } while (0 )
170
-
171
- static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = false ;
172
-
173
- #else // HAVE_OPENCL
174
-
175
139
#ifndef _DEBUG
176
140
static bool isRaiseError ()
177
141
{
@@ -270,7 +234,6 @@ static const String getBuildExtraOptions()
270
234
static const bool CV_OPENCL_ENABLE_MEM_USE_HOST_PTR = utils::getConfigurationParameterBool(" OPENCV_OPENCL_ENABLE_MEM_USE_HOST_PTR" , true );
271
235
static const size_t CV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR = utils::getConfigurationParameterSizeT(" OPENCV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR" , 4 );
272
236
273
- #endif // HAVE_OPENCL
274
237
275
238
struct UMat2D
276
239
{
@@ -331,7 +294,7 @@ static uint64 crc64( const uchar* data, size_t size, uint64 crc0=0 )
331
294
return ~crc;
332
295
}
333
296
334
- #if defined HAVE_OPENCL && OPENCV_HAVE_FILESYSTEM_SUPPORT
297
+ #if OPENCV_HAVE_FILESYSTEM_SUPPORT
335
298
struct OpenCLBinaryCacheConfigurator
336
299
{
337
300
cv::String cache_path_;
@@ -872,7 +835,6 @@ static bool g_isOpenCVActivated = false;
872
835
bool haveOpenCL ()
873
836
{
874
837
CV_TRACE_FUNCTION ();
875
- #ifdef HAVE_OPENCL
876
838
static bool g_isOpenCLInitialized = false ;
877
839
static bool g_isOpenCLAvailable = false ;
878
840
@@ -902,9 +864,6 @@ bool haveOpenCL()
902
864
g_isOpenCLInitialized = true ;
903
865
}
904
866
return g_isOpenCLAvailable;
905
- #else
906
- return false ;
907
- #endif
908
867
}
909
868
910
869
bool useOpenCL ()
@@ -924,14 +883,12 @@ bool useOpenCL()
924
883
return data.useOpenCL > 0 ;
925
884
}
926
885
927
- #ifdef HAVE_OPENCL
928
886
bool isOpenCLActivated ()
929
887
{
930
888
if (!g_isOpenCVActivated)
931
889
return false ; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
932
890
return useOpenCL ();
933
891
}
934
- #endif
935
892
936
893
void setUseOpenCL (bool flag)
937
894
{
@@ -1958,7 +1915,6 @@ static unsigned int getSVMCapabilitiesMask()
1958
1915
} // namespace
1959
1916
#endif
1960
1917
1961
- #ifdef HAVE_OPENCL
1962
1918
static size_t getProgramCountLimit ()
1963
1919
{
1964
1920
static bool initialized = false ;
@@ -1970,7 +1926,6 @@ static size_t getProgramCountLimit()
1970
1926
}
1971
1927
return count;
1972
1928
}
1973
- #endif
1974
1929
1975
1930
struct Context ::Impl
1976
1931
{
@@ -3553,8 +3508,6 @@ internal::ProgramEntry::operator ProgramSource&() const
3553
3508
3554
3509
// ///////////////////////////////////////// Program /////////////////////////////////////////////
3555
3510
3556
- #ifdef HAVE_OPENCL
3557
-
3558
3511
static
3559
3512
cv::String joinBuildOptions (const cv::String& a, const cv::String& b)
3560
3513
{
@@ -3968,10 +3921,6 @@ struct Program::Impl
3968
3921
String sourceName_;
3969
3922
};
3970
3923
3971
- #else // HAVE_OPENCL
3972
- struct Program ::Impl : public DummyImpl {};
3973
- #endif // HAVE_OPENCL
3974
-
3975
3924
3976
3925
Program::Program () { p = 0 ; }
3977
3926
@@ -4014,26 +3963,18 @@ bool Program::create(const ProgramSource& src,
4014
3963
p->release ();
4015
3964
p = NULL ;
4016
3965
}
4017
- #ifdef HAVE_OPENCL
4018
3966
p = new Impl (src, buildflags, errmsg);
4019
3967
if (!p->handle )
4020
3968
{
4021
3969
p->release ();
4022
3970
p = 0 ;
4023
3971
}
4024
3972
return p != 0 ;
4025
- #else
4026
- CV_OPENCL_NO_SUPPORT ();
4027
- #endif
4028
3973
}
4029
3974
4030
3975
void * Program::ptr () const
4031
3976
{
4032
- #ifdef HAVE_OPENCL
4033
3977
return p ? p->handle : 0 ;
4034
- #else
4035
- CV_OPENCL_NO_SUPPORT ();
4036
- #endif
4037
3978
}
4038
3979
4039
3980
#ifndef OPENCV_REMOVE_DEPRECATED_API
@@ -4056,44 +3997,30 @@ bool Program::write(String& bin) const
4056
3997
4057
3998
String Program::getPrefix () const
4058
3999
{
4059
- #ifdef HAVE_OPENCL
4060
4000
if (!p)
4061
4001
return String ();
4062
4002
Context::Impl* ctx_ = Context::getDefault ().getImpl ();
4063
4003
CV_Assert (ctx_);
4064
4004
return cv::format (" opencl=%s\n buildflags=%s" , ctx_->getPrefixString ().c_str (), p->buildflags .c_str ());
4065
- #else
4066
- CV_OPENCL_NO_SUPPORT ();
4067
- #endif
4068
4005
}
4069
4006
4070
4007
String Program::getPrefix (const String& buildflags)
4071
4008
{
4072
- #ifdef HAVE_OPENCL
4073
4009
Context::Impl* ctx_ = Context::getDefault ().getImpl ();
4074
4010
CV_Assert (ctx_);
4075
4011
return cv::format (" opencl=%s\n buildflags=%s" , ctx_->getPrefixString ().c_str (), buildflags.c_str ());
4076
- #else
4077
- CV_OPENCL_NO_SUPPORT ();
4078
- #endif
4079
4012
}
4080
- #endif
4013
+ #endif // OPENCV_REMOVE_DEPRECATED_API
4081
4014
4082
4015
void Program::getBinary (std::vector<char >& binary) const
4083
4016
{
4084
- #ifdef HAVE_OPENCL
4085
4017
CV_Assert (p && " Empty program" );
4086
4018
p->getProgramBinary (binary);
4087
- #else
4088
- binary.clear ();
4089
- CV_OPENCL_NO_SUPPORT ();
4090
- #endif
4091
4019
}
4092
4020
4093
4021
Program Context::Impl::getProg (const ProgramSource& src,
4094
4022
const String& buildflags, String& errmsg)
4095
4023
{
4096
- #ifdef HAVE_OPENCL
4097
4024
size_t limit = getProgramCountLimit ();
4098
4025
const ProgramSource::Impl* src_ = src.getImpl ();
4099
4026
CV_Assert (src_);
@@ -4145,9 +4072,6 @@ Program Context::Impl::getProg(const ProgramSource& src,
4145
4072
cacheList.push_front (key);
4146
4073
}
4147
4074
return prog;
4148
- #else
4149
- CV_OPENCL_NO_SUPPORT ();
4150
- #endif
4151
4075
}
4152
4076
4153
4077
@@ -4707,9 +4631,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
4707
4631
4708
4632
bool allocate (UMatData* u, int accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
4709
4633
{
4710
- #ifndef HAVE_OPENCL
4711
- return false ;
4712
- #else
4713
4634
if (!u)
4714
4635
return false ;
4715
4636
@@ -4828,7 +4749,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
4828
4749
u->markHostCopyObsolete (true );
4829
4750
opencl_allocator_stats.onAllocate (u->size );
4830
4751
return true ;
4831
- #endif // HAVE_OPENCL
4832
4752
}
4833
4753
4834
4754
/* void sync(UMatData* u) const
@@ -6699,27 +6619,19 @@ struct Timer::Impl
6699
6619
6700
6620
void start ()
6701
6621
{
6702
- #ifdef HAVE_OPENCL
6703
6622
CV_OCL_DBG_CHECK (clFinish ((cl_command_queue)queue.ptr ()));
6704
6623
timer.start ();
6705
- #endif
6706
6624
}
6707
6625
6708
6626
void stop ()
6709
6627
{
6710
- #ifdef HAVE_OPENCL
6711
6628
CV_OCL_DBG_CHECK (clFinish ((cl_command_queue)queue.ptr ()));
6712
6629
timer.stop ();
6713
- #endif
6714
6630
}
6715
6631
6716
6632
uint64 durationNS () const
6717
6633
{
6718
- #ifdef HAVE_OPENCL
6719
6634
return (uint64)(timer.getTimeSec () * 1e9 );
6720
- #else
6721
- return 0 ;
6722
- #endif
6723
6635
}
6724
6636
6725
6637
TickMeter timer;
@@ -6746,13 +6658,6 @@ uint64 Timer::durationNS() const
6746
6658
return p->durationNS ();
6747
6659
}
6748
6660
6749
- #ifndef HAVE_OPENCL
6750
- #if defined(_MSC_VER)
6751
- #pragma warning(pop)
6752
- #elif defined(__clang__)
6753
- #pragma clang diagnostic pop
6754
- #elif defined(__GNUC__)
6755
- #pragma GCC diagnostic pop
6756
- #endif
6757
- #endif
6758
6661
}} // namespace
6662
+
6663
+ #endif // HAVE_OPENCL
0 commit comments