Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
0ec98409
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0ec98409
编写于
3月 22, 2018
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set Adreno settings only for Adreno GPU
上级
b8f73840
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
84 addition
and
109 deletion
+84
-109
mace/benchmark/benchmark_model.cc
mace/benchmark/benchmark_model.cc
+0
-5
mace/core/mace.cc
mace/core/mace.cc
+6
-8
mace/core/runtime/opencl/opencl_allocator.cc
mace/core/runtime/opencl/opencl_allocator.cc
+0
-1
mace/core/runtime/opencl/opencl_runtime.cc
mace/core/runtime/opencl/opencl_runtime.cc
+71
-59
mace/core/runtime/opencl/opencl_runtime.h
mace/core/runtime/opencl/opencl_runtime.h
+5
-5
mace/core/testing/test_benchmark_main.cc
mace/core/testing/test_benchmark_main.cc
+0
-13
mace/examples/mace_run.cc
mace/examples/mace_run.cc
+0
-16
mace/public/mace.h
mace/public/mace.h
+2
-2
未找到文件。
mace/benchmark/benchmark_model.cc
浏览文件 @
0ec98409
...
@@ -212,7 +212,6 @@ DEFINE_bool(show_flops, true, "whether to estimate the model's FLOPs");
...
@@ -212,7 +212,6 @@ DEFINE_bool(show_flops, true, "whether to estimate the model's FLOPs");
DEFINE_int32
(
warmup_runs
,
1
,
"how many runs to initialize model"
);
DEFINE_int32
(
warmup_runs
,
1
,
"how many runs to initialize model"
);
DEFINE_string
(
model_data_file
,
""
,
DEFINE_string
(
model_data_file
,
""
,
"model data file name, used when EMBED_MODEL_DATA set to 0"
);
"model data file name, used when EMBED_MODEL_DATA set to 0"
);
DEFINE_string
(
gpu_type
,
"ADRENO"
,
"ADRENO/MALI"
);
DEFINE_int32
(
gpu_perf_hint
,
2
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_perf_hint
,
2
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
1
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
1
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
omp_num_threads
,
8
,
"num of openmp threads"
);
DEFINE_int32
(
omp_num_threads
,
8
,
"num of openmp threads"
);
...
@@ -227,7 +226,6 @@ int Main(int argc, char **argv) {
...
@@ -227,7 +226,6 @@ int Main(int argc, char **argv) {
LOG
(
INFO
)
<<
"Benchmark name: ["
<<
FLAGS_benchmark_name
<<
"]"
;
LOG
(
INFO
)
<<
"Benchmark name: ["
<<
FLAGS_benchmark_name
<<
"]"
;
LOG
(
INFO
)
<<
"Device: ["
<<
FLAGS_device
<<
"]"
;
LOG
(
INFO
)
<<
"Device: ["
<<
FLAGS_device
<<
"]"
;
LOG
(
INFO
)
<<
"gpu_type: ["
<<
FLAGS_gpu_type
<<
"]"
;
LOG
(
INFO
)
<<
"gpu_perf_hint: ["
<<
FLAGS_gpu_perf_hint
<<
"]"
;
LOG
(
INFO
)
<<
"gpu_perf_hint: ["
<<
FLAGS_gpu_perf_hint
<<
"]"
;
LOG
(
INFO
)
<<
"gpu_priority_hint: ["
<<
FLAGS_gpu_priority_hint
<<
"]"
;
LOG
(
INFO
)
<<
"gpu_priority_hint: ["
<<
FLAGS_gpu_priority_hint
<<
"]"
;
LOG
(
INFO
)
<<
"omp_num_threads: ["
<<
FLAGS_omp_num_threads
<<
"]"
;
LOG
(
INFO
)
<<
"omp_num_threads: ["
<<
FLAGS_omp_num_threads
<<
"]"
;
...
@@ -270,10 +268,7 @@ int Main(int argc, char **argv) {
...
@@ -270,10 +268,7 @@ int Main(int argc, char **argv) {
// config runtime
// config runtime
if
(
device_type
==
OPENCL
)
{
if
(
device_type
==
OPENCL
)
{
GPUType
gpu_type
=
ADRENO
;
if
(
FLAGS_gpu_type
==
"MALI"
)
gpu_type
=
MALI
;
mace
::
ConfigOpenCLRuntime
(
mace
::
ConfigOpenCLRuntime
(
gpu_type
,
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
}
else
if
(
device_type
==
CPU
)
{
}
else
if
(
device_type
==
CPU
)
{
...
...
mace/core/mace.cc
浏览文件 @
0ec98409
...
@@ -351,19 +351,17 @@ const OperatorDef &NetDef::op(const int idx) const {
...
@@ -351,19 +351,17 @@ const OperatorDef &NetDef::op(const int idx) const {
return
op_
[
idx
];
return
op_
[
idx
];
}
}
void
ConfigOpenCLRuntime
(
GPUType
gpu_type
,
void
ConfigOpenCLRuntime
(
GPUPerfHint
gpu_perf_hint
,
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
GPUPriorityHint
gpu_priority_hint
)
{
LOG
(
INFO
)
<<
"Config OpenCL Runtime: gpu_type: "
<<
gpu_type
VLOG
(
1
)
<<
"Set GPU configurations, gpu_perf_hint: "
<<
gpu_perf_hint
<<
", gpu_perf_hint: "
<<
gpu_perf_hint
<<
", gpu_priority_hint: "
<<
gpu_priority_hint
;
<<
", gpu_priority_hint: "
<<
gpu_priority_hint
;
OpenCLRuntime
::
CreateGlobal
(
gpu_perf_hint
,
gpu_priority_hint
);
OpenCLRuntime
::
CreateGlobal
(
gpu_type
,
gpu_perf_hint
,
gpu_priority_hint
);
}
}
void
ConfigOmpThreadsAndAffinity
(
int
omp_num_threads
,
void
ConfigOmpThreadsAndAffinity
(
int
omp_num_threads
,
CPUPowerOption
power_option
)
{
CPUPowerOption
power_option
)
{
LOG
(
INFO
)
<<
"Config CPU Runtime: omp_num_threads: "
<<
omp_num_threads
VLOG
(
1
)
<<
"Config CPU Runtime: omp_num_threads: "
<<
omp_num_threads
<<
", cpu_power_option: "
<<
power_option
;
<<
", cpu_power_option: "
<<
power_option
;
SetOmpThreadsAndAffinity
(
omp_num_threads
,
power_option
);
SetOmpThreadsAndAffinity
(
omp_num_threads
,
power_option
);
}
}
...
...
mace/core/runtime/opencl/opencl_allocator.cc
浏览文件 @
0ec98409
...
@@ -41,7 +41,6 @@ void *OpenCLAllocator::New(size_t nbytes) const {
...
@@ -41,7 +41,6 @@ void *OpenCLAllocator::New(size_t nbytes) const {
CL_MEM_READ_WRITE
|
CL_MEM_ALLOC_HOST_PTR
,
CL_MEM_READ_WRITE
|
CL_MEM_ALLOC_HOST_PTR
,
nbytes
,
nullptr
,
&
error
);
nbytes
,
nullptr
,
&
error
);
MACE_CHECK
(
error
==
CL_SUCCESS
)
<<
"error code: "
<<
error
;
MACE_CHECK
(
error
==
CL_SUCCESS
)
<<
"error code: "
<<
error
;
MACE_CHECK_NOTNULL
(
buffer
);
return
static_cast
<
void
*>
(
buffer
);
return
static_cast
<
void
*>
(
buffer
);
}
}
...
...
mace/core/runtime/opencl/opencl_runtime.cc
浏览文件 @
0ec98409
...
@@ -70,66 +70,61 @@ std::unique_ptr<OpenCLRuntime> OpenCLRuntime::runtime_instance_ = nullptr;
...
@@ -70,66 +70,61 @@ std::unique_ptr<OpenCLRuntime> OpenCLRuntime::runtime_instance_ = nullptr;
OpenCLRuntime
*
OpenCLRuntime
::
Global
()
{
OpenCLRuntime
*
OpenCLRuntime
::
Global
()
{
// FIXME: not thread safe
// FIXME: not thread safe
if
(
runtime_instance_
==
nullptr
)
{
if
(
runtime_instance_
==
nullptr
)
{
return
CreateGlobal
(
GPU
Type
::
ADRENO
,
GPU
PerfHint
::
PERF_DEFAULT
,
return
CreateGlobal
(
GPUPerfHint
::
PERF_DEFAULT
,
GPUPriorityHint
::
PRIORITY_DEFAULT
);
GPUPriorityHint
::
PRIORITY_DEFAULT
);
}
}
return
runtime_instance_
.
get
();
return
runtime_instance_
.
get
();
}
}
OpenCLRuntime
*
OpenCLRuntime
::
CreateGlobal
(
GPUType
gpu_type
,
OpenCLRuntime
*
OpenCLRuntime
::
CreateGlobal
(
GPUPerfHint
gpu_perf_hint
,
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
GPUPriorityHint
gpu_priority_hint
)
{
runtime_instance_
=
runtime_instance_
=
std
::
unique_ptr
<
OpenCLRuntime
>
(
new
OpenCLRuntime
(
gpu_
type
,
gpu_
perf_hint
,
std
::
unique_ptr
<
OpenCLRuntime
>
(
new
OpenCLRuntime
(
gpu_perf_hint
,
gpu_priority_hint
));
gpu_priority_hint
));
return
runtime_instance_
.
get
();
return
runtime_instance_
.
get
();
}
}
void
ParseOpenCLRuntimeConfig
(
std
::
vector
<
cl_context_properties
>
*
properties
,
void
GetAdrenoContextProperties
(
std
::
vector
<
cl_context_properties
>
*
properties
,
GPUType
gpu_type
,
GPUPerfHint
gpu_perf_hint
,
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
GPUPriorityHint
gpu_priority_hint
)
{
MACE_CHECK_NOTNULL
(
properties
);
MACE_CHECK_NOTNULL
(
properties
);
if
(
gpu_type
==
GPUType
::
ADRENO
)
{
switch
(
gpu_perf_hint
)
{
switch
(
gpu_perf_hint
)
{
case
GPUPerfHint
::
PERF_LOW
:
case
GPUPerfHint
::
PERF_LOW
:
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_LOW_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_LOW_QCOM
);
break
;
break
;
case
GPUPerfHint
::
PERF_NORMAL
:
case
GPUPerfHint
::
PERF_NORMAL
:
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_NORMAL_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_NORMAL_QCOM
);
break
;
break
;
case
GPUPerfHint
::
PERF_HIGH
:
case
GPUPerfHint
::
PERF_HIGH
:
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PERF_HINT_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_HIGH_QCOM
);
properties
->
push_back
(
CL_PERF_HINT_HIGH_QCOM
);
break
;
break
;
default:
default:
break
;
break
;
}
}
switch
(
gpu_priority_hint
)
{
switch
(
gpu_priority_hint
)
{
case
GPUPriorityHint
::
PRIORITY_LOW
:
case
GPUPriorityHint
::
PRIORITY_LOW
:
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_LOW_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_LOW_QCOM
);
break
;
break
;
case
GPUPriorityHint
::
PRIORITY_NORMAL
:
case
GPUPriorityHint
::
PRIORITY_NORMAL
:
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_NORMAL_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_NORMAL_QCOM
);
break
;
break
;
case
GPUPriorityHint
::
PRIORITY_HIGH
:
case
GPUPriorityHint
::
PRIORITY_HIGH
:
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_CONTEXT_PRIORITY_HINT_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_HIGH_QCOM
);
properties
->
push_back
(
CL_PRIORITY_HINT_HIGH_QCOM
);
break
;
break
;
default:
break
;
default:
}
break
;
}
else
{
LOG
(
WARNING
)
<<
"GPU options are only supported by Adreno GPU"
;
}
}
// The properties list should be terminated with 0
// The properties list should be terminated with 0
properties
->
push_back
(
0
);
properties
->
push_back
(
0
);
}
}
OpenCLRuntime
::
OpenCLRuntime
(
GPU
Type
gpu_type
,
GPU
PerfHint
gpu_perf_hint
,
OpenCLRuntime
::
OpenCLRuntime
(
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
GPUPriorityHint
gpu_priority_hint
)
{
LoadOpenCLLibrary
();
LoadOpenCLLibrary
();
...
@@ -151,12 +146,19 @@ OpenCLRuntime::OpenCLRuntime(GPUType gpu_type, GPUPerfHint gpu_perf_hint,
...
@@ -151,12 +146,19 @@ OpenCLRuntime::OpenCLRuntime(GPUType gpu_type, GPUPerfHint gpu_perf_hint,
}
}
bool
gpu_detected
=
false
;
bool
gpu_detected
=
false
;
cl
::
Device
gpu_device
;
bool
is_adreno_gpu
=
false
;
device_
=
std
::
make_shared
<
cl
::
Device
>
();
for
(
auto
device
:
all_devices
)
{
for
(
auto
device
:
all_devices
)
{
if
(
device
.
getInfo
<
CL_DEVICE_TYPE
>
()
==
CL_DEVICE_TYPE_GPU
)
{
if
(
device
.
getInfo
<
CL_DEVICE_TYPE
>
()
==
CL_DEVICE_TYPE_GPU
)
{
gpu_device
=
device
;
*
device_
=
device
;
gpu_detected
=
true
;
gpu_detected
=
true
;
VLOG
(
1
)
<<
"Using device: "
<<
device
.
getInfo
<
CL_DEVICE_NAME
>
();
const
std
::
string
device_name
=
device
.
getInfo
<
CL_DEVICE_NAME
>
();
constexpr
const
char
*
kQualcommAdrenoGPUStr
=
"QUALCOMM Adreno(TM)"
;
if
(
device_name
==
kQualcommAdrenoGPUStr
)
{
is_adreno_gpu
=
true
;
}
VLOG
(
1
)
<<
"Using device: "
<<
device_name
;
break
;
break
;
}
}
}
}
...
@@ -172,28 +174,38 @@ OpenCLRuntime::OpenCLRuntime(GPUType gpu_type, GPUPerfHint gpu_perf_hint,
...
@@ -172,28 +174,38 @@ OpenCLRuntime::OpenCLRuntime(GPUType gpu_type, GPUPerfHint gpu_perf_hint,
properties
|=
CL_QUEUE_PROFILING_ENABLE
;
properties
|=
CL_QUEUE_PROFILING_ENABLE
;
}
}
std
::
vector
<
cl_context_properties
>
context_properties
;
cl_int
err
;
context_properties
.
reserve
(
5
);
if
(
is_adreno_gpu
)
{
ParseOpenCLRuntimeConfig
(
&
context_properties
,
gpu_type
,
gpu_perf_hint
,
std
::
vector
<
cl_context_properties
>
context_properties
;
gpu_priority_hint
);
context_properties
.
reserve
(
5
);
GetAdrenoContextProperties
(
&
context_properties
,
gpu_perf_hint
,
gpu_priority_hint
);
context_
=
std
::
shared_ptr
<
cl
::
Context
>
(
new
cl
::
Context
({
*
device_
},
context_properties
.
data
(),
nullptr
,
nullptr
,
&
err
));
}
else
{
context_
=
std
::
shared_ptr
<
cl
::
Context
>
(
new
cl
::
Context
({
*
device_
},
nullptr
,
nullptr
,
nullptr
,
&
err
));
}
MACE_CHECK
(
err
==
CL_SUCCESS
)
<<
"error code: "
<<
err
;
cl
::
Context
context
({
gpu_device
},
context_properties
.
data
());
command_queue_
=
std
::
make_shared
<
cl
::
CommandQueue
>
(
*
context_
,
cl
::
CommandQueue
command_queue
(
context
,
gpu_device
,
properties
);
*
device_
,
properties
,
&
err
);
MACE_CHECK
(
err
==
CL_SUCCESS
)
<<
"error code: "
<<
err
;
const
char
*
kernel_path
=
getenv
(
"MACE_KERNEL_PATH"
);
const
char
*
kernel_path
=
getenv
(
"MACE_KERNEL_PATH"
);
this
->
kernel_path_
=
this
->
kernel_path_
=
std
::
string
(
kernel_path
==
nullptr
?
""
:
kernel_path
)
+
"/"
;
std
::
string
(
kernel_path
==
nullptr
?
""
:
kernel_path
)
+
"/"
;
this
->
device_
=
new
cl
::
Device
(
gpu_device
);
this
->
context_
=
new
cl
::
Context
(
context
);
this
->
command_queue_
=
new
cl
::
CommandQueue
(
command_queue
);
}
}
OpenCLRuntime
::~
OpenCLRuntime
()
{
OpenCLRuntime
::~
OpenCLRuntime
()
{
built_program_map_
.
clear
();
built_program_map_
.
clear
();
delete
command_queue_
;
// We need to control the destruction order, which has dependencies
delete
context_
;
command_queue_
.
reset
();
delete
device_
;
context_
.
reset
();
device_
.
reset
();
UnloadOpenCLLibrary
();
UnloadOpenCLLibrary
();
}
}
...
...
mace/core/runtime/opencl/opencl_runtime.h
浏览文件 @
0ec98409
...
@@ -39,7 +39,7 @@ class OpenCLProfilingTimer : public Timer {
...
@@ -39,7 +39,7 @@ class OpenCLProfilingTimer : public Timer {
class
OpenCLRuntime
{
class
OpenCLRuntime
{
public:
public:
static
OpenCLRuntime
*
Global
();
static
OpenCLRuntime
*
Global
();
static
OpenCLRuntime
*
CreateGlobal
(
GPU
Type
,
GPU
PerfHint
,
GPUPriorityHint
);
static
OpenCLRuntime
*
CreateGlobal
(
GPUPerfHint
,
GPUPriorityHint
);
cl
::
Context
&
context
();
cl
::
Context
&
context
();
cl
::
Device
&
device
();
cl
::
Device
&
device
();
...
@@ -55,7 +55,7 @@ class OpenCLRuntime {
...
@@ -55,7 +55,7 @@ class OpenCLRuntime {
~
OpenCLRuntime
();
~
OpenCLRuntime
();
private:
private:
OpenCLRuntime
(
GPU
Type
,
GPU
PerfHint
,
GPUPriorityHint
);
OpenCLRuntime
(
GPUPerfHint
,
GPUPriorityHint
);
OpenCLRuntime
(
const
OpenCLRuntime
&
)
=
delete
;
OpenCLRuntime
(
const
OpenCLRuntime
&
)
=
delete
;
OpenCLRuntime
&
operator
=
(
const
OpenCLRuntime
&
)
=
delete
;
OpenCLRuntime
&
operator
=
(
const
OpenCLRuntime
&
)
=
delete
;
...
@@ -68,9 +68,9 @@ class OpenCLRuntime {
...
@@ -68,9 +68,9 @@ class OpenCLRuntime {
private:
private:
// All OpenCL object must be a pointer and manually deleted before unloading
// All OpenCL object must be a pointer and manually deleted before unloading
// OpenCL library.
// OpenCL library.
cl
::
Context
*
context_
;
std
::
shared_ptr
<
cl
::
Context
>
context_
;
cl
::
Device
*
device_
;
std
::
shared_ptr
<
cl
::
Device
>
device_
;
cl
::
CommandQueue
*
command_queue_
;
std
::
shared_ptr
<
cl
::
CommandQueue
>
command_queue_
;
std
::
map
<
std
::
string
,
cl
::
Program
>
built_program_map_
;
std
::
map
<
std
::
string
,
cl
::
Program
>
built_program_map_
;
std
::
mutex
program_build_mutex_
;
std
::
mutex
program_build_mutex_
;
std
::
string
kernel_path_
;
std
::
string
kernel_path_
;
...
...
mace/core/testing/test_benchmark_main.cc
浏览文件 @
0ec98409
...
@@ -9,31 +9,18 @@
...
@@ -9,31 +9,18 @@
#include "mace/public/mace.h"
#include "mace/public/mace.h"
DEFINE_string
(
pattern
,
"all"
,
"op benchmark pattern, eg:.*CONV.*"
);
DEFINE_string
(
pattern
,
"all"
,
"op benchmark pattern, eg:.*CONV.*"
);
DEFINE_string
(
gpu_type
,
"ADRENO"
,
"ADRENO/MALI"
);
DEFINE_int32
(
gpu_perf_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_perf_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
omp_num_threads
,
1
,
"num of openmp threads"
);
DEFINE_int32
(
omp_num_threads
,
1
,
"num of openmp threads"
);
DEFINE_int32
(
cpu_power_option
,
1
,
DEFINE_int32
(
cpu_power_option
,
1
,
"0:DEFAULT/1:HIGH_PERFORMANCE/2:BATTERY_SAVE"
);
"0:DEFAULT/1:HIGH_PERFORMANCE/2:BATTERY_SAVE"
);
mace
::
GPUType
ParseGPUType
(
const
std
::
string
&
gpu_type_str
)
{
if
(
gpu_type_str
.
compare
(
"ADRENO"
)
==
0
)
{
return
mace
::
GPUType
::
ADRENO
;
}
else
if
(
gpu_type_str
.
compare
(
"MALI"
)
==
0
)
{
return
mace
::
GPUType
::
MALI
;
}
else
{
return
mace
::
GPUType
::
ADRENO
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
gflags
::
SetUsageMessage
(
"some usage message"
);
gflags
::
SetUsageMessage
(
"some usage message"
);
gflags
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
gflags
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
// config runtime
// config runtime
mace
::
GPUType
gpu_type
=
ParseGPUType
(
FLAGS_gpu_type
);
mace
::
ConfigOpenCLRuntime
(
mace
::
ConfigOpenCLRuntime
(
gpu_type
,
static_cast
<
mace
::
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
mace
::
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
mace
::
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
static_cast
<
mace
::
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
mace
::
ConfigOmpThreadsAndAffinity
(
mace
::
ConfigOmpThreadsAndAffinity
(
...
...
mace/examples/mace_run.cc
浏览文件 @
0ec98409
...
@@ -98,16 +98,6 @@ DeviceType ParseDeviceType(const std::string &device_str) {
...
@@ -98,16 +98,6 @@ DeviceType ParseDeviceType(const std::string &device_str) {
}
}
}
}
GPUType
ParseGPUType
(
const
std
::
string
&
gpu_type_str
)
{
if
(
gpu_type_str
.
compare
(
"ADRENO"
)
==
0
)
{
return
GPUType
::
ADRENO
;
}
else
if
(
gpu_type_str
.
compare
(
"MALI"
)
==
0
)
{
return
GPUType
::
MALI
;
}
else
{
return
GPUType
::
ADRENO
;
}
}
struct
mallinfo
LogMallinfoChange
(
struct
mallinfo
prev
)
{
struct
mallinfo
LogMallinfoChange
(
struct
mallinfo
prev
)
{
struct
mallinfo
curr
=
mallinfo
();
struct
mallinfo
curr
=
mallinfo
();
if
(
prev
.
arena
!=
curr
.
arena
)
{
if
(
prev
.
arena
!=
curr
.
arena
)
{
...
@@ -173,7 +163,6 @@ DEFINE_string(device, "OPENCL", "CPU/NEON/OPENCL/HEXAGON");
...
@@ -173,7 +163,6 @@ DEFINE_string(device, "OPENCL", "CPU/NEON/OPENCL/HEXAGON");
DEFINE_int32
(
round
,
1
,
"round"
);
DEFINE_int32
(
round
,
1
,
"round"
);
DEFINE_int32
(
restart_round
,
1
,
"restart round"
);
DEFINE_int32
(
restart_round
,
1
,
"restart round"
);
DEFINE_int32
(
malloc_check_cycle
,
-
1
,
"malloc debug check cycle, -1 to disable"
);
DEFINE_int32
(
malloc_check_cycle
,
-
1
,
"malloc debug check cycle, -1 to disable"
);
DEFINE_string
(
gpu_type
,
"ADRENO"
,
"ADRENO/MALI"
);
DEFINE_int32
(
gpu_perf_hint
,
2
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_perf_hint
,
2
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
1
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
1
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
omp_num_threads
,
8
,
"num of openmp threads"
);
DEFINE_int32
(
omp_num_threads
,
8
,
"num of openmp threads"
);
...
@@ -196,9 +185,7 @@ bool SingleInputAndOutput(const std::vector<int64_t> &input_shape,
...
@@ -196,9 +185,7 @@ bool SingleInputAndOutput(const std::vector<int64_t> &input_shape,
// config runtime
// config runtime
if
(
device_type
==
DeviceType
::
OPENCL
)
{
if
(
device_type
==
DeviceType
::
OPENCL
)
{
GPUType
gpu_type
=
ParseGPUType
(
FLAGS_gpu_type
);
mace
::
ConfigOpenCLRuntime
(
mace
::
ConfigOpenCLRuntime
(
gpu_type
,
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
}
else
if
(
device_type
==
DeviceType
::
CPU
)
{
}
else
if
(
device_type
==
DeviceType
::
CPU
)
{
...
@@ -302,9 +289,7 @@ bool MultipleInputOrOutput(
...
@@ -302,9 +289,7 @@ bool MultipleInputOrOutput(
// config runtime
// config runtime
if
(
device_type
==
DeviceType
::
OPENCL
)
{
if
(
device_type
==
DeviceType
::
OPENCL
)
{
GPUType
gpu_type
=
ParseGPUType
(
FLAGS_gpu_type
);
mace
::
ConfigOpenCLRuntime
(
mace
::
ConfigOpenCLRuntime
(
gpu_type
,
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPerfHint
>
(
FLAGS_gpu_perf_hint
),
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
static_cast
<
GPUPriorityHint
>
(
FLAGS_gpu_priority_hint
));
}
else
if
(
device_type
==
DeviceType
::
CPU
)
{
}
else
if
(
device_type
==
DeviceType
::
CPU
)
{
...
@@ -418,7 +403,6 @@ int Main(int argc, char **argv) {
...
@@ -418,7 +403,6 @@ int Main(int argc, char **argv) {
LOG
(
INFO
)
<<
"device: "
<<
FLAGS_device
;
LOG
(
INFO
)
<<
"device: "
<<
FLAGS_device
;
LOG
(
INFO
)
<<
"round: "
<<
FLAGS_round
;
LOG
(
INFO
)
<<
"round: "
<<
FLAGS_round
;
LOG
(
INFO
)
<<
"restart_round: "
<<
FLAGS_restart_round
;
LOG
(
INFO
)
<<
"restart_round: "
<<
FLAGS_restart_round
;
LOG
(
INFO
)
<<
"gpu_type: "
<<
FLAGS_gpu_type
;
LOG
(
INFO
)
<<
"gpu_perf_hint: "
<<
FLAGS_gpu_perf_hint
;
LOG
(
INFO
)
<<
"gpu_perf_hint: "
<<
FLAGS_gpu_perf_hint
;
LOG
(
INFO
)
<<
"gpu_priority_hint: "
<<
FLAGS_gpu_priority_hint
;
LOG
(
INFO
)
<<
"gpu_priority_hint: "
<<
FLAGS_gpu_priority_hint
;
LOG
(
INFO
)
<<
"omp_num_threads: "
<<
FLAGS_omp_num_threads
;
LOG
(
INFO
)
<<
"omp_num_threads: "
<<
FLAGS_omp_num_threads
;
...
...
mace/public/mace.h
浏览文件 @
0ec98409
...
@@ -61,13 +61,13 @@ enum DataType {
...
@@ -61,13 +61,13 @@ enum DataType {
DT_UINT32
=
22
DT_UINT32
=
22
};
};
enum
GPUType
{
ADRENO
=
0
,
MALI
=
1
};
enum
GPUPerfHint
{
enum
GPUPerfHint
{
PERF_DEFAULT
=
0
,
PERF_DEFAULT
=
0
,
PERF_LOW
=
1
,
PERF_LOW
=
1
,
PERF_NORMAL
=
2
,
PERF_NORMAL
=
2
,
PERF_HIGH
=
3
PERF_HIGH
=
3
};
};
enum
GPUPriorityHint
{
enum
GPUPriorityHint
{
PRIORITY_DEFAULT
=
0
,
PRIORITY_DEFAULT
=
0
,
PRIORITY_LOW
=
1
,
PRIORITY_LOW
=
1
,
...
@@ -385,7 +385,7 @@ struct MaceInputInfo {
...
@@ -385,7 +385,7 @@ struct MaceInputInfo {
const
float
*
data
;
const
float
*
data
;
};
};
void
ConfigOpenCLRuntime
(
GPU
Type
,
GPU
PerfHint
,
GPUPriorityHint
);
void
ConfigOpenCLRuntime
(
GPUPerfHint
,
GPUPriorityHint
);
void
ConfigOmpThreadsAndAffinity
(
int
omp_num_threads
,
void
ConfigOmpThreadsAndAffinity
(
int
omp_num_threads
,
CPUPowerOption
power_option
);
CPUPowerOption
power_option
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录