<p><ahref="classtf_1_1syclFlow.html" class="m-doc">tf::<wbr/>syclFlow</a> provides a template method, <ahref="classtf_1_1syclFlow.html#ae278939334a90b6d58d8771e87b2e793" class="m-doc">tf::<wbr/>syclFlow::<wbr/>transform</a>, for creating a task to perform parallel transforms by applying the given function to a range of item and stores the transformed result in another range.</p><sectionid="IteratorBasedParallelTransformSYCL"><h2><ahref="#IteratorBasedParallelTransformSYCL">Iterator-based Parallel Transforms</a></h2><p>Iterator-based parallel-transform applies the given transform function to a range of items and store the result in another range specified by two iterators, <code>first</code> and <code>last</code>. The two iterators are typically two raw pointers to the first element and the next to the last element in the range in GPU memory space. The task created by <ahref="classtf_1_1syclFlow.html#ae278939334a90b6d58d8771e87b2e793" class="m-doc">tf::<wbr/>syclFlow::<wbr/>transform</a>(I first, I last, C&& callable, S... srcs) represents a kernel of parallel execution for the following loop:</p><preclass="m-code"><spanclass="k">while</span><spanclass="w"></span><spanclass="p">(</span><spanclass="n">first</span><spanclass="w"></span><spanclass="o">!=</span><spanclass="w"></span><spanclass="n">last</span><spanclass="p">)</span><spanclass="w"></span><spanclass="p">{</span><spanclass="w"></span>
<spanclass="p">}</span><spanclass="w"></span></pre><p>The two iterators, <code>first</code> and <code>last</code>, are typically two raw pointers to the first element and the next to the last element in the range. The following example creates a <code>transform</code> kernel that assigns each element, starting from <code>gpu_data</code> to <code>gpu_data + 1000</code>, to the sum of the corresponding elements at <code>gpu_data_x</code>, <code>gpu_data_y</code>, and <code>gpu_data_z</code>.</p><preclass="m-code"><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace_on</span><spanclass="p">([](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">syclFlow</span><spanclass="o">&</span><spanclass="w"></span><spanclass="n">sf</span><spanclass="p">){</span><spanclass="w"></span>
<spanclass="p">},</span><spanclass="w"></span><spanclass="n">sycl_queue</span><spanclass="p">);</span><spanclass="w"></span></pre><p>Each iteration is independent of each other and is assigned one kernel thread to run the callable.</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>