diff --git a/mace/benchmark/benchmark_model.cc b/mace/benchmark/benchmark_model.cc index 746a6c8952ea3e64d25d01fc08b124e6334a2565..5be6d77778963531ecebc0b0cb6aad1963732846 100644 --- a/mace/benchmark/benchmark_model.cc +++ b/mace/benchmark/benchmark_model.cc @@ -261,6 +261,9 @@ int Main(int argc, char **argv) { mace::SetGPUHints( static_cast(FLAGS_gpu_perf_hint), static_cast(FLAGS_gpu_priority_hint)); + + std::vector 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 opencl_binary_paths = {FLAGS_opencl_binary_file}; - mace::SetOpenCLBinaryPaths(opencl_binary_paths); - } - // Create Engine std::shared_ptr engine; MaceStatus create_engine_status; diff --git a/mace/core/file_storage.cc b/mace/core/file_storage.cc index 20e98c5431ff02dc561714f0208e1c157d5235d9..4d93da5106d74f13e1668e71fd6ef4bae4c5fc73 100644 --- a/mace/core/file_storage.cc +++ b/mace/core/file_storage.cc @@ -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; diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 1a611bebf261672525a391b5df2603db93977cd8..0fad713155671c3df9506e6aea8cf395034dd06c 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -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(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"; } } } diff --git a/mace/tools/validation/mace_run.cc b/mace/tools/validation/mace_run.cc index bb2887ad12cf3cd6d396bc51305b022373b8cc58..2bf71bc384dd1fc856c9e5f57de92799934fa55b 100644 --- a/mace/tools/validation/mace_run.cc +++ b/mace/tools/validation/mace_run.cc @@ -202,6 +202,9 @@ bool RunModel(const std::string &model_name, mace::SetGPUHints( static_cast(FLAGS_gpu_perf_hint), static_cast(FLAGS_gpu_priority_hint)); + + std::vector 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 opencl_binary_paths = {FLAGS_opencl_binary_file}; - mace::SetOpenCLBinaryPaths(opencl_binary_paths); - } - std::vector model_pb_data; if (FLAGS_model_file != "") { if (!mace::ReadBinaryFile(&model_pb_data, FLAGS_model_file)) {