提交 cf3b5830 编写于 作者: L Liangliang He

Fix half and opencl build

上级 63433b7b
...@@ -48,22 +48,16 @@ cc_library( ...@@ -48,22 +48,16 @@ cc_library(
["*.cc",], ["*.cc",],
exclude=[ exclude=[
"logging.cc", "logging.cc",
"opencl_allocator.cc",
]) + if_android([
"opencl_allocator.cc",
]), ]),
hdrs = glob( hdrs = glob(
["*.h"], ["*.h"],
exclude=[ exclude=[
"logging.h", "logging.h",
"opencl_allocator.h",
]) + if_android([
"opencl_allocator.h",
]), ]),
copts = ["-std=c++11"] + if_android([ copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1"] + if_android([
"-D__USE_OPENCL", "-D__USE_OPENCL",
]), ]),
linkopts = if_android([ linkopts = ["-ldl"] + if_android([
"-pie", "-pie",
]), ]),
deps = [ deps = [
...@@ -71,9 +65,8 @@ cc_library( ...@@ -71,9 +65,8 @@ cc_library(
"//mace/proto:cc_proto", "//mace/proto:cc_proto",
"//mace/proto:stats_proto", "//mace/proto:stats_proto",
"//mace/utils", "//mace/utils",
] + if_android([
":opencl_runtime", ":opencl_runtime",
]), ],
) )
# Main program for tests # Main program for tests
...@@ -86,7 +79,10 @@ cc_library( ...@@ -86,7 +79,10 @@ cc_library(
hdrs = glob([ hdrs = glob([
"testing/*.h", "testing/*.h",
]), ]),
copts = ["-std=c++11"], copts = [
"-std=c++11",
"-D_GLIBCXX_USE_C99_MATH_TR1",
],
linkopts = ["-lm"], linkopts = ["-lm"],
deps = [ deps = [
":core", ":core",
......
...@@ -53,6 +53,9 @@ bool SimpleNet::Run(RunMetadata *run_metadata) { ...@@ -53,6 +53,9 @@ bool SimpleNet::Run(RunMetadata *run_metadata) {
if (run_metadata) { if (run_metadata) {
if (device_type_ == DeviceType::OPENCL) { if (device_type_ == DeviceType::OPENCL) {
#ifndef __USE_OPENCL
LOG(FATAL) << "OpenCL is not supported";
#endif
OpenCLRuntime::Get()->command_queue().finish(); OpenCLRuntime::Get()->command_queue().finish();
op_stats = run_metadata->add_op_stats(); op_stats = run_metadata->add_op_stats();
op_stats->set_operator_name(op->debug_def().name()); op_stats->set_operator_name(op->debug_def().name());
......
...@@ -11,19 +11,16 @@ load("//mace:mace.bzl", "if_android", "if_android_arm64") ...@@ -11,19 +11,16 @@ load("//mace:mace.bzl", "if_android", "if_android_arm64")
cc_library( cc_library(
name = "kernels", name = "kernels",
srcs = glob(["*.cc"]) + if_android(glob([ srcs = glob(["*.cc", "opencl/*.cc"]) + if_android_arm64(glob([
"opencl/*.cc",
])) + if_android_arm64(glob([
"neon/*.cc", "neon/*.cc",
])), ])),
hdrs = glob(["*.h"]) + if_android(glob([ hdrs = glob(["*.h", "opencl/*.h"]) + if_android_arm64(glob([
"opencl/*.h",
])) + if_android_arm64(glob([
"neon/*.h", "neon/*.h",
])), ])),
copts = [ copts = [
"-std=c++11", "-std=c++11",
"-fopenmp", "-fopenmp",
"-D_GLIBCXX_USE_C99_MATH_TR1",
], ],
linkopts = if_android(["-lm"]), linkopts = if_android(["-lm"]),
deps = [ deps = [
......
...@@ -36,7 +36,7 @@ cc_library( ...@@ -36,7 +36,7 @@ cc_library(
), ),
copts = [ copts = [
"-std=c++11", "-std=c++11",
"-fopenmp", "-D_GLIBCXX_USE_C99_MATH_TR1",
], ],
deps = [ deps = [
"//mace/kernels", "//mace/kernels",
...@@ -52,7 +52,7 @@ cc_test( ...@@ -52,7 +52,7 @@ cc_test(
["*_test.cc"], ["*_test.cc"],
), ),
copts = ["-std=c++11"], copts = ["-std=c++11"],
linkopts = ["-fopenmp"] + if_android(["-ldl"]), linkopts = ["-fopenmp"],
linkstatic = 1, linkstatic = 1,
deps = [ deps = [
":ops", ":ops",
...@@ -65,7 +65,11 @@ cc_test( ...@@ -65,7 +65,11 @@ cc_test(
name = "ops_benchmark", name = "ops_benchmark",
testonly = 1, testonly = 1,
srcs = glob(["*_benchmark.cc"]), srcs = glob(["*_benchmark.cc"]),
copts = ["-std=c++11"], copts = [
"-std=c++11",
"-fopenmp",
"-D_GLIBCXX_USE_C99_MATH_TR1",
],
linkopts = ["-fopenmp"] + if_android(["-ldl"]), linkopts = ["-fopenmp"] + if_android(["-ldl"]),
linkstatic = 1, linkstatic = 1,
deps = [ deps = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册