diff options
| author | Matt Wala <wala@google.com> | 2015-07-30 17:30:25 -0700 |
|---|---|---|
| committer | Matt Wala <wala@google.com> | 2015-08-14 12:24:24 -0700 |
| commit | 14ce007a633b10e3b9a3fae29d8f53a7e8c9b59f (patch) | |
| tree | d9089fc8c60a65d071cb817b156cc0edc3bb5015 /rsScriptC.cpp | |
| parent | 2b4632b580c756af046ee4b9a6ecc77a01388d4e (diff) | |
Add a basic implementation of the reduce kernel API to the CPU
reference implementation.
Bug: 22631253
For now, this just runs a serial reduction on one thread.
Change-Id: I34c96d24bb6f44274de72bb53160abcf79d143b0
Diffstat (limited to 'rsScriptC.cpp')
| -rw-r--r-- | rsScriptC.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/rsScriptC.cpp b/rsScriptC.cpp index a24334e3..618c0c94 100644 --- a/rsScriptC.cpp +++ b/rsScriptC.cpp @@ -201,6 +201,12 @@ void ScriptC::runForEach(Context *rsc, sc = &sc_copy; } + if (slot >= mHal.info.exportedForEachCount) { + rsc->setError(RS_ERROR_BAD_SCRIPT, + "The forEach kernel index is out of bounds"); + return; + } + // Trace this function call. // To avoid overhead we only build the string if tracing is actually // enabled. @@ -220,6 +226,10 @@ void ScriptC::runForEach(Context *rsc, setupGLState(rsc); setupScript(rsc); + if (rsc->props.mLogScripts) { + ALOGV("%p ScriptC::runForEach invoking slot %i, ptr %p", rsc, slot, this); + } + if (rsc->mHal.funcs.script.invokeForEachMulti != nullptr) { rsc->mHal.funcs.script.invokeForEachMulti(rsc, this, slot, ains, inLen, aout, usr, usrBytes, sc); @@ -238,11 +248,31 @@ void ScriptC::runForEach(Context *rsc, } } +void ScriptC::runReduce(Context *rsc, uint32_t slot, const Allocation *ain, + Allocation *aout, const RsScriptCall *sc) { + // TODO: Record the name of the kernel in the tracing information. + ATRACE_CALL(); + + if (slot >= mHal.info.exportedReduceCount) { + rsc->setError(RS_ERROR_BAD_SCRIPT, "The reduce kernel index is out of bounds"); + return; + } + if (mRSC->hadFatalError()) return; + + setupScript(rsc); + + if (rsc->props.mLogScripts) { + ALOGV("%p ScriptC::runReduce invoking slot %i, ptr %p", rsc, slot, this); + } + + rsc->mHal.funcs.script.invokeReduce(rsc, this, slot, ain, aout, sc); +} + void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { ATRACE_CALL(); if (slot >= mHal.info.exportedFunctionCount) { - rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); + rsc->setError(RS_ERROR_BAD_SCRIPT, "The invokable index is out of bounds"); return; } if (mRSC->hadFatalError()) return; |
