当前位置: 首页>>代码示例>>C++>>正文


C++ CommandQueue::enqueueTask方法代码示例

本文整理汇总了C++中CommandQueue::enqueueTask方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandQueue::enqueueTask方法的具体用法?C++ CommandQueue::enqueueTask怎么用?C++ CommandQueue::enqueueTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandQueue的用法示例。


在下文中一共展示了CommandQueue::enqueueTask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
        * resources: i.e. buffers and arrays.
        *--------------------------------------------------------------------*/
        int     circIdx = i % inflight;
        Buffer &buf(*bufs[circIdx]);
        int    *ary(arys [circIdx]);
        Event   nullEv;

        K.setArg(0, buf);

        /*---------------------------------------------------------------------
        * Since we are reusing N sets of buffers in this loop, we need to make
        * sure than iteration I does not start until after iteration I-N 
        * completes. Iterations < N can start immediately.
        *--------------------------------------------------------------------*/
        int    eIdx = circIdx;
        vecEv *start_waits = (i < inflight) ? 0 : &evt[eIdx][RUM];

        evt[circIdx][WMP][0] = nullEv;
        evt[circIdx][PRD][0] = nullEv;
        evt[circIdx][WUM][0] = nullEv;
        evt[circIdx][CMP][0] = nullEv;
        evt[circIdx][RMP][0] = nullEv;
        evt[circIdx][CNS][0] = nullEv;

        int *p = (int*)QdspOO->enqueueMapBuffer(buf, CL_FALSE, CL_MAP_WRITE, 
                                  0, size, start_waits,  &evt[eIdx][WMP][0]);

        evt[circIdx][RUM][0] = nullEv;

        /*---------------------------------------------------------------------
        * Native kernels are only passed a single pointer, so define a structure
        * that contains the actual arguments, populate that and then create 
        * a C++ binding native argument class that has the pointer and a size.
        *--------------------------------------------------------------------*/
        arguments_t proArgs = { p, elements, i,   i };
        native_arg_t proNargs(&proArgs, sizeof(proArgs));

        QcpuOO->enqueueNativeKernel(cpu_produce, proNargs, 0, 0,          
                &evt[eIdx][WMP], &evt[eIdx][PRD][0]);

        QdspOO->enqueueUnmapMemObject(buf, p,                               
                &evt[eIdx][PRD], &evt[eIdx][WUM][0]);

        QdspOO->enqueueTask(K,                                    
                &evt[eIdx][WUM], &evt[eIdx][CMP][0]);

        p = (int*)QdspOO->enqueueMapBuffer(buf, CL_FALSE, CL_MAP_READ, 0, size,
                &evt[eIdx][CMP], &evt[eIdx][RMP][0]);

        arguments_t conArgs = { p, elements, i+1, i };
        native_arg_t conNargs(&conArgs, sizeof(conArgs));

        QcpuIO->enqueueNativeKernel (cpu_consume, conNargs, 0, 0,          
                &evt[eIdx][RMP], &evt[eIdx][CNS][0]);

        QdspOO->enqueueUnmapMemObject (buf, p,                               
                &evt[eIdx][CNS], &evt[eIdx][RUM][0]);
     }

     /*------------------------------------------------------------------------
     * Only need to wait for the CPU In Order queue to finish, since all all
     * other enqueue events must finish before the CPU IO queue can finish
     *-----------------------------------------------------------------------*/
     // QcpuIO.finish();
     QdspOO->finish();

     delete QcpuIO;
     delete QcpuOO;
     delete QdspOO;

     clock_gettime(CLOCK_MONOTONIC, &tp_end);
     double elapsed = clock_diff (&tp_start, &tp_end);
     printf("Elapsed : %8.4f secs\n", elapsed);

     /*------------------------------------------------------------------------
     * After the running is complete, report timing for each step
     *-----------------------------------------------------------------------*/
#if PROFILE 
     cl_ulong ref;
     evt[0][0][0].getProfilingInfo(CL_PROFILING_COMMAND_QUEUED, &ref);

     for (int i = 0; i < tasks; ++i)
     {
          for (int s = 0; s < STAGES; ++s)
              ocl_relative_times(evt[i][s][0], stage_names[s], ref);
          cout << endl;
     }
#endif
   }

   catch (Error err)
   {
       cerr << "ERROR: " << err.what() << "("
            << ocl_decode_error(err.err()) << ")"
            << endl;
       incorrect_results = true;
   }

   if (incorrect_results) return -1;
}
开发者ID:rcn-ee,项目名称:ti-opencl,代码行数:101,代码来源:ooo.cpp


注:本文中的CommandQueue::enqueueTask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。