12#include <unordered_map>
15#include <xaiefal/common/xaiefal-base.hpp>
16#include <xaiefal/common/xaiefal-log.hpp>
72 XAieRsc(std::shared_ptr<XAieDevHandle> DevHd):
75 throw std::invalid_argument(
"aie rsc: empty device handle");
83 throw std::invalid_argument(
"aie rsc: empty device handle");
93 if (
State.Running == 1) {
95 }
else if (
State.Reserved == 1) {
96 if (
State.Prereserved == 1) {
117 if (
State.Reserved == 1) {
118 RC = XAIE_INVALID_ARGS;
122 if (isStaticAllocated) {
124 RC = XAIE_INVALID_ARGS;
126 typeid(*this).name() <<
127 " If Rsc ID is any, cannot be statically allocated" << std::endl;
129 State.Prereserved = 1;
164 if (
State.Reserved == 1) {
166 typeid(*this).name() <<
" resource has been allocated." << std::endl;
168 }
else if (
State.Initialized == 0) {
170 typeid(*this).name() <<
" resource not configured." << std::endl;
191 if (
State.Running == 1) {
193 typeid(*this).name() <<
"resource is running." << std::endl;
195 }
else if (
State.Reserved == 1) {
198 State.Prereserved = 0;
216 if (
State.Prereserved == 0) {
218 typeid(*this).name() <<
" resource is not preserved." << std::endl;
219 RC = XAIE_INVALID_ARGS;
221 if (
State.Running == 1) {
223 typeid(*this).name() <<
" resource is running." << std::endl;
224 RC = XAIE_INVALID_ARGS;
225 }
else if (
State.Reserved == 1) {
242 if (
State.Running == 1) {
244 }
else if (
State.Reserved == 1) {
245 if (
State.Configured == 1) {
252 typeid(*this).name() <<
" resource is not configured." << std::endl;
257 typeid(*this).name() <<
" resource is not allocated." << std::endl;
272 if (
State.Running == 0) {
288 return State.Initialized;
296 return State.Reserved;
305 return State.Configured;
313 return State.Running;
322 if (
State.Reserved != 0) {
323 _getReservedRscs(vOutRscs);
332 AieRC
getRscs(std::vector<XAieUserRsc> &vOutRscs) {
342 AieRC
setRscs(std::vector<XAieUserRsc> &vInRscs) {
364 std::string rName(
typeid(*this).name());
367 throw std::invalid_argument(
"get rsc stat not supported of rsc" +
382 std::string rName(
typeid(*this).name());
383 throw std::invalid_argument(
"get max rsc num not supported of rsc " +
392 std::string rName(
typeid(*this).name());
393 throw std::invalid_argument(
"get managed rsc type not supported of rsc " +
400 std::shared_ptr<XAieDevHandle>
AieHd;
411 virtual AieRC _reserve() {
return XAIE_OK;}
418 virtual AieRC _release() {
return XAIE_OK;}
425 virtual AieRC _free() {
return XAIE_OK;}
432 virtual AieRC _start() {
return XAIE_OK;}
439 virtual AieRC _stop() {
return XAIE_OK;}
446 virtual void _getReservedRscs(std::vector<XAieUserRsc> &vOutRscs)
const {
447 std::string rName(
typeid(*this).name());
450 throw std::invalid_argument(
"get resource not supported of rsc" +
458 virtual void _getRscs(std::vector<XAieUserRsc> &vOutRscs) {
459 vOutRscs.insert(vOutRscs.end(),
vRscs.begin(),
vRscs.end());
466 virtual void _setRscs(std::vector<XAieUserRsc> &vInRscs) {
483 throw std::invalid_argument(
"invalid module tile");
491 throw std::invalid_argument(
"invalid module tile");
503 uint8_t TType = XAie_GetTileTypefromLoc(
505 if (TType == XAIEGBL_TILE_TYPE_MAX) {
506 throw std::invalid_argument(
"Invalid tile");
508 if (TType == XAIEGBL_TILE_TYPE_AIETILE) {
510 }
else if (TType == XAIEGBL_TILE_TYPE_SHIMPL ||
511 TType == XAIEGBL_TILE_TYPE_SHIMNOC) {
520 uint8_t TType = XAie_GetTileTypefromLoc(
522 if (TType == XAIEGBL_TILE_TYPE_MAX) {
523 throw std::invalid_argument(
"Invalid tile");
525 if (TType == XAIEGBL_TILE_TYPE_AIETILE) {
527 }
else if (TType == XAIEGBL_TILE_TYPE_SHIMPL ||
528 TType == XAIEGBL_TILE_TYPE_SHIMNOC) {
542 XAie_LocType
loc()
const {
562 uint32_t &OutRscId) {
565 if (
State.Reserved == 0) {
568 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
")" <<
569 " Expect Mod= " <<
Mod <<
570 " resource not reserved." << std::endl;
572 if (
vRscs.size() > 0) {
573 OutMod =
vRscs[0].Mod;
586 return AieHd->getRscGroup(GName).getRscStat(
Loc,
589 return AieHd->getRscGroup(GName).getRscStat(
Loc,
602 virtual void _getReservedRscs(std::vector<XAieUserRsc> &vOutRscs)
const {
603 if (
vRscs.size() > 0) {
604 vOutRscs.push_back(
vRscs[0]);
612 std::vector<XAieUserRsc> &Rscs) {
613 Rsc->getReservedRscs(Rscs);
static std::ostream & log(LogLevel Lvl=LogLevel::FAL_MAX)
Definition xaiefal-log.hpp:50
AI engine device class. It defines AI engine device operations.
Definition xaiefal-base.hpp:259
Base AI engine resource class. It defines resource operations and maintains resource state machine.
Definition xaiefal-rsc-base.hpp:69
virtual XAieRscStat getRscStat(const std::string &GName) const
Definition xaiefal-rsc-base.hpp:362
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
uint32_t getPreferredId()
Definition xaiefal-rsc-base.hpp:141
AieRC free()
Definition xaiefal-rsc-base.hpp:213
XAieRsc(XAieDev &Dev)
Definition xaiefal-rsc-base.hpp:87
virtual XAieRscType getRscType() const
Definition xaiefal-rsc-base.hpp:351
XAieRsc(std::shared_ptr< XAieDevHandle > DevHd, XAieRscType Type)
Definition xaiefal-rsc-base.hpp:80
bool isReserved() const
Definition xaiefal-rsc-base.hpp:295
XAie_DevInst * dev()
Definition xaiefal-rsc-base.hpp:373
virtual XAieRscType getManagedRscsType()
Definition xaiefal-rsc-base.hpp:391
AieRC release()
Definition xaiefal-rsc-base.hpp:188
virtual uint32_t getAvailManagedRscs()
Definition xaiefal-rsc-base.hpp:381
AieRC setPreferredId(uint32_t id, bool isStaticAllocated=false)
Definition xaiefal-rsc-base.hpp:114
AieRC reserve()
Definition xaiefal-rsc-base.hpp:161
AieRC start()
Definition xaiefal-rsc-base.hpp:239
void getReservedRscs(std::vector< XAieUserRsc > &vOutRscs) const
Definition xaiefal-rsc-base.hpp:321
uint32_t preferredId
Definition xaiefal-rsc-base.hpp:401
bool isConfigured() const
Definition xaiefal-rsc-base.hpp:304
uint32_t reservedId
Definition xaiefal-rsc-base.hpp:402
bool isRunning() const
Definition xaiefal-rsc-base.hpp:312
std::shared_ptr< XAieDevHandle > AieHd
Definition xaiefal-rsc-base.hpp:400
AieRC getRscs(std::vector< XAieUserRsc > &vOutRscs)
Definition xaiefal-rsc-base.hpp:332
AieRC stop()
Definition xaiefal-rsc-base.hpp:269
XAieRsc(std::shared_ptr< XAieDevHandle > DevHd)
Definition xaiefal-rsc-base.hpp:72
virtual ~XAieRsc()
Definition xaiefal-rsc-base.hpp:92
AieRC setRscs(std::vector< XAieUserRsc > &vInRscs)
Definition xaiefal-rsc-base.hpp:342
bool isInitialized() const
Definition xaiefal-rsc-base.hpp:287
XAieSingleTileRsc(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc)
Definition xaiefal-rsc-base.hpp:500
XAieSingleTileRsc(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod)
Definition xaiefal-rsc-base.hpp:494
virtual XAieRscStat getRscStat(const std::string &GName) const
Definition xaiefal-rsc-base.hpp:581
XAieSingleTileRsc(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAie_ModuleType Mod)
Definition xaiefal-rsc-base.hpp:478
XAie_ModuleType mod() const
Definition xaiefal-rsc-base.hpp:550
XAieSingleTileRsc()=delete
XAieSingleTileRsc(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAie_ModuleType Mod, XAieRscType Type)
Definition xaiefal-rsc-base.hpp:486
virtual ~XAieSingleTileRsc()
Definition xaiefal-rsc-base.hpp:536
XAieSingleTileRsc(XAieDev &Dev, XAie_LocType Loc, XAieRscType Type)
Definition xaiefal-rsc-base.hpp:534
XAieSingleTileRsc(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAieRscType Type)
Definition xaiefal-rsc-base.hpp:517
XAie_LocType loc() const
Definition xaiefal-rsc-base.hpp:542
XAie_LocType Loc
Definition xaiefal-rsc-base.hpp:594
XAie_ModuleType Mod
Definition xaiefal-rsc-base.hpp:595
XAieSingleTileRsc(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod, XAieRscType Type)
Definition xaiefal-rsc-base.hpp:497
AieRC getRscId(XAie_LocType &OutLoc, XAie_ModuleType &OutMod, uint32_t &OutRscId)
Definition xaiefal-rsc-base.hpp:561
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
XAieRscType
Enums representing all requestable resources.
Definition xaiefal-rsc-group.hpp:27
@ FAL_ERROR
Definition xaiefal-log.hpp:14
~XAieRscGetRscsWrapper()
Definition xaiefal-rsc-base.hpp:615
XAieRscGetRscsWrapper()=delete
XAieRscGetRscsWrapper(std::shared_ptr< XAieRsc > &Rsc, std::vector< XAieUserRsc > &Rscs)
Definition xaiefal-rsc-base.hpp:611
struct of resource usage statistics
Definition xaiefal-rsc-group.hpp:66
Definition xaiefal-rsc-base.hpp:50
uint8_t Prereserved
Definition xaiefal-rsc-base.hpp:54
uint8_t Running
Definition xaiefal-rsc-base.hpp:61
uint8_t Initialized
Definition xaiefal-rsc-base.hpp:51
uint8_t Configured
Definition xaiefal-rsc-base.hpp:52
uint8_t Reserved
Definition xaiefal-rsc-base.hpp:53
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_TYPE_ANY
Definition xaiefal-common.hpp:8
#define XAIE_LOC_ANY
Definition xaiefal-common.hpp:10
#define XAIE_MOD_ANY
Definition xaiefal-common.hpp:9
#define XAIE_RSC_ID_ANY
Definition xaiefal-common.hpp:7