Skip to content

[polly][ScheduleOptimizer] Use IslMaxOperationsGuard helper instead of explicit restoration #79303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions polly/lib/Transform/ScheduleOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,23 +868,14 @@ static void runIslScheduleOptimizer(
SC = SC.set_validity(Validity);
SC = SC.set_coincidence(Validity);

// Save error handling behavior
long MaxOperations = isl_ctx_get_max_operations(Ctx);
isl_ctx_set_max_operations(Ctx, ScheduleComputeOut);
Schedule = SC.compute_schedule();
bool ScheduleQuota = false;
if (isl_ctx_last_error(Ctx) == isl_error_quota) {
isl_ctx_reset_error(Ctx);
LLVM_DEBUG(
dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
ScheduleQuota = true;
}
isl_options_set_on_error(Ctx, ISL_ON_ERROR_ABORT);
isl_ctx_reset_operations(Ctx);
isl_ctx_set_max_operations(Ctx, MaxOperations);
{
IslMaxOperationsGuard MaxOpGuard(Ctx, ScheduleComputeOut);
Schedule = SC.compute_schedule();

if (ScheduleQuota)
return;
if (MaxOpGuard.hasQuotaExceeded())
LLVM_DEBUG(
dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
}

isl_options_set_on_error(Ctx, OnErrorStatus);

Expand Down
4 changes: 2 additions & 2 deletions polly/test/ScheduleOptimizer/schedule_computeout.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; RUN: opt %loadPolly -S -polly-optree -polly-delicm -polly-opt-isl -polly-schedule-computeout=100000 -debug-only="polly-opt-isl" < %s 2>&1 | FileCheck %s
; RUN: opt %loadPolly -S -polly-optree -polly-delicm -polly-opt-isl -polly-schedule-computeout=10000 -debug-only="polly-opt-isl" < %s 2>&1 | FileCheck %s
; REQUIRES: asserts

; Bailout if the computations of schedule compute exceeds the max scheduling quota.
; Max compute out is initialized to 300000, Here it is set to 100000 for test purpose.
; Max compute out is initialized to 300000, Here it is set to 10000 for test purpose.

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
Expand Down