diff options
author | Stephen Hines <srhines@google.com> | 2013-09-10 17:40:41 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2013-09-10 18:13:28 -0700 |
commit | c78839b5bbcffae7d64a5a1c9aa60c9a4c5d3918 (patch) | |
tree | 92c7b189452259dd5f103394ee4d5701275297a2 /cpu_ref/rsCpuScriptGroup.cpp | |
parent | 17e3cdc24776d8fdbf1ce16287b9b4dcd516708f (diff) | |
download | android_frameworks_rs-c78839b5bbcffae7d64a5a1c9aa60c9a4c5d3918.tar.gz android_frameworks_rs-c78839b5bbcffae7d64a5a1c9aa60c9a4c5d3918.tar.bz2 android_frameworks_rs-c78839b5bbcffae7d64a5a1c9aa60c9a4c5d3918.zip |
Detect use of RS objects in kernels to disable a ScriptGroup optimization.
Bug: 10394865
This change disables a ScriptGroup optimization when we can't guarantee
that there is no implicit ordering between two kernels. In this case, it
is possible to communicate between kernels using the same bound global
RS object (like Allocation). A subsequent kernel in the ScriptGroup could
accidentally pick up stale data, leading to incorrect results.
Now, we disable this optimization whenever we see binds/sets of variables
that are potentiall RS object types for a given Script/kernel. This is
overly conservative, but sufficient for now.
This change also fixes a small issue with preLaunch/postLaunch missing for
the default ScriptGroup execution case.
Change-Id: I0d19d200cc8dc397d68008a4df6ea423b1e4d04f
Diffstat (limited to 'cpu_ref/rsCpuScriptGroup.cpp')
-rw-r--r-- | cpu_ref/rsCpuScriptGroup.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cpu_ref/rsCpuScriptGroup.cpp b/cpu_ref/rsCpuScriptGroup.cpp index 1db6e16c..40eddf20 100644 --- a/cpu_ref/rsCpuScriptGroup.cpp +++ b/cpu_ref/rsCpuScriptGroup.cpp @@ -119,6 +119,11 @@ void CpuScriptGroupImpl::execute() { for (size_t ct=0; ct < mSG->mNodes.size(); ct++) { ScriptGroup::Node *n = mSG->mNodes[ct]; Script *s = n->mKernels[0]->mScript; + if (s->hasObjectSlots()) { + // Disable the ScriptGroup optimization if we have global RS + // objects that might interfere between kernels. + fieldDep = true; + } //ALOGE("node %i, order %i, in %i out %i", (int)ct, n->mOrder, (int)n->mInputs.size(), (int)n->mOutputs.size()); @@ -136,6 +141,12 @@ void CpuScriptGroupImpl::execute() { bool inExt = false; bool outExt = false; + if (k->mScript->hasObjectSlots()) { + // Disable the ScriptGroup optimization if we have global RS + // objects that might interfere between kernels. + fieldDep = true; + } + for (size_t ct3=0; ct3 < n->mInputs.size(); ct3++) { if (n->mInputs[ct3]->mDstKernel.get() == k) { ain = n->mInputs[ct3]->mAlloc.get(); @@ -189,7 +200,9 @@ void CpuScriptGroupImpl::execute() { si->forEachMtlsSetup(ins[ct], outs[ct], NULL, 0, NULL, &mtls); si->forEachKernelSetup(slot, &mtls); + si->preLaunch(slot, ins[ct], outs[ct], mtls.fep.usr, mtls.fep.usrLen, NULL); mCtx->launchThreads(ins[ct], outs[ct], NULL, &mtls); + si->postLaunch(slot, ins[ct], outs[ct], NULL, 0, NULL); } } else { ScriptList sl; |