1 /******************************************************************************
2 * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Texas Instruments Incorporated nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 *****************************************************************************/
29 #pragma once
31 #include <string>
32 #include <cstddef>
33 #include "configuration.h"
35 namespace tidl {
37 std::size_t GetBinaryFileSize (const std::string &F);
38 bool ReadBinary (const std::string &F, char* buffer, int size);
39 bool CompareFiles (const std::string &F1, const std::string &F2);
40 bool CompareFrames(const std::string &F1, const std::string &F2,
41 int numFrames, int width, int height);
43 class TimeStamp
44 {
45 public:
46 enum EventKind { EOP_PFSA_START=0, EOP_PFSA_END,
47 EOP_PFW_START, EOP_PFW_END,
48 EOP_RAN_START, EOP_RAN_END,
49 EO1_PFSA_START, EO1_PFSA_END,
50 EO1_PFW_START, EO1_PFW_END,
51 EO2_PFSA_START, EO2_PFSA_END,
52 EO2_PFW_START, EO2_PFW_END,
53 NUM_EVENTS };
54 struct Entry
55 {
56 unsigned int eo1_type;
57 unsigned int eo1_id;
58 unsigned int eo2_type;
59 unsigned int eo2_id;
60 unsigned long long frame_idx;
61 unsigned long long timestamp[EventKind::NUM_EVENTS];
62 };
65 TimeStamp(const std::string& file, int num_entries);
66 ~TimeStamp();
67 void Update(int frame_idx, EventKind k, int type=0, int id=0);
68 void Zero (int frame_idx, EventKind k);
70 TimeStamp(const TimeStamp&) = delete;
71 TimeStamp& operator=(const TimeStamp&) = delete;
73 private:
74 Entry* entries_m;
75 const int num_entries_m;
76 const std::string file_m;
77 };
80 void RecordEvent(int frame_idx, TimeStamp::EventKind k,
81 int eo_type=0, int eo_id=0);
83 void ResetEvent(int frame_idx, TimeStamp::EventKind k);
84 } // namespace tidl