MCPcopy Create free account
hub / github.com/CMU-Perceptual-Computing-Lab/openpose / buildKernelIntoManager

Method buildKernelIntoManager

src/openpose/gpu/opencl.cpp:298–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296
297 template <typename T>
298 bool OpenCL::buildKernelIntoManager(const std::string& kernelName, const std::string& src, bool isFile)
299 {
300 #ifdef USE_OPENCL
301 // Set type
302 std::string type = getType<T>();
303 std::string key = kernelName + "_" + type;
304
305 // Program not built
306 if (!(upImpl->mClPrograms.find(key) != upImpl->mClPrograms.end()))
307 {
308 cl::Program program;
309 buildProgramFromSource<T>(program, upImpl->mContext, src, isFile);
310 upImpl->mClPrograms[key] = program;
311 }
312
313 cl::Program& program = upImpl->mClPrograms[key];
314
315 // Kernel not built
316 if (!(upImpl->mClKernels.find(key) != upImpl->mClKernels.end()))
317 {
318 upImpl->mClKernels[key] = cl::Kernel(program, kernelName.c_str());
319 opLog("Kernel: " + kernelName + " Type: " + type + + " GPU: " + std::to_string(upImpl->mId) +
320 " built successfully");
321 return true;
322 }
323 else
324 {
325 opLog("Kernel " + kernelName + " already built");
326 return false;
327 }
328 #else
329 UNUSED(kernelName);
330 UNUSED(src);
331 UNUSED(isFile);
332 error("OpenPose must be compiled with the `USE_OPENCL` macro definition in order to use this"
333 " functionality.", __LINE__, __FUNCTION__, __FILE__);
334 return false;
335 #endif
336 }
337
338 template <typename T>
339 cl::Kernel& OpenCL::getKernelFromManager(const std::string& kernelName, const std::string& src, bool isFile)

Callers

nothing calls this directly

Calls 3

KernelClass · 0.85
opLogFunction · 0.50
errorFunction · 0.50

Tested by

no test coverage detected