Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a351161f
Commit
a351161f
authored
Oct 10, 2013
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Oct 10, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1591 from alalek:ocl_remove_cl_hpp_h
parents
37a9c7bd
43c638d0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
60 deletions
+148
-60
opencl_utils.hpp
modules/ocl/include/opencv2/ocl/private/opencl_utils.hpp
+110
-0
cl_context.cpp
modules/ocl/src/cl_context.cpp
+37
-44
cl_programcache.cpp
modules/ocl/src/cl_programcache.cpp
+0
-15
precomp.hpp
modules/ocl/src/precomp.hpp
+1
-1
No files found.
modules/ocl/include/opencv2/ocl/private/opencl_utils.hpp
0 → 100644
View file @
a351161f
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_OCL_PRIVATE_OPENCL_UTILS_HPP__
#define __OPENCV_OCL_PRIVATE_OPENCL_UTILS_HPP__
#include "opencv2/ocl/cl_runtime/cl_runtime.hpp"
#include <vector>
#include <string>
namespace
cl_utils
{
inline
cl_int
getPlatforms
(
std
::
vector
<
cl_platform_id
>&
platforms
)
{
cl_uint
n
=
0
;
cl_int
err
=
::
clGetPlatformIDs
(
0
,
NULL
,
&
n
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
platforms
.
clear
();
platforms
.
resize
(
n
);
err
=
::
clGetPlatformIDs
(
n
,
&
platforms
[
0
],
NULL
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
return
CL_SUCCESS
;
}
inline
cl_int
getDevices
(
cl_platform_id
platform
,
cl_device_type
type
,
std
::
vector
<
cl_device_id
>&
devices
)
{
cl_uint
n
=
0
;
cl_int
err
=
::
clGetDeviceIDs
(
platform
,
type
,
0
,
NULL
,
&
n
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
devices
.
clear
();
devices
.
resize
(
n
);
err
=
::
clGetDeviceIDs
(
platform
,
type
,
n
,
&
devices
[
0
],
NULL
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
return
CL_SUCCESS
;
}
template
<
typename
Functor
,
typename
ObjectType
,
typename
T
>
inline
cl_int
getScalarInfo
(
Functor
f
,
ObjectType
obj
,
cl_uint
name
,
T
&
param
)
{
return
f
(
obj
,
name
,
sizeof
(
T
),
&
param
,
NULL
);
}
template
<
typename
Functor
,
typename
ObjectType
>
inline
cl_int
getStringInfo
(
Functor
f
,
ObjectType
obj
,
cl_uint
name
,
std
::
string
&
param
)
{
::
size_t
required
;
cl_int
err
=
f
(
obj
,
name
,
0
,
NULL
,
&
required
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
param
.
resize
(
required
);
err
=
f
(
obj
,
name
,
required
,
&
param
.
at
(
0
),
NULL
);
if
(
err
!=
CL_SUCCESS
)
return
err
;
return
CL_SUCCESS
;
};
}
// namespace cl_utils
#endif // __OPENCV_OCL_PRIVATE_OPENCL_UTILS_HPP__
modules/ocl/src/cl_context.cpp
View file @
a351161f
...
@@ -50,20 +50,7 @@
...
@@ -50,20 +50,7 @@
#include <fstream>
#include <fstream>
#include "cl_programcache.hpp"
#include "cl_programcache.hpp"
// workaround for OpenCL C++ bindings
#include "opencv2/ocl/private/opencl_utils.hpp"
#if defined(HAVE_OPENCL12)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl12_wrappers.hpp"
#elif defined(HAVE_OPENCL11)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl11_wrappers.hpp"
#else
#error Invalid OpenCL configuration
#endif
#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning( disable: 4100 4101 4127 4244 4267 4510 4512 4610)
#endif
#undef __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
namespace
cv
{
namespace
cv
{
namespace
ocl
{
namespace
ocl
{
...
@@ -329,17 +316,19 @@ static cv::Mutex __initializedMutex;
...
@@ -329,17 +316,19 @@ static cv::Mutex __initializedMutex;
static
bool
__initialized
=
false
;
static
bool
__initialized
=
false
;
static
int
initializeOpenCLDevices
()
static
int
initializeOpenCLDevices
()
{
{
using
namespace
cl_utils
;
assert
(
!
__initialized
);
assert
(
!
__initialized
);
__initialized
=
true
;
__initialized
=
true
;
assert
(
global_devices
.
size
()
==
0
);
assert
(
global_devices
.
size
()
==
0
);
std
::
vector
<
cl
::
Platform
>
platforms
;
std
::
vector
<
cl
_platform_id
>
platforms
;
try
try
{
{
openCLSafeCall
(
cl
::
Platform
::
get
(
&
platforms
));
openCLSafeCall
(
getPlatforms
(
platforms
));
}
}
catch
(
cv
::
Exception
&
e
)
catch
(
cv
::
Exception
&
)
{
{
return
0
;
// OpenCL not found
return
0
;
// OpenCL not found
}
}
...
@@ -351,20 +340,20 @@ static int initializeOpenCLDevices()
...
@@ -351,20 +340,20 @@ static int initializeOpenCLDevices()
PlatformInfoImpl
&
platformInfo
=
global_platforms
[
i
];
PlatformInfoImpl
&
platformInfo
=
global_platforms
[
i
];
platformInfo
.
info
.
_id
=
i
;
platformInfo
.
info
.
_id
=
i
;
cl
::
Platform
&
platform
=
platforms
[
i
];
cl
_platform_id
platform
=
platforms
[
i
];
platformInfo
.
platform_id
=
platform
()
;
platformInfo
.
platform_id
=
platform
;
openCLSafeCall
(
platform
.
getInfo
(
CL_PLATFORM_PROFILE
,
&
platformInfo
.
info
.
platformProfile
));
openCLSafeCall
(
getStringInfo
(
clGetPlatformInfo
,
platform
,
CL_PLATFORM_PROFILE
,
platformInfo
.
info
.
platformProfile
));
openCLSafeCall
(
platform
.
getInfo
(
CL_PLATFORM_VERSION
,
&
platformInfo
.
info
.
platformVersion
));
openCLSafeCall
(
getStringInfo
(
clGetPlatformInfo
,
platform
,
CL_PLATFORM_VERSION
,
platformInfo
.
info
.
platformVersion
));
openCLSafeCall
(
platform
.
getInfo
(
CL_PLATFORM_NAME
,
&
platformInfo
.
info
.
platformName
));
openCLSafeCall
(
getStringInfo
(
clGetPlatformInfo
,
platform
,
CL_PLATFORM_NAME
,
platformInfo
.
info
.
platformName
));
openCLSafeCall
(
platform
.
getInfo
(
CL_PLATFORM_VENDOR
,
&
platformInfo
.
info
.
platformVendor
));
openCLSafeCall
(
getStringInfo
(
clGetPlatformInfo
,
platform
,
CL_PLATFORM_VENDOR
,
platformInfo
.
info
.
platformVendor
));
openCLSafeCall
(
platform
.
getInfo
(
CL_PLATFORM_EXTENSIONS
,
&
platformInfo
.
info
.
platformExtensons
));
openCLSafeCall
(
getStringInfo
(
clGetPlatformInfo
,
platform
,
CL_PLATFORM_EXTENSIONS
,
platformInfo
.
info
.
platformExtensons
));
parseOpenCLVersion
(
platformInfo
.
info
.
platformVersion
,
parseOpenCLVersion
(
platformInfo
.
info
.
platformVersion
,
platformInfo
.
info
.
platformVersionMajor
,
platformInfo
.
info
.
platformVersionMinor
);
platformInfo
.
info
.
platformVersionMajor
,
platformInfo
.
info
.
platformVersionMinor
);
std
::
vector
<
cl
::
Device
>
devices
;
std
::
vector
<
cl
_device_id
>
devices
;
cl_int
status
=
platform
.
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
cl_int
status
=
getDevices
(
platform
,
CL_DEVICE_TYPE_ALL
,
devices
);
if
(
status
!=
CL_DEVICE_NOT_FOUND
)
if
(
status
!=
CL_DEVICE_NOT_FOUND
)
openCLVerifyCall
(
status
);
openCLVerifyCall
(
status
);
...
@@ -377,60 +366,60 @@ static int initializeOpenCLDevices()
...
@@ -377,60 +366,60 @@ static int initializeOpenCLDevices()
for
(
size_t
j
=
0
;
j
<
devices
.
size
();
++
j
)
for
(
size_t
j
=
0
;
j
<
devices
.
size
();
++
j
)
{
{
cl
::
Device
&
device
=
devices
[
j
];
cl
_device_id
device
=
devices
[
j
];
DeviceInfoImpl
&
deviceInfo
=
global_devices
[
baseIndx
+
j
];
DeviceInfoImpl
&
deviceInfo
=
global_devices
[
baseIndx
+
j
];
deviceInfo
.
info
.
_id
=
baseIndx
+
j
;
deviceInfo
.
info
.
_id
=
baseIndx
+
j
;
deviceInfo
.
platform_id
=
platform
()
;
deviceInfo
.
platform_id
=
platform
;
deviceInfo
.
device_id
=
device
()
;
deviceInfo
.
device_id
=
device
;
deviceInfo
.
info
.
platform
=
&
platformInfo
.
info
;
deviceInfo
.
info
.
platform
=
&
platformInfo
.
info
;
platformInfo
.
deviceIDs
[
j
]
=
deviceInfo
.
info
.
_id
;
platformInfo
.
deviceIDs
[
j
]
=
deviceInfo
.
info
.
_id
;
cl_device_type
type
=
cl_device_type
(
-
1
);
cl_device_type
type
=
cl_device_type
(
-
1
);
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_TYPE
,
&
type
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_TYPE
,
type
));
deviceInfo
.
info
.
deviceType
=
DeviceType
(
type
);
deviceInfo
.
info
.
deviceType
=
DeviceType
(
type
);
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_PROFILE
,
&
deviceInfo
.
info
.
deviceProfile
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_PROFILE
,
deviceInfo
.
info
.
deviceProfile
));
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_VERSION
,
&
deviceInfo
.
info
.
deviceVersion
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_VERSION
,
deviceInfo
.
info
.
deviceVersion
));
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_NAME
,
&
deviceInfo
.
info
.
deviceName
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_NAME
,
deviceInfo
.
info
.
deviceName
));
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_VENDOR
,
&
deviceInfo
.
info
.
deviceVendor
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_VENDOR
,
deviceInfo
.
info
.
deviceVendor
));
cl_uint
vendorID
=
0
;
cl_uint
vendorID
=
0
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_VENDOR_ID
,
&
vendorID
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_VENDOR_ID
,
vendorID
));
deviceInfo
.
info
.
deviceVendorId
=
vendorID
;
deviceInfo
.
info
.
deviceVendorId
=
vendorID
;
openCLSafeCall
(
device
.
getInfo
(
CL_DRIVER_VERSION
,
&
deviceInfo
.
info
.
deviceDriverVersion
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DRIVER_VERSION
,
deviceInfo
.
info
.
deviceDriverVersion
));
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_EXTENSIONS
,
&
deviceInfo
.
info
.
deviceExtensions
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_EXTENSIONS
,
deviceInfo
.
info
.
deviceExtensions
));
parseOpenCLVersion
(
deviceInfo
.
info
.
deviceVersion
,
parseOpenCLVersion
(
deviceInfo
.
info
.
deviceVersion
,
deviceInfo
.
info
.
deviceVersionMajor
,
deviceInfo
.
info
.
deviceVersionMinor
);
deviceInfo
.
info
.
deviceVersionMajor
,
deviceInfo
.
info
.
deviceVersionMinor
);
size_t
maxWorkGroupSize
=
0
;
size_t
maxWorkGroupSize
=
0
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_MAX_WORK_GROUP_SIZE
,
&
maxWorkGroupSize
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_MAX_WORK_GROUP_SIZE
,
maxWorkGroupSize
));
deviceInfo
.
info
.
maxWorkGroupSize
=
maxWorkGroupSize
;
deviceInfo
.
info
.
maxWorkGroupSize
=
maxWorkGroupSize
;
cl_uint
maxDimensions
=
0
;
cl_uint
maxDimensions
=
0
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
,
&
maxDimensions
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
,
maxDimensions
));
std
::
vector
<
size_t
>
maxWorkItemSizes
(
maxDimensions
);
std
::
vector
<
size_t
>
maxWorkItemSizes
(
maxDimensions
);
openCLSafeCall
(
clGetDeviceInfo
(
device
()
,
CL_DEVICE_MAX_WORK_ITEM_SIZES
,
sizeof
(
size_t
)
*
maxDimensions
,
openCLSafeCall
(
clGetDeviceInfo
(
device
,
CL_DEVICE_MAX_WORK_ITEM_SIZES
,
sizeof
(
size_t
)
*
maxDimensions
,
(
void
*
)
&
maxWorkItemSizes
[
0
],
0
));
(
void
*
)
&
maxWorkItemSizes
[
0
],
0
));
deviceInfo
.
info
.
maxWorkItemSizes
=
maxWorkItemSizes
;
deviceInfo
.
info
.
maxWorkItemSizes
=
maxWorkItemSizes
;
cl_uint
maxComputeUnits
=
0
;
cl_uint
maxComputeUnits
=
0
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_MAX_COMPUTE_UNITS
,
&
maxComputeUnits
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_MAX_COMPUTE_UNITS
,
maxComputeUnits
));
deviceInfo
.
info
.
maxComputeUnits
=
maxComputeUnits
;
deviceInfo
.
info
.
maxComputeUnits
=
maxComputeUnits
;
cl_ulong
localMemorySize
=
0
;
cl_ulong
localMemorySize
=
0
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_LOCAL_MEM_SIZE
,
&
localMemorySize
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_LOCAL_MEM_SIZE
,
localMemorySize
));
deviceInfo
.
info
.
localMemorySize
=
(
size_t
)
localMemorySize
;
deviceInfo
.
info
.
localMemorySize
=
(
size_t
)
localMemorySize
;
cl_bool
unifiedMemory
=
false
;
cl_bool
unifiedMemory
=
false
;
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_HOST_UNIFIED_MEMORY
,
&
unifiedMemory
));
openCLSafeCall
(
getScalarInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_HOST_UNIFIED_MEMORY
,
unifiedMemory
));
deviceInfo
.
info
.
isUnifiedMemory
=
unifiedMemory
!=
0
;
deviceInfo
.
info
.
isUnifiedMemory
=
unifiedMemory
!=
0
;
//initialize extra options for compilation. Currently only fp64 is included.
//initialize extra options for compilation. Currently only fp64 is included.
//Assume 4KB is enough to store all possible extensions.
//Assume 4KB is enough to store all possible extensions.
openCLSafeCall
(
device
.
getInfo
(
CL_DEVICE_EXTENSIONS
,
&
deviceInfo
.
info
.
deviceExtensions
));
openCLSafeCall
(
getStringInfo
(
clGetDeviceInfo
,
device
,
CL_DEVICE_EXTENSIONS
,
deviceInfo
.
info
.
deviceExtensions
));
size_t
fp64_khr
=
deviceInfo
.
info
.
deviceExtensions
.
find
(
"cl_khr_fp64"
);
size_t
fp64_khr
=
deviceInfo
.
info
.
deviceExtensions
.
find
(
"cl_khr_fp64"
);
if
(
fp64_khr
!=
std
::
string
::
npos
)
if
(
fp64_khr
!=
std
::
string
::
npos
)
...
@@ -501,6 +490,10 @@ public:
...
@@ -501,6 +490,10 @@ public:
bool
supportsFeature
(
FEATURE_TYPE
featureType
)
const
;
bool
supportsFeature
(
FEATURE_TYPE
featureType
)
const
;
static
void
cleanupContext
(
void
);
static
void
cleanupContext
(
void
);
private
:
ContextImpl
(
const
ContextImpl
&
);
// disabled
ContextImpl
&
operator
=
(
const
ContextImpl
&
);
// disabled
};
};
static
cv
::
Mutex
currentContextMutex
;
static
cv
::
Mutex
currentContextMutex
;
...
...
modules/ocl/src/cl_programcache.cpp
View file @
a351161f
...
@@ -50,21 +50,6 @@
...
@@ -50,21 +50,6 @@
#include <fstream>
#include <fstream>
#include "cl_programcache.hpp"
#include "cl_programcache.hpp"
// workaround for OpenCL C++ bindings
#if defined(HAVE_OPENCL12)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl12_wrappers.hpp"
#elif defined(HAVE_OPENCL11)
#include "opencv2/ocl/cl_runtime/cl_runtime_opencl11_wrappers.hpp"
#else
#error Invalid OpenCL configuration
#endif
#if defined _MSC_VER && _MSC_VER >= 1200
# pragma warning( disable: 4100 4244 4267 4510 4512 4610)
#endif
#undef __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
namespace
cv
{
namespace
ocl
{
namespace
cv
{
namespace
ocl
{
#define MAX_PROG_CACHE_SIZE 1024
#define MAX_PROG_CACHE_SIZE 1024
...
...
modules/ocl/src/precomp.hpp
View file @
a351161f
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
#define __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#if defined _MSC_VER && _MSC_VER >= 1200
#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 )
#pragma warning( disable: 4
127 4
267 4324 4244 4251 4710 4711 4514 4996 )
#endif
#endif
#if defined(_WIN32)
#if defined(_WIN32)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment