summaryrefslogtreecommitdiff
path: root/cpu_ref/rsCpuCore.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpu_ref/rsCpuCore.h')
-rw-r--r--cpu_ref/rsCpuCore.h54
1 files changed, 40 insertions, 14 deletions
diff --git a/cpu_ref/rsCpuCore.h b/cpu_ref/rsCpuCore.h
index 0f784382..cfdb29a6 100644
--- a/cpu_ref/rsCpuCore.h
+++ b/cpu_ref/rsCpuCore.h
@@ -31,8 +31,14 @@ namespace renderscript {
// Whether the CPU we're running on supports SIMD instructions
extern bool gArchUseSIMD;
-typedef void (* InvokeFunc_t)(void);
-typedef void (* ForEachFunc_t)(void);
+// Function types found in RenderScript code
+typedef void (*ReduceFunc_t)(const uint8_t *inBuf, uint8_t *outBuf, uint32_t len);
+typedef void (*ForEachFunc_t)(const RsExpandKernelDriverInfo *info, uint32_t x1, uint32_t x2, uint32_t outStride);
+typedef void (*InvokeFunc_t)(void *params);
+typedef void (*InitOrDtorFunc_t)(void);
+typedef int (*RootFunc_t)(void);
+
+// Internal driver callback used to execute a kernel
typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
class RsdCpuScriptImpl;
@@ -44,23 +50,38 @@ struct ScriptTLSStruct {
RsdCpuScriptImpl *mImpl;
};
-struct MTLaunchStruct {
- RsExpandKernelDriverInfo fep;
-
- RsdCpuReferenceImpl *rsc;
+// MTLaunchStruct passes information about a multithreaded kernel launch.
+struct MTLaunchStructCommon {
+ RsdCpuReferenceImpl *rs;
RsdCpuScriptImpl *script;
- ForEachFunc_t kernel;
- uint32_t sig;
- const Allocation * ains[RS_KERNEL_INPUT_LIMIT];
- Allocation * aout[RS_KERNEL_INPUT_LIMIT];
-
uint32_t mSliceSize;
volatile int mSliceNum;
bool isThreadable;
+ // Boundary information about the launch
RsLaunchDimensions start;
RsLaunchDimensions end;
+ // Points to MTLaunchStructForEach::fep::dim or
+ // MTLaunchStructReduce::inputDim.
+ RsLaunchDimensions *dimPtr;
+};
+
+struct MTLaunchStructForEach : public MTLaunchStructCommon {
+ // Driver info structure
+ RsExpandKernelDriverInfo fep;
+
+ ForEachFunc_t kernel;
+ uint32_t sig;
+ const Allocation *ains[RS_KERNEL_INPUT_LIMIT];
+ Allocation *aout[RS_KERNEL_INPUT_LIMIT];
+};
+
+struct MTLaunchStructReduce : public MTLaunchStructCommon {
+ ReduceFunc_t kernel;
+ const uint8_t *inBuf;
+ uint8_t *outBuf;
+ RsLaunchDimensions inputDim;
};
class RsdCpuReferenceImpl : public RsdCpuReference {
@@ -82,8 +103,13 @@ public:
return mWorkers.mCount + 1;
}
- void launchThreads(const Allocation** ains, uint32_t inLen, Allocation* aout,
- const RsScriptCall* sc, MTLaunchStruct* mtls);
+ // Launch foreach kernel
+ void launchForEach(const Allocation **ains, uint32_t inLen, Allocation *aout,
+ const RsScriptCall *sc, MTLaunchStructForEach *mtls);
+
+ // Launch a reduce kernel
+ void launchReduce(const Allocation *ain, Allocation *aout,
+ MTLaunchStructReduce *mtls);
CpuScript * createScript(const ScriptC *s, char const *resName, char const *cacheDir,
uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags) override;
@@ -92,7 +118,7 @@ public:
const RsdCpuReference::CpuSymbol *symLookup(const char *);
- RsdCpuReference::CpuScript * lookupScript(const Script *s) {
+ RsdCpuReference::CpuScript *lookupScript(const Script *s) {
return mScriptLookupFn(mRSC, s);
}