[PATCH] D107401: [Polly][test] Add tests for IslMaxOperationsGuard.

3 views
Skip to first unread message

Michael Kruse via Phabricator

unread,
Aug 3, 2021, 5:17:11 PM8/3/21
to pat...@autistici.org, siddu...@gmail.com, llvm-c...@lists.llvm.org, poll...@googlegroups.com, bhuvanend...@amd.com, yanli...@intel.com, lege...@outlook.com, micha...@web.de, doug...@gmail.com, jatin....@gmail.com, n...@google.com, wic...@vitalitystudios.com, michae...@gmail.com, phabr...@grosser.es
Meinersbur created this revision.
Meinersbur added a reviewer: patacca.
Meinersbur added a project: Polly.
Herald added a reviewer: bollu.
Meinersbur requested review of this revision.
Herald added a project: LLVM.

Add unittests for IslMaxOperationsGuard and the behaviour of the isl-noexception.h wrapper under exceeded max_operations.


Repository:
rG LLVM Github Monorepo

https://reviews.llvm.org/D107401

Files:
polly/unittests/Isl/IslTest.cpp


Index: polly/unittests/Isl/IslTest.cpp
===================================================================
--- polly/unittests/Isl/IslTest.cpp
+++ polly/unittests/Isl/IslTest.cpp
@@ -1117,4 +1117,77 @@
UMAP("{ DomainRangeA[] -> NewDomainRangeA[];"
"DomainRangeB[] -> NewDomainRangeB[] }")));
}
+
+TEST(Isl, Quota) {
+ std::unique_ptr<isl_ctx, decltype(&isl_ctx_free)> Ctx(isl_ctx_alloc(),
+ &isl_ctx_free);
+
+ isl::set TestSet1{Ctx.get(), "{ [0] }"};
+ isl::set TestSet2{Ctx.get(), "{ [i] : i > 0 }"};
+
+ {
+ IslMaxOperationsGuard MaxOpGuard(Ctx.get(), 1);
+ ASSERT_EQ(isl_options_get_on_error(Ctx.get()), ISL_ON_ERROR_CONTINUE);
+ ASSERT_EQ(isl_ctx_get_max_operations(Ctx.get()), 1ul);
+ ASSERT_FALSE(MaxOpGuard.hasQuotaExceeded());
+
+ // Intentionally exceed the quota. Each allocation will use at least one
+ // operation, guaranteed to exceed the max_operations of 1.
+ isl::id::alloc(Ctx.get(), "A", nullptr);
+ isl::id::alloc(Ctx.get(), "B", nullptr);
+ ASSERT_TRUE(MaxOpGuard.hasQuotaExceeded());
+
+ // Check returned object after exceeded quota.
+ isl::set Union = TestSet1.unite(TestSet2);
+ EXPECT_TRUE(Union.is_null());
+
+ // Check isl::boolean result after exceeded quota.
+ isl::boolean BoolResult = TestSet1.is_empty();
+ EXPECT_TRUE(BoolResult.is_error());
+ EXPECT_FALSE(BoolResult.is_false());
+ EXPECT_FALSE(BoolResult.is_true());
+ EXPECT_DEATH((bool)BoolResult,
+ "IMPLEMENTATION ERROR: Unhandled error state");
+ EXPECT_DEATH((bool)!BoolResult,
+ "IMPLEMENTATION ERROR: Unhandled error state");
+ EXPECT_DEATH(
+ {
+ if (BoolResult) {
+ }
+ },
+ "IMPLEMENTATION ERROR: Unhandled error state");
+ EXPECT_DEATH((void)(BoolResult == false),
+ "IMPLEMENTATION ERROR: Unhandled error state");
+ EXPECT_DEATH((void)(BoolResult == true),
+ "IMPLEMENTATION ERROR: Unhandled error state");
+
+ // Check isl::stat result after exceeded quota.
+ isl::stat StatResult =
+ TestSet1.foreach_point([](isl::point) { return isl::stat::ok(); });
+ EXPECT_TRUE(StatResult.is_error());
+ EXPECT_FALSE(StatResult.is_ok());
+ }
+ ASSERT_EQ(isl_ctx_last_error(Ctx.get()), isl_error_quota);
+ ASSERT_EQ(isl_options_get_on_error(Ctx.get()), ISL_ON_ERROR_WARN);
+ ASSERT_EQ(isl_ctx_get_max_operations(Ctx.get()), 0ul);
+
+ // Operations must work again after leaving the quota scope.
+ {
+ isl::set Union = TestSet1.unite(TestSet2);
+ EXPECT_FALSE(Union.is_null());
+
+ isl::boolean BoolResult = TestSet1.is_empty();
+ EXPECT_FALSE(BoolResult.is_error());
+ EXPECT_TRUE(BoolResult.is_false());
+ EXPECT_FALSE(BoolResult.is_true());
+ EXPECT_FALSE(BoolResult);
+ EXPECT_TRUE(!BoolResult);
+
+ isl::stat StatResult =
+ TestSet1.foreach_point([](isl::point) { return isl::stat::ok(); });
+ EXPECT_FALSE(StatResult.is_error());
+ EXPECT_TRUE(StatResult.is_ok());
+ }
+}
+
} // anonymous namespace


D107401.363877.patch

Riccardo Mori via Phabricator

unread,
Aug 5, 2021, 10:36:50 AM8/5/21
to ll...@meinersbur.de, pat...@autistici.org, siddu...@gmail.com, llvm-c...@lists.llvm.org, poll...@googlegroups.com, bhuvanend...@amd.com, yanli...@intel.com, lege...@outlook.com, micha...@web.de, doug...@gmail.com, jatin....@gmail.com, n...@google.com, wic...@vitalitystudios.com, michae...@gmail.com, phabr...@grosser.es
patacca accepted this revision.
patacca added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107401/new/

https://reviews.llvm.org/D107401

Michael Kruse via Phabricator

unread,
Aug 5, 2021, 3:58:36 PM8/5/21
to pat...@autistici.org, siddu...@gmail.com, llvm-c...@lists.llvm.org, poll...@googlegroups.com, bhuvanend...@amd.com, yanli...@intel.com, lege...@outlook.com, micha...@web.de, doug...@gmail.com, jatin....@gmail.com, n...@google.com, wic...@vitalitystudios.com, michae...@gmail.com, phabr...@grosser.es
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f50ffb3365e: [Polly][test] Add tests for IslMaxOperationsGuard. (authored by Meinersbur).

Repository:
rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107401/new/

https://reviews.llvm.org/D107401

Files:
polly/unittests/Isl/IslTest.cpp


Index: polly/unittests/Isl/IslTest.cpp
===================================================================
--- polly/unittests/Isl/IslTest.cpp
+++ polly/unittests/Isl/IslTest.cpp
@@ -1113,4 +1113,77 @@
D107401.364589.patch
Reply all
Reply to author
Forward
0 new messages