[polly] r310175 - [unittests] Add unittest for getPartialTilePrefixes
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 5 02:38:09 PDT 2017
Author: grosser
Date: Sat Aug 5 02:38:09 2017
New Revision: 310175
URL: http://llvm.org/viewvc/llvm-project?rev=310175&view=rev
Log:
[unittests] Add unittest for getPartialTilePrefixes
In https://reviews.llvm.org/D36278 it was pointed out that the behavior of
getPartialTilePrefixes is not very well understood. To allow for a better
understanding, we first provide some basic unittests.
Added:
polly/trunk/unittests/ScheduleOptimizer/
polly/trunk/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
Modified:
polly/trunk/include/polly/ScheduleOptimizer.h
polly/trunk/lib/Transform/ScheduleOptimizer.cpp
polly/trunk/unittests/CMakeLists.txt
Modified: polly/trunk/include/polly/ScheduleOptimizer.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScheduleOptimizer.h?rev=310175&r1=310174&r2=310175&view=diff
==============================================================================
--- polly/trunk/include/polly/ScheduleOptimizer.h (original)
+++ polly/trunk/include/polly/ScheduleOptimizer.h Sat Aug 5 02:38:09 2017
@@ -333,4 +333,21 @@ private:
MicroKernelParamsTy MicroKernelParams);
};
+/// Build the desired set of partial tile prefixes.
+///
+/// We build a set of partial tile prefixes, which are prefixes of the vector
+/// loop that have exactly VectorWidth iterations.
+///
+/// 1. Get all prefixes of the vector loop.
+/// 2. Extend it to a set, which has exactly VectorWidth iterations for
+/// any prefix from the set that was built on the previous step.
+/// 3. Subtract loop domain from it, project out the vector loop dimension and
+/// get a set of prefixes, which don't have exactly VectorWidth iterations.
+/// 4. Subtract it from all prefixes of the vector loop and get the desired
+/// set.
+///
+/// @param ScheduleRange A range of a map, which describes a prefix schedule
+/// relation.
+isl::set getPartialTilePrefixes(isl::set ScheduleRange, int VectorWidth);
+
#endif
Modified: polly/trunk/lib/Transform/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/ScheduleOptimizer.cpp?rev=310175&r1=310174&r2=310175&view=diff
==============================================================================
--- polly/trunk/lib/Transform/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/Transform/ScheduleOptimizer.cpp Sat Aug 5 02:38:09 2017
@@ -308,23 +308,7 @@ static isl::set addExtentConstraints(isl
return Set.add_constraint(ExtConstr);
}
-/// Build the desired set of partial tile prefixes.
-///
-/// We build a set of partial tile prefixes, which are prefixes of the vector
-/// loop that have exactly VectorWidth iterations.
-///
-/// 1. Get all prefixes of the vector loop.
-/// 2. Extend it to a set, which has exactly VectorWidth iterations for
-/// any prefix from the set that was built on the previous step.
-/// 3. Subtract loop domain from it, project out the vector loop dimension and
-/// get a set of prefixes, which don't have exactly VectorWidth iterations.
-/// 4. Subtract it from all prefixes of the vector loop and get the desired
-/// set.
-///
-/// @param ScheduleRange A range of a map, which describes a prefix schedule
-/// relation.
-static isl::set getPartialTilePrefixes(isl::set ScheduleRange,
- int VectorWidth) {
+isl::set getPartialTilePrefixes(isl::set ScheduleRange, int VectorWidth) {
unsigned Dims = ScheduleRange.dim(isl::dim::set);
isl::set LoopPrefixes = ScheduleRange.project_out(isl::dim::set, Dims - 1, 1);
isl::set ExtentPrefixes = LoopPrefixes.add_dims(isl::dim::set, 1);
Modified: polly/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/unittests/CMakeLists.txt?rev=310175&r1=310174&r2=310175&view=diff
==============================================================================
--- polly/trunk/unittests/CMakeLists.txt (original)
+++ polly/trunk/unittests/CMakeLists.txt Sat Aug 5 02:38:09 2017
@@ -23,3 +23,4 @@ add_subdirectory(Isl)
add_subdirectory(Flatten)
add_subdirectory(DeLICM)
add_subdirectory(ScopPassManager)
+add_subdirectory(ScheduleOptimizer)
Added: polly/trunk/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp?rev=310175&view=auto
==============================================================================
--- polly/trunk/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp (added)
+++ polly/trunk/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp Sat Aug 5 02:38:09 2017
@@ -0,0 +1,60 @@
+//===- ScheduleOptimizerTest.cpp ------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "polly/ScheduleOptimizer.h"
+#include "gtest/gtest.h"
+#include "isl/stream.h"
+#include "isl/val.h"
+
+using namespace isl;
+namespace {
+
+TEST(ScheduleOptimizer, getPartialTilePrefixes) {
+
+ isl_ctx *ctx = isl_ctx_alloc();
+
+ {
+ // Verify that for loop with 3 iterations starting at 0 that is
+ // pre-vectorized (strip-mined with a factor of 2), we correctly identify
+ // that only the first two iterations are full vector iterations.
+ isl::map Schedule(
+ ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 0 <= i < 3 }");
+ isl::set ScheduleRange = Schedule.range();
+ isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
+
+ EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[0]}")));
+ }
+
+ {
+ // Verify that for loop with 3 iterations starting at 1 that is
+ // pre-vectorized (strip-mined with a factor of 2), we correctly identify
+ // that only the last two iterations are full vector iterations.
+ isl::map Schedule(
+ ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 4 }");
+ isl::set ScheduleRange = Schedule.range();
+ isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
+
+ EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]}")));
+ }
+
+ {
+ // Verify that for loop with 6 iterations starting at 1 that is
+ // pre-vectorized (strip-mined with a factor of 2), we correctly identify
+ // that all but the first and the last iteration are full vector iterations.
+ isl::map Schedule(
+ ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 6 }");
+ isl::set ScheduleRange = Schedule.range();
+ isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
+
+ EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]; [2]}")));
+ }
+
+ isl_ctx_free(ctx);
+}
+} // anonymous namespace
More information about the llvm-commits
mailing list