rsCpuCore.h revision 10adb0c2029f112b5738228617d5645f6ecea0c5
1709a0978ae141198018ca9769f8d96292a8928e6Jason Sams/* 2709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * Copyright (C) 2012 The Android Open Source Project 3709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * 4709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 5709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * you may not use this file except in compliance with the License. 6709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * You may obtain a copy of the License at 7709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * 8709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 9709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * 10709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * Unless required by applicable law or agreed to in writing, software 11709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 12709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * See the License for the specific language governing permissions and 14709a0978ae141198018ca9769f8d96292a8928e6Jason Sams * limitations under the License. 15709a0978ae141198018ca9769f8d96292a8928e6Jason Sams */ 16709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 17709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#ifndef RSD_CPU_CORE_H 18709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#define RSD_CPU_CORE_H 19709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 20709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#include "rsd_cpu.h" 21709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#include "rsSignal.h" 22709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#include "rsContext.h" 23c31585b8ca865bf2b35abc79c8a8ee42de27bee8Yang Ni#include "rsCppUtils.h" 24709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#include "rsElement.h" 25709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#include "rsScriptC.h" 26dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross#include "rsCpuCoreRuntime.h" 27709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 28709a0978ae141198018ca9769f8d96292a8928e6Jason Samsnamespace android { 29709a0978ae141198018ca9769f8d96292a8928e6Jason Samsnamespace renderscript { 30709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 3111fd9ec1ab8dfa7ae45c6edeea48dddc4633efeaMatt Wala// Whether the CPU we're running on supports SIMD instructions 32f5ef8df639ba6363aa5d546e57ce872d04144cb6Jason Samsextern bool gArchUseSIMD; 33709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 3414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala// Function types found in RenderScript code 3514ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walatypedef void (*ReduceFunc_t)(const uint8_t *inBuf, uint8_t *outBuf, uint32_t len); 366c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Grosstypedef void (*ReduceNewAccumulatorFunc_t)(const RsExpandKernelDriverInfo *info, uint32_t x1, uint32_t x2, uint8_t *accum); 3710adb0c2029f112b5738228617d5645f6ecea0c5David Grosstypedef void (*ReduceNewCombinerFunc_t)(uint8_t *accum, const uint8_t *other); 386c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Grosstypedef void (*ReduceNewInitializerFunc_t)(uint8_t *accum); 396c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Grosstypedef void (*ReduceNewOutConverterFunc_t)(uint8_t *out, const uint8_t *accum); 4014ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walatypedef void (*ForEachFunc_t)(const RsExpandKernelDriverInfo *info, uint32_t x1, uint32_t x2, uint32_t outStride); 4114ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walatypedef void (*InvokeFunc_t)(void *params); 4214ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walatypedef void (*InitOrDtorFunc_t)(void); 4314ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walatypedef int (*RootFunc_t)(void); 4414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala 456c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Grossstruct ReduceNewDescription { 466c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewAccumulatorFunc_t accumFunc; // expanded accumulator function 476c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewInitializerFunc_t initFunc; // user initializer function 4810adb0c2029f112b5738228617d5645f6ecea0c5David Gross ReduceNewCombinerFunc_t combFunc; // user combiner function 496c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewOutConverterFunc_t outFunc; // user outconverter function 506c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross size_t accumSize; // accumulator datum size, in bytes 516c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross}; 526c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 5314ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala// Internal driver callback used to execute a kernel 54709a0978ae141198018ca9769f8d96292a8928e6Jason Samstypedef void (*WorkerCallback_t)(void *usr, uint32_t idx); 55709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 56709a0978ae141198018ca9769f8d96292a8928e6Jason Samsclass RsdCpuScriptImpl; 57709a0978ae141198018ca9769f8d96292a8928e6Jason Samsclass RsdCpuReferenceImpl; 58709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 59f37121300217d3b39ab66dd9c8881bcbcad932dfChris Wailesstruct ScriptTLSStruct { 60709a0978ae141198018ca9769f8d96292a8928e6Jason Sams android::renderscript::Context * mContext; 61709a0978ae141198018ca9769f8d96292a8928e6Jason Sams const android::renderscript::Script * mScript; 62709a0978ae141198018ca9769f8d96292a8928e6Jason Sams RsdCpuScriptImpl *mImpl; 63f37121300217d3b39ab66dd9c8881bcbcad932dfChris Wailes}; 64709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 6514ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala// MTLaunchStruct passes information about a multithreaded kernel launch. 6614ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walastruct MTLaunchStructCommon { 6714ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala RsdCpuReferenceImpl *rs; 68709a0978ae141198018ca9769f8d96292a8928e6Jason Sams RsdCpuScriptImpl *script; 69709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 70709a0978ae141198018ca9769f8d96292a8928e6Jason Sams uint32_t mSliceSize; 71709a0978ae141198018ca9769f8d96292a8928e6Jason Sams volatile int mSliceNum; 72709a0978ae141198018ca9769f8d96292a8928e6Jason Sams bool isThreadable; 73709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 7414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala // Boundary information about the launch 75bf2111d3b3de310932099514f06924e48fa1d7b2Jason Sams RsLaunchDimensions start; 76bf2111d3b3de310932099514f06924e48fa1d7b2Jason Sams RsLaunchDimensions end; 7714ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala // Points to MTLaunchStructForEach::fep::dim or 7810adb0c2029f112b5738228617d5645f6ecea0c5David Gross // MTLaunchStructReduce::inputDim or 7910adb0c2029f112b5738228617d5645f6ecea0c5David Gross // MTLaunchStructReduceNew::redp::dim. 8014ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala RsLaunchDimensions *dimPtr; 8114ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala}; 8214ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala 8314ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walastruct MTLaunchStructForEach : public MTLaunchStructCommon { 8414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala // Driver info structure 8514ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala RsExpandKernelDriverInfo fep; 8614ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala 8714ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala ForEachFunc_t kernel; 8814ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala const Allocation *ains[RS_KERNEL_INPUT_LIMIT]; 8914ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala Allocation *aout[RS_KERNEL_INPUT_LIMIT]; 9014ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala}; 9114ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala 9214ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Walastruct MTLaunchStructReduce : public MTLaunchStructCommon { 9314ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala ReduceFunc_t kernel; 9414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala const uint8_t *inBuf; 9514ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala uint8_t *outBuf; 9614ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala RsLaunchDimensions inputDim; 97f37121300217d3b39ab66dd9c8881bcbcad932dfChris Wailes}; 98709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 996c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Grossstruct MTLaunchStructReduceNew : public MTLaunchStructCommon { 1006c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross // Driver info structure 1016c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross RsExpandKernelDriverInfo redp; 1026c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 1036c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross const Allocation *ains[RS_KERNEL_INPUT_LIMIT]; 1046c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 1056c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewAccumulatorFunc_t accumFunc; 1066c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewInitializerFunc_t initFunc; 10710adb0c2029f112b5738228617d5645f6ecea0c5David Gross ReduceNewCombinerFunc_t combFunc; 1086c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross ReduceNewOutConverterFunc_t outFunc; 1096c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 1106c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross size_t accumSize; // accumulator datum size in bytes 11110adb0c2029f112b5738228617d5645f6ecea0c5David Gross 11210adb0c2029f112b5738228617d5645f6ecea0c5David Gross size_t accumStride; // stride between accumulators in accumAlloc (below) 11310adb0c2029f112b5738228617d5645f6ecea0c5David Gross 11410adb0c2029f112b5738228617d5645f6ecea0c5David Gross // These fields are used for managing accumulator data items in a 11510adb0c2029f112b5738228617d5645f6ecea0c5David Gross // multithreaded execution. 11610adb0c2029f112b5738228617d5645f6ecea0c5David Gross // 11710adb0c2029f112b5738228617d5645f6ecea0c5David Gross // Let the number of threads be N. 11810adb0c2029f112b5738228617d5645f6ecea0c5David Gross // Let Outc be true iff there is an outconverter. 11910adb0c2029f112b5738228617d5645f6ecea0c5David Gross // 12010adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumAlloc is a pointer to a single allocation of (N - !Outc) 12110adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumulators. (If there is no outconverter, then the output 12210adb0c2029f112b5738228617d5645f6ecea0c5David Gross // allocation acts as an accumulator.) It is created at kernel 12310adb0c2029f112b5738228617d5645f6ecea0c5David Gross // launch time. Within that allocation, the distance between the 12410adb0c2029f112b5738228617d5645f6ecea0c5David Gross // start of adjacent accumulators is accumStride bytes -- this 12510adb0c2029f112b5738228617d5645f6ecea0c5David Gross // might be the same as accumSize, or it might be larger, if we 12610adb0c2029f112b5738228617d5645f6ecea0c5David Gross // are attempting to avoid false sharing. 12710adb0c2029f112b5738228617d5645f6ecea0c5David Gross // 12810adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumCount is an atomic counter of how many accumulators have 12910adb0c2029f112b5738228617d5645f6ecea0c5David Gross // been grabbed by threads. It is initialized to zero at kernel 13010adb0c2029f112b5738228617d5645f6ecea0c5David Gross // launch time. See accumPtr for further description. 13110adb0c2029f112b5738228617d5645f6ecea0c5David Gross // 13210adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumPtr is pointer to an array of N pointers to accumulators. 13310adb0c2029f112b5738228617d5645f6ecea0c5David Gross // The array is created at kernel launch time, and each element is 13410adb0c2029f112b5738228617d5645f6ecea0c5David Gross // initialized to nullptr. When a particular thread goes to work, 13510adb0c2029f112b5738228617d5645f6ecea0c5David Gross // that thread obtains its accumulator from its entry in this 13610adb0c2029f112b5738228617d5645f6ecea0c5David Gross // array. If the entry is nullptr, that thread needs to obtain an 13710adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumulator, and initialize its entry in the array accordingly. 13810adb0c2029f112b5738228617d5645f6ecea0c5David Gross // It does so via atomic access (fetch-and-add) to accumCount. 13910adb0c2029f112b5738228617d5645f6ecea0c5David Gross // - If Outc, then the fetched value is used as an index into 14010adb0c2029f112b5738228617d5645f6ecea0c5David Gross // accumAlloc. 14110adb0c2029f112b5738228617d5645f6ecea0c5David Gross // - If !Outc, then 14210adb0c2029f112b5738228617d5645f6ecea0c5David Gross // - If the fetched value is zero, then this thread gets the 14310adb0c2029f112b5738228617d5645f6ecea0c5David Gross // output allocation for its accumulator. 14410adb0c2029f112b5738228617d5645f6ecea0c5David Gross // - If the fetched value is nonzero, then (fetched value - 1) 14510adb0c2029f112b5738228617d5645f6ecea0c5David Gross // is used as an index into accumAlloc. 14610adb0c2029f112b5738228617d5645f6ecea0c5David Gross uint8_t *accumAlloc; 14710adb0c2029f112b5738228617d5645f6ecea0c5David Gross uint8_t **accumPtr; 14810adb0c2029f112b5738228617d5645f6ecea0c5David Gross uint32_t accumCount; 14910adb0c2029f112b5738228617d5645f6ecea0c5David Gross 15010adb0c2029f112b5738228617d5645f6ecea0c5David Gross // Logging control 15110adb0c2029f112b5738228617d5645f6ecea0c5David Gross bool logReduceAccum; 1526c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross}; 1536c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 154709a0978ae141198018ca9769f8d96292a8928e6Jason Samsclass RsdCpuReferenceImpl : public RsdCpuReference { 155709a0978ae141198018ca9769f8d96292a8928e6Jason Samspublic: 156c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines ~RsdCpuReferenceImpl() override; 157709a0978ae141198018ca9769f8d96292a8928e6Jason Sams RsdCpuReferenceImpl(Context *); 158709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 159709a0978ae141198018ca9769f8d96292a8928e6Jason Sams void lockMutex(); 160709a0978ae141198018ca9769f8d96292a8928e6Jason Sams void unlockMutex(); 161709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 162709a0978ae141198018ca9769f8d96292a8928e6Jason Sams bool init(uint32_t version_major, uint32_t version_minor, sym_lookup_t, script_lookup_t); 163c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines void setPriority(int32_t priority) override; 164709a0978ae141198018ca9769f8d96292a8928e6Jason Sams virtual void launchThreads(WorkerCallback_t cbk, void *data); 165709a0978ae141198018ca9769f8d96292a8928e6Jason Sams static void * helperThreadProc(void *vrsc); 166709a0978ae141198018ca9769f8d96292a8928e6Jason Sams RsdCpuScriptImpl * setTLS(RsdCpuScriptImpl *sc); 167709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 168709a0978ae141198018ca9769f8d96292a8928e6Jason Sams Context * getContext() {return mRSC;} 169c44d6706868749abe37780fc28b2cc627ddcf269Jason Sams uint32_t getThreadCount() const { 170c44d6706868749abe37780fc28b2cc627ddcf269Jason Sams return mWorkers.mCount + 1; 171c44d6706868749abe37780fc28b2cc627ddcf269Jason Sams } 172709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 17314ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala // Launch foreach kernel 17414ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala void launchForEach(const Allocation **ains, uint32_t inLen, Allocation *aout, 17514ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala const RsScriptCall *sc, MTLaunchStructForEach *mtls); 17614ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala 1776c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross // Launch a simple reduce kernel 17814ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala void launchReduce(const Allocation *ain, Allocation *aout, 17914ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala MTLaunchStructReduce *mtls); 1804b3c34e6833e39bc89c2128002806b654b8e623dChris Wailes 1816c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross // Launch a general reduce kernel 1826c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross void launchReduceNew(const Allocation ** ains, uint32_t inLen, Allocation *aout, 1836c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross MTLaunchStructReduceNew *mtls); 1846c1876bbef1b2c89975dce91230a168bd2d2ce4cDavid Gross 185c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines CpuScript * createScript(const ScriptC *s, char const *resName, char const *cacheDir, 186c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags) override; 187c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines CpuScript * createIntrinsic(const Script *s, RsScriptIntrinsicID iid, Element *e) override; 188c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines void* createScriptGroup(const ScriptGroupBase *sg) override; 189709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 190709a0978ae141198018ca9769f8d96292a8928e6Jason Sams const RsdCpuReference::CpuSymbol *symLookup(const char *); 191709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 19214ce007a633b10e3b9a3fae29d8f53a7e8c9b59fMatt Wala RsdCpuReference::CpuScript *lookupScript(const Script *s) { 193709a0978ae141198018ca9769f8d96292a8928e6Jason Sams return mScriptLookupFn(mRSC, s); 194709a0978ae141198018ca9769f8d96292a8928e6Jason Sams } 195709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 1961d476620399d54774e4fd386c1d23cc583d49522Stephen Hines void setSelectRTCallback(RSSelectRTCallback pSelectRTCallback) { 1971d476620399d54774e4fd386c1d23cc583d49522Stephen Hines mSelectRTCallback = pSelectRTCallback; 1981d476620399d54774e4fd386c1d23cc583d49522Stephen Hines } 1991d476620399d54774e4fd386c1d23cc583d49522Stephen Hines RSSelectRTCallback getSelectRTCallback() { 2001d476620399d54774e4fd386c1d23cc583d49522Stephen Hines return mSelectRTCallback; 2011d476620399d54774e4fd386c1d23cc583d49522Stephen Hines } 202b7d9c80c98fc96aa7c638e3124be24f13a6436b2Stephen Hines 203005113297b19ed256b6db9d6bc293ed9266899fcStephen Hines virtual void setBccPluginName(const char *name) { 204c31585b8ca865bf2b35abc79c8a8ee42de27bee8Yang Ni mBccPluginName.setTo(name); 205005113297b19ed256b6db9d6bc293ed9266899fcStephen Hines } 206005113297b19ed256b6db9d6bc293ed9266899fcStephen Hines virtual const char *getBccPluginName() const { 207c31585b8ca865bf2b35abc79c8a8ee42de27bee8Yang Ni return mBccPluginName.string(); 208005113297b19ed256b6db9d6bc293ed9266899fcStephen Hines } 20910adb0c2029f112b5738228617d5645f6ecea0c5David Gross bool getInKernel() override { return mInKernel; } 210709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 2118409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Set to true if we should embed global variable information in the code. 212c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines void setEmbedGlobalInfo(bool v) override { 2138409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines mEmbedGlobalInfo = v; 2148409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines } 2158409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 2168409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Returns true if we should embed global variable information in the code. 217c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines bool getEmbedGlobalInfo() const override { 2188409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines return mEmbedGlobalInfo; 2198409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines } 2208409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 2218409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Set to true if we should skip constant (immutable) global variables when 2228409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // potentially embedding information about globals. 223c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines void setEmbedGlobalInfoSkipConstant(bool v) override { 2248409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines mEmbedGlobalInfoSkipConstant = v; 2258409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines } 2268409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 2278409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Returns true if we should skip constant (immutable) global variables when 2288409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // potentially embedding information about globals. 229c060f1435e7b9405f3be8974417fa6f410f03753Stephen Hines bool getEmbedGlobalInfoSkipConstant() const override { 2308409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines return mEmbedGlobalInfoSkipConstant; 2318409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines } 2328409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 233709a0978ae141198018ca9769f8d96292a8928e6Jason Samsprotected: 234709a0978ae141198018ca9769f8d96292a8928e6Jason Sams Context *mRSC; 235709a0978ae141198018ca9769f8d96292a8928e6Jason Sams uint32_t version_major; 236709a0978ae141198018ca9769f8d96292a8928e6Jason Sams uint32_t version_minor; 237709a0978ae141198018ca9769f8d96292a8928e6Jason Sams //bool mHasGraphics; 23810adb0c2029f112b5738228617d5645f6ecea0c5David Gross bool mInKernel; // Is a parallel kernel execution underway? 239709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 240709a0978ae141198018ca9769f8d96292a8928e6Jason Sams struct Workers { 241709a0978ae141198018ca9769f8d96292a8928e6Jason Sams volatile int mRunningCount; 242709a0978ae141198018ca9769f8d96292a8928e6Jason Sams volatile int mLaunchCount; 243709a0978ae141198018ca9769f8d96292a8928e6Jason Sams uint32_t mCount; 244709a0978ae141198018ca9769f8d96292a8928e6Jason Sams pthread_t *mThreadId; 245709a0978ae141198018ca9769f8d96292a8928e6Jason Sams pid_t *mNativeThreadId; 246709a0978ae141198018ca9769f8d96292a8928e6Jason Sams Signal mCompleteSignal; 247709a0978ae141198018ca9769f8d96292a8928e6Jason Sams Signal *mLaunchSignals; 248709a0978ae141198018ca9769f8d96292a8928e6Jason Sams WorkerCallback_t mLaunchCallback; 249709a0978ae141198018ca9769f8d96292a8928e6Jason Sams void *mLaunchData; 250709a0978ae141198018ca9769f8d96292a8928e6Jason Sams }; 251709a0978ae141198018ca9769f8d96292a8928e6Jason Sams Workers mWorkers; 252709a0978ae141198018ca9769f8d96292a8928e6Jason Sams bool mExit; 253709a0978ae141198018ca9769f8d96292a8928e6Jason Sams sym_lookup_t mSymLookupFn; 254709a0978ae141198018ca9769f8d96292a8928e6Jason Sams script_lookup_t mScriptLookupFn; 255709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 256709a0978ae141198018ca9769f8d96292a8928e6Jason Sams ScriptTLSStruct mTlsStruct; 257f218bf115af4ae4fd79adbb8842608b308a4cf07Stephen Hines 2581d476620399d54774e4fd386c1d23cc583d49522Stephen Hines RSSelectRTCallback mSelectRTCallback; 259c31585b8ca865bf2b35abc79c8a8ee42de27bee8Yang Ni String8 mBccPluginName; 2608409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 2618409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Specifies whether we should embed global variable information in the 2628409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // code via special RS variables that can be examined later by the driver. 2638409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Defaults to true. 2648409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines bool mEmbedGlobalInfo; 2658409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines 2668409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Specifies whether we should skip constant (immutable) global variables 2678409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // when potentially embedding information about globals. 2688409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines // Defaults to true. 2698409d6414dd4a42aa59779fcfe9fce18648cb135Stephen Hines bool mEmbedGlobalInfoSkipConstant; 27010adb0c2029f112b5738228617d5645f6ecea0c5David Gross 27110adb0c2029f112b5738228617d5645f6ecea0c5David Gross long mPageSize; 27210adb0c2029f112b5738228617d5645f6ecea0c5David Gross 27310adb0c2029f112b5738228617d5645f6ecea0c5David Gross // Launch a general reduce kernel 27410adb0c2029f112b5738228617d5645f6ecea0c5David Gross void launchReduceNewSerial(const Allocation ** ains, uint32_t inLen, Allocation *aout, 27510adb0c2029f112b5738228617d5645f6ecea0c5David Gross MTLaunchStructReduceNew *mtls); 27610adb0c2029f112b5738228617d5645f6ecea0c5David Gross void launchReduceNewParallel(const Allocation ** ains, uint32_t inLen, Allocation *aout, 27710adb0c2029f112b5738228617d5645f6ecea0c5David Gross MTLaunchStructReduceNew *mtls); 278709a0978ae141198018ca9769f8d96292a8928e6Jason Sams}; 279709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 280709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 281709a0978ae141198018ca9769f8d96292a8928e6Jason Sams} 282709a0978ae141198018ca9769f8d96292a8928e6Jason Sams} 283709a0978ae141198018ca9769f8d96292a8928e6Jason Sams 284709a0978ae141198018ca9769f8d96292a8928e6Jason Sams#endif 285