Skip to content

Commit

Permalink
debugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tarinduj committed Dec 11, 2024
1 parent e377fa7 commit 108747e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
12 changes: 12 additions & 0 deletions mlir/include/mlir/Analysis/Presburger/Set-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ template <typename Int>
void subtractRecursively(PresburgerBasicSet<Int> &b, Simplex<Int> &simplex,
const PresburgerSet<Int> &s, unsigned i,
PresburgerSet<Int> &result) {
std::cout << "subtractRecursively\n";
if (i == s.getNumBasicSets()) {
// PresburgerBasicSet<Int> BCopy = B;
// BCopy.simplify();
Expand Down Expand Up @@ -330,6 +331,7 @@ PresburgerSet<Int>::eliminateExistentials(const PresburgerBasicSet<Int> &bs) {

template <typename Int>
PresburgerSet<Int> PresburgerSet<Int>::eliminateExistentials(const PresburgerSet<Int> &set) {
std::cout << "In PresburgerSet<Int>::eliminateExistentials\n";
PresburgerSet<Int> unquantifiedSet(set.getNumDims(), set.getNumSyms());
for (const auto &bs : set.getBasicSets()) {
if (bs.getNumExists() == 0) {
Expand Down Expand Up @@ -368,15 +370,25 @@ PresburgerSet<Int> PresburgerSet<Int>::eliminateExistentials(PresburgerSet<Int>
template <typename Int>
PresburgerSet<Int> PresburgerSet<Int>::subtract(PresburgerBasicSet<Int> cs,
const PresburgerSet<Int> &set) {

std::cout << "In Presburger Set Subtract\n";
assertDimensionsCompatible(cs, set);

std::cout << "After assertDimensionsCompatible\n";

if (set.isUniverse())
return PresburgerSet<Int>::makeEmptySet(set.getNumDims(), set.getNumSyms());
if (set.isMarkedEmpty())
return PresburgerSet<Int>(cs);

std::cout << "After isUniverse and isMarkedEmpty\n";

Simplex<Int> simplex(cs);
std::cout << "After Simplex<Int> simplex(cs)\n";

PresburgerSet<Int> result(set.getNumDims(), set.getNumSyms());
std::cout << "After PresburgerSet<Int> result(set.getNumDims(), set.getNumSyms())\n";

subtractRecursively(cs, simplex, eliminateExistentials(set), 0, result);
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions mlir/include/mlir/Analysis/Presburger/Simplex-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Simplex<Int>::~Simplex() {

template <typename Int>
Simplex<Int>::Simplex(const PresburgerBasicSet<Int> &bs) : Simplex(bs.getNumTotalDims()) {
std::cout << "Simplex constructor called with PresburgerBasicSet\n";
addBasicSet(bs);
}

Expand Down Expand Up @@ -578,6 +579,7 @@ LogicalResult Simplex<Int>::restoreRow(Unknown &u) {
assert(u.orientation == Orientation::Row &&
"unknown should be in row position");

std::cout << "restoreRow: pivot call here\n";
while (tableau(u.pos, 1) < 0) {
Optional<Pivot> maybePivot = findPivot(u.pos, Direction::Up);
if (!maybePivot)
Expand Down Expand Up @@ -754,6 +756,7 @@ bool Simplex<Int>::constraintIsEquality(int conIndex) const {
/// empty and we mark it as such.
template <typename Int>
void Simplex<Int>::addInequality(ArrayRef<Int> coeffs) {
std::cout << "addInequality \n";
unsigned conIndex = addRow(coeffs);
Unknown &u = con[conIndex];
u.restricted = true;
Expand Down Expand Up @@ -1159,6 +1162,7 @@ void Simplex<Int>::addFlatAffineConstraints(const FlatAffineConstraints &cs) {

template <typename Int>
void Simplex<Int>::addBasicSet(const PresburgerBasicSet<Int> &bs) {
std::cout << "addBasicSet \n";
assert(bs.getNumTotalDims() == numVariables() &&
"BasicSet must have same dimensionality as simplex");
unsigned totNewCons = bs.getNumInequalities() + bs.getNumEqualities() + 2*bs.getNumDivs();
Expand Down
1 change: 1 addition & 0 deletions mlir/include/mlir/Analysis/Presburger/TransprecSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class TransprecSet {
}

void subtract(TransprecSet &set) {
std::cout << "In TransprecSet Subtract\n";
harmonizePrecisions(*this, set);
std::visit([&](auto &&thisPS) {
std::visit([&](auto &&oPS) {
Expand Down
15 changes: 3 additions & 12 deletions mlir/tools/run-presburger/run-presburger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void consumeNewline() {

template <typename Set, bool printAuxInfo>
void run(std::string op, std::string suffix, llvm::Optional<unsigned> maxWaterline) {
std::cout << "Running " << op << '\n';
if (!suffix.empty())
assert(!printAuxInfo && "NYI");
if (printAuxInfo)
Expand All @@ -117,21 +118,10 @@ void run(std::string op, std::string suffix, llvm::Optional<unsigned> maxWaterli
suffix = "_" + suffix;
std::ifstream fwaterlineIn("data/waterline_fpl_" + op + ".txt");
std::ofstream fruntime("data/runtime_fpl" + suffix + "_" + op + ".txt");
// std::ofstream fwaterline, fstat;
// std::error_code EC;
// llvm::raw_fd_ostream fout(printAuxInfo ? "data/outputs_fpl_" + op + ".txt" : "data/empty_file_used_for_a_hack", EC, llvm::sys::fs::OpenFlags::OF_Append);
// if (printAuxInfo) {
// fwaterline = std::ofstream("data/waterline_fpl_" + op + ".txt", std::ios_base::app);
// fstat = std::ofstream("data/stats_fpl_" + op + ".txt", std::ios_base::app);
// if (EC) {
// std::cerr << "Could not open outputs_fpl_" + op + ".txt!\n";
// std::abort();
// }
// fout << numCases << '\n';
// }

for (unsigned j = 0; j < numCases; ++j) {
int times[numRuns];
// printing progress
if (j % 50000 == 0)
std::cerr << op << ' ' << j << '/' << numCases << '\n';

Expand Down Expand Up @@ -246,6 +236,7 @@ times[i] = static_cast<int>(duration);
auto b = setB;
unsigned int dummy;
auto start = std::chrono::high_resolution_clock::now();
std::cout << "Subtract call\n";
a.subtract(b);
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
Expand Down

0 comments on commit 108747e

Please sign in to comment.