OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomese-simd commits / 921ecca

Check for kernel availability
921ecca1670811da3edae55b2091573db21a33e1
by Linas Vepštas <linasvepstas@gmail.com> · 2025-09-12T03:24:03.000Z

Changed files (1) +15 -17

opencog/atoms/opencl/OpenclJobValue.cc +15 -17
……@@ -215,28 +215,26 @@ void OpenclJobValue::build(const Handle& oclno)
215215
216216 std::string kname = get_kern_name();
217217
218 // Get our program from the OpenclNode.
219 const cl::Program& proggy = OpenclNodeCast(oclno)->get_program();
220
221 // If the user mistyped the kernel name, the `cl:Kernel` will
222 // throw an exception that is not meaningful to most users.
223 // Rewrite it to Atomese standard.
224 try
225 {
226 _kernel = cl::Kernel(proggy, kname.c_str());
227 }
228 catch (const std::exception& ex)
229 {
218 // See if its a kernel that we know.
219 // XXX FIXME this will fail for SPV files, because we don't
220 // (yet) generate signatures for them.
221 OpenclNodePtr ocn = OpenclNodeCast(oclno);
222 AtomSpace* as = ocn->getAtomSpace();
223 Handle kit = as->add_node(ITEM_NODE, std::string(kname));
224 const HandleMap& ifmap = ocn->_kernel_interfaces;
225 if (ifmap.find(kit) == ifmap.end())
230226 throw RuntimeException(TRACE_INFO,
231 "Unknown kernel name \"%s\" given to %s\n", kname.c_str(), ex.what());
232 }
227 "This OpenclNode does not know about the kernel \"%s\"\n",
228 kname.c_str());
229
230 // Get our kernel from the program from the OpenclNode.
231 const cl::Program& proggy = ocn->get_program();
232 _kernel = cl::Kernel(proggy, kname.c_str());
233233
234234 // Build the OpenclJobValue itself.
235235 ValueSeq flovecs = make_vectors (oclno);
236236 ValuePtr args = createLinkValue(flovecs);
237 AtomSpace* as = oclno->getAtomSpace();
238 Handle kh = as->add_node(ITEM_NODE, std::move(kname));
239 _value = ValueSeq{kh, args};
237 _value = ValueSeq{kit, args};
240238
241239 // Bind the kernel to the kernel arguments
242240 size_t pos = 0;