From 3ae2a70f80332b22ce54bec6853e054d31ae2d9a Mon Sep 17 00:00:00 2001 From: Raimund Merkert Date: Wed, 13 Nov 2024 15:56:32 -0500 Subject: [PATCH 1/3] Add regression test for issue 2426. --- tests/scheduler/CMakeLists.txt | 1 + tests/scheduler/bug2426/bug2426.dl | 9 +++++++++ tests/scheduler/bug2426/bug2426.err | 3 +++ tests/scheduler/bug2426/bug2426.out | 0 tests/scheduler/bug2426/res.csv | 1 + 5 files changed, 14 insertions(+) create mode 100644 tests/scheduler/bug2426/bug2426.dl create mode 100644 tests/scheduler/bug2426/bug2426.err create mode 100644 tests/scheduler/bug2426/bug2426.out create mode 100644 tests/scheduler/bug2426/res.csv diff --git a/tests/scheduler/CMakeLists.txt b/tests/scheduler/CMakeLists.txt index 0fd3c244a9a..a8a6f113c09 100644 --- a/tests/scheduler/CMakeLists.txt +++ b/tests/scheduler/CMakeLists.txt @@ -94,4 +94,5 @@ endfunction() if (NOT MSVC) souffle_add_scheduler_test(functionality) souffle_add_scheduler_test(eqrel) + souffle_add_scheduler_test(bug2426) endif() diff --git a/tests/scheduler/bug2426/bug2426.dl b/tests/scheduler/bug2426/bug2426.dl new file mode 100644 index 00000000000..4b9d4cabd76 --- /dev/null +++ b/tests/scheduler/bug2426/bug2426.dl @@ -0,0 +1,9 @@ +.decl A(x:float) +.decl B(x: unsigned) +.decl res(a:float) +.output res + +A(-1). +B(1). + +res(a) :- B(x), A(a). diff --git a/tests/scheduler/bug2426/bug2426.err b/tests/scheduler/bug2426/bug2426.err new file mode 100644 index 00000000000..468c0c1762e --- /dev/null +++ b/tests/scheduler/bug2426/bug2426.err @@ -0,0 +1,3 @@ +Warning: Variable x only occurs once in file bug2426.dl at line 9 +res(a) :- B(x), A(a). +------------^--------- diff --git a/tests/scheduler/bug2426/bug2426.out b/tests/scheduler/bug2426/bug2426.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/scheduler/bug2426/res.csv b/tests/scheduler/bug2426/res.csv new file mode 100644 index 00000000000..3a2e3f4984a --- /dev/null +++ b/tests/scheduler/bug2426/res.csv @@ -0,0 +1 @@ +-1 From 5187f9096cb738e3f6e5176b167239546b8abac3 Mon Sep 17 00:00:00 2001 From: Raimund Merkert Date: Wed, 13 Nov 2024 08:03:29 -0500 Subject: [PATCH 2/3] Do not use SelingerProfileSipsMetric if no profile available. There is a bug #2426, which causes an assertion in the SelingerProfileSipsMetric::getReordering. Rther than fixing the problem I decided to work-around it for the time being, until we have a proper fix. We can work around this problem in one of two ways: 1. don't assert and just don't reorder atoms (this should be fine) 2. don't create the metric in the first place, if there is no profile I decided to use #2 as that seems to be the safer option. I added code for a warning, but disabled it because it is incompatible with the ctest suite. --- src/ast2ram/utility/SipsMetric.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ast2ram/utility/SipsMetric.cpp b/src/ast2ram/utility/SipsMetric.cpp index fb94638d0db..3cf82a8df25 100644 --- a/src/ast2ram/utility/SipsMetric.cpp +++ b/src/ast2ram/utility/SipsMetric.cpp @@ -310,8 +310,15 @@ std::vector SelingerProfileSipsMetric::getReordering( /** Create a SIPS metric based on a given heuristic. */ std::unique_ptr SipsMetric::create(const std::string& heuristic, const TranslationUnit& tu) { if (tu.global().config().has("auto-schedule")) { - return mk(tu); - } else if (heuristic == "strict") + if (tu.getAnalysis().hasAutoSchedulerStats()) { + return mk(tu); + } else { + std::cerr << "WARNING: `--auto-schedule` cannot be used due to missing scheduler stats; falling back " + "to heuristic '" + << heuristic << "'" << ::std::endl; + } + } + if (heuristic == "strict") return mk(tu); else if (heuristic == "all-bound") return mk(tu); From d70d25c8949e844a5bd44b8f23115bc28c6e43ff Mon Sep 17 00:00:00 2001 From: Raimund Merkert Date: Wed, 13 Nov 2024 16:36:38 -0500 Subject: [PATCH 3/3] Disable printing a warning about --auto-schedule. We should print a warning about --auto-schedule not being enabled. If we do that we also need to change the unit test setups for scheduler tests. --- src/ast2ram/utility/SipsMetric.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ast2ram/utility/SipsMetric.cpp b/src/ast2ram/utility/SipsMetric.cpp index 3cf82a8df25..0b06cb9d417 100644 --- a/src/ast2ram/utility/SipsMetric.cpp +++ b/src/ast2ram/utility/SipsMetric.cpp @@ -313,9 +313,12 @@ std::unique_ptr SipsMetric::create(const std::string& heuristic, con if (tu.getAnalysis().hasAutoSchedulerStats()) { return mk(tu); } else { +// TODO: enable this, but if we do the scheduler tests won't run as they do now +#if 0 std::cerr << "WARNING: `--auto-schedule` cannot be used due to missing scheduler stats; falling back " "to heuristic '" << heuristic << "'" << ::std::endl; +#endif } } if (heuristic == "strict")