[llvm-dev] How to use the pass 'Unroll and Jam'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] How to use the pass 'Unroll and Jam'

Tingyuan LIANG via llvm-dev
Dear LLVM developers,

Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps.

Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8:

1) Simple 2D array source code (loop.c) is given

```
#define M 32768
#define N 32768

double a[M][N], b[M][N], c[M][N];

int main() {
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            c[i][j] = a[i][j] + b[i][j];
        }
    }
    return 0;
}
```

2) Create an LLVM IR file
./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll

3) Run the 'unroll-and-jam' pass
./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll

I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager.
```
   ModulePass Manager
       FunctionPass Manager
        Dominator Tree Construction
        Basic Alias Analysis (stateless AA impl)
        Function Alias Analysis Results
        Natural Loop Information
        Scalar Evolution Analysis
        Dependence Analysis
        Canonicalize natural loops
        LCSSA Verifier
        Loop-Closed SSA Form Pass
        Loop Pass Manager
          Unroll and Jam loops
        Module Verifier
       Print Module IR
```

I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing.

Thank you very much.
--
Zhen Wei (魏禛)
Master Student
Department of Computer Science & Information  Engineering
National Taiwan University
Email:  [hidden email]

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] How to use the pass 'Unroll and Jam'

Tingyuan LIANG via llvm-dev

Try the combo:

 

-enable-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4

 

From: llvm-dev <[hidden email]> On Behalf Of ZHEN WEI via llvm-dev
Sent: Thursday, April 25, 2019 12:13 PM
To: [hidden email]
Subject: [llvm-dev] How to use the pass 'Unroll and Jam'

 

Dear LLVM developers,

 

Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps.

 

Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8:

1) Simple 2D array source code (loop.c) is given

 

```

#define M 32768

#define N 32768

 

double a[M][N], b[M][N], c[M][N];

 

int main() {

    for (int i = 0; i < M; i++) {

        for (int j = 0; j < N; j++) {

            c[i][j] = a[i][j] + b[i][j];

        }

    }

    return 0;

}

```

2) Create an LLVM IR file

./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll

 

3) Run the 'unroll-and-jam' pass

./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll

 

I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager.

```

   ModulePass Manager
       FunctionPass Manager
        Dominator Tree Construction
        Basic Alias Analysis (stateless AA impl)
        Function Alias Analysis Results
        Natural Loop Information
        Scalar Evolution Analysis
        Dependence Analysis
        Canonicalize natural loops
        LCSSA Verifier
        Loop-Closed SSA Form Pass
        Loop Pass Manager
          Unroll and Jam loops
        Module Verifier
       Print Module IR

```

 

I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing.

 

Thank you very much.

--

Zhen Wei (魏禛)
Master Student
Department of Computer Science & Information  Engineering
National Taiwan University
Email:  [hidden email]


_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] How to use the pass 'Unroll and Jam'

Tingyuan LIANG via llvm-dev
Hi Das,

Thanks for your reply! I have received similar responses from @LebedevRI on the IRC.

After I modified the arguments for opt as the following, my loops can be unroll-and-jam successfully:
-loop-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=2

'loop-unroll-and-jam' and 'allow-unroll-and-jam' are both needed to turn on the functionality.

Thanks again. Have a nice day.

Das, Dibyendu <[hidden email]> 於 2019年4月25日 週四 下午4:24寫道:

Try the combo:

 

-enable-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4

 

From: llvm-dev <[hidden email]> On Behalf Of ZHEN WEI via llvm-dev
Sent: Thursday, April 25, 2019 12:13 PM
To: [hidden email]
Subject: [llvm-dev] How to use the pass 'Unroll and Jam'

 

Dear LLVM developers,

 

Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps.

 

Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8:

1) Simple 2D array source code (loop.c) is given

 

```

#define M 32768

#define N 32768

 

double a[M][N], b[M][N], c[M][N];

 

int main() {

    for (int i = 0; i < M; i++) {

        for (int j = 0; j < N; j++) {

            c[i][j] = a[i][j] + b[i][j];

        }

    }

    return 0;

}

```

2) Create an LLVM IR file

./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll

 

3) Run the 'unroll-and-jam' pass

./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll

 

I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager.

```

   ModulePass Manager
       FunctionPass Manager
        Dominator Tree Construction
        Basic Alias Analysis (stateless AA impl)
        Function Alias Analysis Results
        Natural Loop Information
        Scalar Evolution Analysis
        Dependence Analysis
        Canonicalize natural loops
        LCSSA Verifier
        Loop-Closed SSA Form Pass
        Loop Pass Manager
          Unroll and Jam loops
        Module Verifier
       Print Module IR

```

 

I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing.

 

Thank you very much.

--

Zhen Wei (魏禛)
Master Student
Department of Computer Science & Information  Engineering
National Taiwan University
Email:  [hidden email]



--
Zhen Wei (魏禛)
Master Student
Department of Computer Science & Information  Engineering
National Taiwan University
Email:  [hidden email]

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev