14#include <unordered_map>
17#include <xaiefal/common/xaiefal-common.hpp>
18#include <xaiefal/common/xaiefal-log.hpp>
19#include <xaiefal/rsc/xaiefal-rsc-group.hpp>
47# define XAIEDEV_DEFAULT_GROUP_STATIC "Static"
48# define XAIEDEV_DEFAULT_GROUP_AVAIL "Avail"
49# define XAIEDEV_DEFAULT_GROUP_GENERIC "Generic"
63 return RscGroup->getRscStat();
66 return RscGroup->getRscStat(Loc);
69 return RscGroup->getRscStat(Loc, RscType);
72 return RscGroup->getRscStat(Loc, Mod);
76 return RscGroup->getRscStat(Loc, Mod, RscType);
80 return RscGroup->getRscStat(Loc, Mod, RscType,
85 return RscGroup->getRscStat(vLocs, RscType);
89 return RscGroup->getRscStat(vLocs, RscType, RscId);
93 AieRC
addRsc(std::shared_ptr<RT> Rsc) {
94 return RscGroup->addRsc(Rsc);
97 std::shared_ptr<XAieRscGroupBase> RscGroup ;
107 bool TurnOnFinishOnDestruct =
false):
109 FinishOnDestruct(TurnOnFinishOnDestruct) {
110 if (DevPtr ==
nullptr) {
111 throw std::invalid_argument(
"AI engine device is NULL");
152 if (FinishOnDestruct) {
169 std::shared_ptr<XAieDevHandle>
getPtr() {
170 return shared_from_this();
188 if (RscGroupsMap.find(GName) == RscGroupsMap.end()) {
189 _createGroup<GT>(GName);
203 if (RscGroupsMap.find(GName) == RscGroupsMap.end()) {
204 _createGroup<XAieRscGroupRuntime>(GName);
206 return RscGroupsMap[GName];
217 auto it = RscGroupsMap.find(GName);
219 if (
it != RscGroupsMap.end()) {
220 RscGroupsMap.erase(
it);
229 AieRscMgr = std::make_shared<XAieRscMgr>(
this);
238 bool FinishOnDestruct;
239 std::shared_ptr<XAieRscMgr> AieRscMgr;
240 std::map <std::string, XAieDevHdRscGroupWrapper> RscGroupsMap;
245 void _createGroup(
const std::string &GName) {
246 auto GPtr = std::make_shared<GT>(shared_from_this(),
250 GName <<
" is created." << std::endl;
263 bool TurnOnFinishOnDestruct =
false);
273 if (Loc.Col > NumCols || Loc.Row > NumRows) {
274 throw std::invalid_argument(
"Invalid tile location");
276 return Tiles[Loc.Col * NumRows + Loc.Row];
287 return tile(XAie_TileLoc(Col, Row));
297 return AieHandle->dev();
306 return AieHandle->getPtr();
318 return AieHandle->getRscGroup(GName);
328 AieHandle->removeRscGroup(GName);
338 return AieHandle->getRscGroup(GName).getRscStat();
396 auto BC = std::make_shared<XAieBroadcast>(*
this, vLocs,
405 AieHandle->getRscGroup(
"Generic");
406 return broadcast(vLocs, StartM, EndM, RGroup);
419 if (Mod == XAIE_CORE_MOD) {
421 }
else if (Mod == XAIE_MEM_MOD) {
423 }
else if (Mod == XAIE_PL_MOD) {
426 RC = XAIE_INVALID_ARGS;
428 "failed. invalid module type." <<
444 if (MString ==
"core") {
446 }
else if (MString ==
"memory") {
448 }
else if (MString ==
"shim") {
451 RC = XAIE_INVALID_ARGS;
453 "failed. invalid module string." << std::endl;
459 std::shared_ptr<XAieDevHandle> AieHandle;
462 std::vector<XAieTile> Tiles;
474 AieHandle(Dev.getDevHandle()), Loc(Loc), Mod(Mod) {
475 if (XAie_CheckModule(AieHandle->dev(), Loc, Mod) !=
477 throw std::invalid_argument(
"Invalid module and tile");
480 TraceCntr = std::make_shared<XAieTraceCntr>(AieHandle,
482 AieHandle->getRscGroup(
"Generic").addRsc(TraceCntr);
483 AieHandle->getRscGroup(
"Avail").addRsc(TraceCntr);
492 XAie_LocType
loc()
const {
513 return AieHandle->getRscGroup(GName).getRscStat(Loc, Mod);
530 auto Rsc = std::make_shared<XAiePerfCounter>(AieHandle,
538 AieHandle->getRscGroup(
"Generic");
557 auto Rsc = std::make_shared<XAieMdmPerfCounter>(AieHandle,
565 AieHandle->getRscGroup(
"Generic");
599 auto Rsc = std::make_shared<XAieTraceEvent>(AieHandle,
600 Loc, Mod, TraceCntr);
607 AieHandle->getRscGroup(
"Generic");
627 auto Rsc = std::make_shared<XAieActiveCycles>(AieHandle,
634 AieHandle->getRscGroup(
"Generic");
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,
662 AieHandle->getRscGroup(
"Generic");
681 auto StallG =
groupEvent(XAIE_EVENT_GROUP_CORE_STALL_CORE);
682 auto Rsc = std::make_shared<XAieStallOccurrences>(AieHandle,
689 AieHandle->getRscGroup(
"Generic");
707 auto Rsc = std::make_shared<XAiePCEvent>(AieHandle, Loc);
713 AieHandle->getRscGroup(
"Generic");
731 auto Rsc = std::make_shared<XAiePCRange>(AieHandle, Loc);
737 AieHandle->getRscGroup(
"Generic");
757 auto Rsc = std::make_shared<XAieComboEvent>(AieHandle,
763 std::shared_ptr<XAieComboEvent>
comboEvent(uint32_t ENum = 2) {
765 AieHandle->getRscGroup(
"Generic");
785 auto gEvent = GroupEvents.find(Event);
786 if (gEvent != GroupEvents.end()) {
787 return std::make_shared<XAieGroupEventHandle>(
788 AieHandle, GroupEvents[Event]);
790 auto gEPtr = std::make_shared<XAieGroupEvent>(AieHandle,
793 GroupEvents.emplace(Event, gEPtr);
794 return std::make_shared<XAieGroupEventHandle>(AieHandle,
800 AieHandle->getRscGroup(
"Generic");
818 auto Rsc = std::make_shared<XAieUserEvent>(AieHandle,
825 AieHandle->getRscGroup(
"Generic");
830 std::shared_ptr<XAieDevHandle> AieHandle;
834 std::shared_ptr<XAieTraceCntr> TraceCntr;
835 std::map<XAie_Events, std::shared_ptr<XAieGroupEvent>> GroupEvents;
846 AieHandle(Dev.getDevHandle()), Loc(Loc) {
849 TType = XAie_GetTileTypefromLoc(Dev.
dev(), Loc);
851 if (TType == XAIEGBL_TILE_TYPE_MAX) {
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));
858 if (TType == XAIEGBL_TILE_TYPE_SHIMPL ||
859 TType == XAIEGBL_TILE_TYPE_SHIMNOC) {
860 Mods.push_back(
XAieMod(Dev, Loc, XAIE_PL_MOD));
862 Mods.push_back(
XAieMod(Dev, Loc, XAIE_MEM_MOD));
874 XAie_LocType
loc()
const {
885 if (XAie_CheckModule(AieHandle->dev(), Loc, Mod) !=
887 std::string str =
"module " +
888 std::to_string(Mod) +
" not in tile.";
892 if (Mod == XAIE_CORE_MOD) {
905 return module(XAIE_CORE_MOD);
914 return module(XAIE_MEM_MOD);
923 return module(XAIE_PL_MOD);
934 return AieHandle->getRscGroup(GName).getRscStat(Loc);
952 std::vector<XAie_LocType> vL;
956 if (XAie_CheckModule(AieHandle->dev(), Loc, XAIE_CORE_MOD)
958 StartM = XAIE_CORE_MOD;
960 }
else if (XAie_CheckModule(AieHandle->dev(), Loc,
961 XAIE_PL_MOD) == XAIE_OK) {
962 StartM = XAIE_PL_MOD;
965 StartM = XAIE_MEM_MOD;
968 auto BC = std::make_shared<XAieBroadcast>(AieHandle,
976 AieHandle->getRscGroup(
"Generic");
995 auto C = std::make_shared<XAiePerfCounter>(AieHandle,
996 Loc, Mods[0].mod(),
true);
1002 AieHandle->getRscGroup(
"Generic");
1021 auto C = std::make_shared<XAieMdmPerfCounter>(AieHandle,
1028 AieHandle->getRscGroup(
"Generic");
1047 auto SS = std::make_shared<XAieStreamPortSelect>(
1054 AieHandle->getRscGroup(
"Generic");
1060 std::shared_ptr<XAieDevHandle> AieHandle;
1063 std::vector<XAieMod> Mods;
1067 bool TurnOnFinishOnDestruct) {
1069 AieHandle = std::make_shared<XAieDevHandle>(DevPtr,
1070 TurnOnFinishOnDestruct);
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++) {
1081 XAie_TileLoc(c, r)));
1084 AieHandle->createRscMgr();
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;
1109 Module = XAIE_PL_MOD;
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