• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RENDER_SERVICE_STDTYPE_H
17 #define RENDER_SERVICE_STDTYPE_H
18 #include <memory>
19 #include <vector>
20 #include "base_stdtype.h"
21 #include "double_map.h"
22 
23 namespace SysTuning {
24 namespace TraceStdtype {
25 using namespace SysTuning::TraceStreamer;
26 struct FrameSliceRow {
27     uint64_t ts = INVALID_UINT64;
28     uint32_t ipid = INVALID_UINT32;
29     uint32_t itid = INVALID_UINT32;
30     uint32_t vsyncId = INVALID_UINT32;
31     uint64_t callStackSliceId = INVALID_UINT64;
32     uint64_t end = INVALID_UINT64;
33     uint8_t type = INVALID_UINT8;
34 };
35 class FrameSlice : public CacheBase, public BatchCacheBase {
36 public:
37     size_t AppendFrame(uint64_t ts, uint32_t ipid, uint32_t itid, uint32_t vsyncId, uint64_t callStackSliceId);
38     size_t AppendFrame(const FrameSliceRow &frameSliceRow);
39     void SetEndTime(uint64_t row, uint64_t end);
40     void SetType(uint64_t row, uint8_t type);
41     void SetDst(uint64_t row, uint64_t dst);
42     void SetSrcs(uint64_t row, const std::vector<uint64_t> &fromSlices);
43     void SetFlags(uint64_t row, const uint32_t flags);
44     void SetVsync(uint64_t row, uint32_t vsync);
45     uint64_t GetExpectEndByItidAndVsyncId(uint32_t mainThreadId, uint32_t vsyncId) const;
46     void UpdateDepth();
47     const std::deque<uint32_t> Ipids() const;
48     const std::deque<uint32_t> VsyncIds() const;
49     const std::deque<uint64_t> CallStackIds() const;
50     const std::deque<uint64_t> EndTss() const;
51     const std::deque<uint64_t> Dsts() const;
52     const std::deque<uint64_t> Durs() const;
53     const std::deque<uint8_t> Types() const;
54     const std::deque<uint8_t> Flags() const;
55     const std::deque<uint8_t> Depths() const;
56     const std::deque<uint32_t> FrameNos() const;
57     const std::deque<std::string> &Srcs() const;
58     void UpdateCallStackSliceId(uint64_t row, uint64_t callStackSliceId);
59     void SetEndTimeAndFlag(uint64_t row, uint64_t ts, uint64_t expectEnd);
60     void Erase(uint64_t row);
GetAbnormalStartEndTimeState()61     static uint32_t GetAbnormalStartEndTimeState()
62     {
63         return abnormalStartEndTimeState_;
64     }
ClearExportedData()65     void ClearExportedData() override
66     {
67         EraseElements(internalTids_, timeStamps_, ids_, ipids_, dsts_, srcs_, vsyncIds_, callStackIds_, endTss_, durs_,
68                       types_, flags_, depths_, frameNos_);
69     }
70 
71 public:
72     typedef enum FrameSliceType { ACTURAL_SLICE, EXPECT_SLICE } FrameSliceType;
73 
74 private:
75     std::deque<uint32_t> ipids_ = {};
76     std::deque<uint64_t> dsts_ = {};
77     std::deque<std::string> srcs_ = {};
78     std::deque<uint32_t> vsyncIds_ = {};
79     std::deque<uint64_t> callStackIds_ = {};
80     std::deque<uint64_t> endTss_ = {};
81     std::deque<uint64_t> durs_ = {};
82     std::deque<uint8_t> types_ = {};
83     std::deque<uint8_t> flags_ = {};
84     std::deque<uint8_t> depths_ = {};
85     std::deque<uint32_t> frameNos_ = {};
86     const uint32_t invalidRow_ = 2;
87     static const uint32_t abnormalStartEndTimeState_ = 3;
88     const uint8_t flagValue_ = 2;
89 };
90 
91 class GPUSlice : public CacheBase, public BatchCacheBase {
92 public:
93     size_t AppendNew(uint32_t frameRow, uint64_t dur);
94     const std::deque<uint32_t> &FrameRows() const;
95     const std::deque<uint64_t> &Durs() const;
Clear()96     void Clear() override
97     {
98         CacheBase::Clear();
99         frameRows_.clear();
100         durs_.clear();
101     }
ClearExportedData()102     void ClearExportedData() override
103     {
104         EraseElements(ids_, frameRows_, durs_);
105     }
106 
107 private:
108     std::deque<uint32_t> frameRows_ = {};
109     std::deque<uint64_t> durs_ = {};
110 };
111 struct DmaFenceRow {
112     uint64_t timeStamp = INVALID_UINT64;
113     uint64_t duration = INVALID_UINT64;
114     DataIndex eventName = INVALID_DATAINDEX;
115     DataIndex driver = INVALID_DATAINDEX;
116     DataIndex timeline = INVALID_DATAINDEX;
117     uint32_t context = INVALID_UINT32;
118     uint32_t seqno = INVALID_UINT32;
119 };
120 
121 class DmaFence : public CacheBase {
122 public:
123     size_t AppendNew(const DmaFenceRow &dmaFenceRow);
124     const std::deque<uint64_t> &DursData() const;
125     const std::deque<DataIndex> &CatsData() const;
126     const std::deque<DataIndex> &DriversData() const;
127     const std::deque<DataIndex> &TimelinesData() const;
128     const std::deque<uint32_t> &ContextsData() const;
129     const std::deque<uint32_t> &SeqnosData() const;
Clear()130     void Clear() override
131     {
132         CacheBase::Clear();
133         durs_.clear();
134         cats_.clear();
135         drivers_.clear();
136         timelines_.clear();
137         contexts_.clear();
138         seqnos_.clear();
139     }
140 
141 private:
142     std::deque<uint64_t> durs_ = {};
143     std::deque<DataIndex> cats_ = {};
144     std::deque<DataIndex> drivers_ = {};
145     std::deque<DataIndex> timelines_ = {};
146     std::deque<uint32_t> contexts_ = {};
147     std::deque<uint32_t> seqnos_ = {};
148 };
149 
150 class FrameMaps : public CacheBase, public BatchCacheBase {
151 public:
152     size_t AppendNew(FrameSlice *frameSlice, uint64_t src, uint64_t dst);
153     const std::deque<uint64_t> &SrcIndexs() const;
154     const std::deque<uint64_t> &DstIndexs() const;
ClearExportedData()155     void ClearExportedData() override
156     {
157         EraseElements(timeStamps_, ids_, srcs_, dsts_);
158     }
159 
160 private:
161     std::deque<uint64_t> srcs_ = {};
162     std::deque<uint64_t> dsts_ = {};
163 };
164 
165 } // namespace TraceStdtype
166 } // namespace SysTuning
167 #endif // RENDER_SERVICE_STDTYPE_H
168