Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
80dafdf5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
80dafdf5
编写于
12月 26, 2017
作者:
D
dzhwinter
提交者:
GitHub
12月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"fix threadpool style" (#7017)
* "fix threadpool style" * "remove header"
上级
52965458
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
13 deletion
+31
-13
paddle/framework/CMakeLists.txt
paddle/framework/CMakeLists.txt
+2
-1
paddle/framework/threadpool.cc
paddle/framework/threadpool.cc
+24
-0
paddle/framework/threadpool.h
paddle/framework/threadpool.h
+3
-8
paddle/framework/threadpool_test.cc
paddle/framework/threadpool_test.cc
+2
-4
未找到文件。
paddle/framework/CMakeLists.txt
浏览文件 @
80dafdf5
...
...
@@ -59,7 +59,8 @@ cc_test(var_type_inference_test SRCS var_type_inference_test.cc DEPS op_registry
cc_library
(
selected_rows SRCS selected_rows.cc DEPS tensor
)
cc_test
(
selected_rows_test SRCS selected_rows_test.cc DEPS selected_rows
)
cc_test
(
threadpool_test SRCS threadpool_test.cc
)
cc_library
(
threadpool SRCS threadpool.cc
)
cc_test
(
threadpool_test SRCS threadpool_test.cc DEPS threadpool
)
cc_library
(
init SRCS init.cc DEPS gflags device_context place stringpiece
)
cc_test
(
init_test SRCS init_test.cc DEPS init
)
...
...
paddle/framework/threadpool.cc
0 → 100644
浏览文件 @
80dafdf5
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/framework/threadpool.h"
namespace
paddle
{
namespace
framework
{
std
::
unique_ptr
<
ThreadPool
>
ThreadPool
::
threadpool
(
nullptr
);
std
::
once_flag
ThreadPool
::
init_flag
;
}
// namespace framework
}
// namespace paddle
paddle/framework/threadpool.h
浏览文件 @
80dafdf5
...
...
@@ -13,15 +13,13 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <condition_variable>
#include <cstdio>
#include <functional>
#include <iostream>
#include <mutex>
#include <queue>
#include <thread>
#include "paddle/platform/call_once.h"
#include "paddle/platform/enforce.h"
namespace
paddle
{
...
...
@@ -81,10 +79,9 @@ class ThreadPool {
}
private:
ThreadPool
&
operator
=
(
const
ThreadPool
&
)
=
delete
;
ThreadPool
(
const
ThreadPool
&
)
=
delete
;
DISABLE_COPY_AND_ASSIGN
(
ThreadPool
);
ThreadPool
(
int
num_threads
)
explicit
ThreadPool
(
int
num_threads
)
:
num_threads_
(
num_threads
),
available_
(
num_threads
),
running_
(
true
)
{
threads_
.
resize
(
num_threads
);
for
(
auto
&
thread
:
threads_
)
{
...
...
@@ -155,7 +152,5 @@ class ThreadPool {
std
::
condition_variable
completed_
;
};
std
::
unique_ptr
<
ThreadPool
>
ThreadPool
::
threadpool
(
nullptr
);
std
::
once_flag
ThreadPool
::
init_flag
;
}
// namespace framework
}
// namespace paddle
paddle/framework/threadpool_test.cc
浏览文件 @
80dafdf5
...
...
@@ -12,12 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "threadpool.h"
#include <gtest/gtest.h>
#include <atomic>
#include <chrono>
#include <map>
#include <thread>
#include "threadpool.h"
namespace
framework
=
paddle
::
framework
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录