60 const std::vector<IDF::FUGenerated::Info>& infos,
61 const std::vector<IDF::FUGenerated::DAGOperation> dagops) {
63 std::vector<TTAMachine::HWOperation*> operations;
64 std::vector<std::string> genops;
70 for (
auto&& op : operations) {
74 maxLatency = op->latency() - 1;
77 maxLatency = op->latency() - 2;
80 maxLatency = op->latency();
83 maxLatency = op->latency() - 1;
86 maxLatency = op->latency() - 2;
88 maxLatency = op->latency();
90 for (
auto&& info : infos) {
91 if (op->name() == info.operationName
92 && maxLatency >= info.latency) {
94 genops.emplace_back(info.operationName);
100 for (
auto&& op : operations) {
101 for (
auto&& dop : dagops) {
102 if (std::find(genops.begin(), genops.end(), op->name()) ==
104 op->name() == dop.operationName) {
106 genops.emplace_back(dop.operationName);
113 if (genops.size() == neededFUops) {
124 const std::string& option, std::vector<std::string> list,
bool enableAll) {
126 for (
auto&& item : list) {
128 if (lowered_item == lowered_option
129 || (enableAll && lowered_item ==
"all")) {
139std::vector<IDF::FUGenerated::DAGOperation>
141 const std::vector<IDF::FUGenerated::Info> infos,
142 std::ostream& verbose) {
143 std::vector<IDF::FUGenerated::DAGOperation> dagops;
144 std::set<std::string> opNames;
146 verbose <<
" can implement DAG operations that use:\n ";
148 for (
auto&& info : infos) {
149 verbose << sep << info.operationName;
160 if (opNames.count(opName) > 0) {
164 for (
int d = 0; d < op.
dagCount(); ++d) {
165 std::vector<IDF::FUGenerated::Info> subops;
166 if (canGenerateFromDAG(op.
dag(d), infos, &subops)) {
170 opNames.insert(opName);
177 verbose <<
" can implement DAG operations:\n ";
179 for (
auto&& op : dagops) {
180 verbose << sep << op.operationName;
194 const std::vector<IDF::FUGenerated::Info> infos,
195 std::vector<IDF::FUGenerated::Info>* subops) {
200 bool canImplement =
true;
201 for (
int n = 0; n < dag.
nodeCount(); ++n) {
208 bool foundOperation =
false;
209 for (
auto&& info : infos) {
210 if (info.operationName == operation) {
211 foundOperation =
true;
213 subops->emplace_back(info);
218 if (foundOperation ==
false) {
219 canImplement =
false;
234 const std::unordered_map<std::string, int>& maxOpLatency) {
242 for (
auto node : sinkNodes) {
243 int latency = maxLatencyToNode(dag, *node, maxOpLatency);
244 maxLatency = std::max(latency, maxLatency);
252 const std::unordered_map<std::string, int>& maxOpLatency) {
260 if (maxOpLatency.find(subOpName) != maxOpLatency.end()) {
261 latency = maxOpLatency.at(subOpName);
275 const std::unordered_map<std::string, int>& maxOpLatency,
276 bool allowDifference) {
279 int maxLeafLatency = -1;
280 for (
auto&& e : dag.
inEdges(node)) {
283 int parentLatency = maxLatencyToNode(dag, nextNode, maxOpLatency)
284 + nodeLatency(nextNode, maxOpLatency);
286 if (!allowDifference && maxLeafLatency != -1) {
287 assert(maxLeafLatency == parentLatency &&
288 "Two input edges of DAG node have different latency!");
291 maxLeafLatency = std::max(maxLeafLatency, parentLatency);
295 maxLeafLatency = std::max(maxLeafLatency, 0);
298 return maxLeafLatency;
304std::vector<IDF::FUGenerated::Info>
307 std::vector<IDF::FUGenerated::Info> infos;
309 for (
auto&& hdb :
options.hdbList) {
310 std::string hdbPath = findHDBPath(hdb);
311 verbose <<
" searching implementations from " << hdbPath <<
"\n";
315 std::vector<IDF::FUGenerated::Info> newInfos;
316 for (
auto&& row : rows) {
319 opimpl.
id, opimpl.latency});
322 std::sort(newInfos.begin(), newInfos.end(),
324 { return a.latency > b.latency; });
326 infos.insert(infos.end(), newInfos.begin(), newInfos.end());
350 std::ostream& verbose) {
352 for (
auto&& hdb :
options.hdbList) {
353 std::string hdbPath = findHDBPath(hdb);
357 for (
auto&& row : rows) {
359 if (!fuEntry->hasImplementation() ||
360 !fuEntry->hasArchitecture()) {
364 auto impl = fuEntry->implementation();
367 arch.architecture().operationCount()) {
370 bool wrongLanguage =
false;
371 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
372 auto f = impl.file(i);
376 wrongLanguage =
true;
378 }
else if (f.format() == HDB::BlockImplementationFile::
381 wrongLanguage =
true;
391 if (!arch.architecture().hasOperation(op->name())) {
396 arch.architecture().operation(op->name())->latency()) {
419 std::ostream& verbose) {
421 for (
auto&& hdb :
options.hdbList) {
422 std::string hdbPath = findHDBPath(hdb);
426 for (
auto&& row : rows) {
429 if (!rfEntry->hasImplementation() ||
430 !rfEntry->hasArchitecture()) {
434 auto impl = rfEntry->implementation();
435 bool wrongLanguage =
false;
436 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
437 auto f = impl.file(i);
441 wrongLanguage =
true;
443 }
else if (f.format() == HDB::BlockImplementationFile::
446 wrongLanguage =
true;
465 if (1 != arch.latency()) {
471 if (!arch.hasParameterizedWidth() &&
472 (rf.
width() != arch.width())) {
475 if (!arch.hasParameterizedSize() &&
476 (rf.
size() != arch.size())) {
493 std::ostream& verbose) {
495 for (
auto&& hdb :
options.hdbList) {
496 std::string hdbPath = findHDBPath(hdb);
500 for (
auto&& row : rows) {
503 if (!rfEntry->hasImplementation() ||
504 !rfEntry->hasArchitecture()) {
508 auto impl = rfEntry->implementation();
509 bool wrongLanguage =
false;
510 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
511 auto f = impl.file(i);
515 wrongLanguage =
true;
517 }
else if (f.format() == HDB::BlockImplementationFile::
520 wrongLanguage =
true;
530 if (iu.
maxReads() != arch.readPortCount()) {
533 if (1 != arch.writePortCount()) {
536 if (iu.
latency() != arch.latency()) {
539 if (!arch.hasParameterizedWidth() &&
540 (iu.
width() != arch.width())) {
543 if (!arch.hasParameterizedSize() &&
544 (iu.
size() != arch.size())) {
#define assert(condition)
static MachInfoCmdLineOptions options
Node & node(const int index) const
virtual Node & tailNode(const Edge &edge) const
virtual NodeSet sinkNodes() const
virtual EdgeSet inEdges(const Node &node) const
static std::vector< std::string > hdbPaths(bool libraryPathsOnly=false)
static std::string findFileInSearchPaths(const std::vector< std::string > &searchPaths, const std::string &file)
static bool fileExists(const std::string fileName)
static CachedHDBManager & instance(const std::string &hdbFile)
FUArchitecture & architecture() const
FUEntry * fuByEntryID(RowID id) const
std::set< RowID > OperationImplementationIDs() const
OperationImplementation OperationImplementationByID(RowID id) const
std::set< RowID > rfEntryIDs() const
RFEntry * rfByEntryID(RowID id) const
std::set< RowID > fuEntryIDs() const
RFArchitecture & architecture() const
void addOperation(const Info &op)
virtual void setHDBFile(std::string file)
virtual void setID(int id)
std::string operationName(int i, const OperationModule &om)
int operationCount(const OperationModule &om)
Operation & referencedOperation() const
Operation & operation(const char *name)
virtual OperationDAG & dag(int index) const
virtual TCEString name() const
virtual int dagCount() const
virtual int width() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual int maxReads() const
virtual int guardLatency() const
virtual bool isUsedAsGuard() const
virtual int bidirPortCount() const
virtual int inputPortCount(bool countBidir=false) const
virtual int outputPortCount(bool countBidir=false) const
int dagLatency(const OperationDAG &dag, const std::unordered_map< std::string, int > &maxOpLatency)
bool checkForSelectableIU(const ProGeOptions &options, TTAMachine::ImmediateUnit &iu, IDF::IUImplementationLocation &loc, std::ostream &verbose)
std::vector< IDF::FUGenerated::DAGOperation > generateableDAGOperations(const std::vector< IDF::FUGenerated::Info > infos, std::ostream &verbose)
std::string findHDBPath(std::string name)
int maxLatencyToNode(const OperationDAG &dag, OperationDAGNode &node, const std::unordered_map< std::string, int > &maxOpLatency, bool allowDifference=true)
bool findInOptionList(const std::string &option, std::vector< std::string > list, bool enableAll=true)
std::vector< IDF::FUGenerated::Info > createFUGeneratableOperationInfos(const ProGeOptions &options, std::ostream &verbose)
int nodeLatency(OperationDAGNode &node, const std::unordered_map< std::string, int > &maxOpLatency)
bool checkForSelectableFU(const ProGeOptions &options, TTAMachine::FunctionUnit &fu, IDF::FUImplementationLocation &loc, std::ostream &verbose)
bool canGenerateFromDAG(const OperationDAG &dag, const std::vector< IDF::FUGenerated::Info > infos, std::vector< IDF::FUGenerated::Info > *subops)
bool checkForGeneratableFU(const ProGeOptions &options, TTAMachine::FunctionUnit &fu, IDF::FUGenerated &fug, const std::vector< IDF::FUGenerated::Info > &infos, const std::vector< IDF::FUGenerated::DAGOperation > dagops)
bool checkForSelectableRF(const ProGeOptions &options, TTAMachine::RegisterFile &rf, IDF::RFImplementationLocation &loc, std::ostream &verbose)