brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a2f3479 Raw
60 lines · cpp
1//===- ScheduleTreeTransformTest.cpp --------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "polly/ScheduleTreeTransform.h"10#include "gtest/gtest.h"11#include "isl/ctx.h"12 13using namespace isl;14using namespace polly;15 16namespace {17 18TEST(ScheduleTreeTransform, getPartialTilePrefixes) {19  isl_ctx *ctx = isl_ctx_alloc();20 21  {22    // Verify that for a loop with 3 iterations starting at 0 that is23    // pre-vectorized (strip-mined with a factor of 2), we correctly identify24    // that only the first two iterations are full vector iterations.25    isl::map Schedule(26        ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 0 <= i < 3 }");27    isl::set ScheduleRange = Schedule.range();28    isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);29 30    EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[0]}")));31  }32 33  {34    // Verify that for a loop with 3 iterations starting at 1 that is35    // pre-vectorized (strip-mined with a factor of 2), we correctly identify36    // that only the last two iterations are full vector iterations.37    isl::map Schedule(38        ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 4 }");39    isl::set ScheduleRange = Schedule.range();40    isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);41 42    EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]}")));43  }44 45  {46    // Verify that for a loop with 6 iterations starting at 1 that is47    // pre-vectorized (strip-mined with a factor of 2), we correctly identify48    // that all but the first and the last iteration are full vector iterations.49    isl::map Schedule(50        ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 6 }");51    isl::set ScheduleRange = Schedule.range();52    isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);53 54    EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]; [2]}")));55  }56 57  isl_ctx_free(ctx);58}59} // anonymous namespace60