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"
34 #include "tidl_create_params.h"
36 namespace tidl {
38 std::size_t GetBinaryFileSize (const std::string &F);
39 bool ReadBinary (const std::string &F, char* buffer, int size);
40 bool ReadNetworkBinary (const std::string &F, char* buffer);
41 void ConvertFromNetwork_1_2(sTIDL_Network_t *new_net,
42 sTIDL_1_2_Network_t *old_net);
43 bool CompareFiles (const std::string &F1, const std::string &F2);
44 bool CompareFrames(const std::string &F1, const std::string &F2,
45 int numFrames, int width, int height);
47 class TimeStamp
48 {
49 public:
50 enum EventKind { EOP_PFSA_START=0, EOP_PFSA_END,
51 EOP_PFW_START, EOP_PFW_END,
52 EOP_RAN_START, EOP_RAN_END,
53 EO1_PFSA_START, EO1_PFSA_END,
54 EO1_PFW_START, EO1_PFW_END,
55 EO2_PFSA_START, EO2_PFSA_END,
56 EO2_PFW_START, EO2_PFW_END,
57 NUM_EVENTS };
58 struct Entry
59 {
60 unsigned int eo1_type;
61 unsigned int eo1_id;
62 unsigned int eo2_type;
63 unsigned int eo2_id;
64 unsigned long long frame_idx;
65 unsigned long long timestamp[EventKind::NUM_EVENTS];
66 };
69 TimeStamp(const std::string& file, int num_entries);
70 ~TimeStamp();
71 void Update(int frame_idx, EventKind k, int type=0, int id=0);
72 void Zero (int frame_idx, EventKind k);
74 TimeStamp(const TimeStamp&) = delete;
75 TimeStamp& operator=(const TimeStamp&) = delete;
77 private:
78 Entry* entries_m;
79 const int num_entries_m;
80 const std::string file_m;
81 };
84 void RecordEvent(int frame_idx, TimeStamp::EventKind k,
85 int eo_type=0, int eo_id=0);
87 void ResetEvent(int frame_idx, TimeStamp::EventKind k);
88 } // namespace tidl