Skip to content

Commit e7e6b96

Browse files
Revert "[OpenCL] Set flush period of command queue (#5905)"
This reverts commit 34b96de.
1 parent 34b96de commit e7e6b96

File tree

4 files changed

+2
-57
lines changed

4 files changed

+2
-57
lines changed

docs/demo_guides/opencl.md

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ adb shell "export LD_LIBRARY_PATH=/data/local/tmp/opencl/; \
172172
# repeats=100, warmup=10
173173
# power_mode=0 绑定大核, thread_num=1
174174
# accelerate_opencl=1 开启 opencl kernel cache & tuning,仅当模型运行在 opencl 后端时该选项才会生效
175-
# print_output=0 不打印模型输出 tensors 详细数据
175+
# print_output=0 不打印模型输出 tensors 详细数
176176
```
177177

178178

@@ -225,34 +225,7 @@ adb shell "export GLOG_v=4; \
225225

226226
**NOTE:** 对OpenCL的支持还在持续开发中。
227227

228-
## 4. 性能分析和精度分析
229-
230-
Android 平台下分析:
231-
```
232-
# 开启性能分析,会打印出每个 op 耗时信息和汇总信息
233-
./lite/tools/build_android.sh --arch=armv7 --toolchain=clang --with_opencl=ON --with_extra=ON --with_profile=ON full_publish
234-
# 开启精度分析,会打印出每个 op 输出数据的均值和标准差信息
235-
./lite/tools/build_android.sh --arch=armv7 --toolchain=clang --with_opencl=ON --with_extra=ON --with_precision_profile=ON full_publish
236-
```
237-
238-
macOS x86 平台下分析:
239-
```
240-
# 开启性能分析,会打印出每个 op 耗时信息和汇总信息
241-
./lite/tools/build.sh --with_opencl=ON --with_extra=ON --with_profile=ON x86
242-
# 开启精度分析,会打印出每个 op 输出数据的均值和标准差信息
243-
./lite/tools/build.sh --with_opencl=ON --with_extra=ON --with_precision_profile=ON x86
244-
```
245-
246-
Windows x86 平台下分析:
247-
```
248-
# 开启性能分析,会打印出每个 op 耗时信息和汇总信息
249-
.\lite\tools\build_windows.bat with_opencl with_extra with_profile
250-
# 开启精度分析,会打印出每个 op 输出数据的均值和标准差信息
251-
.\lite\tools\build_windows.bat with_opencl with_extra with_precision_profile
252-
```
253-
详细输出信息的说明可查阅[调试工具](../user_guides/debug)。
254-
255-
## 5. 常见问题
228+
## 4. 常见问题
256229

257230
1. opencl计算过程中大多以`cl::Image2D`的数据排布进行计算,不同gpu支持的最大`cl::Image2D`的宽度和高度有限制,模型输入的数据格式是buffer形式的`NCHW`数据排布方式。要计算你的模型是否超出最大支持(大部分手机支持的`cl::Image2D`最大宽度和高度均为16384),可以通过公式`image_h = tensor_n * tensor_h, image_w=tensor_w * (tensor_c + 3) / 4`计算当前层NCHW排布的Tensor所需的`cl::Image2D`的宽度和高度;
258231
2. 部署时需考虑不支持opencl的情况,可预先使用API`bool ::IsOpenCLBackendValid()`判断,对于不支持的情况加载CPU模型,详见[./lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc](https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc);

lite/backends/opencl/cl_context.cc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,6 @@ cl::Kernel &CLContext::GetKernel(const std::string &name) {
7171
return GetKernel(it->second);
7272
}
7373

74-
cl_int CLContext::RunKernel(const cl::Kernel &kernel,
75-
const cl::NDRange &global,
76-
const cl::NDRange &local,
77-
cl::Event *event) {
78-
cl_int ret = GetCommandQueue().enqueueNDRangeKernel(
79-
kernel, cl::NullRange, global, local, nullptr, event);
80-
CL_CHECK_FATAL(ret);
81-
82-
static int cnt = 0;
83-
const int flush_period = 10;
84-
if (cnt % flush_period == 0) {
85-
ret = GetCommandQueue().flush();
86-
CL_CHECK_FATAL(ret);
87-
}
88-
cnt++;
89-
90-
return ret;
91-
}
92-
9374
cl::NDRange CLContext::DefaultGlobalWorkSize(const CLImage &image) {
9475
// n c h w
9576
auto image_dim = image.tensor_dims();

lite/backends/opencl/cl_context.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ class CLContext {
5656

5757
cl::Kernel &GetKernel(const std::string &name);
5858

59-
cl_int RunKernel(const cl::Kernel &kernel,
60-
const cl::NDRange &global,
61-
const cl::NDRange &local,
62-
cl::Event *event = nullptr);
63-
6459
cl::NDRange DefaultGlobalWorkSize(const CLImage &image);
6560

6661
cl::NDRange DefaultLocalWorkSize(

lite/kernels/opencl/conv_image_compute.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,17 +1346,13 @@ void ConvImageCompute::Run() {
13461346
(this->*impl_)();
13471347

13481348
auto& context = ctx_->As<OpenCLContext>();
1349-
status_ = context.cl_context()->RunKernel(
1350-
kernel_, global_work_size_, local_work_size_, &event_);
1351-
/*
13521349
status_ = EnqueueNDRangeKernel(context,
13531350
kernel_,
13541351
cl::NullRange,
13551352
global_work_size_,
13561353
local_work_size_,
13571354
nullptr,
13581355
event_);
1359-
*/
13601356
CL_CHECK_FATAL(status_);
13611357
}
13621358

0 commit comments

Comments
 (0)