提交 c0c0dfe5 编写于 作者: L Liangliang He

Merge branch 'fix-host-bug' into 'master'

Fix host runtime bug for calling SetOpenCLBinaryPaths.

See merge request !557
......@@ -261,6 +261,9 @@ int Main(int argc, char **argv) {
mace::SetGPUHints(
static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint),
static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint));
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
#endif // MACE_ENABLE_OPENCL
......@@ -273,11 +276,6 @@ int Main(int argc, char **argv) {
new FileStorageFactory(kernel_file_path));
SetKVStorageFactory(storage_factory);
if (device_type == DeviceType::GPU) {
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
// Create Engine
std::shared_ptr<mace::MaceEngine> engine;
MaceStatus create_engine_status;
......
......@@ -68,7 +68,7 @@ int FileStorage::Load() {
return 0;
} else {
LOG(WARNING) << "Stat file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
return -1;
}
}
......@@ -81,7 +81,7 @@ int FileStorage::Load() {
return 0;
} else {
LOG(WARNING) << "open file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
return -1;
}
}
......@@ -92,12 +92,12 @@ int FileStorage::Load() {
int res = 0;
if (file_data == MAP_FAILED) {
LOG(WARNING) << "mmap file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
res = close(fd);
if (res != 0) {
LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
}
return -1;
}
......@@ -130,18 +130,18 @@ int FileStorage::Load() {
res = munmap(file_data, file_size);
if (res != 0) {
LOG(WARNING) << "munmap file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
res = close(fd);
if (res != 0) {
LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
}
return -1;
}
res = close(fd);
if (res != 0) {
LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
return -1;
}
return 0;
......@@ -169,7 +169,7 @@ int FileStorage::Flush() {
int fd = open(file_path_.c_str(), O_WRONLY | O_CREAT, 0600);
if (fd < 0) {
LOG(WARNING) << "open file " << file_path_
<< " failed, error code:" << errno;
<< " failed, error code: " << strerror(errno);
return -1;
}
......@@ -208,11 +208,11 @@ int FileStorage::Flush() {
res = write(fd, buffer_ptr, buffer_size);
if (res == -1) {
LOG(WARNING) << "write file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
res = close(fd);
if (res != 0) {
LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
}
return -1;
}
......@@ -223,7 +223,7 @@ int FileStorage::Flush() {
res = close(fd);
if (res != 0) {
LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno;
<< " failed, error code: " << strerror(errno);
return -1;
}
data_changed_ = false;
......
......@@ -409,7 +409,9 @@ OpenCLRuntime::OpenCLRuntime():
kStorageFactory->CreateStorage(kPrecompiledProgramFileName);
if (cache_storage_->Load() != 0) {
LOG(FATAL) << "Load OpenCL cached compiled kernel file failed";
LOG(WARNING) << "Load OpenCL cached compiled kernel file failed. "
<< "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
}
auto platform_info_array =
this->cache_storage_->Find(kOpenCLPlatformInfoKey);
......@@ -428,7 +430,9 @@ OpenCLRuntime::OpenCLRuntime():
precompiled_binary_storage_.reset(
new FileStorage(OpenCLRuntime::kPrecompiledBinaryPath));
if (precompiled_binary_storage_->Load() != 0) {
LOG(FATAL) << "Load OpenCL precompiled kernel file failed";
LOG(WARNING) << "Load OpenCL precompiled kernel file failed. "
<< "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
}
auto platform_info_array =
......@@ -657,8 +661,9 @@ void OpenCLRuntime::SaveBuiltCLProgram() {
std::vector<unsigned char>(platform_info_.begin(),
platform_info_.end()));
if (cache_storage_->Flush() != 0) {
LOG(FATAL) << "Store OPENCL compiled kernel to file failed."
" Please Make sure the storage directory exist.";
LOG(FATAL) << "Store OPENCL compiled kernel to file failed. "
<< "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
}
}
}
......
......@@ -202,6 +202,9 @@ bool RunModel(const std::string &model_name,
mace::SetGPUHints(
static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint),
static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint));
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
#endif // MACE_ENABLE_OPENCL
......@@ -214,11 +217,6 @@ bool RunModel(const std::string &model_name,
new FileStorageFactory(kernel_file_path));
SetKVStorageFactory(storage_factory);
if (device_type == DeviceType::GPU) {
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
std::vector<unsigned char> model_pb_data;
if (FLAGS_model_file != "") {
if (!mace::ReadBinaryFile(&model_pb_data, FLAGS_model_file)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册