Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
649bb7ac
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
649bb7ac
编写于
2月 28, 2017
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: parallel_for_(): update RNG state of the main thread
上级
ebdd7410
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
3 deletion
+22
-3
modules/core/include/opencv2/core.hpp
modules/core/include/opencv2/core.hpp
+2
-0
modules/core/include/opencv2/core/operations.hpp
modules/core/include/opencv2/core/operations.hpp
+2
-0
modules/core/src/parallel.cpp
modules/core/src/parallel.cpp
+18
-3
未找到文件。
modules/core/include/opencv2/core.hpp
浏览文件 @
649bb7ac
...
...
@@ -2834,6 +2834,8 @@ public:
double
gaussian
(
double
sigma
);
uint64
state
;
bool
operator
==
(
const
RNG
&
other
)
const
;
};
/** @brief Mersenne Twister random number generator
...
...
modules/core/include/opencv2/core/operations.hpp
浏览文件 @
649bb7ac
...
...
@@ -349,6 +349,8 @@ inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next(
inline
float
RNG
::
uniform
(
float
a
,
float
b
)
{
return
((
float
)
*
this
)
*
(
b
-
a
)
+
a
;
}
inline
double
RNG
::
uniform
(
double
a
,
double
b
)
{
return
((
double
)
*
this
)
*
(
b
-
a
)
+
a
;
}
inline
bool
RNG
::
operator
==
(
const
RNG
&
other
)
const
{
return
state
==
other
.
state
;
}
inline
unsigned
RNG
::
next
()
{
state
=
(
uint64
)(
unsigned
)
state
*
/*CV_RNG_COEFF*/
4164903690U
+
(
unsigned
)(
state
>>
32
);
...
...
modules/core/src/parallel.cpp
浏览文件 @
649bb7ac
...
...
@@ -166,7 +166,8 @@ namespace
class
ParallelLoopBodyWrapper
:
public
cv
::
ParallelLoopBody
{
public:
ParallelLoopBodyWrapper
(
const
cv
::
ParallelLoopBody
&
_body
,
const
cv
::
Range
&
_r
,
double
_nstripes
)
ParallelLoopBodyWrapper
(
const
cv
::
ParallelLoopBody
&
_body
,
const
cv
::
Range
&
_r
,
double
_nstripes
)
:
is_rng_used
(
false
)
{
body
=
&
_body
;
...
...
@@ -181,13 +182,23 @@ namespace
pThreadRoot
=
cv
::
instr
::
getInstrumentTLSStruct
().
pCurrentNode
;
#endif
}
#ifdef ENABLE_INSTRUMENTATION
~
ParallelLoopBodyWrapper
()
{
#ifdef ENABLE_INSTRUMENTATION
for
(
size_t
i
=
0
;
i
<
pThreadRoot
->
m_childs
.
size
();
i
++
)
SyncNodes
(
pThreadRoot
->
m_childs
[
i
]);
}
#endif
if
(
is_rng_used
)
{
// Some parallel backends execute nested jobs in the main thread,
// so we need to restore initial RNG state here.
cv
::
theRNG
()
=
rng
;
// We can't properly update RNG state based on RNG usage in worker threads,
// so lets just change main thread RNG state to the next value.
// Note: this behaviour is not equal to single-threaded mode.
cv
::
theRNG
().
next
();
}
}
void
operator
()(
const
cv
::
Range
&
sr
)
const
{
#ifdef ENABLE_INSTRUMENTATION
...
...
@@ -207,6 +218,9 @@ namespace
r
.
end
=
sr
.
end
>=
nstripes
?
wholeRange
.
end
:
(
int
)(
wholeRange
.
start
+
((
uint64
)
sr
.
end
*
(
wholeRange
.
end
-
wholeRange
.
start
)
+
nstripes
/
2
)
/
nstripes
);
(
*
body
)(
r
);
if
(
!
is_rng_used
&&
!
(
cv
::
theRNG
()
==
rng
))
is_rng_used
=
true
;
}
cv
::
Range
stripeRange
()
const
{
return
cv
::
Range
(
0
,
nstripes
);
}
...
...
@@ -215,6 +229,7 @@ namespace
cv
::
Range
wholeRange
;
int
nstripes
;
cv
::
RNG
rng
;
mutable
bool
is_rng_used
;
#ifdef ENABLE_INSTRUMENTATION
cv
::
instr
::
InstrNode
*
pThreadRoot
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录