提交 a59c5c10 编写于 作者: 开心的小妮's avatar 开心的小妮

Add cl context. test=develop

上级 6262bc32
......@@ -45,7 +45,6 @@ cl::Program &CLContext::GetProgram(const std::string &file_name,
}
auto program = CLRuntime::Global()->CreateProgram(GetContext(), file_name);
VLOG(3) << " --- begin build program -> " << program_key << " --- ";
CLRuntime::Global()->BuildProgram(program.get(), options);
VLOG(3) << " --- end build program -> " << program_key << " --- ";
......@@ -77,6 +76,23 @@ void CLContext::AddKernel(const std::string &kernel_name,
kernel_offset_map[kernel_key.str()] = kernels.size() - 1;
}
std::shared_ptr<cl::Kernel> CLContext::CreateKernel(
const std::string &kernel_name,
const std::string &file_name,
const std::string &options,
const std::string &time_stamp) {
cl_int status{CL_SUCCESS};
VLOG(3) << " --- to get program " << file_name << " --- ";
auto program = GetProgram(file_name, options);
VLOG(3) << " --- end get program --- ";
VLOG(3) << " --- to create kernel: " << kernel_name << " --- ";
std::shared_ptr<cl::Kernel> kernel(
new cl::Kernel(program, kernel_name.c_str(), &status));
CL_CHECK_FATAL(status);
VLOG(3) << " --- end create kernel --- ";
return kernel;
}
cl::Kernel &CLContext::GetKernel(const int index) {
auto &kernels = CLRuntime::Global()->kernels();
VLOG(3) << " --- kernel count: " << kernels.size() << " --- ";
......
......@@ -39,6 +39,11 @@ class CLContext {
const std::string &options = "",
const std::string &time_stamp = "");
std::shared_ptr<cl::Kernel> CreateKernel(const std::string &kernel_name,
const std::string &file_name,
const std::string &options = "",
const std::string &time_stamp = "");
cl::Kernel &GetKernel(const int index);
cl::Kernel &GetKernel(const std::string &name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册