From 0d62d7830b5be4b9501d9541198fe45b57e3d52a Mon Sep 17 00:00:00 2001 From: liuruilong Date: Tue, 16 Oct 2018 14:15:44 +0800 Subject: [PATCH] add log info --- src/framework/cl/cl_engine.h | 2 ++ src/framework/cl/cl_scope.h | 13 +++++++++++++ src/io/api_paddle_mobile.cc | 2 ++ src/io/paddle_inference_api.h | 2 +- src/operators/kernel/cl/cl_kernel/reshape.cl | 4 ++-- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/framework/cl/cl_engine.h b/src/framework/cl/cl_engine.h index 15af651136..d8a4c771a5 100644 --- a/src/framework/cl/cl_engine.h +++ b/src/framework/cl/cl_engine.h @@ -88,6 +88,8 @@ class CLEngine { return true; } + cl_device_id DeviceID(int index = 0) { return devices_[index]; } + private: CLEngine() { initialized_ = false; } diff --git a/src/framework/cl/cl_scope.h b/src/framework/cl/cl_scope.h index 93a74a3645..58357632be 100644 --- a/src/framework/cl/cl_scope.h +++ b/src/framework/cl/cl_scope.h @@ -58,11 +58,24 @@ class CLScope { auto program = CLEngine::Instance()->CreateProgramWith( context_.get(), "./cl_kernel/" + file_name); + DLOG << " --- begin build program -> " << file_name << " --- "; status_ = clBuildProgram(program.get(), 0, 0, "-cl-fast-relaxed-math", 0, 0); CL_CHECK_ERRORS(status_); + if (status_ == CL_BUILD_PROGRAM_FAILURE) { + size_t log_size; + clGetProgramBuildInfo(program.get(), CLEngine::Instance()->DeviceID(), + CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); + char *log = (char *)malloc(log_size); + clGetProgramBuildInfo(program.get(), CLEngine::Instance()->DeviceID(), + CL_PROGRAM_BUILD_LOG, log_size, log, NULL); + DLOG << " program build error: " << log; + } + + DLOG << " --- end build program -> " << file_name << " --- "; + programs_[file_name] = std::move(program); return programs_[file_name].get(); diff --git a/src/io/api_paddle_mobile.cc b/src/io/api_paddle_mobile.cc index 4609438ec9..5dce367b52 100644 --- a/src/io/api_paddle_mobile.cc +++ b/src/io/api_paddle_mobile.cc @@ -114,6 +114,8 @@ CreatePaddlePredictor( x.reset(new PaddleMobilePredictor(config)); } else if (config.device == PaddleMobileConfig::kGPU_MALI) { x.reset(new PaddleMobilePredictor(config)); + } else if (config.device == PaddleMobileConfig::kGPU_CL) { + x.reset(new PaddleMobilePredictor(config)); } else { LOG(kLOG_ERROR) << "unsupport device type!"; return nullptr; diff --git a/src/io/paddle_inference_api.h b/src/io/paddle_inference_api.h index 97564f4132..6c3ce7ef77 100644 --- a/src/io/paddle_inference_api.h +++ b/src/io/paddle_inference_api.h @@ -111,7 +111,7 @@ class PaddlePredictor { struct PaddleMobileConfig : public PaddlePredictor::Config { enum Precision { FP32 = 0 }; - enum Device { kCPU = 0, kFPGA = 1, kGPU_MALI = 2 }; + enum Device { kCPU = 0, kFPGA = 1, kGPU_MALI = 2, kGPU_CL = 3 }; enum Precision precision; enum Device device; diff --git a/src/operators/kernel/cl/cl_kernel/reshape.cl b/src/operators/kernel/cl/cl_kernel/reshape.cl index 4055445d15..767a7105d2 100644 --- a/src/operators/kernel/cl/cl_kernel/reshape.cl +++ b/src/operators/kernel/cl/cl_kernel/reshape.cl @@ -43,7 +43,7 @@ __kernel void reshape(__read_only image2d_t input, int i0 = oindex; int ix = (i1 / 4) * d3 + i3; int iy = i0 * d2 + i2; - r[i] = read_imageh(input, sampler, int2(ix, iy))[i1%4]; + r[i] = read_imageh(input, sampler, (int2)(ix, iy))[i1%4]; } - write_imageh(output, int2(x, y), r); + write_imageh(output, (int2)(x, y), r); } \ No newline at end of file -- GitLab