bool ParserFloatItem::equalDimensions(const ParserItem& other) const { bool equal=false; if (other.numDimensions() == numDimensions()) { equal = true; for (size_t idim=0; idim < numDimensions(); idim++) { if (other.getDimension(idim) != getDimension(idim)) equal = false; } } return equal; }
void petabricks::MatrixDef::readFromFileCode(CodeGenerator& o, const std::string& fn, RuleFlavor rf){ if (rf == RuleFlavor::DISTRIBUTED && numDimensions() > 0) { // read to tmp then copy to real matrix o.write(typeName(rf, false) + " tmp_" + name()+" = petabricks::MatrixIOGeneral("+fn+",\"r\").read_"+rf.str()+"<"+jalib::XToString(numDimensions())+">();"); // allocate std::string distributionType = o.className() + "_" + name() + "_distribution_type"; std::string distributionSize = o.className() + "_" + name() + "_distribution_size"; std::string migrationType = o.className() + "_" + name() + "_migration_type"; o.createTunable(true, "system.data.distribution.type", distributionType, 0, 0, 5); o.createTunable(true, "system.data.distribution.size", distributionSize, jalib::maxval<int>(), 2, jalib::maxval<int>()); o.createTunable(true, "system.data.migration.type", migrationType, 0, 0, 1); o.write(name()+" = "+typeName(rf)+"::allocate(tmp_"+name()+".size(), distributedcutoff, "+distributionType+", "+distributionSize+", "+migrationType+");"); // copy o.beginIf(name()+".isRegionDataRaw()"); o.write(name()+" = tmp_"+name()+";"); o.elseIf(); o.write(name()+".fromScratchRegion(tmp_"+name()+");"); o.endIf(); // o.write("petabricks::MatrixIOGeneral().write("+name()+");"); } else { o.varDecl(name()+" = petabricks::MatrixIOGeneral("+fn+",\"r\").read_"+rf.str()+"<"+jalib::XToString(numDimensions())+">()"); } }
void petabricks::MatrixDef::allocateTemporary(CodeGenerator& o, RuleFlavor rf, bool setOnly, bool reallocAllowed){ if(!setOnly) o.addMember(typeName(rf), name(), ""); if(reallocAllowed) o.beginIf("!"+name()+".isSize("+_size.toString()+")"); if (rf == RuleFlavor::DISTRIBUTED && numDimensions() > 0) { std::string distributionType = o.className() + "_" + name() + "_distribution_type"; std::string distributionSize = o.className() + "_" + name() + "_distribution_size"; std::string migrationType = o.className() + "_" + name() + "_migration_type"; o.createTunable(true, "system.data.distribution.type", distributionType, 0, 0, 5); o.createTunable(true, "system.data.distribution.size", distributionSize, jalib::maxval<int>(), 2, jalib::maxval<int>()); o.createTunable(true, "system.data.migration.type", migrationType, 0, 0, 1); o.write("{"); o.incIndent(); o.write("IndexT size[] = {"+_size.toString()+"};"); o.write(name()+" = "+typeName(rf)+"::allocate(size, distributedcutoff, "+distributionType+", "+distributionSize+", "+migrationType+");"); o.decIndent(); o.write("}"); } else { o.write(name()+" = "+allocateStr(rf)+";"); } if(reallocAllowed) o.endIf(); }
DenseTensorAddressCombiner::DenseTensorAddressCombiner(const eval::ValueType &combined, const eval::ValueType &lhs, const eval::ValueType &rhs) : _rightAddress(rhs), _combinedAddress(combined), _left(), _commonRight(), _right() { auto rhsItr = rhs.dimensions().cbegin(); auto rhsItrEnd = rhs.dimensions().cend(); uint32_t numDimensions(0); for (const auto &lhsDim : lhs.dimensions()) { while ((rhsItr != rhsItrEnd) && (rhsItr->name < lhsDim.name)) { _right.emplace_back(numDimensions++, rhsItr-rhs.dimensions().cbegin()); ++rhsItr; } if ((rhsItr != rhsItrEnd) && (rhsItr->name == lhsDim.name)) { _left.emplace_back(numDimensions, _left.size()); _commonRight.emplace_back(numDimensions, rhsItr-rhs.dimensions().cbegin()); ++numDimensions; ++rhsItr; } else { _left.emplace_back(numDimensions++, _left.size()); } } while (rhsItr != rhsItrEnd) { _right.emplace_back(numDimensions++, rhsItr-rhs.dimensions().cbegin()); ++rhsItr; } }