1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * @file rdtsc_buckets.h
25 * @brief declaration for rdtsc buckets.
29 ******************************************************************************/
42 BUCKET
* pParent
{nullptr};
43 std::vector
<BUCKET
> children
;
48 // name of bucket, used in reports
51 // description of bucket, used in threadviz
52 std::string description
;
54 // enable for threadviz dumping
57 // threadviz color of bucket, in RGBA8_UNORM format
64 // name of thread, used in reports
67 // id for this thread, assigned by the thread manager
70 // root of the bucket hierarchy for this thread
73 // currently executing bucket somewhere in the hierarchy
74 BUCKET
* pCurrent
{nullptr};
76 // currently executing hierarchy level
79 // threadviz file object
80 FILE* vizFile
{nullptr};
84 BUCKET_THREAD(const BUCKET_THREAD
& that
)
90 vizFile
= that
.vizFile
;
101 struct VIZ_START_DATA
114 inline void Serialize(FILE* f
, const VIZ_START_DATA
& data
)
116 fwrite(&data
, sizeof(VIZ_START_DATA
), 1, f
);
119 inline void Deserialize(FILE* f
, VIZ_START_DATA
& data
)
121 fread(&data
, sizeof(VIZ_START_DATA
), 1, f
);
122 assert(data
.type
== VIZ_START
);
125 inline void Serialize(FILE* f
, const VIZ_STOP_DATA
& data
)
127 fwrite(&data
, sizeof(VIZ_STOP_DATA
), 1, f
);
130 inline void Deserialize(FILE* f
, VIZ_STOP_DATA
& data
)
132 fread(&data
, sizeof(VIZ_STOP_DATA
), 1, f
);
133 assert(data
.type
== VIZ_STOP
);
136 inline void Serialize(FILE* f
, const std::string
& string
)
138 assert(string
.size() <= 256);
140 uint8_t length
= (uint8_t)string
.size();
141 fwrite(&length
, sizeof(length
), 1, f
);
142 fwrite(string
.c_str(), string
.size(), 1, f
);
145 inline void Deserialize(FILE* f
, std::string
& string
)
149 fread(&length
, sizeof(length
), 1, f
);
150 fread(cstr
, length
, 1, f
);
155 inline void Serialize(FILE* f
, const BUCKET_DESC
& desc
)
157 Serialize(f
, desc
.name
);
158 Serialize(f
, desc
.description
);
159 fwrite(&desc
.enableThreadViz
, sizeof(desc
.enableThreadViz
), 1, f
);
160 fwrite(&desc
.color
, sizeof(desc
.color
), 1, f
);
163 inline void Deserialize(FILE* f
, BUCKET_DESC
& desc
)
165 Deserialize(f
, desc
.name
);
166 Deserialize(f
, desc
.description
);
167 fread(&desc
.enableThreadViz
, sizeof(desc
.enableThreadViz
), 1, f
);
168 fread(&desc
.color
, sizeof(desc
.color
), 1, f
);