示例#1
0
 QCLKernelPrivate(const QCLKernelPrivate *other)
     : context(other->context)
     , id(other->id)
     , globalWorkSize(other->globalWorkSize)
     , localWorkSize(other->localWorkSize)
 {
     if (id)
         clRetainKernel(id);
 }
示例#2
0
/*!
    Requests that this kernel instance be run on globalWorkSize() items,
    optionally subdivided into work groups of localWorkSize() items.
    The kernel will be enqueued and executed in a background thread.

    Returns a QFuture object that can be used to wait for the kernel
    to finish execution.  The request is executed on the active
    command queue for context().

    Usually runInThread() is called implicitly via QtConcurrent::run():

    \code
    kernel.setGlobalWorkSize(100, 100);
    QFuture<void> future = QtConcurrent::run(kernel, a1, b1);
    future.waitForFinished();
    \endcode

    The kernel object must not be reused until the background
    thread finishes execution of the kernel.  Thus, the following
    code will have unexpected effects:

    \code
    QFuture<void> future1 = QtConcurrent::run(kernel, a1, b1);
    QFuture<void> future2 = QtConcurrent::run(kernel, a2, b2);
    future1.waitForFinished();
    future2.waitForFinished();
    \endcode

    The recommended method to run the same kernel multiple times in a
    background thread is as follows:

    \code
    void runKernelTwice(QCLKernel &kernel)
    {
        kernel(a1, b1);
        kernel(a2, b2).waitForFinished();
    }

    QFuture<void> future = QtConcurrent::run(runKernelTwice, kernel);
    \endcode

    \sa run()
*/
QFuture<void> QCLKernel::runInThread()
{
    Q_D(const QCLKernel);
    cl_kernel kernel = m_kernelId;
    cl_command_queue queue = d->context->activeQueue();
    if (!kernel || !queue)
        return QFuture<void>();
    clRetainKernel(kernel);
    clRetainCommandQueue(queue);
    return QtConcurrent::run
           (qt_run_kernel, kernel, queue, d->globalWorkSize, d->localWorkSize);
}
示例#3
0
 void copy(const QCLKernelPrivate *other)
 {
     context = other->context;
     globalWorkSize = other->globalWorkSize;
     localWorkSize = other->localWorkSize;
     if (id != other->id) {
         if (id)
             clReleaseKernel(id);
         id = other->id;
         if (id)
             clRetainKernel(id);
     }
 }
示例#4
0
static void
ufo_fftmult_task_setup (UfoTask *task,
                       UfoResources *resources,
                       GError **error)
{
    UfoFftmultTaskPrivate *priv;

    priv = UFO_FFTMULT_TASK_GET_PRIVATE (task);
    priv->resources = resources;

    priv->k_fftmult = ufo_resources_get_kernel (resources, "fftmult.cl", "mult", error);

    if (priv->k_fftmult != NULL)
        UFO_RESOURCES_CHECK_CLERR (clRetainKernel (priv->k_fftmult));
}
示例#5
0
文件: kernel.c 项目: dche/rcl
static VALUE
rcl_kernel_init_copy(VALUE copy, VALUE orig)
{
    if (copy == orig) return copy;
    EXPECT_RCL_TYPE(orig, Kernel);

    rcl_kernel_t *copy_p, *orig_p;
    Data_Get_Struct(copy, rcl_kernel_t, copy_p);
    Data_Get_Struct(orig, rcl_kernel_t, orig_p);

    if (copy_p->k == orig_p->k) return copy;

    cl_int res;
    if (copy_p->k != NULL) {
        res = clReleaseKernel(copy_p->k);
        CHECK_AND_RAISE(res);
    }
    res = clRetainKernel(orig_p->k);
    CHECK_AND_RAISE(res);

    copy_p->k = orig_p->k;
    return copy;
}
示例#6
0
 static void inc(cl_kernel & something)
 {
   cl_int err = clRetainKernel(something);
   VIENNACL_ERR_CHECK(err);
 }