Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
9ccf27c7
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9ccf27c7
编写于
2月 27, 2013
作者:
Y
yao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add interfaces enable custom oclMat device memory type
上级
620c6994
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
29 deletion
+88
-29
modules/ocl/include/opencv2/ocl/ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+31
-0
modules/ocl/src/initialization.cpp
modules/ocl/src/initialization.cpp
+41
-28
modules/ocl/src/matrix_operations.cpp
modules/ocl/src/matrix_operations.cpp
+13
-1
modules/ocl/src/precomp.hpp
modules/ocl/src/precomp.hpp
+3
-0
未找到文件。
modules/ocl/include/opencv2/ocl/ocl.hpp
浏览文件 @
9ccf27c7
...
...
@@ -66,6 +66,32 @@ namespace cv
//CVCL_DEVICE_TYPE_CUSTOM = (1 << 4)
CVCL_DEVICE_TYPE_ALL
=
0xFFFFFFFF
};
enum
DevMemRW
{
DEVICE_MEM_R_W
=
0
,
DEVICE_MEM_R_ONLY
,
DEVICE_MEM_W_ONLY
};
enum
DevMemType
{
DEVICE_MEM_DEFAULT
=
0
,
DEVICE_MEM_AHP
,
//alloc host pointer
DEVICE_MEM_UHP
,
//use host pointer
DEVICE_MEM_CHP
,
//copy host pointer
DEVICE_MEM_PM
//persistent memory
};
//Get the global device memory and read/write type
//return 1 if unified memory system supported, otherwise return 0
CV_EXPORTS
int
getDevMemType
(
DevMemRW
&
rw_type
,
DevMemType
&
mem_type
);
//Set the global device memory and read/write type,
//the newly generated oclMat will all use this type
//return -1 if the target type is unsupported, otherwise return 0
CV_EXPORTS
int
setDevMemType
(
DevMemRW
rw_type
=
DEVICE_MEM_R_W
,
DevMemType
mem_type
=
DEVICE_MEM_DEFAULT
);
//this class contains ocl runtime information
class
CV_EXPORTS
Info
{
...
...
@@ -228,6 +254,11 @@ namespace cv
// previous data is unreferenced if needed.
void
create
(
int
rows
,
int
cols
,
int
type
);
void
create
(
Size
size
,
int
type
);
//! allocates new oclMatrix with specified device memory type.
void
createEx
(
int
rows
,
int
cols
,
int
type
,
DevMemRW
rw_type
,
DevMemType
mem_type
);
void
createEx
(
Size
size
,
int
type
,
DevMemRW
rw_type
,
DevMemType
mem_type
);
//! decreases reference counter;
// deallocate the data when reference counter reaches 0.
void
release
();
...
...
modules/ocl/src/initialization.cpp
浏览文件 @
9ccf27c7
...
...
@@ -72,6 +72,15 @@ namespace cv
*/
auto_ptr
<
ProgramCache
>
ProgramCache
::
programCache
;
ProgramCache
*
programCache
=
NULL
;
DevMemType
gDeviceMemType
=
DEVICE_MEM_DEFAULT
;
DevMemRW
gDeviceMemRW
=
DEVICE_MEM_R_W
;
int
gDevMemTypeValueMap
[
5
]
=
{
0
,
CL_MEM_ALLOC_HOST_PTR
,
CL_MEM_USE_HOST_PTR
,
CL_MEM_COPY_HOST_PTR
,
CL_MEM_USE_PERSISTENT_MEM_AMD
};
int
gDevMemRWValueMap
[
3
]
=
{
CL_MEM_READ_WRITE
,
CL_MEM_READ_ONLY
,
CL_MEM_WRITE_ONLY
};
ProgramCache
::
ProgramCache
()
{
codeCache
.
clear
();
...
...
@@ -113,30 +122,25 @@ namespace cv
}
////////////////////////Common OpenCL specific calls///////////////
//Info::Info()
//{
// oclplatform = 0;
// oclcontext = 0;
// devnum = 0;
//}
//Info::~Info()
//{
// release();
//}
//void Info::release()
//{
// if(oclplatform)
// {
// oclplatform = 0;
// }
// if(oclcontext)
// {
// openCLSafeCall(clReleaseContext(oclcontext));
// }
// devices.empty();
// devName.empty();
//}
struct
Info
::
Impl
int
getDevMemType
(
DevMemRW
&
rw_type
,
DevMemType
&
mem_type
)
{
rw_type
=
gDeviceMemRW
;
mem_type
=
gDeviceMemType
;
return
Context
::
getContext
()
->
impl
->
unified_memory
;
}
int
setDevMemType
(
DevMemRW
rw_type
,
DevMemType
mem_type
)
{
if
(
(
mem_type
==
DEVICE_MEM_PM
&&
Context
::
getContext
()
->
impl
->
unified_memory
==
0
)
||
mem_type
==
DEVICE_MEM_UHP
||
mem_type
==
DEVICE_MEM_CHP
)
return
-
1
;
gDeviceMemRW
=
rw_type
;
gDeviceMemType
=
mem_type
;
return
0
;
}
struct
Info
::
Impl
{
cl_platform_id
oclplatform
;
std
::
vector
<
cl_device_id
>
devices
;
...
...
@@ -290,11 +294,8 @@ namespace cv
}
void
*
getoclContext
()
{
return
&
(
Context
::
getContext
()
->
impl
->
clContext
);
}
void
*
getoclCommandQueue
()
...
...
@@ -319,10 +320,16 @@ namespace cv
void
openCLMallocPitch
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
)
{
openCLMallocPitchEx
(
clCxt
,
dev_ptr
,
pitch
,
widthInBytes
,
height
,
gDeviceMemRW
,
gDeviceMemType
);
}
void
openCLMallocPitchEx
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
,
DevMemRW
rw_type
,
DevMemType
mem_type
)
{
cl_int
status
;
*
dev_ptr
=
clCreateBuffer
(
clCxt
->
impl
->
clContext
,
CL_MEM_READ_WRITE
,
*
dev_ptr
=
clCreateBuffer
(
clCxt
->
impl
->
clContext
,
gDevMemRWValueMap
[
rw_type
]
|
gDevMemTypeValueMap
[
mem_type
]
,
widthInBytes
*
height
,
0
,
&
status
);
openCLVerifyCall
(
status
);
*
pitch
=
widthInBytes
;
...
...
@@ -837,6 +844,11 @@ namespace cv
clcxt
->
impl
->
double_support
=
oclinfo
.
impl
->
double_support
;
//extra options to recognize compiler options
memcpy
(
clcxt
->
impl
->
extra_options
,
oclinfo
.
impl
->
extra_options
,
512
);
cl_bool
unfymem
=
false
;
openCLSafeCall
(
clGetDeviceInfo
(
clcxt
->
impl
->
devices
,
CL_DEVICE_HOST_UNIFIED_MEMORY
,
sizeof
(
cl_bool
),
(
void
*
)
&
unfymem
,
NULL
));
if
(
unfymem
)
clcxt
->
impl
->
unified_memory
=
1
;
}
Context
::
Context
()
{
...
...
@@ -853,6 +865,7 @@ namespace cv
impl
->
double_support
=
0
;
//extra options to recognize vendor specific fp64 extensions
memset
(
impl
->
extra_options
,
0
,
512
);
impl
->
unified_memory
=
0
;
programCache
=
ProgramCache
::
getProgramCache
();
}
...
...
modules/ocl/src/matrix_operations.cpp
浏览文件 @
9ccf27c7
...
...
@@ -69,6 +69,8 @@ namespace cv
extern
const
char
*
operator_setTo
;
extern
const
char
*
operator_setToM
;
extern
const
char
*
convertC3C4
;
extern
DevMemType
gDeviceMemType
;
extern
DevMemRW
gDeviceMemRW
;
}
}
...
...
@@ -912,7 +914,17 @@ oclMat cv::ocl::oclMat::reshape(int new_cn, int new_rows) const
}
void
cv
::
ocl
::
oclMat
::
createEx
(
Size
size
,
int
type
,
DevMemRW
rw_type
,
DevMemType
mem_type
)
{
createEx
(
size
.
height
,
size
.
width
,
type
,
rw_type
,
mem_type
);
}
void
cv
::
ocl
::
oclMat
::
create
(
int
_rows
,
int
_cols
,
int
_type
)
{
createEx
(
_rows
,
_cols
,
_type
,
gDeviceMemRW
,
gDeviceMemType
);
}
void
cv
::
ocl
::
oclMat
::
createEx
(
int
_rows
,
int
_cols
,
int
_type
,
DevMemRW
rw_type
,
DevMemType
mem_type
)
{
clCxt
=
Context
::
getContext
();
/* core logic */
...
...
@@ -937,7 +949,7 @@ void cv::ocl::oclMat::create(int _rows, int _cols, int _type)
size_t
esz
=
elemSize
();
void
*
dev_ptr
;
openCLMallocPitch
(
clCxt
,
&
dev_ptr
,
&
step
,
GPU_MATRIX_MALLOC_STEP
(
esz
*
cols
),
rows
);
openCLMallocPitch
Ex
(
clCxt
,
&
dev_ptr
,
&
step
,
GPU_MATRIX_MALLOC_STEP
(
esz
*
cols
),
rows
,
rw_type
,
mem_type
);
//openCLMallocPitch(clCxt,&dev_ptr, &step, esz * cols, rows);
if
(
esz
*
cols
==
step
)
...
...
modules/ocl/src/precomp.hpp
浏览文件 @
9ccf27c7
...
...
@@ -95,6 +95,8 @@ namespace cv
///////////////////////////OpenCL call wrappers////////////////////////////
void
openCLMallocPitch
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
);
void
openCLMallocPitchEx
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
,
DevMemRW
rw_type
,
DevMemType
mem_type
);
void
openCLMemcpy2D
(
Context
*
clCxt
,
void
*
dst
,
size_t
dpitch
,
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
enum
openCLMemcpyKind
kind
,
int
channels
=
-
1
);
...
...
@@ -143,6 +145,7 @@ namespace cv
//extra options to recognize vendor specific fp64 extensions
char
extra_options
[
512
];
string
Binpath
;
int
unified_memory
;
//1 means integrated GPU, otherwise this value is 0
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录