|
43 | 43 | /* See header for documentation. */ |
44 | 44 | void LayerConfig::parseSamplingOptions(const json& config) |
45 | 45 | { |
46 | | - // Decode top level options |
47 | | - std::string rawMode = config.at("sample_mode"); |
| 46 | + // Decode frame selection mode |
| 47 | + std::string rawFrameMode = config.at("frame_mode"); |
48 | 48 |
|
49 | | - if (rawMode == "disabled") |
| 49 | + if (rawFrameMode == "disabled") |
50 | 50 | { |
51 | | - mode = MODE_DISABLED; |
| 51 | + frameMode = FRAME_SELECTION_DISABLED; |
52 | 52 | } |
53 | | - else if (rawMode == "periodic_frame") |
| 53 | + else if (rawFrameMode == "periodic") |
54 | 54 | { |
55 | | - mode = MODE_PERIODIC_FRAME; |
| 55 | + frameMode = FRAME_SELECTION_PERIODIC; |
56 | 56 | periodicFrame = config.at("periodic_frame"); |
57 | 57 | periodicMinFrame = config.at("periodic_min_frame"); |
58 | 58 | } |
59 | | - else if (rawMode == "frame_list") |
| 59 | + else if (rawFrameMode == "list") |
60 | 60 | { |
61 | | - mode = MODE_FRAME_LIST; |
| 61 | + frameMode = FRAME_SELECTION_LIST; |
62 | 62 | specificFrames = config.at("frame_list").get<std::vector<uint64_t>>(); |
63 | 63 | } |
64 | 64 | else |
65 | 65 | { |
66 | | - LAYER_ERR("Unknown counter sample_mode: %s", rawMode.c_str()); |
67 | | - rawMode = "disabled"; |
| 66 | + LAYER_ERR("Unknown frame_mode: %s", rawFrameMode.c_str()); |
| 67 | + frameMode = FRAME_SELECTION_DISABLED; |
| 68 | + rawFrameMode = "disabled"; |
| 69 | + } |
| 70 | + |
| 71 | + // Decode counter sampling mode |
| 72 | + std::string rawSampleMode = config.at("sample_mode"); |
| 73 | + |
| 74 | + if (rawSampleMode == "disabled") |
| 75 | + { |
| 76 | + samplingMode = COUNTER_SAMPLING_DISABLED; |
| 77 | + } |
| 78 | + else if (rawSampleMode == "frame") |
| 79 | + { |
| 80 | + samplingMode = COUNTER_SAMPLING_FRAMES; |
| 81 | + } |
| 82 | + else if (rawSampleMode == "workload") |
| 83 | + { |
| 84 | + samplingMode = COUNTER_SAMPLING_WORKLOADS; |
| 85 | + } |
| 86 | + else |
| 87 | + { |
| 88 | + LAYER_ERR("Unknown sample_mode: %s", rawSampleMode.c_str()); |
| 89 | + samplingMode = COUNTER_SAMPLING_DISABLED; |
| 90 | + rawSampleMode = "disabled"; |
68 | 91 | } |
69 | 92 |
|
70 | 93 | LAYER_LOG("Layer sampling configuration"); |
71 | 94 | LAYER_LOG("============================"); |
72 | | - LAYER_LOG(" - Sample mode: %s", rawMode.c_str()); |
| 95 | + LAYER_LOG(" - Frame selection mode: %s", rawFrameMode.c_str()); |
73 | 96 |
|
74 | | - if (mode == MODE_PERIODIC_FRAME) |
| 97 | + if (frameMode == FRAME_SELECTION_PERIODIC) |
75 | 98 | { |
76 | 99 | LAYER_LOG(" - Frame period: %" PRIu64, periodicFrame); |
77 | 100 | LAYER_LOG(" - Minimum frame: %" PRIu64, periodicMinFrame); |
78 | 101 | } |
79 | | - else if (mode == MODE_FRAME_LIST) |
| 102 | + else if (frameMode == FRAME_SELECTION_LIST) |
80 | 103 | { |
81 | 104 | std::stringstream result; |
82 | 105 | std::copy(specificFrames.begin(), specificFrames.end(), std::ostream_iterator<uint64_t>(result, " ")); |
83 | 106 | LAYER_LOG(" - Frames: %s", result.str().c_str()); |
84 | 107 | } |
| 108 | + |
| 109 | + LAYER_LOG(" - Counter sampling mode: %s", rawSampleMode.c_str()); |
85 | 110 | } |
86 | 111 |
|
87 | 112 | /* See header for documentation. */ |
@@ -131,18 +156,36 @@ LayerConfig::LayerConfig() |
131 | 156 | bool LayerConfig::isFrameOfInterest( |
132 | 157 | uint64_t frameID |
133 | 158 | ) const { |
134 | | - switch(mode) |
| 159 | + switch(frameMode) |
135 | 160 | { |
136 | | - case MODE_DISABLED: |
| 161 | + case FRAME_SELECTION_DISABLED: |
137 | 162 | return false; |
138 | | - case MODE_PERIODIC_FRAME: |
| 163 | + case FRAME_SELECTION_PERIODIC: |
139 | 164 | return (frameID >= periodicMinFrame) && |
140 | 165 | ((frameID % periodicFrame) == 0); |
141 | | - case MODE_FRAME_LIST: |
| 166 | + case FRAME_SELECTION_LIST: |
142 | 167 | return isIn(frameID, specificFrames); |
143 | 168 | } |
144 | 169 |
|
145 | 170 | // Should never reach here |
146 | 171 | return false; |
147 | 172 | } |
148 | 173 |
|
| 174 | +/* See header for documentation. */ |
| 175 | +bool LayerConfig::isSamplingWorkloads() const { |
| 176 | + return frameMode != FRAME_SELECTION_DISABLED && |
| 177 | + samplingMode == COUNTER_SAMPLING_WORKLOADS; |
| 178 | +} |
| 179 | + |
| 180 | +/* See header for documentation. */ |
| 181 | +bool LayerConfig::isSamplingFrames() const { |
| 182 | + return frameMode != FRAME_SELECTION_DISABLED && |
| 183 | + samplingMode == COUNTER_SAMPLING_FRAMES; |
| 184 | +} |
| 185 | + |
| 186 | +/* See header for documentation. */ |
| 187 | +bool LayerConfig::isSamplingAny() const { |
| 188 | + return frameMode != FRAME_SELECTION_DISABLED && |
| 189 | + samplingMode != COUNTER_SAMPLING_DISABLED; |
| 190 | +} |
| 191 | + |
0 commit comments