page.title=RenderScript Kernel Invocation Functions and Types
page.title=RenderScript Kernel Launch Functions and Types
@jd:body
<div class='renderscript'>
<h2>Overview</h2>
<p> The <a href='rs_for_each.html#android_rs:rsForEach'>rsForEach</a>() function can be used to invoke the root kernel of a script.
<p> The <a href='rs_for_each.html#android_rs:rsForEach'>rsForEach</a>() and <a href='rs_for_each.html#android_rs:rsForEachWithOptions'>rsForEachWithOptions</a>() functions are used to launch foreach kernels.
</p>
<p> The other functions are used to get the characteristics of the invocation of
@@ -22,6 +22,14 @@ a <a href='rs_for_each.html#android_rs:rs_kernel_context'>rs_kernel_context</a>
@@ -300,35 +337,89 @@ over cells 4, 5, 6, and 7 in the X dimension, set xStart to 4 and xEnd to 8.
<table class='jd-tagtable'><tbody>
<tr><th>script</th><td>Script to call.</td></tr>
<tr><th>input</th><td>Allocation to source data from.</td></tr>
<tr><th>output</th><td>Allocation to write date into.</td></tr>
<tr><th>output</th><td>Allocation to write data into.</td></tr>
<tr><th>usrData</th><td>User defined data to pass to the script. May be NULL.</td></tr>
<tr><th>sc</th><td>Extra control information used to select a sub-region of the allocation to be processed or suggest a walking strategy. May be NULL.</td></tr>
<tr><th>usrDataLen</th><td>Size of the userData structure. This will be used to perform a shallow copy of the data if necessary.</td></tr>
<tr><th>kernel</th><td>Function designator of the kernel function to call, which must be defined with the kernel attribute.</td></tr>
<tr><th>...</th><td>Input and output allocations</td></tr>
</tbody></table>
</div>
<div class='jd-tagdata jd-tagdescr'>
<p> Invoke the kernel named "root" of the specified script. Like other kernels, this root()
function will be invoked repeatedly over the cells of the specificed allocation, filling
the output allocation with the results.
<p> Runs the kernel over zero or more input allocations. They are passed after the
<a href='rs_for_each.html#android_rs:rs_kernel'>rs_kernel</a> argument. If the specified kernel returns a value, an output allocation
must be specified as the last argument. All input allocations,
and the output allocation if it exists, must have the same dimensions.
</p>
<p> When rsForEach is called, the root script is launched immediately. rsForEach returns
only when the script has completed and the output allocation is ready to use.
<p> This is a synchronous function. A call to this function only returns after all
the work has completed. If the kernel
function returns any value, the call waits until all results have been written
to the output allocation.
</p>
<p> The rs_script argument is typically initialized using a global variable set from Java.
<p> Up to API level 23, the kernel is implicitly specified as the kernel named
"root" in the specified script, and only a single input allocation can be used.
Starting in API level 24, an arbitrary kernel function can be used,
as specified by the kernel argument.
The kernel must be defined in the current script. In addition, more than one
input can be used.
</p>
<p> The kernel can be invoked with just an input allocation or just an output allocation.
This can be done by defining an rs_allocation variable and not initializing it. E.g.<code><br/>