xaiefal
Loading...
Searching...
No Matches
xaiefal-base.hpp
Go to the documentation of this file.
1// Copyright(C) 2020 - 2021 by Xilinx, Inc. All rights reserved.
2// SPDX-License-Identifier: MIT
7
8#include <fstream>
9#include <functional>
10#include <map>
11#include <memory>
12#include <mutex>
13#include <stdexcept>
14#include <unordered_map>
15#include <vector>
16#include <xaiengine.h>
17#include <xaiefal/common/xaiefal-common.hpp>
18#include <xaiefal/common/xaiefal-log.hpp>
19#include <xaiefal/rsc/xaiefal-rsc-group.hpp>
20
21#pragma once
22
23namespace xaiefal {
24 class XAieDevHandle;
25 class XAieMod;
26 class XAieTile;
27 class XAieBroadcast;
28 class XAieComboEvent;
29 class XAieGroupEvent;
31 class XAieUserEvent;
32 class XAiePerfCounter;
34 class XAieTraceCntr;
35 class XAieTraceEvent;
36 class XAieActiveCycles;
37 class XAieStallCycles;
39 class XAiePCEvent;
40 class XAiePCRange;
45 class XAieRscMgr;
46
47# define XAIEDEV_DEFAULT_GROUP_STATIC "Static"
48# define XAIEDEV_DEFAULT_GROUP_AVAIL "Avail"
49# define XAIEDEV_DEFAULT_GROUP_GENERIC "Generic"
50
56 public:
58 XAieDevHdRscGroupWrapper(std::shared_ptr<XAieRscGroupBase> RGroup):
59 RscGroup(RGroup) {}
61
63 return RscGroup->getRscStat();
64 }
65 XAieRscStat getRscStat(XAie_LocType Loc) const {
66 return RscGroup->getRscStat(Loc);
67 }
68 XAieRscStat getRscStat(XAie_LocType Loc, XAieRscType RscType) const {
69 return RscGroup->getRscStat(Loc, RscType);
70 }
71 XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod) const {
72 return RscGroup->getRscStat(Loc, Mod);
73 }
74 XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod,
75 XAieRscType RscType) const {
76 return RscGroup->getRscStat(Loc, Mod, RscType);
77 }
78 XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod,
79 XAieRscType RscType, uint32_t RscId) const {
80 return RscGroup->getRscStat(Loc, Mod, RscType,
81 RscId);
82 }
83 XAieRscStat getRscStat(const std::vector<XAie_LocType> &vLocs,
84 XAieRscType RscType) const {
85 return RscGroup->getRscStat(vLocs, RscType);
86 }
87 XAieRscStat getRscStat(const std::vector<XAie_LocType> &vLocs,
88 XAieRscType RscType, uint32_t RscId) const {
89 return RscGroup->getRscStat(vLocs, RscType, RscId);
90 }
91
92 template<class RT>
93 AieRC addRsc(std::shared_ptr<RT> Rsc) {
94 return RscGroup->addRsc(Rsc);
95 }
96 private:
97 std::shared_ptr<XAieRscGroupBase> RscGroup ;
98 };
99
104 class XAieDevHandle: public std::enable_shared_from_this<XAieDevHandle>{
105 public:
106 XAieDevHandle(XAie_DevInst *DevPtr,
107 bool TurnOnFinishOnDestruct = false):
108 Dev(DevPtr),
109 FinishOnDestruct(TurnOnFinishOnDestruct) {
110 if (DevPtr == nullptr) {
111 throw std::invalid_argument("AI engine device is NULL");
112 }
113
114 XAieGroupEventMapCore[0] = XAIE_EVENT_GROUP_0_CORE;
115 XAieGroupEventMapCore[1] = XAIE_EVENT_GROUP_PC_EVENT_CORE;
116 XAieGroupEventMapCore[2] = XAIE_EVENT_GROUP_CORE_STALL_CORE;
117 XAieGroupEventMapCore[3] = XAIE_EVENT_GROUP_CORE_PROGRAM_FLOW_CORE;
118 XAieGroupEventMapCore[4] = XAIE_EVENT_GROUP_ERRORS_0_CORE;
119 XAieGroupEventMapCore[5] = XAIE_EVENT_GROUP_ERRORS_1_CORE;
120 XAieGroupEventMapCore[6] = XAIE_EVENT_GROUP_STREAM_SWITCH_CORE;
121 XAieGroupEventMapCore[7] = XAIE_EVENT_GROUP_BROADCAST_CORE;
122 XAieGroupEventMapCore[8] = XAIE_EVENT_GROUP_USER_EVENT_CORE;
123
124 XAieGroupEventMapMem[0] = XAIE_EVENT_GROUP_0_MEM;
125 XAieGroupEventMapMem[1] = XAIE_EVENT_GROUP_WATCHPOINT_MEM;
126 XAieGroupEventMapMem[2] = XAIE_EVENT_GROUP_DMA_ACTIVITY_MEM;
127 XAieGroupEventMapMem[3] = XAIE_EVENT_GROUP_LOCK_MEM;
128 XAieGroupEventMapMem[4] = XAIE_EVENT_GROUP_MEMORY_CONFLICT_MEM;
129 XAieGroupEventMapMem[5] = XAIE_EVENT_GROUP_ERRORS_MEM;
130 XAieGroupEventMapMem[6] = XAIE_EVENT_GROUP_BROADCAST_MEM;
131 XAieGroupEventMapMem[7] = XAIE_EVENT_GROUP_USER_EVENT_MEM;
132
133 XAieGroupEventMapPl[0] = XAIE_EVENT_GROUP_0_PL;
134 XAieGroupEventMapPl[1] = XAIE_EVENT_GROUP_DMA_ACTIVITY_PL;
135 XAieGroupEventMapPl[2] = XAIE_EVENT_GROUP_LOCK_PL;
136 XAieGroupEventMapPl[3] = XAIE_EVENT_GROUP_ERRORS_PL;
137 XAieGroupEventMapPl[4] = XAIE_EVENT_GROUP_STREAM_SWITCH_PL;
138 XAieGroupEventMapPl[5] = XAIE_EVENT_GROUP_BROADCAST_A_PL;
139 XAieGroupEventMapPl[6] = XAIE_EVENT_GROUP_USER_EVENT_PL;
140
141 XAieGroupEventMapMemTile[0] = XAIE_EVENT_GROUP_0_MEM_TILE;
142 XAieGroupEventMapMemTile[1] = XAIE_EVENT_GROUP_WATCHPOINT_MEM_TILE;
143 XAieGroupEventMapMemTile[2] = XAIE_EVENT_GROUP_DMA_ACTIVITY_MEM_TILE;
144 XAieGroupEventMapMemTile[3] = XAIE_EVENT_GROUP_LOCK_MEM_TILE;
145 XAieGroupEventMapMemTile[4] = XAIE_EVENT_GROUP_STREAM_SWITCH_MEM_TILE;
146 XAieGroupEventMapMemTile[5] = XAIE_EVENT_GROUP_MEMORY_CONFLICT_MEM_TILE;
147 XAieGroupEventMapMemTile[6] = XAIE_EVENT_GROUP_ERRORS_MEM_TILE;
148 XAieGroupEventMapMemTile[7] = XAIE_EVENT_GROUP_BROADCAST_MEM_TILE;
149 XAieGroupEventMapMemTile[8] = XAIE_EVENT_GROUP_USER_EVENT_MEM_TILE;
150 }
152 if (FinishOnDestruct) {
153 XAie_Finish(Dev);
154 }
155 }
156
161 XAie_DevInst *dev() {
162 return Dev;
163 }
164
169 std::shared_ptr<XAieDevHandle> getPtr() {
170 return shared_from_this();
171 }
172
177 std::shared_ptr<XAieRscMgr> rscMgr() {
178 return AieRscMgr;
179 }
180
185 template<class GT>
186 void createGroup(const std::string &GName) {
188 if (RscGroupsMap.find(GName) == RscGroupsMap.end()) {
189 _createGroup<GT>(GName);
190 }
191 }
192
201 XAieDevHdRscGroupWrapper &getRscGroup(const std::string &GName) {
203 if (RscGroupsMap.find(GName) == RscGroupsMap.end()) {
204 _createGroup<XAieRscGroupRuntime>(GName);
205 }
206 return RscGroupsMap[GName];
207 }
208
215 void removeRscGroup(const std::string &GName) {
217 auto it = RscGroupsMap.find(GName);
218
219 if (it != RscGroupsMap.end()) {
220 RscGroupsMap.erase(it);
221 }
222 }
223
229 AieRscMgr = std::make_shared<XAieRscMgr>(this);
230 }
231
236 private:
237 XAie_DevInst *Dev;
238 bool FinishOnDestruct;
239 std::shared_ptr<XAieRscMgr> AieRscMgr;
240 std::map <std::string, XAieDevHdRscGroupWrapper> RscGroupsMap;
242
243 private:
244 template<class GT>
245 void _createGroup(const std::string &GName) {
246 auto GPtr = std::make_shared<GT>(shared_from_this(),
247 GName);
248 RscGroupsMap[GName] = XAieDevHdRscGroupWrapper(GPtr);
249 Logger::log(LogLevel::FAL_INFO) << "Resource group " <<
250 GName << " is created." << std::endl;
251 }
252 };
253
259 class XAieDev {
260 public:
261 XAieDev() = delete;
262 XAieDev(XAie_DevInst *DevPtr,
263 bool TurnOnFinishOnDestruct = false);
265
272 XAieTile &tile(XAie_LocType Loc) {
273 if (Loc.Col > NumCols || Loc.Row > NumRows) {
274 throw std::invalid_argument("Invalid tile location");
275 }
276 return Tiles[Loc.Col * NumRows + Loc.Row];
277 }
278
286 XAieTile &tile(uint8_t Col, uint32_t Row) {
287 return tile(XAie_TileLoc(Col, Row));
288 }
289
295
296 XAie_DevInst *dev() {
297 return AieHandle->dev();
298 }
299
305 std::shared_ptr<XAieDevHandle> getDevHandle() {
306 return AieHandle->getPtr();
307 }
308
317 XAieDevHdRscGroupWrapper &getRscGroup(const std::string &GName) {
318 return AieHandle->getRscGroup(GName);
319 }
320
327 void removeRscGroup(const std::string &GName) {
328 AieHandle->removeRscGroup(GName);
329 }
330
337 XAieRscStat getRscStat(const std::string &GName) {
338 return AieHandle->getRscGroup(GName).getRscStat();
339 }
340
348 AieRC saveAllocatedRscsToFile(const std::string &File);
349
357 AieRC loadStaticRscsFromMem(const char *MetaData);
358
365 AieRC reserveEcc();
366
373 AieRC reserveErrorHandling();
374
375
392 std::shared_ptr<XAieBroadcast> broadcast(
393 std::vector<XAie_LocType> &vLocs, XAie_ModuleType StartM,
394 XAie_ModuleType EndM,
395 XAieDevHdRscGroupWrapper &RGroup) {
396 auto BC = std::make_shared<XAieBroadcast>(*this, vLocs,
397 StartM, EndM);
398 RGroup.addRsc(BC);
399 return BC;
400 }
401 std::shared_ptr<XAieBroadcast> broadcast(
402 std::vector<XAie_LocType> &vLocs, XAie_ModuleType StartM,
403 XAie_ModuleType EndM) {
405 AieHandle->getRscGroup("Generic");
406 return broadcast(vLocs, StartM, EndM, RGroup);
407 }
408
416 AieRC modToString(XAie_ModuleType Mod, std::string &MString) {
417 AieRC RC = XAIE_OK;
418
419 if (Mod == XAIE_CORE_MOD) {
420 MString = "core";
421 } else if (Mod == XAIE_MEM_MOD) {
422 MString = "memory";
423 } else if (Mod == XAIE_PL_MOD) {
424 MString = "shim";
425 } else {
426 RC = XAIE_INVALID_ARGS;
427 Logger::log(LogLevel::FAL_ERROR) << __func__ <<
428 "failed. invalid module type." <<
429 std::endl;
430 }
431 return RC;
432 }
433
440 AieRC stringToMod(const std::string &MString,
441 XAie_ModuleType &Mod) {
442 AieRC RC = XAIE_OK;
443
444 if (MString == "core") {
445 Mod = XAIE_CORE_MOD;
446 } else if (MString == "memory") {
447 Mod = XAIE_MEM_MOD;
448 } else if (MString == "shim") {
449 Mod = XAIE_PL_MOD;
450 } else {
451 RC = XAIE_INVALID_ARGS;
452 Logger::log(LogLevel::FAL_ERROR) << __func__ <<
453 "failed. invalid module string." << std::endl;
454 }
455 return RC;
456 }
457
458 private:
459 std::shared_ptr<XAieDevHandle> AieHandle;
460 uint32_t NumCols;
461 uint32_t NumRows;
462 std::vector<XAieTile> Tiles;
463 };
464
470 class XAieMod {
471 public:
473 XAieMod(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod):
474 AieHandle(Dev.getDevHandle()), Loc(Loc), Mod(Mod) {
475 if (XAie_CheckModule(AieHandle->dev(), Loc, Mod) !=
476 XAIE_OK) {
477 throw std::invalid_argument("Invalid module and tile");
478 }
479 AieHandle = Dev.getDevHandle();
480 TraceCntr = std::make_shared<XAieTraceCntr>(AieHandle,
481 Loc, Mod);
482 AieHandle->getRscGroup("Generic").addRsc(TraceCntr);
483 AieHandle->getRscGroup("Avail").addRsc(TraceCntr);
484 }
486
492 XAie_LocType loc() const {
493 return Loc;
494 }
495
502 return Mod;
503 }
504
512 XAieRscStat getRscStat(const std::string &GName) {
513 return AieHandle->getRscGroup(GName).getRscStat(Loc, Mod);
514 }
515
528 std::shared_ptr<XAiePerfCounter> perfCounter(
529 XAieDevHdRscGroupWrapper &RGroup) {
530 auto Rsc = std::make_shared<XAiePerfCounter>(AieHandle,
531 Loc, Mod);
532
533 RGroup.addRsc(Rsc);
534 return Rsc;
535 }
536 std::shared_ptr<XAiePerfCounter> perfCounter() {
538 AieHandle->getRscGroup("Generic");
539
540 return perfCounter(RGroup);
541 }
542
555 std::shared_ptr<XAieMdmPerfCounter> mdmPerfCounter(
556 XAieDevHdRscGroupWrapper &RGroup) {
557 auto Rsc = std::make_shared<XAieMdmPerfCounter>(AieHandle,
558 Loc);
559
560 RGroup.addRsc(Rsc);
561 return Rsc;
562 }
563 std::shared_ptr<XAieMdmPerfCounter> mdmPerfCounter() {
565 AieHandle->getRscGroup("Generic");
566
567 return mdmPerfCounter(RGroup);
568 }
569
581 std::shared_ptr<XAieTraceCntr> traceControl() {
582 return TraceCntr;
583 }
584
597 std::shared_ptr<XAieTraceEvent> traceEvent(
598 XAieDevHdRscGroupWrapper &RGroup) {
599 auto Rsc = std::make_shared<XAieTraceEvent>(AieHandle,
600 Loc, Mod, TraceCntr);
601
602 RGroup.addRsc(Rsc);
603 return Rsc;
604 }
605 std::shared_ptr<XAieTraceEvent> traceEvent() {
607 AieHandle->getRscGroup("Generic");
608
609 return traceEvent(RGroup);
610 }
611
612
625 std::shared_ptr<XAieActiveCycles> activeCycles(
626 XAieDevHdRscGroupWrapper &RGroup) {
627 auto Rsc = std::make_shared<XAieActiveCycles>(AieHandle,
628 Loc);
629 RGroup.addRsc(Rsc);
630 return Rsc;
631 }
632 std::shared_ptr<XAieActiveCycles> activeCycles() {
634 AieHandle->getRscGroup("Generic");
635
636 return activeCycles(RGroup);
637 }
638
651 std::shared_ptr<XAieStallCycles> stallCycles(
652 XAieDevHdRscGroupWrapper &RGroup) {
653 auto StallG = groupEvent(XAIE_EVENT_GROUP_CORE_STALL_CORE);
654 auto FlowG = groupEvent(XAIE_EVENT_GROUP_CORE_PROGRAM_FLOW_CORE);
655 auto Rsc = std::make_shared<XAieStallCycles>(AieHandle,
656 Loc, StallG, FlowG);
657 RGroup.addRsc(Rsc);
658 return Rsc;
659 }
660 std::shared_ptr<XAieStallCycles> stallCycles() {
662 AieHandle->getRscGroup("Generic");
663
664 return stallCycles(RGroup);
665 }
666
679 std::shared_ptr<XAieStallOccurrences> stallOccurrences(
680 XAieDevHdRscGroupWrapper &RGroup) {
681 auto StallG = groupEvent(XAIE_EVENT_GROUP_CORE_STALL_CORE);
682 auto Rsc = std::make_shared<XAieStallOccurrences>(AieHandle,
683 Loc, StallG);
684 RGroup.addRsc(Rsc);
685 return Rsc;
686 }
687 std::shared_ptr<XAieStallOccurrences> stallOccurrences() {
689 AieHandle->getRscGroup("Generic");
690
691 return stallOccurrences(RGroup);
692 }
693
705 std::shared_ptr<XAiePCEvent> pcEvent(
706 XAieDevHdRscGroupWrapper &RGroup) {
707 auto Rsc = std::make_shared<XAiePCEvent>(AieHandle, Loc);
708 RGroup.addRsc(Rsc);
709 return Rsc;
710 }
711 std::shared_ptr<XAiePCEvent> pcEvent() {
713 AieHandle->getRscGroup("Generic");
714
715 return pcEvent(RGroup);
716 }
717
729 std::shared_ptr<XAiePCRange> pcRange(
730 XAieDevHdRscGroupWrapper &RGroup) {
731 auto Rsc = std::make_shared<XAiePCRange>(AieHandle, Loc);
732 RGroup.addRsc(Rsc);
733 return Rsc;
734 }
735 std::shared_ptr<XAiePCRange> pcRange() {
737 AieHandle->getRscGroup("Generic");
738
739 return pcRange(RGroup);
740 }
741
754 std::shared_ptr<XAieComboEvent> comboEvent(
756 uint32_t ENum = 2) {
757 auto Rsc = std::make_shared<XAieComboEvent>(AieHandle,
758 Loc, Mod,
759 ENum);
760 RGroup.addRsc(Rsc);
761 return Rsc;
762 }
763 std::shared_ptr<XAieComboEvent> comboEvent(uint32_t ENum = 2) {
765 AieHandle->getRscGroup("Generic");
766
767 return comboEvent(RGroup, ENum);
768 }
769
782 std::shared_ptr<XAieGroupEventHandle> groupEvent(
784 XAie_Events Event) {
785 auto gEvent = GroupEvents.find(Event);
786 if (gEvent != GroupEvents.end()) {
787 return std::make_shared<XAieGroupEventHandle>(
788 AieHandle, GroupEvents[Event]);
789 }
790 auto gEPtr = std::make_shared<XAieGroupEvent>(AieHandle,
791 Loc, Mod, Event);
792 RGroup.addRsc(gEPtr);
793 GroupEvents.emplace(Event, gEPtr);
794 return std::make_shared<XAieGroupEventHandle>(AieHandle,
795 gEPtr);
796 }
797 std::shared_ptr<XAieGroupEventHandle> groupEvent(
798 XAie_Events Event) {
800 AieHandle->getRscGroup("Generic");
801
802 return groupEvent(RGroup, Event);
803 }
804
816 std::shared_ptr<XAieUserEvent> userEvent(
817 XAieDevHdRscGroupWrapper &RGroup) {
818 auto Rsc = std::make_shared<XAieUserEvent>(AieHandle,
819 Loc, Mod);
820 RGroup.addRsc(Rsc);
821 return Rsc;
822 }
823 std::shared_ptr<XAieUserEvent> userEvent() {
825 AieHandle->getRscGroup("Generic");
826
827 return userEvent(RGroup);
828 }
829 private:
830 std::shared_ptr<XAieDevHandle> AieHandle;
832 XAie_LocType Loc;
833 XAie_ModuleType Mod;
834 std::shared_ptr<XAieTraceCntr> TraceCntr;
835 std::map<XAie_Events, std::shared_ptr<XAieGroupEvent>> GroupEvents;
836 };
837
842 class XAieTile {
843 public:
845 XAieTile(XAieDev &Dev, XAie_LocType Loc):
846 AieHandle(Dev.getDevHandle()), Loc(Loc) {
847 uint32_t TType;
848
849 TType = XAie_GetTileTypefromLoc(Dev.dev(), Loc);
850
851 if (TType == XAIEGBL_TILE_TYPE_MAX) {
852 throw std::invalid_argument("Invalid tile");
853 }
854 if (TType == XAIEGBL_TILE_TYPE_AIETILE) {
855 Mods.push_back(XAieMod(Dev, Loc, XAIE_MEM_MOD));
856 Mods.push_back(XAieMod(Dev, Loc, XAIE_CORE_MOD));
857 } else {
858 if (TType == XAIEGBL_TILE_TYPE_SHIMPL ||
859 TType == XAIEGBL_TILE_TYPE_SHIMNOC) {
860 Mods.push_back(XAieMod(Dev, Loc, XAIE_PL_MOD));
861 } else {
862 Mods.push_back(XAieMod(Dev, Loc, XAIE_MEM_MOD));
863 }
864 }
865 AieHandle = Dev.getDevHandle();
866 }
868
874 XAie_LocType loc() const {
875 return Loc;
876 }
877
884 XAieMod &module (XAie_ModuleType Mod) {
885 if (XAie_CheckModule(AieHandle->dev(), Loc, Mod) !=
886 XAIE_OK) {
887 std::string str = "module " +
888 std::to_string(Mod) + " not in tile.";
889
891 }
892 if (Mod == XAIE_CORE_MOD) {
893 return Mods[1];
894 } else {
895 return Mods[0];
896 }
897 }
898
905 return module(XAIE_CORE_MOD);
906 }
907
914 return module(XAIE_MEM_MOD);
915 }
916
923 return module(XAIE_PL_MOD);
924 }
925
933 XAieRscStat getRscStat(const std::string &GName) {
934 return AieHandle->getRscGroup(GName).getRscStat(Loc);
935 }
936
950 std::shared_ptr<XAieBroadcast> broadcast(
951 XAieDevHdRscGroupWrapper &RGroup) {
952 std::vector<XAie_LocType> vL;
953 XAie_ModuleType StartM, EndM;
954
955 vL.push_back(Loc);
956 if (XAie_CheckModule(AieHandle->dev(), Loc, XAIE_CORE_MOD)
957 == XAIE_OK) {
958 StartM = XAIE_CORE_MOD;
959 EndM = XAIE_MEM_MOD;
960 } else if (XAie_CheckModule(AieHandle->dev(), Loc,
961 XAIE_PL_MOD) == XAIE_OK) {
962 StartM = XAIE_PL_MOD;
963 EndM = XAIE_PL_MOD;
964 } else {
965 StartM = XAIE_MEM_MOD;
966 EndM = XAIE_MEM_MOD;
967 }
968 auto BC = std::make_shared<XAieBroadcast>(AieHandle,
969 vL, StartM, EndM);
970 RGroup.addRsc(BC);
971
972 return BC;
973 }
974 std::shared_ptr<XAieBroadcast> broadcast() {
976 AieHandle->getRscGroup("Generic");
977
978 return broadcast(RGroup);
979 }
980
993 std::shared_ptr<XAiePerfCounter> perfCounter(
994 XAieDevHdRscGroupWrapper &RGroup) {
995 auto C = std::make_shared<XAiePerfCounter>(AieHandle,
996 Loc, Mods[0].mod(), true);
997 RGroup.addRsc(C);
998 return C;
999 }
1000 std::shared_ptr<XAiePerfCounter> perfCounter() {
1002 AieHandle->getRscGroup("Generic");
1003
1004 return perfCounter(RGroup);
1005 }
1006
1019 std::shared_ptr<XAieMdmPerfCounter> mdmPerfCounter(
1020 XAieDevHdRscGroupWrapper &RGroup) {
1021 auto C = std::make_shared<XAieMdmPerfCounter>(AieHandle,
1022 Loc);
1023 RGroup.addRsc(C);
1024 return C;
1025 }
1026 std::shared_ptr<XAieMdmPerfCounter> mdmPerfCounter() {
1028 AieHandle->getRscGroup("Generic");
1029
1030 return mdmPerfCounter(RGroup);
1031 }
1032
1045 std::shared_ptr<XAieStreamPortSelect> sswitchPort(
1046 XAieDevHdRscGroupWrapper &RGroup) {
1047 auto SS = std::make_shared<XAieStreamPortSelect>(
1048 AieHandle, Loc);
1049 RGroup.addRsc(SS);
1050 return SS;
1051 }
1052 std::shared_ptr<XAieStreamPortSelect> sswitchPort() {
1054 AieHandle->getRscGroup("Generic");
1055
1056 return sswitchPort(RGroup);
1057 }
1058
1059 private:
1060 std::shared_ptr<XAieDevHandle> AieHandle;
1062 XAie_LocType Loc;
1063 std::vector<XAieMod> Mods;
1064 };
1065
1066 inline XAieDev::XAieDev(XAie_DevInst *DevPtr,
1067 bool TurnOnFinishOnDestruct) {
1068
1069 AieHandle = std::make_shared<XAieDevHandle>(DevPtr,
1070 TurnOnFinishOnDestruct);
1071
1072 AieHandle->createGroup<XAieRscGroupAvail>("Avail");
1073 AieHandle->createGroup<XAieRscGroupStatic>("Static");
1074 AieHandle->createGroup<XAieRscGroupRuntime>("Generic");
1075
1076 NumCols = DevPtr->NumCols;
1077 NumRows = DevPtr->NumRows;
1078 for (uint32_t c = 0; c < NumCols; c++) {
1079 for (uint32_t r = 0; r < NumRows; r++) {
1080 Tiles.push_back(XAieTile(*this,
1081 XAie_TileLoc(c, r)));
1082 }
1083 }
1084 AieHandle->createRscMgr();
1085 }
1086
1098 static inline XAie_ModuleType XAieEstimateModFromEvent(XAie_Events Event)
1099 {
1100 XAie_ModuleType Module;
1101
1102 if (Event < XAIE_EVENT_NONE_MEM) {
1103 Module = XAIE_CORE_MOD;
1104 } else if (Event < XAIE_EVENT_NONE_PL ||
1105 (Event >= XAIE_EVENT_NONE_MEM_TILE &&
1106 Event <= XAIE_EVENT_USER_EVENT_1_MEM_TILE)) {
1107 Module = XAIE_MEM_MOD;
1108 } else {
1109 Module = XAIE_PL_MOD;
1110 }
1111 return Module;
1112 }
1113}
static std::ostream & log(LogLevel Lvl=LogLevel::FAL_MAX)
Definition xaiefal-log.hpp:50
Definition xaiefal-profile.hpp:14
class for broadcast channel resource. A broadcast channel resource represents a broadcast channel bet...
Definition xaiefal-bc.hpp:29
AI engine combo event resource class.
Definition xaiefal-events.hpp:20
AI engine low level device pointer handle.
Definition xaiefal-base.hpp:104
std::shared_ptr< XAieRscMgr > rscMgr()
Definition xaiefal-base.hpp:177
std::shared_ptr< XAieDevHandle > getPtr()
Definition xaiefal-base.hpp:169
void createGroup(const std::string &GName)
Definition xaiefal-base.hpp:186
uint32_t XAieGroupEventMapMemTile[9]
Definition xaiefal-base.hpp:235
XAieDevHandle(XAie_DevInst *DevPtr, bool TurnOnFinishOnDestruct=false)
Definition xaiefal-base.hpp:106
uint32_t XAieGroupEventMapMem[8]
Definition xaiefal-base.hpp:233
void createRscMgr()
Definition xaiefal-base.hpp:228
uint32_t XAieGroupEventMapCore[9]
Definition xaiefal-base.hpp:232
XAieDevHdRscGroupWrapper & getRscGroup(const std::string &GName)
Definition xaiefal-base.hpp:201
XAie_DevInst * dev()
Definition xaiefal-base.hpp:161
uint32_t XAieGroupEventMapPl[8]
Definition xaiefal-base.hpp:234
void removeRscGroup(const std::string &GName)
Definition xaiefal-base.hpp:215
~XAieDevHandle()
Definition xaiefal-base.hpp:151
AI engine device handle resource group wrapper.
Definition xaiefal-base.hpp:55
XAieRscStat getRscStat(XAie_LocType Loc, XAieRscType RscType) const
Definition xaiefal-base.hpp:68
XAieRscStat getRscStat() const
Definition xaiefal-base.hpp:62
XAieRscStat getRscStat(const std::vector< XAie_LocType > &vLocs, XAieRscType RscType) const
Definition xaiefal-base.hpp:83
XAieRscStat getRscStat(const std::vector< XAie_LocType > &vLocs, XAieRscType RscType, uint32_t RscId) const
Definition xaiefal-base.hpp:87
XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod, XAieRscType RscType) const
Definition xaiefal-base.hpp:74
XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod) const
Definition xaiefal-base.hpp:71
AieRC addRsc(std::shared_ptr< RT > Rsc)
Definition xaiefal-base.hpp:93
XAieRscStat getRscStat(XAie_LocType Loc, XAie_ModuleType Mod, XAieRscType RscType, uint32_t RscId) const
Definition xaiefal-base.hpp:78
XAieDevHdRscGroupWrapper(std::shared_ptr< XAieRscGroupBase > RGroup)
Definition xaiefal-base.hpp:58
XAieDevHdRscGroupWrapper()
Definition xaiefal-base.hpp:57
~XAieDevHdRscGroupWrapper()
Definition xaiefal-base.hpp:60
XAieRscStat getRscStat(XAie_LocType Loc) const
Definition xaiefal-base.hpp:65
AI engine device class. It defines AI engine device operations.
Definition xaiefal-base.hpp:259
~XAieDev()
Definition xaiefal-base.hpp:264
XAieRscStat getRscStat(const std::string &GName)
Definition xaiefal-base.hpp:337
AieRC reserveErrorHandling()
Definition xaiefal-rscmgr.hpp:456
void removeRscGroup(const std::string &GName)
Definition xaiefal-base.hpp:327
AieRC modToString(XAie_ModuleType Mod, std::string &MString)
Definition xaiefal-base.hpp:416
std::shared_ptr< XAieDevHandle > getDevHandle()
Definition xaiefal-base.hpp:305
XAieTile & tile(uint8_t Col, uint32_t Row)
Definition xaiefal-base.hpp:286
AieRC stringToMod(const std::string &MString, XAie_ModuleType &Mod)
Definition xaiefal-base.hpp:440
AieRC saveAllocatedRscsToFile(const std::string &File)
Definition xaiefal-rscmgr.hpp:425
AieRC reserveEcc()
Definition xaiefal-rscmgr.hpp:446
XAie_DevInst * dev()
Definition xaiefal-base.hpp:296
std::shared_ptr< XAieBroadcast > broadcast(std::vector< XAie_LocType > &vLocs, XAie_ModuleType StartM, XAie_ModuleType EndM)
Definition xaiefal-base.hpp:401
std::shared_ptr< XAieBroadcast > broadcast(std::vector< XAie_LocType > &vLocs, XAie_ModuleType StartM, XAie_ModuleType EndM, XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:392
XAieTile & tile(XAie_LocType Loc)
Definition xaiefal-base.hpp:272
AieRC loadStaticRscsFromMem(const char *MetaData)
Definition xaiefal-rscmgr.hpp:436
XAieDevHdRscGroupWrapper & getRscGroup(const std::string &GName)
Definition xaiefal-base.hpp:317
class for group event resource reference
Definition xaiefal-groupevent.hpp:344
class for group event resource
Definition xaiefal-groupevent.hpp:19
class for uC MDM Perfcounter resource.
Definition xaiefal-perf.hpp:577
AI enigne module. It defines AI engine module operations. such as get resource within a module.
Definition xaiefal-base.hpp:470
std::shared_ptr< XAieStallCycles > stallCycles()
Definition xaiefal-base.hpp:660
~XAieMod()
Definition xaiefal-base.hpp:485
std::shared_ptr< XAiePCEvent > pcEvent(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:705
std::shared_ptr< XAieComboEvent > comboEvent(XAieDevHdRscGroupWrapper &RGroup, uint32_t ENum=2)
Definition xaiefal-base.hpp:754
std::shared_ptr< XAieTraceCntr > traceControl()
Definition xaiefal-base.hpp:581
std::shared_ptr< XAiePCEvent > pcEvent()
Definition xaiefal-base.hpp:711
std::shared_ptr< XAieActiveCycles > activeCycles()
Definition xaiefal-base.hpp:632
XAieRscStat getRscStat(const std::string &GName)
Definition xaiefal-base.hpp:512
std::shared_ptr< XAieMdmPerfCounter > mdmPerfCounter(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:555
std::shared_ptr< XAieGroupEventHandle > groupEvent(XAie_Events Event)
Definition xaiefal-base.hpp:797
std::shared_ptr< XAiePCRange > pcRange(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:729
XAie_ModuleType mod() const
Definition xaiefal-base.hpp:501
std::shared_ptr< XAiePCRange > pcRange()
Definition xaiefal-base.hpp:735
XAieMod()
Definition xaiefal-base.hpp:472
std::shared_ptr< XAieActiveCycles > activeCycles(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:625
std::shared_ptr< XAiePerfCounter > perfCounter()
Definition xaiefal-base.hpp:536
std::shared_ptr< XAieGroupEventHandle > groupEvent(XAieDevHdRscGroupWrapper &RGroup, XAie_Events Event)
Definition xaiefal-base.hpp:782
std::shared_ptr< XAieTraceEvent > traceEvent(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:597
std::shared_ptr< XAieStallOccurrences > stallOccurrences(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:679
std::shared_ptr< XAieUserEvent > userEvent()
Definition xaiefal-base.hpp:823
std::shared_ptr< XAiePerfCounter > perfCounter(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:528
std::shared_ptr< XAieStallCycles > stallCycles(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:651
XAieMod(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod)
Definition xaiefal-base.hpp:473
std::shared_ptr< XAieComboEvent > comboEvent(uint32_t ENum=2)
Definition xaiefal-base.hpp:763
XAie_LocType loc() const
Definition xaiefal-base.hpp:492
std::shared_ptr< XAieStallOccurrences > stallOccurrences()
Definition xaiefal-base.hpp:687
std::shared_ptr< XAieMdmPerfCounter > mdmPerfCounter()
Definition xaiefal-base.hpp:563
std::shared_ptr< XAieUserEvent > userEvent(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:816
std::shared_ptr< XAieTraceEvent > traceEvent()
Definition xaiefal-base.hpp:605
AI engine PC event resource class.
Definition xaiefal-pc.hpp:20
AI engine PC addresses range resource class.
Definition xaiefal-pc.hpp:124
class for Perfcounter resource. Each perfcounter resources contains the resource ID of in a module of...
Definition xaiefal-perf.hpp:32
class to runtime resources functional group Each element in the group is a resource.
Definition xaiefal-rsc-group-impl.hpp:157
class to runtime resources functional group Each element in the group is a resource.
Definition xaiefal-rsc-group-impl.hpp:21
class to statically allocated resources group Each element in the group is a resource.
Definition xaiefal-rsc-group-impl.hpp:101
Resource Manager class.
Definition xaiefal-rscmgr.hpp:25
Definition xaiefal-profile.hpp:27
class for number of stall occurences
Definition xaiefal-profile.hpp:142
class for stream port select resource There are limited numter of ports events, in order to generate ...
Definition xaiefal-ss.hpp:22
AI enigne tile. It defines AI engine tile operations. such as get resource within a tile,...
Definition xaiefal-base.hpp:842
XAieMod & pl()
Definition xaiefal-base.hpp:922
XAieTile()
Definition xaiefal-base.hpp:844
std::shared_ptr< XAieStreamPortSelect > sswitchPort()
Definition xaiefal-base.hpp:1052
std::shared_ptr< XAiePerfCounter > perfCounter()
Definition xaiefal-base.hpp:1000
std::shared_ptr< XAieStreamPortSelect > sswitchPort(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:1045
XAieMod & mem()
Definition xaiefal-base.hpp:913
XAieMod & core()
Definition xaiefal-base.hpp:904
XAieRscStat getRscStat(const std::string &GName)
Definition xaiefal-base.hpp:933
std::shared_ptr< XAieMdmPerfCounter > mdmPerfCounter()
Definition xaiefal-base.hpp:1026
std::shared_ptr< XAiePerfCounter > perfCounter(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:993
XAieTile(XAieDev &Dev, XAie_LocType Loc)
Definition xaiefal-base.hpp:845
~XAieTile()
Definition xaiefal-base.hpp:867
throw std::invalid_argument(str)
std::shared_ptr< XAieMdmPerfCounter > mdmPerfCounter(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:1019
std::shared_ptr< XAieBroadcast > broadcast(XAieDevHdRscGroupWrapper &RGroup)
Definition xaiefal-base.hpp:950
std::shared_ptr< XAieBroadcast > broadcast()
Definition xaiefal-base.hpp:974
XAie_LocType loc() const
Definition xaiefal-base.hpp:874
Trace Event resource class.
Definition xaiefal-trace.hpp:22
Trace event resource class. Each event to trace is presented as a trace event resource class.
Definition xaiefal-trace.hpp:540
AI engine user event resource class.
Definition xaiefal-events.hpp:253
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
Definition license.txt:89
Definition xaiefal-base.hpp:23
XAieRscType
Enums representing all requestable resources.
Definition xaiefal-rsc-group.hpp:27
static XAie_ModuleType XAieEstimateModFromEvent(XAie_Events Event)
Definition xaiefal-base.hpp:1098
@ FAL_INFO
Definition xaiefal-log.hpp:12
@ FAL_ERROR
Definition xaiefal-log.hpp:14
struct of resource usage statistics
Definition xaiefal-rsc-group.hpp:66
#define _XAIEFAL_MUTEX_ACQUIRE(...)
Definition xaiefal-common.hpp:27
#define _XAIEFAL_MUTEX_DECLARE(...)
Definition xaiefal-common.hpp:28