提交 4512ed21 编写于 作者: L liuqi

Use singleton pattern to load OpenCL library.

上级 7a9ee4ca
......@@ -308,8 +308,6 @@ OpenCLRuntime::OpenCLRuntime():
precompiled_binary_storage_(nullptr),
cache_storage_(nullptr),
is_profiling_enabled_(false) {
LoadOpenCLLibrary();
std::vector<cl::Platform> all_platforms;
cl::Platform::get(&all_platforms);
if (all_platforms.size() == 0) {
......@@ -456,7 +454,6 @@ OpenCLRuntime::~OpenCLRuntime() {
command_queue_.reset();
context_.reset();
device_.reset();
UnloadOpenCLLibrary();
}
cl::Context &OpenCLRuntime::context() { return *context_; }
......
......@@ -24,7 +24,6 @@
#include "mace/core/future.h"
#include "mace/core/runtime/opencl/cl2_header.h"
#include "mace/core/runtime/opencl/opencl_wrapper.h"
#include "mace/public/mace_runtime.h"
#include "mace/utils/string_util.h"
#include "mace/utils/timer.h"
......
// Copyright 2018 Xiaomi, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MACE_CORE_RUNTIME_OPENCL_OPENCL_WRAPPER_H_
#define MACE_CORE_RUNTIME_OPENCL_OPENCL_WRAPPER_H_
namespace mace {
// These functions are not thread-safe.
void LoadOpenCLLibrary();
void UnloadOpenCLLibrary();
} // namespace mace
#endif // MACE_CORE_RUNTIME_OPENCL_OPENCL_WRAPPER_H_
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册