<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://www.khronos.org/bugzilla/bugzilla.dtd">

<bugzilla version="4.2.4"
          urlbase="http://www.khronos.org/bugzilla/"
          
          maintainer="webmaster@khronos.org"
>

    <bug>
          <bug_id>200</bug_id>
          
          <creation_ts>2009-08-24 03:46:00 -0700</creation_ts>
          <short_desc>Feedback on OpenCL C++ bindings</short_desc>
          <delta_ts>2009-09-10 12:04:13 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>OpenCL</product>
          <component>Man Pages, Reference Card &amp; Other Documentation</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>thomas7755</reporter>
          <assigned_to name="Benedict Gaster">bgaster</assigned_to>
          <cc>devrel</cc>
    
    <cc>stapostol</cc>
          <qa_contact name="OpenCL Working Group">opencl</qa_contact>

      

      

      

          <long_desc isprivate="0">
            <commentid>646</commentid>
            <who name="">thomas7755</who>
            <bug_when>2009-08-24 03:46:19 -0700</bug_when>
            <thetext>When handling multiple devices it would be handy to be able to maintain a vector of kernel functors, where each functor is associated with a command queue:

std::vector&lt;cl::KernelFunctor&gt; kernelFunctors;
for (int d = 0 ; d &lt; commandQueues.size() ; d++)
{
    kernelFunctors.push_back(kernel.bind(commandQueues[d], globalNDRange, localNDRange));
}

Any ideas for how to implement something like this, given that this won&apos;t work without being able to copy KernelFunctors?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>647</commentid>
            <who name="Jon Leech">devrel</who>
            <bug_when>2009-08-24 05:07:18 -0700</bug_when>
            <thetext>Reassign to Benedict.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>649</commentid>
            <who name="Benedict Gaster">bgaster</who>
            <bug_when>2009-08-24 23:15:43 -0700</bug_when>
            <thetext>I have updated the C++ bindings to provide copy constructor for KernelFunctor and the following program now compiles without error:

#include &lt;CL/cl.hpp&gt;


int main(void)
{
    std::vector&lt;cl::CommandQueue&gt; commandQueues;
    cl::Kernel kernel;

    cl::NDRange globalNDRange;
    cl::NDRange localNDRange;

    std::vector&lt;cl::KernelFunctor&gt; kernelFunctors;
    for (int d = 0 ; d &lt; commandQueues.size() ; d++) {
        kernelFunctors.push_back(
            kernel.bind(
                commandQueues[d], 
                globalNDRange,
                localNDRange));
    }
}

Please let me know if you have any problems using it and thanks for feedback.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>650</commentid>
            <who name="">thomas7755</who>
            <bug_when>2009-08-28 10:50:56 -0700</bug_when>
            <thetext>This doesn&apos;t work as hoped unfortunately. The KernelFunctor has a reference to a Kernel and a CommandQueue, and so strange things start happening when you try reseat the reference in the assignment operator.

I can get the original code to execute by changing the copy constructor to:

inline KernelFunctor::KernelFunctor(const KernelFunctor&amp; rhs) :
    kernel_(rhs.kernel_),
    queue_(rhs.queue_),
    offset_(rhs.offset_),
    global_(rhs.global_),
    local_(rhs.local_),
    err_(rhs.err_)
{
    //*this = rhs;
}

(i.e. complete the initializer list and remove the call to the assignment operator)

In this case the assignment operator is never called, but it must still be present as stl::vectors mandate it. Perhaps the assignment operator should fail if rhs != lhs. KernelFunctor could maintain a pointer instead of a reference, but that&apos;s possibly not as elegant.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>651</commentid>
            <who name="Benedict Gaster">bgaster</who>
            <bug_when>2009-08-28 10:58:57 -0700</bug_when>
            <thetext>Indeed. Let me think about this some more and I will get back with a solution. Might be best to simply remove the reference. I do not what to have pointers.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>658</commentid>
            <who name="">thomas7755</who>
            <bug_when>2009-09-10 11:59:32 -0700</bug_when>
            <thetext>(In reply to comment #4)
&gt; Indeed. Let me think about this some more and I will get back with a solution.
&gt; Might be best to simply remove the reference. I do not what to have pointers.

Have you had any thoughts on this? I agree it would be preferable to avoid pointers. My suggestion would be to provide the corrected copy constructor and make the assignment illegal.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>659</commentid>
            <who name="Benedict Gaster">bgaster</who>
            <bug_when>2009-09-10 12:04:13 -0700</bug_when>
            <thetext>I&apos;m working on  fix for this, not using ponters, and will update the C++ bindings with some other fixes in the next few days.</thetext>
          </long_desc>
      
      

    </bug>

</bugzilla>