From f353e8c377c1c6e7e2c43d9c1450442d362248ae Mon Sep 17 00:00:00 2001 From: yejianwu Date: Fri, 8 Dec 2017 11:32:25 +0800 Subject: [PATCH] remove build with kernel binary --- mace/core/runtime/opencl/opencl_runtime.cc | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 47020d05..99e5872a 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -201,25 +201,21 @@ void OpenCLRuntime::BuildProgram(const std::string &program_file_name, sources.push_back({kernel_source.c_str(), kernel_source.length()}); *program = cl::Program(this->context(), sources); - } else { - LOG(ERROR) << "Failed to open kernel file " << binary_filename << " and " - << source_filename; - } - std::string build_options_str = build_options + - " -Werror -cl-mad-enable -cl-fast-relaxed-math -I" + kernel_path_; - // TODO(heliangliang) -cl-unsafe-math-optimizations -cl-fast-relaxed-math - cl_int ret = program->build({device()}, build_options_str.c_str()); - if (ret != CL_SUCCESS) { - if (program->getBuildInfo(device()) == - CL_BUILD_ERROR) { - std::string build_log = - program->getBuildInfo(device()); - LOG(INFO) << "Program build log: " << build_log; + + std::string build_options_str = build_options + + " -Werror -cl-mad-enable -cl-fast-relaxed-math -I" + kernel_path_; + // TODO(heliangliang) -cl-unsafe-math-optimizations -cl-fast-relaxed-math + cl_int ret = program->build({device()}, build_options_str.c_str()); + if (ret != CL_SUCCESS) { + if (program->getBuildInfo(device()) == + CL_BUILD_ERROR) { + std::string build_log = + program->getBuildInfo(device()); + LOG(INFO) << "Program build log: " << build_log; + } + LOG(FATAL) << "Build program failed: " << ret; } - LOG(FATAL) << "Build program failed: " << ret; - } - if (!std::ifstream(binary_filename).is_open()) { size_t deviceListSize = 1; size_t *programBinarySizes = new size_t[deviceListSize]; clGetProgramInfo((*program)(), @@ -240,6 +236,9 @@ void OpenCLRuntime::BuildProgram(const std::string &program_file_name, programBinarySizes[0]); WriteFile(binary_filename, content, true); + } else { + LOG(ERROR) << "Failed to open kernel file " << binary_filename << " and " + << source_filename; } } -- GitLab