Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
087f73d9
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
087f73d9
编写于
4年前
作者:
M
mindspore-ci-bot
提交者:
Gitee
4年前
浏览文件
操作
浏览文件
下载
差异文件
!5332 remove include/thread_pool_config.h
Merge pull request !5332 from wangzhe/master
上级
31a51c17
1a246475
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
45 addition
and
62 deletion
+45
-62
mindspore/lite/include/context.h
mindspore/lite/include/context.h
+7
-1
mindspore/lite/include/thread_pool_config.h
mindspore/lite/include/thread_pool_config.h
+0
-35
mindspore/lite/src/runtime/parallel_executor.cc
mindspore/lite/src/runtime/parallel_executor.cc
+0
-1
mindspore/lite/src/runtime/runtime_api.h
mindspore/lite/src/runtime/runtime_api.h
+0
-1
mindspore/lite/src/runtime/thread_pool.c
mindspore/lite/src/runtime/thread_pool.c
+9
-10
mindspore/lite/src/runtime/thread_pool.h
mindspore/lite/src/runtime/thread_pool.h
+24
-10
mindspore/lite/test/ut/src/infer_test.cc
mindspore/lite/test/ut/src/infer_test.cc
+4
-4
mindspore/lite/tools/benchmark/benchmark.cc
mindspore/lite/tools/benchmark/benchmark.cc
+1
-0
未找到文件。
mindspore/lite/include/context.h
浏览文件 @
087f73d9
...
...
@@ -20,7 +20,6 @@
#include <string>
#include <memory>
#include "include/ms_tensor.h"
#include "include/thread_pool_config.h"
namespace
mindspore
::
lite
{
/// \brief Allocator defined a memory pool for malloc memory and free memory dynamically.
...
...
@@ -28,6 +27,13 @@ namespace mindspore::lite {
/// \note List public class and interface for reference.
class
Allocator
;
/// \brief CpuBindMode defined for holding bind cpu strategy argument.
typedef
enum
{
MID_CPU
=
-
1
,
/**< bind middle cpu first */
HIGHER_CPU
=
1
,
/**< bind higher cpu first */
NO_BIND
=
0
/**< no bind */
}
CpuBindMode
;
/// \brief DeviceType defined for holding user's preferred backend.
typedef
enum
{
DT_CPU
,
/**< CPU device type */
...
...
This diff is collapsed.
Click to expand it.
mindspore/lite/include/thread_pool_config.h
已删除
100644 → 0
浏览文件 @
31a51c17
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* 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.
*/
#ifndef MINDSPORE_LITE_INCLUDE_THREAD_POOL_CONFIG_H_
#define MINDSPORE_LITE_INCLUDE_THREAD_POOL_CONFIG_H_
/// \brief CpuBindMode defined for holding bind cpu strategy argument.
typedef
enum
Mode
{
MID_CPU
=
-
1
,
/**< bind middle cpu first */
HIGHER_CPU
=
1
,
/**< bind higher cpu first */
NO_BIND
=
0
/**< no bind */
}
CpuBindMode
;
/// \brief ThreadPoolId defined for specifying which thread pool to use.
typedef
enum
Id
{
THREAD_POOL_DEFAULT
=
0
,
/**< default thread pool id */
THREAD_POOL_SECOND
=
1
,
/**< the second thread pool id */
THREAD_POOL_THIRD
=
2
,
/**< the third thread pool id */
THREAD_POOL_FOURTH
=
3
/**< the fourth thread pool id */
}
ThreadPoolId
;
#endif // LITE_MINDSPORE_LITE_INCLUDE_THREAD_POOL_CONFIG_H_
This diff is collapsed.
Click to expand it.
mindspore/lite/src/runtime/parallel_executor.cc
浏览文件 @
087f73d9
...
...
@@ -16,7 +16,6 @@
#include <utility>
#include "src/runtime/parallel_executor.h"
#include "include/thread_pool_config.h"
#include "src/runtime/runtime_api.h"
#define MAX_THREAD_NUM 8
...
...
This diff is collapsed.
Click to expand it.
mindspore/lite/src/runtime/runtime_api.h
浏览文件 @
087f73d9
...
...
@@ -16,7 +16,6 @@
#ifndef PREDICT_SRC_RUNTIME_RUNTIME_API_H_
#define PREDICT_SRC_RUNTIME_RUNTIME_API_H_
#include <memory>
#include "include/thread_pool_config.h"
#ifndef INTERNAL_API_DLL
#ifdef _WIN32
...
...
This diff is collapsed.
Click to expand it.
mindspore/lite/src/runtime/thread_pool.c
浏览文件 @
087f73d9
...
...
@@ -15,7 +15,6 @@
*/
#include "src/runtime/thread_pool.h"
#include "include/thread_pool_config.h"
#define _GNU_SOURCE
#include <pthread.h>
#include <stdatomic.h>
...
...
@@ -75,7 +74,7 @@ typedef struct {
typedef
struct
ThreadPool
{
ThreadList
*
thread_list
;
int
thread_num
;
Cpu
BindMode
mode
;
BindMode
mode
;
atomic_bool
is_alive
;
}
ThreadPool
;
...
...
@@ -315,7 +314,7 @@ int BindMasterThread(int thread_pool_id, bool is_bind) {
CPU_ZERO
(
&
mask
);
if
(
is_bind
)
{
unsigned
int
attach_id
;
if
(
thread_pool
->
mode
==
MID_
CPU
)
{
if
(
thread_pool
->
mode
==
MID_
MODE
)
{
attach_id
=
cpu_cores
[
gHigNum
+
gMidNum
-
1
];
}
else
{
attach_id
=
cpu_cores
[
0
];
...
...
@@ -343,10 +342,10 @@ int BindSalverThreads(int thread_pool_id, bool is_bind) {
return
RET_TP_ERROR
;
}
cpu_set_t
mask
;
if
(
is_bind
&&
thread_pool
->
mode
!=
NO_BIND
)
{
if
(
is_bind
&&
thread_pool
->
mode
!=
NO_BIND
_MODE
)
{
unsigned
int
attach_id
;
for
(
int
i
=
0
;
i
<
thread_pool
->
thread_num
-
1
;
++
i
)
{
if
(
thread_pool
->
mode
==
MID_
CPU
)
{
if
(
thread_pool
->
mode
==
MID_
MODE
)
{
int
core_id
=
gHigNum
+
gMidNum
-
i
-
2
;
if
(
core_id
>=
0
)
{
attach_id
=
cpu_cores
[
core_id
];
...
...
@@ -393,9 +392,9 @@ int BindSalverThreads(int thread_pool_id, bool is_bind) {
}
#endif
int
BindThreads
(
int
thread_pool_id
,
bool
is_bind
,
CpuBindMode
mode
)
{
int
BindThreads
(
int
thread_pool_id
,
bool
is_bind
,
int
mode
)
{
#ifdef BIND_CORE
if
(
mode
==
NO_BIND
)
{
if
(
mode
==
NO_BIND
_MODE
)
{
return
RET_TP_OK
;
}
ThreadPool
*
thread_pool
=
GetInstance
(
thread_pool_id
);
...
...
@@ -605,7 +604,7 @@ int CreateNewThread(int thread_pool_id, int thread_id) {
return
RET_TP_OK
;
}
int
ReConfigThreadPool
(
int
thread_pool_id
,
int
thread_num
,
CpuBindMode
mode
)
{
int
ReConfigThreadPool
(
int
thread_pool_id
,
int
thread_num
,
int
mode
)
{
LOG_INFO
(
"reconfig thread pool, thread_pool_id: %d, thread_num: %d, mode: %d"
,
thread_pool_id
,
thread_num
,
mode
);
if
(
thread_num
<=
0
||
thread_num
>
MAX_THREAD_NUM
)
{
LOG_INFO
(
"invalid thread num: %d"
,
thread_num
);
...
...
@@ -646,7 +645,7 @@ int ReConfigThreadPool(int thread_pool_id, int thread_num, CpuBindMode mode) {
return
BindThreads
(
thread_pool_id
,
true
,
mode
);
}
int
CreateThreadPool
(
int
thread_pool_id
,
int
thread_num
,
CpuBindMode
mode
)
{
int
CreateThreadPool
(
int
thread_pool_id
,
int
thread_num
,
int
mode
)
{
LOG_INFO
(
"create thread pool, thread_pool_id: %d, thread_num: %d, mode: %d"
,
thread_pool_id
,
thread_num
,
mode
);
if
(
thread_num
<=
0
||
thread_num
>
MAX_THREAD_NUM
)
{
LOG_INFO
(
"invalid thread num: %d"
,
thread_num
);
...
...
@@ -690,7 +689,7 @@ int CreateThreadPool(int thread_pool_id, int thread_num, CpuBindMode mode) {
return
RET_TP_OK
;
}
int
ConfigThreadPool
(
int
thread_pool_id
,
int
thread_num
,
CpuBindMode
mode
)
{
int
ConfigThreadPool
(
int
thread_pool_id
,
int
thread_num
,
int
mode
)
{
LOG_INFO
(
"config: thread_pool_id: %d, thread_num: %d, mode: %d, is_created: %d, refcount: %d"
,
thread_pool_id
,
thread_num
,
mode
,
thread_pool_is_created
[
thread_pool_id
],
thread_pool_refcount
[
thread_pool_id
]);
if
(
thread_pool_id
>=
MAX_THREAD_POOL_NUM
)
{
...
...
This diff is collapsed.
Click to expand it.
mindspore/lite/src/runtime/thread_pool.h
浏览文件 @
087f73d9
...
...
@@ -18,14 +18,28 @@
#define MINDSPORE_LITE_SRC_RUNTIME_THREAD_POOL_H_
#include <stdbool.h>
#include "include/thread_pool_config.h"
/// \brief BindMode defined for holding bind cpu strategy argument.
typedef
enum
{
MID_MODE
=
-
1
,
/**< bind middle cpu first */
HIGHER_MODE
=
1
,
/**< bind higher cpu first */
NO_BIND_MODE
=
0
/**< no bind */
}
BindMode
;
/// \brief ThreadPoolId defined for specifying which thread pool to use.
typedef
enum
{
THREAD_POOL_DEFAULT
=
0
,
/**< default thread pool id */
THREAD_POOL_SECOND
=
1
,
/**< the second thread pool id */
THREAD_POOL_THIRD
=
2
,
/**< the third thread pool id */
THREAD_POOL_FOURTH
=
3
/**< the fourth thread pool id */
}
ThreadPoolId
;
/**
* create thread pool and init
* @param thread_num
* @param mode
*/
int
ConfigThreadPool
(
int
context_id
,
int
thread_num
,
CpuBindMode
mode
);
int
ConfigThreadPool
(
int
thread_pool_id
,
int
thread_num
,
int
mode
);
/**
*
...
...
@@ -34,36 +48,36 @@ int ConfigThreadPool(int context_id, int thread_num, CpuBindMode mode);
* @param content
* @param task_num
*/
int
ParallelLaunch
(
int
context
_id
,
int
(
*
job
)(
void
*
,
int
),
void
*
content
,
int
task_num
);
int
ParallelLaunch
(
int
thread_pool
_id
,
int
(
*
job
)(
void
*
,
int
),
void
*
content
,
int
task_num
);
/**
* bind each thread to specified cpu core
* @param is_bind
* @param mode
*/
int
BindThreads
(
int
context_id
,
bool
is_bind
,
CpuBindMode
mode
);
int
BindThreads
(
int
thread_pool_id
,
bool
is_bind
,
int
mode
);
/**
* activate the thread pool
* @param
context
_id
* @param
thread_pool
_id
*/
void
ActivateThreadPool
(
int
context
_id
);
void
ActivateThreadPool
(
int
thread_pool
_id
);
/**
* deactivate the thread pool
* @param
context
_id
* @param
thread_pool
_id
*/
void
DeactivateThreadPool
(
int
context
_id
);
void
DeactivateThreadPool
(
int
thread_pool
_id
);
/**
*
* @return current thread num
*/
int
GetCurrentThreadNum
(
int
context
_id
);
int
GetCurrentThreadNum
(
int
thread_pool
_id
);
/**
* destroy thread pool, and release resource
*/
void
DestroyThreadPool
(
int
context
_id
);
void
DestroyThreadPool
(
int
thread_pool
_id
);
#endif // MINDSPORE_LITE_SRC_RUNTIME_THREAD_POOL_H_
This diff is collapsed.
Click to expand it.
mindspore/lite/test/ut/src/infer_test.cc
浏览文件 @
087f73d9
...
...
@@ -106,7 +106,7 @@ TEST_F(InferTest, TestConvNode) {
meta_graph
.
reset
();
content
=
nullptr
;
auto
context
=
new
lite
::
Context
;
context
->
cpu_bind_mode_
=
NO_BIND
;
context
->
cpu_bind_mode_
=
lite
::
NO_BIND
;
context
->
device_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
...
...
@@ -205,7 +205,7 @@ TEST_F(InferTest, TestAddNode) {
meta_graph
.
reset
();
content
=
nullptr
;
auto
context
=
new
lite
::
Context
;
context
->
cpu_bind_mode_
=
NO_BIND
;
context
->
cpu_bind_mode_
=
lite
::
NO_BIND
;
context
->
device_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
...
...
@@ -307,7 +307,7 @@ TEST_F(InferTest, TestParallelExecutor) {
meta_graph
.
reset
();
content
=
nullptr
;
auto
context
=
new
lite
::
Context
;
context
->
cpu_bind_mode_
=
NO_BIND
;
context
->
cpu_bind_mode_
=
lite
::
NO_BIND
;
context
->
device_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread_num_
=
4
;
auto
session
=
new
SessionWithParallelExecutor
();
...
...
@@ -348,7 +348,7 @@ TEST_F(InferTest, TestModel) {
ASSERT_NE
(
nullptr
,
model
);
delete
[]
buf
[
0
];
auto
context
=
new
lite
::
Context
;
context
->
cpu_bind_mode_
=
NO_BIND
;
context
->
cpu_bind_mode_
=
lite
::
NO_BIND
;
context
->
device_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
...
...
This diff is collapsed.
Click to expand it.
mindspore/lite/tools/benchmark/benchmark.cc
浏览文件 @
087f73d9
...
...
@@ -25,6 +25,7 @@
#include "src/common/common.h"
#include "include/ms_tensor.h"
#include "include/context.h"
#include "src/runtime/runtime_api.h"
namespace
mindspore
{
namespace
lite
{
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部