Ahmad Siavosh
Ahmad Siavosh

Reputation: 676

OpenCL - Releasing platform object

I was studying OpenCL releasing functions ( clRelease(objectName) ) and it was interesting for me that there was no function to release Platform (more specifically, cl_platform_id) objects. Does anybody know the reason ?

Upvotes: 1

Views: 664

Answers (1)

CaptainObvious
CaptainObvious

Reputation: 2565

It's because you create platform objects with a regular malloc and not a clCreateObjectName() function. So you release them with a regular free. I guess it's like that because platforms are host resources.
Note that it is the same for device objects.

EDIT: To clarify a bit, thanks to @chippies' comment: The clGetPlatformIDs() function has two uses. first to query the number of platforms available in the system. Second, to fill the memory space you allocated for the platforms with the actual platform(s) you decided to use. You store these platforms in a memory space that you first malloc. Therefore when you are done with these platforms you release them with a free the memory that you malloc-ed.

Upvotes: 1

Related Questions