本文整理汇总了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;
}