提交 25ce72b7 编写于 作者: R Ray Liu 提交者: GitHub

Merge pull request #1095 from codeWorm2015/opencl

 add log info
...@@ -88,6 +88,8 @@ class CLEngine { ...@@ -88,6 +88,8 @@ class CLEngine {
return true; return true;
} }
cl_device_id DeviceID(int index = 0) { return devices_[index]; }
private: private:
CLEngine() { initialized_ = false; } CLEngine() { initialized_ = false; }
......
...@@ -58,11 +58,24 @@ class CLScope { ...@@ -58,11 +58,24 @@ class CLScope {
auto program = CLEngine::Instance()->CreateProgramWith( auto program = CLEngine::Instance()->CreateProgramWith(
context_.get(), "./cl_kernel/" + file_name); context_.get(), "./cl_kernel/" + file_name);
DLOG << " --- begin build program -> " << file_name << " --- ";
status_ = status_ =
clBuildProgram(program.get(), 0, 0, "-cl-fast-relaxed-math", 0, 0); clBuildProgram(program.get(), 0, 0, "-cl-fast-relaxed-math", 0, 0);
CL_CHECK_ERRORS(status_); 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); programs_[file_name] = std::move(program);
return programs_[file_name].get(); return programs_[file_name].get();
......
...@@ -114,6 +114,8 @@ CreatePaddlePredictor<PaddleMobileConfig, PaddleEngineKind::kPaddleMobile>( ...@@ -114,6 +114,8 @@ CreatePaddlePredictor<PaddleMobileConfig, PaddleEngineKind::kPaddleMobile>(
x.reset(new PaddleMobilePredictor<FPGA, Precision::FP32>(config)); x.reset(new PaddleMobilePredictor<FPGA, Precision::FP32>(config));
} else if (config.device == PaddleMobileConfig::kGPU_MALI) { } else if (config.device == PaddleMobileConfig::kGPU_MALI) {
x.reset(new PaddleMobilePredictor<GPU_MALI, Precision::FP32>(config)); x.reset(new PaddleMobilePredictor<GPU_MALI, Precision::FP32>(config));
} else if (config.device == PaddleMobileConfig::kGPU_CL) {
x.reset(new PaddleMobilePredictor<GPU_CL, Precision::FP32>(config));
} else { } else {
LOG(kLOG_ERROR) << "unsupport device type!"; LOG(kLOG_ERROR) << "unsupport device type!";
return nullptr; return nullptr;
......
...@@ -111,7 +111,7 @@ class PaddlePredictor { ...@@ -111,7 +111,7 @@ class PaddlePredictor {
struct PaddleMobileConfig : public PaddlePredictor::Config { struct PaddleMobileConfig : public PaddlePredictor::Config {
enum Precision { FP32 = 0 }; 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 Precision precision;
enum Device device; enum Device device;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册