[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. llvm-svn: 310175
This commit is contained in:
parent
691d0243a5
commit
feae3dfe9f
@ -333,4 +333,21 @@ private:
|
|||||||
MicroKernelParamsTy MicroKernelParams);
|
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
|
#endif
|
||||||
|
@ -308,23 +308,7 @@ static isl::set addExtentConstraints(isl::set Set, int VectorWidth) {
|
|||||||
return Set.add_constraint(ExtConstr);
|
return Set.add_constraint(ExtConstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the desired set of partial tile prefixes.
|
isl::set getPartialTilePrefixes(isl::set ScheduleRange, int VectorWidth) {
|
||||||
///
|
|
||||||
/// 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) {
|
|
||||||
unsigned Dims = ScheduleRange.dim(isl::dim::set);
|
unsigned Dims = ScheduleRange.dim(isl::dim::set);
|
||||||
isl::set LoopPrefixes = ScheduleRange.project_out(isl::dim::set, Dims - 1, 1);
|
isl::set LoopPrefixes = ScheduleRange.project_out(isl::dim::set, Dims - 1, 1);
|
||||||
isl::set ExtentPrefixes = LoopPrefixes.add_dims(isl::dim::set, 1);
|
isl::set ExtentPrefixes = LoopPrefixes.add_dims(isl::dim::set, 1);
|
||||||
|
@ -23,3 +23,4 @@ add_subdirectory(Isl)
|
|||||||
add_subdirectory(Flatten)
|
add_subdirectory(Flatten)
|
||||||
add_subdirectory(DeLICM)
|
add_subdirectory(DeLICM)
|
||||||
add_subdirectory(ScopPassManager)
|
add_subdirectory(ScopPassManager)
|
||||||
|
add_subdirectory(ScheduleOptimizer)
|
||||||
|
60
polly/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
Normal file
60
polly/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user