Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
a61eb543
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a61eb543
编写于
12月 12, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add RWLock to Scope
上级
1b61021c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
13 deletion
+18
-13
paddle/fluid/framework/rw_lock.h
paddle/fluid/framework/rw_lock.h
+12
-4
paddle/fluid/framework/scope.cc
paddle/fluid/framework/scope.cc
+4
-7
paddle/fluid/framework/scope.h
paddle/fluid/framework/scope.h
+2
-2
未找到文件。
paddle/fluid/framework/rw_lock.h
浏览文件 @
a61eb543
...
@@ -16,6 +16,8 @@ limitations under the License. */
...
@@ -16,6 +16,8 @@ limitations under the License. */
#if !defined(_WIN32)
#if !defined(_WIN32)
#include <pthread.h>
#include <pthread.h>
#else
#include <mutex> // NOLINT
#endif // !_WIN32
#endif // !_WIN32
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
...
@@ -51,9 +53,15 @@ struct RWLock {
...
@@ -51,9 +53,15 @@ struct RWLock {
// https://stackoverflow.com/questions/7125250/making-pthread-rwlock-wrlock-recursive
// https://stackoverflow.com/questions/7125250/making-pthread-rwlock-wrlock-recursive
// In windows, rw_lock seems like a hack. Use empty object and do nothing.
// In windows, rw_lock seems like a hack. Use empty object and do nothing.
struct
RWLock
{
struct
RWLock
{
void
RDLock
()
{}
// FIXME(minqiyang): use mutex here to do fake lock
void
WRLock
()
{}
void
RDLock
()
{
mutex_
.
lock
();
}
void
UNLock
()
{}
void
WRLock
()
{
mutex_
.
lock
();
}
void
UNLock
()
{
mutex_
.
unlock
();
}
private:
std
::
mutex
mutex_
;
};
};
#endif
#endif
...
...
paddle/fluid/framework/scope.cc
浏览文件 @
a61eb543
...
@@ -46,13 +46,10 @@ DEFINE_double(
...
@@ -46,13 +46,10 @@ DEFINE_double(
#define SCOPE_READER_LOCK
#define SCOPE_READER_LOCK
#define SCOPE_WRITER_LOCK
#define SCOPE_WRITER_LOCK
#else
#else
// TODO(minqiyang): use reader lock and writer lock in all platforms
// TODO(minqiyang): use rwlock in all platforms, now rwlock is a fake one
#define SCOPE_READER_LOCK
// in _WIN32 platform
#define SCOPE_WRITER_LOCK
#define SCOPE_READER_LOCK RWLockGuard(&rw_lock_, RWLockGuard::Status::kRDLock);
// #define SCOPE_READER_LOCK boost::shared_lock<boost::shared_mutex>
#define SCOPE_WRITER_LOCK RWLockGuard(&rw_lock_, RWLockGuard::Status::kWRLock);
// lock(mutex_);
// #define SCOPE_WRITER_LOCK boost::unique_lock<boost::shared_mutex>
// lock(mutex_);
#endif
#endif
namespace
paddle
{
namespace
paddle
{
...
...
paddle/fluid/framework/scope.h
浏览文件 @
a61eb543
...
@@ -15,11 +15,11 @@ limitations under the License. */
...
@@ -15,11 +15,11 @@ limitations under the License. */
#pragma once
#pragma once
#include <list>
#include <list>
#include <mutex> // NOLINT
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include "paddle/fluid/framework/rw_lock.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/macros.h"
...
@@ -123,7 +123,7 @@ class Scope {
...
@@ -123,7 +123,7 @@ class Scope {
DISABLE_COPY_AND_ASSIGN
(
Scope
);
DISABLE_COPY_AND_ASSIGN
(
Scope
);
private:
private:
mutable
std
::
mutex
mutex
_
;
mutable
RWLock
rw_lock
_
;
};
};
// Generate some debug string about the inherience structure of scope, quite
// Generate some debug string about the inherience structure of scope, quite
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录