Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
fe86d256
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,发现更多精彩内容 >>
提交
fe86d256
编写于
7月 07, 2011
作者:
S
salmanulhaq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
renamed gpu to ocl
上级
e22ad805
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
0 addition
and
445 deletion
+0
-445
modules/ocl/src/gpu/ocl_util.cpp
modules/ocl/src/gpu/ocl_util.cpp
+0
-86
modules/ocl/src/gpu/oclmat.cpp
modules/ocl/src/gpu/oclmat.cpp
+0
-253
modules/ocl/src/gpu/precomp.cpp
modules/ocl/src/gpu/precomp.cpp
+0
-44
modules/ocl/src/gpu/precomp.hpp
modules/ocl/src/gpu/precomp.hpp
+0
-62
未找到文件。
modules/ocl/src/gpu/ocl_util.cpp
已删除
100644 → 0
浏览文件 @
e22ad805
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage 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.
//
// * 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 the Intel Corporation or 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*/
#include "ocl.hpp"
cl_platform_id
cv
::
ocl
::
util
::
GetOCLPlatform
()
{
cl_platform_id
pPlatforms
[
10
]
=
{
0
};
char
pPlatformName
[
128
]
=
{
0
};
cl_uint
uiPlatformsCount
=
0
;
cl_int
err
=
clGetPlatformIDs
(
10
,
pPlatforms
,
&
uiPlatformsCount
);
for
(
cl_uint
ui
=
0
;
ui
<
uiPlatformsCount
;
++
ui
)
{
err
=
clGetPlatformInfo
(
pPlatforms
[
ui
],
CL_PLATFORM_NAME
,
128
*
sizeof
(
char
),
pPlatformName
,
NULL
);
if
(
err
!=
CL_SUCCESS
)
{
return
NULL
;
}
return
pPlatforms
[
ui
];
}
}
int
cv
::
ocl
::
util
::
createContext
(
cl_context
*
context
,
cl_command_queue
*
cmd_queue
,
bool
hasGPU
){
size_t
cb
;
cl_int
err
;
cl_platform_id
platform_id
=
cv
::
ocl
::
util
::
GetOCLPlatform
();
cl_context_properties
context_properties
[
3
]
=
{
CL_CONTEXT_PLATFORM
,
(
cl_context_properties
)
platform_id
,
NULL
};
//If the GPU is present, create the context on GPU
if
(
hasGPU
)
*
context
=
clCreateContextFromType
(
context_properties
,
CL_DEVICE_TYPE_GPU
,
NULL
,
NULL
,
NULL
);
else
*
context
=
clCreateContextFromType
(
context_properties
,
CL_DEVICE_TYPE_CPU
,
NULL
,
NULL
,
NULL
);
// get the list of devices associated with context
err
=
clGetContextInfo
(
*
context
,
CL_CONTEXT_DEVICES
,
0
,
NULL
,
&
cb
);
cl_device_id
*
devices
=
(
cl_device_id
*
)
malloc
(
cb
);
clGetContextInfo
(
*
context
,
CL_CONTEXT_DEVICES
,
cb
,
devices
,
NULL
);
// create a command-queue
*
cmd_queue
=
clCreateCommandQueue
(
*
context
,
devices
[
0
],
0
,
NULL
);
free
(
devices
);
return
CL_SUCCESS
;
}
modules/ocl/src/gpu/oclmat.cpp
已删除
100644 → 0
浏览文件 @
e22ad805
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage 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 GpuMaterials 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 the Intel Corporation or 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*/
#include "ocl.hpp"
namespace
cv
{
namespace
ocl
{
cl_context
ocl_context
;
cl_command_queue
ocl_cmd_queue
;
bool
initialized
=
false
;
inline
OclMat
::
OclMat
()
:
rows
(
0
),
cols
(
0
),
step
(
0
),
data
(
0
),
refcount
(
0
)
{}
inline
OclMat
::
OclMat
(
int
_rows
,
int
_cols
,
int
_type
)
:
flags
(
0
),
rows
(
0
),
cols
(
0
),
step
(
0
),
data
(
0
),
refcount
(
0
){
if
(
_rows
>
0
&&
_cols
>
0
)
create
(
_rows
,
_cols
,
_type
);
}
inline
OclMat
::
OclMat
(
Size
size
,
int
_type
)
:
flags
(
0
),
rows
(
0
),
cols
(
0
),
step
(
0
),
data
(
0
),
refcount
(
0
){
if
(
size
.
height
>
0
&&
size
.
width
>
0
)
create
(
size
,
_type
);
}
inline
OclMat
::
OclMat
(
const
OclMat
&
m
)
:
flags
(
m
.
flags
),
rows
(
m
.
rows
),
cols
(
m
.
cols
),
step
(
m
.
step
),
data
(
m
.
data
),
refcount
(
m
.
refcount
){
if
(
refcount
)
CV_XADD
(
refcount
,
1
);
}
inline
OclMat
::
OclMat
(
const
Mat
&
m
)
:
flags
(
0
),
rows
(
0
),
cols
(
0
),
step
(
0
),
data
(
0
),
refcount
(
0
)
{
upload
(
m
);
}
inline
OclMat
::~
OclMat
(){
release
();
}
void
OclMat
::
_upload
(
size_t
size
,
void
*
src
){
this
->
data
=
clCreateBuffer
(
ocl_context
,
CL_MEM_READ_WRITE
|
CL_MEM_COPY_HOST_PTR
,
size
,
src
,
NULL
);
}
void
OclMat
::
_download
(
size_t
size
,
void
*
dst
){
cl_int
err
=
clEnqueueReadBuffer
(
ocl_cmd_queue
,
data
,
CL_TRUE
,
0
,
size
,
dst
,
0
,
NULL
,
NULL
);
}
void
OclMat
::
release
(){
if
(
refcount
&&
CV_XADD
(
refcount
,
-
1
)
==
1
)
{
free
(
refcount
);
clReleaseMemObject
(
data
);
}
clReleaseMemObject
(
data
);
data
=
0
;
step
=
rows
=
cols
=
0
;
refcount
=
0
;
}
void
OclMat
::
upload
(
const
Mat
&
m
){
create
(
m
.
rows
,
m
.
cols
,
m
.
type
());
int
ch
=
channels
();
int
d
=
elemSize
();
size_t
s
=
rows
*
cols
*
ch
*
d
;
if
(
initialized
)
this
->
_upload
(
s
,
m
.
data
);
else
{
init
();
this
->
_upload
(
s
,
m
.
data
);
#ifdef _DEBUG
printf
(
"Context and Command queues not initialized. First call cv::ocl::init()"
);
#endif
}
}
void
OclMat
::
download
(
Mat
&
m
){
size_t
s
=
rows
*
cols
*
channels
()
*
elemSize
();
m
.
create
(
rows
,
cols
,
type
());
if
(
initialized
){
this
->
_download
(
s
,
m
.
data
);
}
else
{
init
();
this
->
_download
(
s
,
m
.
data
);
#ifdef _DEBUG
printf
(
"Context and Command queues not initialized. First call cv::ocl::init()"
);
#endif
}
}
void
init
(){
if
(
!
initialized
){
cv
::
ocl
::
util
::
createContext
(
&
ocl_context
,
&
ocl_cmd_queue
,
false
);
initialized
=
true
;
}
}
void
OclMat
::
create
(
int
_rows
,
int
_cols
,
int
_type
){
if
(
!
initialized
)
init
();
_type
&=
TYPE_MASK
;
if
(
rows
==
_rows
&&
cols
==
_cols
&&
type
()
==
_type
&&
data
)
return
;
if
(
data
)
release
();
if
(
_rows
>
0
&&
_cols
>
0
){
flags
=
Mat
::
MAGIC_VAL
+
_type
;
rows
=
_rows
;
cols
=
_cols
;
size_t
esz
=
elemSize
();
int
ch
=
channels
();
step
=
esz
*
cols
*
ch
;
size_t
size
=
esz
*
rows
*
cols
*
ch
;
data
=
clCreateBuffer
(
ocl_context
,
CL_MEM_READ_WRITE
,
size
,
NULL
,
NULL
);
if
(
esz
*
cols
==
step
)
flags
|=
Mat
::
CONTINUOUS_FLAG
;
/*
refcount = (int*)fastMalloc(sizeof(*refcount));
*refcount = 1;
*/
}
}
void
OclMat
::
create
(
Size
size
,
int
_type
){
return
create
(
size
.
height
,
size
.
width
,
_type
);
}
inline
OclMat
::
operator
Mat
()
{
Mat
m
;
download
(
m
);
return
m
;
}
inline
OclMat
&
OclMat
::
operator
=
(
const
OclMat
&
m
)
{
if
(
this
!=
&
m
)
{
if
(
m
.
refcount
)
CV_XADD
(
m
.
refcount
,
1
);
release
();
flags
=
m
.
flags
;
rows
=
m
.
rows
;
cols
=
m
.
cols
;
step
=
m
.
step
;
data
=
m
.
data
;
data
=
m
.
data
;
refcount
=
m
.
refcount
;
}
return
*
this
;
}
inline
OclMat
::
OclMat
(
int
_rows
,
int
_cols
,
int
_type
,
const
Scalar
&
_s
)
:
flags
(
0
),
rows
(
0
),
cols
(
0
),
step
(
0
),
data
(
0
),
refcount
(
0
)
{
if
(
_rows
>
0
&&
_cols
>
0
)
{
create
(
_rows
,
_cols
,
_type
);
*
this
=
_s
;
}
}
inline
OclMat
&
OclMat
::
operator
=
(
const
Mat
&
m
)
{
upload
(
m
);
return
*
this
;
}
OclMat
&
OclMat
::
operator
=
(
const
Scalar
&
s
)
{
setTo
(
s
);
return
*
this
;
}
OclMat
&
OclMat
::
setTo
(
const
Scalar
&
s
){
//if (s[0] == 0.0 && s[1] == 0.0 && s[2] == 0.0 && s[3] == 0.0)
//{
size_t
sz
=
rows
*
cols
*
channels
()
*
elemSize
();
//void* ptr = (void*)malloc(sz);
//memset(ptr, s[0], sz);
//clEnqueueWriteBuffer(ocl_cmd_queue, data, CL_TRUE, 0, sz, ptr, NULL, NULL, NULL);
//free(ptr); ptr = 0;
return
*
this
;
//}
}
inline
size_t
OclMat
::
elemSize
()
const
{
return
CV_ELEM_SIZE
(
flags
);
}
inline
size_t
OclMat
::
elemSize1
()
const
{
return
CV_ELEM_SIZE1
(
flags
);
}
inline
int
OclMat
::
type
()
const
{
return
CV_MAT_TYPE
(
flags
);
}
inline
int
OclMat
::
depth
()
const
{
return
CV_MAT_DEPTH
(
flags
);
}
inline
int
OclMat
::
channels
()
const
{
return
CV_MAT_CN
(
flags
);
}
inline
size_t
OclMat
::
step1
()
const
{
return
step
/
elemSize1
();
}
inline
Size
OclMat
::
size
()
const
{
return
Size
(
cols
,
rows
);
}
inline
bool
OclMat
::
empty
()
const
{
return
data
==
0
;
}
}
}
\ No newline at end of file
modules/ocl/src/gpu/precomp.cpp
已删除
100644 → 0
浏览文件 @
e22ad805
/*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.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, 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 materials provided with the distribution.
//
// * The name of Intel Corporation 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 the Intel Corporation or 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*/
#include "precomp.hpp"
/* End of file. */
\ No newline at end of file
modules/ocl/src/gpu/precomp.hpp
已删除
100644 → 0
浏览文件 @
e22ad805
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage 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 materials 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 the Intel Corporation or 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 PRECOMP_H__
#define PRECOMP_H__
#define OCL_EXPORTS __declspec(dllexport)
#include <exception>
#include "opencv/highgui.h"
#include "opencv/cv.h"
#include <CL/cl.h> //General OpenCL include file. Current version is written for Intel architecture using Intel's OpenCL SDK
#include "ocl.hpp"
#include "oclmat.hpp"
#include "ocldefs.h"
#include "ocl_util.h"
#ifdef _DEBUG
#include <stdio.h>
#endif
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录