1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef RSD_CPU_SCRIPT_INTRINSIC_H
18 #define RSD_CPU_SCRIPT_INTRINSIC_H
19 
20 #include "rsCpuScript.h"
21 
22 
23 namespace android {
24 namespace renderscript {
25 
26 
27 struct MTLaunchStructForEachBlas : public MTLaunchStructCommon {
28     // Driver info structure
29     RsExpandKernelDriverInfo fep;
30 
31     // Tile size info for M, and N dimensions.
32     uint32_t tileSizeM;
33     uint32_t numTileM;
34     uint32_t tileSizeN;
35     uint32_t numTileN;
36 
37     const Allocation *ains[RS_KERNEL_INPUT_LIMIT];
38     const RsBlasCall *sc;
39 };
40 
41 
42 class RsdCpuScriptIntrinsic : public RsdCpuScriptImpl {
43 public:
44     void populateScript(Script *) override = 0;
45 
46     void invokeFunction(uint32_t slot, const void * params, size_t paramLength) override;
47     int invokeRoot() override;
48 
49     void invokeForEach(uint32_t slot,
50                        const Allocation ** ain,
51                        uint32_t inLen,
52                        Allocation * aout,
53                        const void * usr,
54                        uint32_t usrLen,
55                        const RsScriptCall *sc) override;
56 
57     void forEachKernelSetup(uint32_t slot, MTLaunchStructForEach * mtls) override;
58     void invokeInit() override;
59     void invokeFreeChildren() override;
60 
61     void preLaunch(uint32_t slot, const Allocation ** ains,
62                    uint32_t inLen, Allocation * aout, const void * usr,
63                    uint32_t usrLen, const RsScriptCall * sc) override;
64     void postLaunch(uint32_t slot, const Allocation ** ains,
65                     uint32_t inLen, Allocation * aout,
66                     const void * usr, uint32_t usrLen,
67                     const RsScriptCall * sc) override;
68 
69     void setGlobalVar(uint32_t slot, const void * data, size_t dataLength) override;
70     void setGlobalVarWithElemDims(uint32_t slot, const void * data,
71                                   size_t dataLength, const Element * e,
72                                   const uint32_t * dims,
73                                   size_t dimLength) override;
74     void setGlobalBind(uint32_t slot, Allocation *data) override;
75     void setGlobalObj(uint32_t slot, ObjectBase *data) override;
76 
77     ~RsdCpuScriptIntrinsic() override;
78     RsdCpuScriptIntrinsic(RsdCpuReferenceImpl * ctx, const Script * s,
79                           const Element * e, RsScriptIntrinsicID iid);
80 
81 protected:
82     RsScriptIntrinsicID mID;
83     ForEachFunc_t mRootPtr;
84     ObjectBaseRef<const Element> mElement;
85 
86 };
87 
88 
89 
90 } // namespace renderscript
91 } // namespace android
92 
93 #endif
94