xaiefal
Loading...
Searching...
No Matches
xaiefal-perf.hpp
Go to the documentation of this file.
1// Copyright(C) 2020 - 2021 by Xilinx, Inc. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4#include <fstream>
5#include <functional>
6#include <map>
7#include <string.h>
8#include <vector>
9#include <xaiengine.h>
10
11#include <xaiefal/rsc/xaiefal-bc.hpp>
12#include <xaiefal/rsc/xaiefal-rsc-base.hpp>
13#include <xaiefal/rsc/xaiefal-rscmgr.hpp>
14
15#pragma once
16
17#define NUM_LATENCY_READS 4U
18
19namespace xaiefal {
33 public:
34 XAiePerfCounter() = delete;
35 XAiePerfCounter(std::shared_ptr<XAieDevHandle> DevHd,
36 XAie_LocType Loc, XAie_ModuleType Mod,
37 bool CrossM = false, uint32_t Threshold = 0):
39 CrossMod(CrossM) {
40 StartMod = Mod;
41 StopMod = Mod;
42 RstMod = Mod;
43 RstEvent = XAIE_EVENT_NONE_CORE;
44 State.Initialized = 1;
45 EventVal = Threshold;
46 }
48 XAie_LocType Loc, XAie_ModuleType Mod,
49 bool CrossM = false):
50 XAiePerfCounter(Dev.getDevHandle(), Loc, Mod, CrossM) {}
52 if (State.Reserved == 1) {
53 if (StartMod != vRscs[0].Mod) {
54 delete StartBC;
55 }
56 if (StopMod != vRscs[0].Mod) {
57 delete StopBC;
58 }
59 if (RstEvent != XAIE_EVENT_NONE_CORE &&
60 RstMod != vRscs[0].Mod) {
61 delete RstBC;
62 }
63 }
64 }
65
77 AieRC initialize(XAie_ModuleType StartM, XAie_Events StartE,
78 XAie_ModuleType StopM, XAie_Events StopE,
79 XAie_ModuleType RstM = XAIE_CORE_MOD, XAie_Events RstE = XAIE_EVENT_NONE_CORE) {
80 AieRC RC;
81
82 if (State.Reserved == 1) {
83 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
84 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
85 " Expect Mod= " << Mod << " resource reserved." << std::endl;
86 return XAIE_ERR;
87 } else {
88 uint16_t HwEvent;
89
90 RC = XAie_EventLogicalToPhysicalConv(dev(), Loc,
91 StartM, StartE, &HwEvent);
92 if (RC == XAIE_OK) {
93 RC = XAie_EventLogicalToPhysicalConv(dev(), Loc,
94 StopM, StopE, &HwEvent);
95 }
96 if (RC == XAIE_OK && RstE != XAIE_EVENT_NONE_CORE) {
97 RC = XAie_EventLogicalToPhysicalConv(dev(), Loc,
98 RstM, RstE, &HwEvent);
99 }
100 if (RC == XAIE_OK) {
101 StartEvent = StartE;
102 StopEvent = StopE;
103 RstEvent = RstE;
104 StartMod = StartM;
105 StopMod = StopM;
106 if (RstE != XAIE_EVENT_NONE_CORE) {
107 RstMod = RstM;
108 }
109 State.Initialized = 1;
110 State.Configured = 1;
111 } else {
112 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
113 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
114 " Expect Mod= " << Mod <<
115 " StartEvent=" <<StartM << "|" << StartE << " (" <<
116 XAie_EventGetString(StartE) << ") " <<
117 " StopEvent=" <<StopM << "|" << StopE << " (" <<
118 XAie_EventGetString(StopE) << ") " <<
119 " RstEvent=" <<RstM << "|" << RstE << " (" <<
120 XAie_EventGetString(RstE) << ") " <<
121 std::endl;
122 }
123 }
124 return RC;
125 }
126
133 {
134 return CrossMod;
135 }
136
145 AieRC changeRstEvent(XAie_ModuleType Module, XAie_Events Event) {
146 AieRC RC;
147
148 if (State.Running == 1) {
149 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
150 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
151 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
152 " resource is in use" << std::endl;
153 RC = XAIE_ERR;
154 } else if (State.Reserved == 1 && Module != RstMod) {
155 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
156 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
157 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
158 " resource is reserved, event module type cannot change." <<
159 std::endl;
160 RC = XAIE_INVALID_ARGS;
161 } else {
162 uint16_t HwEvent;
163
164 RC = XAie_EventLogicalToPhysicalConv(dev(),
165 Loc, Module, Event, &HwEvent);
166 if (RC == XAIE_OK) {
167 RstEvent = Event;
168 RstMod = Module;
169 }
170 }
171 return RC;
172 }
173
181 AieRC changeThreshold(uint32_t Val) {
182 AieRC RC;
183
184 if (State.Running == 1) {
185 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
186 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
187 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
188 " resource is in use." << std::endl;
189 RC = XAIE_ERR;
190 } else {
191 EventVal = Val;
192 RC = XAIE_OK;
193 }
194 return RC;
195 }
196
206 AieRC changeStartEvent(XAie_ModuleType Module, XAie_Events Event) {
207 AieRC RC;
208
209 if (State.Running == 1) {
210 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
211 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
212 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
213 " resource is in use." << std::endl;
214 RC = XAIE_ERR;
215 } else if (State.Reserved == 1 && Module != StartMod) {
216 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
217 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
218 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
219 " resource is reserved, event module type cannot change." <<
220 std::endl;
221 RC = XAIE_INVALID_ARGS;
222 } else {
223 uint16_t HwEvent;
224
225 RC = XAie_EventLogicalToPhysicalConv(dev(), Loc,
226 Module, Event, &HwEvent);
227 if (RC == XAIE_OK) {
228 StartEvent = Event;
229 StartMod = Module;
230 }
231 }
232 return RC;
233 }
234
243 AieRC changeStopEvent(XAie_ModuleType Module, XAie_Events Event) {
244 AieRC RC;
245
246 if (State.Running == 1) {
247 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
248 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
249 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
250 " resource is in use." << std::endl;
251 RC = XAIE_ERR;
252 } else if (State.Reserved == 1 && Module != StopMod) {
253 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
254 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
255 " Expect Mod= " << Mod << " Actual Counter Mod=" << (int)vRscs[0].Mod <<
256 " resource is reserved, event module type cannot change." <<
257 std::endl;
258 RC = XAIE_INVALID_ARGS;
259 } else {
260 uint16_t HwEvent;
261
262 RC = XAie_EventLogicalToPhysicalConv(dev(), Loc,
263 Module, Event, &HwEvent);
264 if (RC == XAIE_OK) {
265 StopEvent = Event;
266 StopMod = Module;
267 }
268 }
269 return RC;
270 }
271
278 AieRC readResult(uint32_t &Result) {
279 AieRC RC;
280
281 if (State.Running == 0) {
282 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
283 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
284 " Expect Mod= " << Mod <<
285 " resource not in use." << std::endl;
286 RC = XAIE_ERR;
287 } else {
288 RC = XAie_PerfCounterGet(dev(), Loc, vRscs[0].Mod,
289 vRscs[0].RscId, &Result);
290 }
291 return RC;
292 }
293
300 AieRC getCounterEvent(XAie_ModuleType &Module, XAie_Events &Event) const {
301 AieRC RC;
302
303 if (State.Reserved == 0) {
304 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
305 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
306 " Expect Mod= " << Mod <<
307 " resource not allocated." << std::endl;
308 RC = XAIE_ERR;
309 } else {
310 Module = vRscs[0].Mod;
311 XAie_PerfCounterGetEventBase(AieHd->dev(), Loc, Module, &Event);
312 Event = static_cast<XAie_Events>(static_cast<uint32_t>(Event) + vRscs[0].RscId);
313 RC = XAIE_OK;
314 }
315
316 return RC;
317 }
318 XAieRscStat getRscStat(const std::string &GName) const {
319 XAieRscStat RscStat(GName);
320 (void) GName;
321
323 if (CrossMod) {
324 return AieHd->getRscGroup(GName).getRscStat(Loc,
325 getRscType());
326 } else {
327 return AieHd->getRscGroup(GName).getRscStat(Loc,
328 Mod, getRscType());
329 }
330 } else {
331 return AieHd->getRscGroup(GName).getRscStat(Loc,
333 }
334 }
335 protected:
336 XAie_Events StartEvent;
337 XAie_Events StopEvent;
338 XAie_Events RstEvent;
342 uint32_t EventVal;
343 bool CrossMod;
348 private:
349 AieRC _reserve() {
350 AieRC RC;
351 uint32_t TType = XAie_GetTileTypefromLoc(dev(), Loc);
352 XAieUserRsc Rsc;
353
354 Rsc.Loc = Loc;
355 Rsc.Mod = Mod;
356 Rsc.RscType = Type;
357 Rsc.RscId = preferredId;
358 vRscs.push_back(Rsc);
359 RC = AieHd->rscMgr()->request(*this);
360 if (RC != XAIE_OK && preferredId == XAIE_RSC_ID_ANY) {
361 if (TType == XAIEGBL_TILE_TYPE_AIETILE && CrossMod) {
363
364 if (Mod == XAIE_CORE_MOD) {
365 lM = XAIE_MEM_MOD;
366 } else {
367 lM = XAIE_CORE_MOD;
368 }
369 vRscs[0].Mod = lM;
370 RC = AieHd->rscMgr()->request(*this);
371 }
372 }
373 if (RC == XAIE_OK && TType == XAIEGBL_TILE_TYPE_AIETILE) {
374 std::vector<XAie_LocType> vL;
375
376 vL.push_back(Loc);
377 if (StartMod != vRscs[0].Mod) {
378 StartBC = new XAieBroadcast(AieHd, vL,
379 StartMod, vRscs[0].Mod);
380 RC = StartBC->reserve();
381 if (RC != XAIE_OK) {
382 delete StartBC;
383 }
384 }
385 if (RC == XAIE_OK && StopMod != vRscs[0].Mod) {
386 StopBC = new XAieBroadcast(AieHd, vL,
387 StartMod, vRscs[0].Mod);
388 RC = StopBC->reserve();
389 if (RC != XAIE_OK) {
390 delete StopBC;
391 if (StartMod != vRscs[0].Mod) {
392 StartBC->release();
393 delete StartBC;
394 }
395 }
396 }
397 if (RC == XAIE_OK && RstEvent != XAIE_EVENT_NONE_CORE &&
398 RstMod != vRscs[0].Mod) {
399 RstBC = new XAieBroadcast(AieHd, vL,
400 StartMod, vRscs[0].Mod);
401 RC = RstBC->reserve();
402 if (RC != XAIE_OK) {
403 delete RstBC;
404 if (StartMod != vRscs[0].Mod) {
405 StartBC->release();
406 delete StartBC;
407 }
408 if (StopMod != vRscs[0].Mod) {
409 StopBC->release();
410 delete StopBC;
411 }
412 }
413 }
414 if (RC != XAIE_OK) {
415 AieHd->rscMgr()->release(*this);
416 vRscs.clear();
417 }
418 }
419 if (RC != XAIE_OK) {
420 Logger::log(LogLevel::FAL_WARN) << "perfcount " << __func__ << " (" <<
421 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
422 " Expect Mod= " << Mod << " resource not available.\n";
423 vRscs.clear();
424 } else {
425 reservedId = vRscs[0].RscId;
426 RC = _reserveAppend();
427 }
428 return RC;
429 }
430 AieRC _release() {
431 AieRC RC;
432
433 if (StartMod != vRscs[0].Mod) {
434 StartBC->release();
435 delete StartBC;
436 }
437 if (StopMod != vRscs[0].Mod) {
438 StopBC->release();
439 delete StopBC;
440 }
441 if (RstEvent != XAIE_EVENT_NONE_CORE && RstMod != vRscs[0].Mod) {
442 RstBC->release();
443 delete RstBC;
444 }
445 _releaseAppend();
446
447 RC = AieHd->rscMgr()->release(*this);
448 vRscs.clear();
449 return RC;
450 }
451 AieRC _start() {
452 AieRC RC;
453
454 RC = _startPrepend();
455 if (RC == XAIE_OK) {
456 XAie_Events lStartE = StartEvent;
457 XAie_Events lStopE = StopEvent;
458 XAie_Events lRstE = RstEvent;
459
460 if(EventVal != 0) {
461 RC = XAie_PerfCounterEventValueSet(dev(), Loc, vRscs[0].Mod,
462 vRscs[0].RscId, EventVal);
463 }
464
465 if (RC == XAIE_OK && StartMod != vRscs[0].Mod) {
466 StartBC->getEvent(Loc, vRscs[0].Mod, lStartE);
467 RC = XAie_EventBroadcast(dev(), Loc, StartMod, StartBC->getBc(), StartEvent);
468 if (RC == XAIE_OK) {
469 RC = StartBC->start();
470 }
471 }
472 if (RC == XAIE_OK && StopMod != vRscs[0].Mod) {
473 StopBC->getEvent(Loc, vRscs[0].Mod, lStopE);
474 XAie_EventBroadcast(dev(), Loc, StopMod, StopBC->getBc(), StopEvent);
475 if (RC == XAIE_OK) {
476 RC = StopBC->start();
477 }
478 }
479 if (RC == XAIE_OK && RstEvent != XAIE_EVENT_NONE_CORE && RstMod != vRscs[0].Mod) {
480 RstBC->getEvent(Loc, vRscs[0].Mod, lRstE);
481 RC = XAie_EventBroadcast(dev(), Loc, RstMod, RstBC->getBc(), RstEvent);
482 if (RC == XAIE_OK) {
483 RC = RstBC->start();
484 }
485 }
486 if (RC == XAIE_OK) {
487 RC = XAie_PerfCounterControlSet(dev(), Loc, vRscs[0].Mod,
488 vRscs[0].RscId, lStartE, lStopE);
489 }
490 if (RC == XAIE_OK && RstEvent != XAIE_EVENT_NONE_CORE) {
491 RC = XAie_PerfCounterResetControlSet(dev(), Loc,
492 vRscs[0].Mod, vRscs[0].RscId, lRstE);
493 }
494 }
495
496 if (RC != XAIE_OK) {
497 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
498 (int)Loc.Col << "," << (int)Loc.Row << ")" <<
499 " Expect Mod= " << Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
500 " failed to start." << std::endl;
501 }
502 return RC;
503 }
504 AieRC _stop() {
505 AieRC RC;
506 int iRC;
507
508 iRC = (int)XAie_PerfCounterControlReset(dev(), Loc, vRscs[0].Mod, vRscs[0].RscId);
509 iRC |= (int)XAie_PerfCounterResetControlReset(dev(), Loc, vRscs[0].Mod, vRscs[0].RscId);
510 iRC |= (int)XAie_PerfCounterReset(dev(), Loc, vRscs[0].Mod, vRscs[0].RscId);
511 iRC |= (int)XAie_PerfCounterEventValueReset(dev(), Loc, vRscs[0].Mod, vRscs[0].RscId);
512
513 if (StartMod != vRscs[0].Mod) {
514 StartBC->getEvent(Loc, vRscs[0].Mod, StartEvent);
515 iRC |= XAie_EventBroadcastReset(dev(), Loc,
516 StartMod, StartBC->getBc());
517 iRC |= StartBC->stop();
518 }
519 if (StopMod != vRscs[0].Mod) {
520 StopBC->getEvent(Loc, vRscs[0].Mod, StopEvent);
521 iRC |= XAie_EventBroadcastReset(dev(), Loc,
522 StopMod, StopBC->getBc());
523 iRC |= StopBC->stop();
524 }
525 if (RstEvent != XAIE_EVENT_NONE_CORE && RstMod != vRscs[0].Mod) {
526 RstBC->getEvent(Loc, vRscs[0].Mod, RstEvent);
527 iRC |= XAie_EventBroadcastReset(dev(), Loc,
528 RstMod, RstBC->getBc());
529 iRC |= RstBC->stop();
530 }
531 if (iRC != (int)XAIE_OK) {
532 Logger::log(LogLevel::FAL_ERROR) << "perfcount " << __func__ << " (" <<
533 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
534 " Expect Mod= " << (int)Mod << " Actual Mod=" << (int)vRscs[0].Mod <<
535 " failed to stop." << std::endl;
536 RC = XAIE_ERR;
537 } else {
538 RC = _stopAppend();
539 }
540 return RC;
541 }
542
543 void _getReservedRscs(std::vector<XAieUserRsc> &vOutRscs) const {
544 vOutRscs.push_back(vRscs[0]);
545 if (StartMod != vRscs[0].Mod) {
546 StartBC->getReservedRscs(vOutRscs);
547 }
548 if (StopMod != vRscs[0].Mod) {
549 StopBC->getReservedRscs(vOutRscs);
550 }
551 if (RstEvent != XAIE_EVENT_NONE_CORE && StopMod != vRscs[0].Mod) {
552 RstBC->getReservedRscs(vOutRscs);
553 }
554 _getRscsAppend(vOutRscs);
555 }
556 virtual AieRC _startPrepend() {
557 return XAIE_OK;
558 }
559 virtual AieRC _reserveAppend() {
560 return XAIE_OK;
561 }
562 virtual AieRC _stopAppend() {
563 return XAIE_OK;
564 }
565 virtual AieRC _releaseAppend() {
566 return XAIE_OK;
567 }
568 virtual void _getRscsAppend(std::vector<XAieUserRsc> &vOutRscs) const {
569 (void)vOutRscs;
570 }
571 };
572
578 public:
580 XAieMdmPerfCounter(std::shared_ptr<XAieDevHandle> DevHd,
581 XAie_LocType Loc):
582 XAieSingleTileRsc(DevHd, Loc, XAIE_PL_MOD, XAIE_MDMPERFCNT) {
583 uint8_t TType = dev()->DevOps->GetTTypefromLoc(dev(), Loc);
584
585 if(XAie_IsUcModulePresent(dev(), TType) == 0U)
586 throw std::invalid_argument("Tile does not contain uC MDM");
587
588 if (XAie_MdmPerfCounterGetConfig(dev(), Loc,
589 &NumEventCounters, &NumLatCounters,
590 &CounterWidth) != XAIE_OK)
591 throw std::invalid_argument("Failed to get MDM configuration");
592
593 if (CounterWidth != 32U)
594 throw std::invalid_argument("MDM configuration not supported");
595
596 CounterStatus.resize(NumEventCounters + NumLatCounters, 0U);
597 /* Latency Counters store 4 values */
598 CounterVals.resize(NumEventCounters + (NumLatCounters * 4U), 0U);
599 State.Initialized = 1;
600 }
602
609 AieRC initialize(std::vector<uint8_t>& UcEvents) {
610 AieRC RC;
611
612 if (State.Reserved == 1) {
613 Logger::log(LogLevel::FAL_ERROR) << "MDM perfcount " << __func__ << " (" <<
614 (uint32_t)Loc.Col << "," << (uint32_t)Loc.Row << ")" <<
615 " resource reserved." << std::endl;
616 return XAIE_ERR;
617 } else {
618 if (UcEvents.size() != NumLatCounters + NumEventCounters) {
619 Logger::log(LogLevel::FAL_ERROR) << "MDM perfcount "
620 << __func__ << " (" << (uint32_t)Loc.Col <<
621 "," << (uint32_t)Loc.Row << ")" <<
622 " invalid UcEvent size" << std::endl;
623 return XAIE_INVALID_ARGS;
624 }
625
626 RC = XAie_MdmPerfCounterControlSet(dev(), Loc,
627 UcEvents.data());
628 if (RC != XAIE_OK) {
630 "MDM perfcount " << __func__ <<
631 " (" << (uint32_t)Loc.Col << "," <<
632 (uint32_t)Loc.Row << ")" <<
633 " failed to set MDM counter event control." <<
634 std::endl;
635 return RC;
636 }
637 }
638 State.Configured = 1;
639 return RC;
640 }
641
649 AieRC readResult(std::vector<uint32_t>& Result) {
650 AieRC RC;
651
652 if (State.Running == 0) {
653 Logger::log(LogLevel::FAL_ERROR) << "MDM perfcount " <<
654 __func__ << " (" << (uint32_t)Loc.Col << "," <<
655 (uint32_t)Loc.Row << ")" <<
656 " resource not in use." << std::endl;
657 return XAIE_ERR;
658 } else {
659 /* Stop and Sample Counters */
660 RC = XAie_MdmPerfCounterStop(dev(), Loc, 1U);
661 if (RC != XAIE_OK) {
663 "MDM perfcount " << __func__ <<
664 " (" << (uint32_t)Loc.Col << "," <<
665 (uint32_t)Loc.Row << ")" <<
666 " failed to stop MDM counters" <<
667 std::endl;
668 return RC;
669 }
670
671 /* Read Status of counters */
672 RC = XAie_MdmPerfCounterGetStatus(dev(), Loc,
673 CounterStatus.data());
674 if (RC != XAIE_OK) {
676 "MDM perfcount " << __func__ <<
677 " (" << (uint32_t)Loc.Col << "," <<
678 (uint32_t)Loc.Row << ")" <<
679 " failed to read MDM counters status" <<
680 std::endl;
681 return RC;
682 }
683
684 for (uint8_t i = 0; i < CounterStatus.size(); i++) {
685 if (CounterStatus[i] & 0x1) {
687 "MDM perfcount " << __func__ <<
688 " (" << (uint32_t)Loc.Col << "," <<
689 (uint32_t)Loc.Row << ")" <<
690 "Counter " << i <<
691 " is full" << std::endl;
692 } else if (CounterStatus[i] & 0x2) {
694 "MDM perfcount " << __func__ <<
695 " (" << (uint32_t)Loc.Col << "," <<
696 (uint32_t)Loc.Row << ")" <<
697 "Counter " << i <<
698 " overflowed" << std::endl;
699 }
700 }
701
702 /* Read values of counters */
703 RC = XAie_MdmPerfCounterGet(dev(), Loc,
704 CounterVals.data());
705 if (RC != XAIE_OK) {
707 "MDM perfcount " << __func__ <<
708 " (" << (uint32_t)Loc.Col << "," <<
709 (uint32_t)Loc.Row << ")" <<
710 " failed to read MDM counters values" <<
711 std::endl;
712 return RC;
713 }
714
715 Result = CounterVals;
716 }
717
718 return RC;
719 }
720
721 private:
722 std::vector<uint8_t> CounterStatus;
723 std::vector<uint32_t> CounterVals;
724 u8 NumLatCounters, NumEventCounters, CounterWidth;
725
726 AieRC _reserve() {
727 AieRC RC;
728 XAieUserRsc Rsc;
729
730 Rsc.Loc = Loc;
731 Rsc.Mod = Mod;
732 Rsc.RscType = Type;
733 Rsc.RscId = 0U;
734 vRscs.push_back(Rsc);
735
736 RC = AieHd->rscMgr()->request(*this);
737 if (RC != XAIE_OK) {
738 Logger::log(LogLevel::FAL_WARN) << "MDM perfcount " <<
739 __func__ << " (" << (uint32_t)Loc.Col <<
740 "," << (uint32_t)Loc.Row << ")" <<
741 " resource not available.\n";
742 vRscs.clear();
743 } else {
744 reservedId = vRscs[0].RscId;
745 }
746 return RC;
747 }
748
749 AieRC _release() {
750 AieRC RC;
751
752 RC = AieHd->rscMgr()->release(*this);
753 vRscs.clear();
754 return RC;
755 }
756
757 AieRC _start() {
758 AieRC RC;
759
760 RC = XAie_MdmPerfCounterReset(dev(), Loc);
761 if (RC != XAIE_OK) {
762 Logger::log(LogLevel::FAL_ERROR) << __func__ << " " <<
763 typeid(*this).name() << " failed to clear MDM counters"
764 << std::endl;
765 return RC;
766 }
767
768 RC = XAie_MdmPerfCounterStart(dev(), Loc);
769 if (RC != XAIE_OK) {
770 Logger::log(LogLevel::FAL_ERROR) << __func__ << " " <<
771 typeid(*this).name() << " failed to start MDM counters"
772 << std::endl;
773 return RC;
774 }
775 return RC;
776 }
777
778 AieRC _stop() {
779 AieRC RC;
780
781 RC = XAie_MdmPerfCounterReset(dev(), Loc);
782 if (RC != XAIE_OK) {
783 Logger::log(LogLevel::FAL_ERROR) << __func__ << " " <<
784 typeid(*this).name() << " failed to clear MDM counters"
785 << std::endl;
786 return RC;
787 }
788
789 RC = XAie_MdmPerfCounterControlReset(dev(), Loc);
790 if (RC != XAIE_OK) {
791 Logger::log(LogLevel::FAL_ERROR) << __func__ << " " <<
792 typeid(*this).name() <<
793 " failed to clear MDM counter event control"
794 << std::endl;
795 return RC;
796 }
797 return RC;
798 }
799 }; /* class XAieMdmPerfCounter */
800}
static std::ostream & log(LogLevel Lvl=LogLevel::FAL_MAX)
Definition xaiefal-log.hpp:50
class for broadcast channel resource. A broadcast channel resource represents a broadcast channel bet...
Definition xaiefal-bc.hpp:29
AI engine device class. It defines AI engine device operations.
Definition xaiefal-base.hpp:259
~XAieMdmPerfCounter()
Definition xaiefal-perf.hpp:601
AieRC readResult(std::vector< uint32_t > &Result)
Definition xaiefal-perf.hpp:649
AieRC initialize(std::vector< uint8_t > &UcEvents)
Definition xaiefal-perf.hpp:609
XAieMdmPerfCounter(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc)
Definition xaiefal-perf.hpp:580
XAiePerfCounter(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod, bool CrossM=false)
Definition xaiefal-perf.hpp:47
AieRC readResult(uint32_t &Result)
Definition xaiefal-perf.hpp:278
XAie_Events RstEvent
Definition xaiefal-perf.hpp:338
XAieBroadcast * RstBC
Definition xaiefal-perf.hpp:347
bool CrossMod
Definition xaiefal-perf.hpp:343
AieRC getCounterEvent(XAie_ModuleType &Module, XAie_Events &Event) const
Definition xaiefal-perf.hpp:300
AieRC changeStartEvent(XAie_ModuleType Module, XAie_Events Event)
Definition xaiefal-perf.hpp:206
AieRC changeStopEvent(XAie_ModuleType Module, XAie_Events Event)
Definition xaiefal-perf.hpp:243
uint32_t EventVal
Definition xaiefal-perf.hpp:342
XAieBroadcast * StopBC
Definition xaiefal-perf.hpp:346
XAie_Events StopEvent
Definition xaiefal-perf.hpp:337
AieRC changeThreshold(uint32_t Val)
Definition xaiefal-perf.hpp:181
XAie_ModuleType StartMod
Definition xaiefal-perf.hpp:339
XAie_ModuleType StopMod
Definition xaiefal-perf.hpp:340
XAieRscStat getRscStat(const std::string &GName) const
Definition xaiefal-perf.hpp:318
XAiePerfCounter(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAie_ModuleType Mod, bool CrossM=false, uint32_t Threshold=0)
Definition xaiefal-perf.hpp:35
AieRC changeRstEvent(XAie_ModuleType Module, XAie_Events Event)
Definition xaiefal-perf.hpp:145
AieRC initialize(XAie_ModuleType StartM, XAie_Events StartE, XAie_ModuleType StopM, XAie_Events StopE, XAie_ModuleType RstM=XAIE_CORE_MOD, XAie_Events RstE=XAIE_EVENT_NONE_CORE)
Definition xaiefal-perf.hpp:77
bool getCrossMod()
Definition xaiefal-perf.hpp:132
XAieBroadcast * StartBC
Definition xaiefal-perf.hpp:345
~XAiePerfCounter()
Definition xaiefal-perf.hpp:51
XAie_ModuleType RstMod
Definition xaiefal-perf.hpp:341
XAie_Events StartEvent
Definition xaiefal-perf.hpp:336
XAieRscType Type
Definition xaiefal-rsc-base.hpp:399
std::vector< XAieUserRsc > vRscs
Definition xaiefal-rsc-base.hpp:403
XAieRscState State
Definition xaiefal-rsc-base.hpp:398
virtual XAieRscType getRscType() const
Definition xaiefal-rsc-base.hpp:351
XAie_DevInst * dev()
Definition xaiefal-rsc-base.hpp:373
AieRC release()
Definition xaiefal-rsc-base.hpp:188
uint32_t preferredId
Definition xaiefal-rsc-base.hpp:401
uint32_t reservedId
Definition xaiefal-rsc-base.hpp:402
std::shared_ptr< XAieDevHandle > AieHd
Definition xaiefal-rsc-base.hpp:400
XAie_LocType Loc
Definition xaiefal-rsc-base.hpp:594
XAie_ModuleType Mod
Definition xaiefal-rsc-base.hpp:595
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition license.txt:197
Definition xaiefal-base.hpp:23
@ XAIE_MDMPERFCNT
Definition xaiefal-rsc-group.hpp:36
@ XAIE_PERFCOUNT
Definition xaiefal-rsc-group.hpp:28
@ FAL_ERROR
Definition xaiefal-log.hpp:14
@ FAL_WARN
Definition xaiefal-log.hpp:13
struct of resource usage statistics
Definition xaiefal-rsc-group.hpp:66
Data needed to make a resource request.
Definition xaiefal-rsc-base.hpp:27
uint32_t RscId
Definition xaiefal-rsc-base.hpp:41
XAieRscType RscType
Definition xaiefal-rsc-base.hpp:37
XAie_LocType Loc
Definition xaiefal-rsc-base.hpp:29
XAie_ModuleType Mod
Definition xaiefal-rsc-base.hpp:33
#define XAIE_RSC_ID_ANY
Definition xaiefal-common.hpp:7