Results 1 to 2 of 2

Thread: Releasing Memory, Kernels, Devices etc

  1. #1
    Junior Member
    Join Date
    Feb 2013

    Releasing Memory, Kernels, Devices etc

    I thought I read somewhere, (though, for the life of me, I can't find the source), that, using the C++ API you don't have to release devices/kernels/memory like w/ the C API as the destructors for cl::Kernel, cl::Buffer, cl:evice do this when the class objects go out of scope, (end of program, etc). However, upon closer examination of cl.hpp (the latest one, 1.1 rev 04), I don't see any destructors defined at all. For example, here is cl:evice -

    Code :
    /*! \class Device
     * \brief Device interface for cl_device_id.
    class Device : public detail::Wrapper<cl_device_id>
        Device(cl_device_id device) { object_ = device; }
        Device() : detail::Wrapper<cl_type>() { }
        Device(const Device& device) : detail::Wrapper<cl_type>(device) { }
        Device& operator = (const Device& rhs)
            if (this != &rhs) {
            return *this;
        template <typename T>
        cl_int getInfo(cl_device_info name, T* param) const
            return detail::errHandler(
                detail::getInfo(&::clGetDeviceInfo, object_, name, param),
        template <cl_int name> typename
        detail::param_traits<detail::cl_device_info, name>::param_type
        getInfo(cl_int* err = NULL) const
            typename detail::param_traits<
                detail::cl_device_info, name>::param_type param;
            cl_int result = getInfo(name, &param);
            if (err != NULL) {
                *err = result;
            return param;
    #if defined(USE_CL_DEVICE_FISSION)
        cl_int createSubDevices(
            const cl_device_partition_property_ext * properties,
            VECTOR_CLASS<Device>* devices)
            typedef CL_API_ENTRY cl_int 
                ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
                    cl_device_id /*in_device*/,
                    const cl_device_partition_property_ext * /* properties */,
                    cl_uint /*num_entries*/,
                    cl_device_id * /*out_devices*/,
                    cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
            static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
            cl_uint n = 0;
            cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
            if (err != CL_SUCCESS) {
                return detail::errHandler(err, __CREATE_SUB_DEVICES);
            cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
            err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL);
            if (err != CL_SUCCESS) {
                return detail::errHandler(err, __CREATE_SUB_DEVICES);
            devices->assign(&ids[0], &ids[n]);
            return CL_SUCCESS;

    Does anyone know anything about this? Should I care about this? In the C++ wrapper documentation they do not even mention anything resembling releaseClMemObject or free(cl_devices), etc.


  2. #2

    The Device class derives from detail::Wrapper, which has a destructor that calls the appropriate release function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean