CLCREATEKERNEL(3clc)
β¨ CLCREATEKERNEL β¨
okay so bestie, we're in the OpenCL manual (yes, 3clc, the whole OpenCL girlie collection) and today's episode is all about clCreateKernel β the function that β¨makes a kernel objectβ¨. it's giving birth but for GPU functions. let's GO π
πΈ NAME πΈ
clCreateKernel β creates a kernel object. that's it, that's the whole job. iconic behavior honestly π
π¦ SYNOPSIS π¦
cl_kernel clCreateKernel(cl_program program, const char *kernel_name,
cl_int *errcode_ret);
π PARAMETERS π
programβ a program object that has a successfully built executable. no half-baked programs allowed, she has to be ready. if it's not built, that's a whole different error, see below.kernel_nameβ a function name in the program that was declared with the__kernelqualifier. so like, the function has to actually be marked as a kernel, mkay?errcode_retβ this one returns an appropriate error code back to you. and iferrcode_retisNULL, then no error code is returned at all. so if you passNULL, don't come crying about not knowing what went wrong π
π NOTES π
so like, a kernel is a function declared in a program. a kernel gets identified by the functionQualifiers(3clc) qualifier being applied to any function in a program. that's the little mark that says "yes queen, you're a kernel."
and a kernel object? it encapsulates the specific __kernel function declared in a program plus the argument values that'll be used when you actually execute that __kernel function. it's the function and its lil set of args, all bundled up together like a little care package π
π₯ ERRORS π₯
clCreateKernel returns a valid non-zero kernel object and sets errcode_ret to CL_SUCCESS when the kernel object is created successfully. slay!
otherwise β and hear me out β it returns a NULL value, and one of these error values comes back in errcode_ret:
CL_INVALID_PROGRAMβ ifprogramis not a valid program object. like, that's not a program bestie, idk what that is.CL_INVALID_PROGRAM_EXECUTABLEβ if there is no successfully built executable forprogram. she's not built yet, she's still in her development era.CL_INVALID_KERNEL_NAMEβ ifkernel_nameis not found inprogram. wrong name, wrong program, no kernel for you πCL_INVALID_KERNEL_DEFINITIONβ if the function definition for the__kernelfunction given bykernel_nameβ like the number of arguments, the argument types β is not the same for all devices for which the program executable has been built. so if your devices can't agree on what this kernel even looks like, that's a no. it's giving miscommunication πCL_INVALID_VALUEβ ifkernel_nameisNULL. you have to give her a name, bestie.CL_OUT_OF_RESOURCESβ if there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYβ if there is a failure to allocate resources required by the OpenCL implementation on the host.
note the difference between those last two!! one is the device being out of resources, the other is the host running out of memory. they are NOT the same vibe check, keep them straight π«Ά
β SPECIFICATION β
OpenCL Specification[1]
π SEE ALSO π
clCreateKernelsInProgram(3clc), clRetainKernel(3clc), clReleaseKernel(3clc), clSetKernelArg(3clc), clGetKernelInfo(3clc), clGetKernelWorkGroupInfo(3clc), classDiagram(3clc)
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
- OpenCL Specification page 157, section 5.7.1 - Creating Kernel Objects
okay that's the whole page, no cap π§ and fr fr, if you made it this far you're a real one. this whole thing came from The Khronos Group, dated 01/14/2021, living under the CLCREATEKERNEL(3clc) name in the OpenCL Manual. go build a kernel bestie, you got this πβ¨π¦
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms