CLCREATEPROGRAMWITHS(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– CLCREATEPROGRAMWITHS πŸ’–

okay bestie, welcome to the OpenCL manual page for clCreateProgramWithSource, from the OpenCL Manual (that's the 3clc section, iykyk). this one's literally the glow-up moment where your source code becomes a whole program object. let's get into it 🫢

✨ NAME ✨

clCreateProgramWithSource β€” creates a program object for a context, and loads the source code specified by the text strings in the strings array into the program object. that's it, that's the job, and she does it flawlessly πŸ’…

🌸 SYNOPSIS 🌸

cl_program clCreateProgramWithSource(cl_context context, cl_uint count,
                                     const char **strings,
                                     const size_t *lengths,
                                     cl_int *errcode_ret);

look at that signature. no cap, she's iconic.


πŸŽ€ PARAMETERS πŸŽ€

  • context β€” must be a valid OpenCL context. that's the vibe check, no fake contexts allowed πŸ™ˆ
  • strings β€” an array of count pointers to optionally null-terminated character strings that make up the source code. yes, optionally β€” she's flexible like that ✨
  • lengths β€” an array with the number of chars in each string (the string length). the deets:
    • if an element in lengths is zero, its accompanying string is null-terminated.
    • if lengths is NULL, all strings in the strings argument are considered null-terminated.
    • any length value passed in that is greater than zero excludes the null terminator in its count β€” so don't be out here counting the \0, bestie, she said no πŸ’€
  • errcode_ret β€” returns an appropriate error code. if errcode_ret is NULL, no error code is returned. she's quiet, she's mysterious, she's not gonna tell you what went wrong 🧚

πŸ’œ DESCRIPTION πŸ’œ

so. this function creates a program object for a context, and loads the source code specified by the text strings in the strings array into the program object. the devices associated with the program object are the devices associated with context β€” they match, they're a set, they're giving main character energy together πŸ‘‘

and the source code specified by strings? it's either an OpenCL C program source, a header, or implementation-defined source for custom devices that support an online compiler. so many options and she supports all of them. obsessed. 🌈


πŸ”₯ ERRORS πŸ”₯

clCreateProgramWithSource returns a valid non-zero program object and errcode_ret is set to CL_SUCCESS if the program object is created successfully. slay βœ…

otherwise? she returns a NULL value with one of the following error values returned in errcode_ret β€” so pay attention, bestie:

  • CL_INVALID_CONTEXT β€” if context is not a valid context. fake context detected, blocked 🚫
  • CL_INVALID_VALUE β€” if count is zero or if strings or any entry in strings is NULL. zero strings? empty? we don't know her πŸ’€
  • CL_OUT_OF_RESOURCES β€” if there is a failure to allocate resources required by the OpenCL implementation on the device. the device is going through it 😭
  • CL_OUT_OF_HOST_MEMORY β€” if there is a failure to allocate resources required by the OpenCL implementation on the host. the host is also going through it 😭

🌟 SPECIFICATION 🌟

OpenCL Specification[1] β€” go read it, it's right there, she's sourced, she's cited, she's academically valid πŸŽ“


πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, fr fr:


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group β€” the icons who wrote this πŸ’–


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.

like, legal said what she said and she ate πŸ’…


πŸ“ NOTES πŸ“

  1. OpenCL Specification β€” page 132, section 5.6.1 - Creating Program Objects. page number and all, we keep receipts 🧾✨

and that's the whole page, bestie!! πŸŽ€ source: The Khronos Group, dated 01/14/2021, from the OpenCL Manual β€” mwah, love you, go create some program objects, periodt πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from