diff options
author | Chris Wailes <chriswailes@google.com> | 2014-07-16 15:18:30 -0700 |
---|---|---|
committer | Chris Wailes <chriswailes@google.com> | 2014-08-15 18:26:36 -0700 |
commit | f37121300217d3b39ab66dd9c8881bcbcad932df (patch) | |
tree | 2e06a02e490f318cc03b95b03112860e3d38e9a6 /cpu_ref/rsCpuIntrinsicHistogram.cpp | |
parent | cd8df40f07d88f896bea05ed06a20d1a4d5e9728 (diff) | |
download | rs-f37121300217d3b39ab66dd9c8881bcbcad932df.tar.gz |
Collapse code paths for single- and multi-input kernels.
This patch simplifies the RenderScript driver and CPU reference implementation
by removing the distinction between sing- and multi-input kernels in many
places. The distinction is maintained in some places due to the need to
maintain backwards compatibility. This permits the deletion of some functions
and struct members that are no longer needed. Several related functions were
also cleaned up.
Change-Id: Id70a223ea5e3aa2b0b935b2b7f9af933339ae8a4
Diffstat (limited to 'cpu_ref/rsCpuIntrinsicHistogram.cpp')
-rw-r--r-- | cpu_ref/rsCpuIntrinsicHistogram.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/cpu_ref/rsCpuIntrinsicHistogram.cpp b/cpu_ref/rsCpuIntrinsicHistogram.cpp index 1c430b72..b5dbfa80 100644 --- a/cpu_ref/rsCpuIntrinsicHistogram.cpp +++ b/cpu_ref/rsCpuIntrinsicHistogram.cpp @@ -36,10 +36,10 @@ public: RsdCpuScriptIntrinsicHistogram(RsdCpuReferenceImpl *ctx, const Script *s, const Element *e); protected: - void preLaunch(uint32_t slot, const Allocation * ain, + void preLaunch(uint32_t slot, const Allocation ** ains, uint32_t inLen, Allocation * aout, const void * usr, uint32_t usrLen, const RsScriptCall *sc); - void postLaunch(uint32_t slot, const Allocation * ain, + void postLaunch(uint32_t slot, const Allocation ** ains, uint32_t inLen, Allocation * aout, const void * usr, uint32_t usrLen, const RsScriptCall *sc); @@ -97,9 +97,12 @@ void RsdCpuScriptIntrinsicHistogram::setGlobalVar(uint32_t slot, const void *dat -void RsdCpuScriptIntrinsicHistogram::preLaunch(uint32_t slot, const Allocation * ain, - Allocation * aout, const void * usr, - uint32_t usrLen, const RsScriptCall *sc) { +void +RsdCpuScriptIntrinsicHistogram::preLaunch(uint32_t slot, + const Allocation ** ains, + uint32_t inLen, Allocation * aout, + const void * usr, uint32_t usrLen, + const RsScriptCall *sc) { const uint32_t threads = mCtx->getThreadCount(); uint32_t vSize = mAllocOut->getType()->getElement()->getVectorSize(); @@ -123,7 +126,7 @@ void RsdCpuScriptIntrinsicHistogram::preLaunch(uint32_t slot, const Allocation * } break; case 1: - switch(ain->getType()->getElement()->getVectorSize()) { + switch(ains[0]->getType()->getElement()->getVectorSize()) { case 1: mRootPtr = &kernelP1L1; break; @@ -142,9 +145,12 @@ void RsdCpuScriptIntrinsicHistogram::preLaunch(uint32_t slot, const Allocation * memset(mSums, 0, 256 * sizeof(int32_t) * threads * vSize); } -void RsdCpuScriptIntrinsicHistogram::postLaunch(uint32_t slot, const Allocation * ain, - Allocation * aout, const void * usr, - uint32_t usrLen, const RsScriptCall *sc) { +void +RsdCpuScriptIntrinsicHistogram::postLaunch(uint32_t slot, + const Allocation ** ains, + uint32_t inLen, Allocation * aout, + const void * usr, uint32_t usrLen, + const RsScriptCall *sc) { unsigned int *o = (unsigned int *)mAllocOut->mHal.drvState.lod[0].mallocPtr; uint32_t threads = mCtx->getThreadCount(); @@ -165,7 +171,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1U4(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * 4 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { @@ -173,7 +179,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1U4(const RsExpandKernelParams *p, sums[(in[1] << 2) + 1] ++; sums[(in[2] << 2) + 2] ++; sums[(in[3] << 2) + 3] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -182,14 +188,14 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1U3(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * 4 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { sums[(in[0] << 2) ] ++; sums[(in[1] << 2) + 1] ++; sums[(in[2] << 2) + 2] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -198,13 +204,13 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1U2(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * 2 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { sums[(in[0] << 1) ] ++; sums[(in[1] << 1) + 1] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -213,7 +219,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L4(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { @@ -222,7 +228,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L4(const RsExpandKernelParams *p, (cp->mDotI[2] * in[2]) + (cp->mDotI[3] * in[3]); sums[(t + 0x7f) >> 8] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -231,7 +237,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L3(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { @@ -239,7 +245,7 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L3(const RsExpandKernelParams *p, (cp->mDotI[1] * in[1]) + (cp->mDotI[2] * in[2]); sums[(t + 0x7f) >> 8] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -248,14 +254,14 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L2(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { int t = (cp->mDotI[0] * in[0]) + (cp->mDotI[1] * in[1]); sums[(t + 0x7f) >> 8] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -264,13 +270,13 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1L1(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { int t = (cp->mDotI[0] * in[0]); sums[(t + 0x7f) >> 8] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -279,12 +285,12 @@ void RsdCpuScriptIntrinsicHistogram::kernelP1U1(const RsExpandKernelParams *p, uint32_t instep, uint32_t outstep) { RsdCpuScriptIntrinsicHistogram *cp = (RsdCpuScriptIntrinsicHistogram *)p->usr; - uchar *in = (uchar *)p->in; + uchar *in = (uchar *)p->ins[0]; int * sums = &cp->mSums[256 * p->lid]; for (uint32_t x = xstart; x < xend; x++) { sums[in[0]] ++; - in += instep; + in += p->inEStrides[0]; } } @@ -323,5 +329,3 @@ RsdCpuScriptImpl * rsdIntrinsic_Histogram(RsdCpuReferenceImpl *ctx, const Script return new RsdCpuScriptIntrinsicHistogram(ctx, s, e); } - - |