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
{
@@ -1953,7 +1910,6 @@ static unsigned int getSVMCapabilitiesMask()
1953
1910
} // namespace
1954
1911
#endif
1955
1912
1956
- #ifdef HAVE_OPENCL
1957
1913
static size_t getProgramCountLimit ()
1958
1914
{
1959
1915
static bool initialized = false ;
@@ -1965,7 +1921,6 @@ static size_t getProgramCountLimit()
1965
1921
}
1966
1922
return count;
1967
1923
}
1968
- #endif
1969
1924
1970
1925
struct Context ::Impl
1971
1926
{
@@ -3548,8 +3503,6 @@ internal::ProgramEntry::operator ProgramSource&() const
3548
3503
3549
3504
// ///////////////////////////////////////// Program /////////////////////////////////////////////
3550
3505
3551
- #ifdef HAVE_OPENCL
3552
-
3553
3506
static
3554
3507
cv::String joinBuildOptions (const cv::String& a, const cv::String& b)
3555
3508
{
@@ -3963,10 +3916,6 @@ struct Program::Impl
3963
3916
String sourceName_;
3964
3917
};
3965
3918
3966
- #else // HAVE_OPENCL
3967
- struct Program ::Impl : public DummyImpl {};
3968
- #endif // HAVE_OPENCL
3969
-
3970
3919
3971
3920
Program::Program () { p = 0 ; }
3972
3921
@@ -4009,26 +3958,18 @@ bool Program::create(const ProgramSource& src,
4009
3958
p->release ();
4010
3959
p = NULL ;
4011
3960
}
4012
- #ifdef HAVE_OPENCL
4013
3961
p = new Impl (src, buildflags, errmsg);
4014
3962
if (!p->handle )
4015
3963
{
4016
3964
p->release ();
4017
3965
p = 0 ;
4018
3966
}
4019
3967
return p != 0 ;
4020
- #else
4021
- CV_OPENCL_NO_SUPPORT ();
4022
- #endif
4023
3968
}
4024
3969
4025
3970
void * Program::ptr () const
4026
3971
{
4027
- #ifdef HAVE_OPENCL
4028
3972
return p ? p->handle : 0 ;
4029
- #else
4030
- CV_OPENCL_NO_SUPPORT ();
4031
- #endif
4032
3973
}
4033
3974
4034
3975
#ifndef OPENCV_REMOVE_DEPRECATED_API
@@ -4051,44 +3992,30 @@ bool Program::write(String& bin) const
4051
3992
4052
3993
String Program::getPrefix () const
4053
3994
{
4054
- #ifdef HAVE_OPENCL
4055
3995
if (!p)
4056
3996
return String ();
4057
3997
Context::Impl* ctx_ = Context::getDefault ().getImpl ();
4058
3998
CV_Assert (ctx_);
4059
3999
return cv::format (" opencl=%s\n buildflags=%s" , ctx_->getPrefixString ().c_str (), p->buildflags .c_str ());
4060
- #else
4061
- CV_OPENCL_NO_SUPPORT ();
4062
- #endif
4063
4000
}
4064
4001
4065
4002
String Program::getPrefix (const String& buildflags)
4066
4003
{
4067
- #ifdef HAVE_OPENCL
4068
4004
Context::Impl* ctx_ = Context::getDefault ().getImpl ();
4069
4005
CV_Assert (ctx_);
4070
4006
return cv::format (" opencl=%s\n buildflags=%s" , ctx_->getPrefixString ().c_str (), buildflags.c_str ());
4071
- #else
4072
- CV_OPENCL_NO_SUPPORT ();
4073
- #endif
4074
4007
}
4075
- #endif
4008
+ #endif // OPENCV_REMOVE_DEPRECATED_API
4076
4009
4077
4010
void Program::getBinary (std::vector<char >& binary) const
4078
4011
{
4079
- #ifdef HAVE_OPENCL
4080
4012
CV_Assert (p && " Empty program" );
4081
4013
p->getProgramBinary (binary);
4082
- #else
4083
- binary.clear ();
4084
- CV_OPENCL_NO_SUPPORT ();
4085
- #endif
4086
4014
}
4087
4015
4088
4016
Program Context::Impl::getProg (const ProgramSource& src,
4089
4017
const String& buildflags, String& errmsg)
4090
4018
{
4091
- #ifdef HAVE_OPENCL
4092
4019
size_t limit = getProgramCountLimit ();
4093
4020
const ProgramSource::Impl* src_ = src.getImpl ();
4094
4021
CV_Assert (src_);
@@ -4140,9 +4067,6 @@ Program Context::Impl::getProg(const ProgramSource& src,
4140
4067
cacheList.push_front (key);
4141
4068
}
4142
4069
return prog;
4143
- #else
4144
- CV_OPENCL_NO_SUPPORT ();
4145
- #endif
4146
4070
}
4147
4071
4148
4072
@@ -4703,9 +4627,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
4703
4627
4704
4628
bool allocate (UMatData* u, AccessFlag accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
4705
4629
{
4706
- #ifndef HAVE_OPENCL
4707
- return false ;
4708
- #else
4709
4630
if (!u)
4710
4631
return false ;
4711
4632
@@ -4825,7 +4746,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
4825
4746
u->markHostCopyObsolete (true );
4826
4747
opencl_allocator_stats.onAllocate (u->size );
4827
4748
return true ;
4828
- #endif // HAVE_OPENCL
4829
4749
}
4830
4750
4831
4751
/* void sync(UMatData* u) const
@@ -6705,27 +6625,19 @@ struct Timer::Impl
6705
6625
6706
6626
void start ()
6707
6627
{
6708
- #ifdef HAVE_OPENCL
6709
6628
CV_OCL_DBG_CHECK (clFinish ((cl_command_queue)queue.ptr ()));
6710
6629
timer.start ();
6711
- #endif
6712
6630
}
6713
6631
6714
6632
void stop ()
6715
6633
{
6716
- #ifdef HAVE_OPENCL
6717
6634
CV_OCL_DBG_CHECK (clFinish ((cl_command_queue)queue.ptr ()));
6718
6635
timer.stop ();
6719
- #endif
6720
6636
}
6721
6637
6722
6638
uint64 durationNS () const
6723
6639
{
6724
- #ifdef HAVE_OPENCL
6725
6640
return (uint64)(timer.getTimeSec () * 1e9 );
6726
- #else
6727
- return 0 ;
6728
- #endif
6729
6641
}
6730
6642
6731
6643
TickMeter timer;
@@ -6752,13 +6664,6 @@ uint64 Timer::durationNS() const
6752
6664
return p->durationNS ();
6753
6665
}
6754
6666
6755
- #ifndef HAVE_OPENCL
6756
- #if defined(_MSC_VER)
6757
- #pragma warning(pop)
6758
- #elif defined(__clang__)
6759
- #pragma clang diagnostic pop
6760
- #elif defined(__GNUC__)
6761
- #pragma GCC diagnostic pop
6762
- #endif
6763
- #endif
6764
6667
}} // namespace
6668
+
6669
+ #endif // HAVE_OPENCL
0 commit comments