<p><ahref="classtf_1_1cudaFlow.html" class="m-doc">tf::<wbr/>cudaFlow</a> provides a template method, <ahref="classtf_1_1cudaFlow.html#a6101318f98d4165f6a7bf49457dba5fc" class="m-doc">tf::<wbr/>cudaFlow::<wbr/>single_task</a>, for creating a task to run the given callable using a single kernel thread.</p><sectionid="SingleTaskCUDASingleTask"><h2><ahref="#SingleTaskCUDASingleTask">Run a Task with a Single Thread</a></h2><p>You can create a task to run a kernel function just once, i.e., using one GPU thread. This is handy when you want to set up a single or a few global variables that do not need multiple threads and will be used by multiple kernels afterwards. The following example creates a single-task kernel that sets <code>gpu_variable</code> to 1.</p><preclass="m-code"><spanclass="kt">int</span><spanclass="o">*</span><spanclass="n">gpu_variable</span><spanclass="p">;</span>
<spanclass="p">});</span></pre><p>Since the callable runs on GPU, it must be declared with a <code>__device__</code> specifier.</p></section><sectionid="SingleTaskCUDAMiscellaneousItems"><h2><ahref="#SingleTaskCUDAMiscellaneousItems">Miscellaneous Items</a></h2><p>The single-task algorithm is also available in <ahref="classtf_1_1cudaFlowCapturer.html#a7d0737ec995f5611c6d706ad105a8a0b" class="m-doc">tf::<wbr/>cudaFlowCapturer::<wbr/>single_task</a>.</p></section>
</div>
</div>
</div>
</article></main>
<divclass="m-doc-search" id="search">
<ahref="#!" onclick="return hideSearch()"></a>
<divclass="m-container">
<divclass="m-row">
<divclass="m-col-m-8 m-push-m-2">
<divclass="m-doc-search-header m-text m-small">
<div><spanclass="m-label m-default">Tab</span> / <spanclass="m-label m-default">T</span> to search, <spanclass="m-label m-default">Esc</span> to close</div>