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")) {
139 std::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;
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) {
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)) {
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;
304 std::vector<IDF::FUGenerated::Info>
307 std::vector<IDF::FUGenerated::Info> infos;
309 for (
auto&& hdb :
options.hdbList) {
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) {
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;
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) {
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;
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) {
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;
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())) {