Skip to content
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

clang: 18: hangs with a short program in Polly's runIslScheduleOptimizer #69090

Closed
wierton opened this issue Oct 15, 2023 · 3 comments
Closed
Labels
hang Compiler hang (infinite loop) polly

Comments

@wierton
Copy link
Member

wierton commented Oct 15, 2023

Reproducer: https://godbolt.org/z/8K3cs6ood
When compile below program with -O1 -mllvm -polly, clang hangs:

#define IND(x, y) ((x) + (y)*516)
float **a, **b, **c;
__attribute__((noinline)) void foo(
    int I, int J, int K1, int K2, int L1, int L2) {
  for (int i = 0; i < I; i++) {
    float *v = c[i];

    for (volatile int j = 0; j < J; j++) {
      float *in = a[j];
      float *out = b[j];
      for (int l = L1; l < L2; l++) {
        for (int k = K1; k < K2; k++) {
          float sum = 0;
          int offset = 0;
          for (int m = -2; m <= 2; m++) {
            for (int n = -2; n <= 2; n++, offset++)
              sum += in[IND((k + n), (l + m))] * v[offset];
          }
          out[IND(k, l)] = sum;
        }
      }
    }
  }
}
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Oct 15, 2023
@dtcxzyw dtcxzyw added polly hang Compiler hang (infinite loop) and removed clang Clang issues not falling into any other category labels Oct 15, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 15, 2023

@llvm/issue-subscribers-polly

Author: wt.cc (wierton)

Reproducer: https://godbolt.org/z/8K3cs6ood When compile below program with `-O1 -mllvm -polly`, clang hangs:
#define IND(x, y) ((x) + (y)*516)
float **a, **b, **c;
__attribute__((noinline)) void foo(
    int I, int J, int K1, int K2, int L1, int L2) {
  for (int i = 0; i &lt; I; i++) {
    float *v = c[i];

    for (volatile int j = 0; j &lt; J; j++) {
      float *in = a[j];
      float *out = b[j];
      for (int l = L1; l &lt; L2; l++) {
        for (int k = K1; k &lt; K2; k++) {
          float sum = 0;
          int offset = 0;
          for (int m = -2; m &lt;= 2; m++) {
            for (int n = -2; n &lt;= 2; n++, offset++)
              sum += in[IND((k + n), (l + m))] * v[offset];
          }
          out[IND(k, l)] = sum;
        }
      }
    }
  }
}

@kartcq
Copy link
Contributor

kartcq commented Nov 28, 2023

Hi @wierton
The hang is due to a very long compile time issue in Polly's Schedule Optimizer in function runIslScheduleOptimizer. It is calling compute_schedule which is taking a very long time to compute the schedule for this test. Will post a patch to address this.

@fhahn fhahn changed the title clang: 18: hangs with a short program clang: 18: hangs with a short program in Polly's runIslScheduleOptimizer Nov 28, 2023
@chrisj-quic
Copy link

chrisj-quic commented Nov 30, 2023

@kartcq It looks like the computation steps for compule_schedule by isl needs to be bounded. (You can refer Dependences::calculateDependences for an example)

efriedma-quic pushed a commit that referenced this issue Jan 8, 2024
…d in polly (#77280)

There is no upper cap set on current Schedule Optimizer to compute
schedule. In some cases a very long compile time taken to compute the
schedule resulting in hang kind of behavior. This patch introduces a
flag 'polly-schedule-computeout' to pass the capwhich is initialized to
300000. This patch handles the compute out cases by bailing out and
exiting gracefully.

Fixed the test that failed in previous commit.

Fixes #69090
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this issue Jan 28, 2024
…d in polly (llvm#77280)

There is no upper cap set on current Schedule Optimizer to compute
schedule. In some cases a very long compile time taken to compute the
schedule resulting in hang kind of behavior. This patch introduces a
flag 'polly-schedule-computeout' to pass the capwhich is initialized to
300000. This patch handles the compute out cases by bailing out and
exiting gracefully.

Fixed the test that failed in previous commit.

Fixes llvm#69090
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hang Compiler hang (infinite loop) polly
Projects
None yet
Development

No branches or pull requests

5 participants