Skip to content

Commit 9845c1f

Browse files
Feature: support opencl3.0
Desc: support opencl3.0 and fix a mace micro compile error Signed-off-by: yuanlonglong <[email protected]>
1 parent 20a0525 commit 9845c1f

File tree

8 files changed

+21
-78
lines changed

8 files changed

+21
-78
lines changed

WORKSPACE

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ new_http_archive(
3535
new_http_archive(
3636
name = "opencl_headers",
3737
build_file = "third_party/opencl-headers/opencl-headers.BUILD",
38-
sha256 = "b2b813dd88a7c39eb396afc153070f8f262504a7f956505b2049e223cfc2229b",
39-
strip_prefix = "OpenCL-Headers-f039db6764d52388658ef15c30b2237bbda49803",
38+
sha256 = "e08f3c77a76f0e3d9ef886c7a7245757a831fdf5bc2c554587f57adb9226f53a",
39+
strip_prefix = "OpenCL-Headers-2021.06.30",
4040
urls = [
41-
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/OpenCL-Headers/f039db6764d52388658ef15c30b2237bbda49803.zip",
42-
"https://github.com/KhronosGroup/OpenCL-Headers/archive/f039db6764d52388658ef15c30b2237bbda49803.zip",
41+
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/OpenCL-Headers/OpenCL-Headers-2021.06.30.zip",
42+
"https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2021.06.30.zip",
4343
],
4444
)
4545

4646
new_http_archive(
4747
name = "opencl_clhpp",
4848
build_file = "third_party/opencl-clhpp/opencl-clhpp.BUILD",
49-
sha256 = "dab6f1834ec6e3843438cc0f97d63817902aadd04566418c1fcc7fb78987d4e7",
50-
strip_prefix = "OpenCL-CLHPP-4c6f7d56271727e37fb19a9b47649dd175df2b12",
49+
sha256 = "767c2e9589739cfca814cbb94c57bcbb3112d94f1a8cafffa8a5cc3a5de00d12",
50+
strip_prefix = "OpenCL-CLHPP-2.0.15",
5151
urls = [
52-
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/OpenCL-CLHPP/OpenCL-CLHPP-4c6f7d56271727e37fb19a9b47649dd175df2b12.zip",
53-
"https://github.com/KhronosGroup/OpenCL-CLHPP/archive/4c6f7d56271727e37fb19a9b47649dd175df2b12.zip",
52+
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/OpenCL-CLHPP/OpenCL-CLHPP-2.0.15.zip",
53+
"https://github.com/KhronosGroup/OpenCL-CLHPP/archive/refs/tags/v2.0.15.zip",
5454
],
5555
)
5656

mace/runtimes/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cc_library(
2727
],
2828
deps = [
2929
"@opencl_clhpp",
30-
"@opencl_headers//:opencl20_headers",
30+
"@opencl_headers//:opencl_headers",
3131
],
3232
)
3333

mace/runtimes/opencl/core/opencl_executor.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,9 @@ OpenCLVersion OpenclExecutor::ParseDeviceVersion(
10451045
// OpenCL<space><major_version.minor_version><space>
10461046
// <vendor-specific information>
10471047
auto words = Split(device_version, ' ');
1048-
if (words[1] == "2.1") {
1048+
if (words[1] == "3.0") {
1049+
return OpenCLVersion::CL_VER_3_0;
1050+
} else if (words[1] == "2.1") {
10491051
return OpenCLVersion::CL_VER_2_1;
10501052
} else if (words[1] == "2.0") {
10511053
return OpenCLVersion::CL_VER_2_0;

mace/runtimes/opencl/core/opencl_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum OpenCLVersion {
4747
CL_VER_1_2,
4848
CL_VER_2_0,
4949
CL_VER_2_1,
50+
CL_VER_3_0,
5051
};
5152

5253
enum IONType {

mace/runtimes/opencl/core/opencl_wrapper.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
typedef cl_queue_properties_APPLE cl_queue_properties;
2929
#endif
3030

31-
#if CL_HPP_TARGET_OPENCL_VERSION < 200
32-
#define CL_API_SUFFIX__VERSION_2_0
33-
#endif
34-
3531
namespace mace {
3632

3733
namespace runtime {
@@ -838,7 +834,7 @@ CL_API_ENTRY cl_int clGetDeviceImageInfoQCOM(
838834
size_t param_value_size,
839835
void *param_value,
840836
size_t *param_value_size_ret)
841-
CL_EXT_SUFFIX__VERSION_1_1 {
837+
CL_API_SUFFIX__VERSION_1_1 {
842838
auto func = mace::runtime::OpenCLLibrary::Get()->clGetDeviceImageInfoQCOM;
843839
if (func != nullptr) {
844840
MACE_LATENCY_LOGGER(3, "clGetDeviceImageInfoQCOM");

micro/ops/cmsis_nn/arm_softmax_int8.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MaceStatus ArmSoftmaxInt8Op::RunForNHWC() {
6565
int32_t scale_q = static_cast<int32_t>(
6666
base::min(static_cast<double>(input_quantize_info.scale) *
6767
(1 << (31 - kInputDeltaIntBits)),
68-
(1ll << 31) - 1.0));
68+
static_cast<double>((1ll << 31) - 1.0)));
6969
int32_t mult;
7070
int32_t shift;
7171
QuantizeMultiplier(scale_q, &mult, &shift);

third_party/opencl-clhpp/opencl-clhpp.BUILD

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,11 @@ licenses(["notice"])
22

33
exports_files(["LICENSE.txt"])
44

5-
genrule(
6-
name = "gen_opencl_clhpp",
7-
srcs = glob([
8-
"*",
9-
"**/*",
10-
]),
11-
outs = ["include/CL/cl.hpp", "include/CL/cl2.hpp"],
12-
cmd = "workdir=$$(mktemp -d -t opencl-clhpp-build.XXXXXXXXXX); cp -aL $$(dirname $(location CMakeLists.txt))/* $$workdir; pushd $$workdir; mkdir build; pushd build; cmake ../ -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF; make generate_clhpp generate_cl2hpp; popd; popd; cp -a $$workdir/build/* $(@D); rm -rf $$workdir; echo installing to $(@D)",
13-
)
14-
15-
# The `srcs` is not used in c++ Code, but we need it to trigger the `genrule`,
16-
# So we add the "include/CL/cl.hpp", "include/CL/cl2.hpp" into `srcs`, these
17-
# two files is imported by the `includes` instead of `srcs`.
185
cc_library(
196
name = "opencl_clhpp",
7+
hdrs = glob([
8+
"include/CL/*.hpp",
9+
]),
2010
includes = ["include"],
21-
srcs = ["include/CL/cl.hpp", "include/CL/cl2.hpp"],
2211
visibility = ["//visibility:public"],
2312
)

third_party/opencl-headers/opencl-headers.BUILD

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,11 @@ licenses(["notice"])
33
exports_files(["LICENSE"])
44

55
cc_library(
6-
name = "opencl10_headers",
6+
name = "opencl_headers",
77
hdrs = glob([
8-
"opencl10/CL/*.h",
8+
"CL/*.h",
99
]),
10-
strip_include_prefix = "opencl10",
11-
visibility = ["//visibility:public"],
12-
)
13-
14-
cc_library(
15-
name = "opencl11_headers",
16-
hdrs = glob([
17-
"opencl11/CL/*.h",
18-
]),
19-
strip_include_prefix = "opencl11",
20-
visibility = ["//visibility:public"],
21-
)
22-
23-
cc_library(
24-
name = "opencl12_headers",
25-
hdrs = glob([
26-
"opencl12/CL/*.h",
27-
]),
28-
strip_include_prefix = "opencl12",
29-
visibility = ["//visibility:public"],
30-
)
31-
32-
cc_library(
33-
name = "opencl20_headers",
34-
hdrs = glob([
35-
"opencl20/CL/*.h",
36-
]),
37-
strip_include_prefix = "opencl20",
38-
visibility = ["//visibility:public"],
39-
)
40-
41-
cc_library(
42-
name = "opencl21_headers",
43-
hdrs = glob([
44-
"opencl21/CL/*.h",
45-
]),
46-
strip_include_prefix = "opencl21",
47-
visibility = ["//visibility:public"],
48-
)
49-
50-
cc_library(
51-
name = "opencl22_headers",
52-
hdrs = glob([
53-
"opencl22/CL/*.h",
54-
]),
55-
strip_include_prefix = "opencl22",
10+
includes = ["."],
5611
visibility = ["//visibility:public"],
5712
)
5813

0 commit comments

Comments
 (0)