diff --git a/lite/api/light_api.cc b/lite/api/light_api.cc index 01f8853cb9ad2de903e2d6ce675a189b4932f309..7a7f870a9ac38e4103f3f8a7c6b95a98bb6722db 100644 --- a/lite/api/light_api.cc +++ b/lite/api/light_api.cc @@ -141,9 +141,6 @@ void LightPredictor::BuildRuntimeProgram(const cpp::ProgramDesc& prog) { // 2. Create Instructs #ifdef LITE_WITH_OPENCL - using WaitListType = - std::unordered_map(nullptr)), - std::shared_ptr>; using OpenCLContext = Context; std::unique_ptr local_ctx(new KernelContext()); local_ctx->As().InitOnce(); diff --git a/lite/backends/opencl/cl_context.cc b/lite/backends/opencl/cl_context.cc index 0edb83acc4772b2f878b22f2ea16b3175b14a7ba..eff959d992200592c21a024f56713b9abb4b87fb 100644 --- a/lite/backends/opencl/cl_context.cc +++ b/lite/backends/opencl/cl_context.cc @@ -58,7 +58,7 @@ void CLContext::AddKernel(const std::string &kernel_name, auto program = GetProgram(file_name, options); VLOG(3) << " --- end get program --- "; VLOG(3) << " --- to create kernel: " << kernel_name << " --- "; - std::unique_ptr kernel( + std::shared_ptr kernel( new cl::Kernel(program, kernel_name.c_str(), &status)); CL_CHECK_FATAL(status); VLOG(3) << " --- end create kernel --- "; diff --git a/lite/backends/opencl/cl_context.h b/lite/backends/opencl/cl_context.h index 586dc3df1267e47c6cdaad1d362cd9ed2df2770e..5061ad20e595ff916ea060fd9aae257293dec7b6 100644 --- a/lite/backends/opencl/cl_context.h +++ b/lite/backends/opencl/cl_context.h @@ -36,6 +36,7 @@ class CLContext { kernel_offset_.clear(); for (auto &p : programs_) { clReleaseProgram(p.second->get()); + p.second.reset(); } programs_.clear(); LOG(INFO) << "release cl::Program, cl::Kernel finished."; @@ -66,9 +67,10 @@ class CLContext { int divitor = 2); // cl::NDRange LocalWorkSizeConv1x1(cl::NDRange global_work_size, // size_t max_work_size); + private: std::unordered_map> programs_; - std::vector> kernels_; + std::vector> kernels_; std::map kernel_offset_; }; diff --git a/lite/backends/opencl/cl_runtime.cc b/lite/backends/opencl/cl_runtime.cc index 8a6b026367986548b017aee263a70d4df33381b5..d5b2d70b09a84cb405c0e7c8f2b55f4254eb7f64 100644 --- a/lite/backends/opencl/cl_runtime.cc +++ b/lite/backends/opencl/cl_runtime.cc @@ -29,12 +29,12 @@ CLRuntime::~CLRuntime() { command_queue_->flush(); command_queue_->finish(); } - // For controlling the destruction order: + // For controlling the destruction order command_queue_.reset(); context_.reset(); device_.reset(); platform_.reset(); - LOG(INFO) << "release ~CLRuntime() "; + device_info_.clear(); } bool CLRuntime::Init() { diff --git a/lite/kernels/opencl/io_copy_buffer_compute.cc b/lite/kernels/opencl/io_copy_buffer_compute.cc index f76f667923fa8d39847db5dae8e07d7398f25f99..eaabf7f37bf1434e8a451fc797e72d706e68ce5b 100644 --- a/lite/kernels/opencl/io_copy_buffer_compute.cc +++ b/lite/kernels/opencl/io_copy_buffer_compute.cc @@ -115,7 +115,6 @@ class IoCopykOpenCLToHostCompute auto& event = *(it->second); event.wait(); auto command_queue = CLRuntime::Global()->command_queue(); - command_queue.flush(); command_queue.finish(); } else { LOG(FATAL) << "Could not find the sync event for the target cl tensor.";