Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

the icx compiler option to unroll all loops is ?

mochongli
Novice
1,587 Views

/O3 /arch:CORE-AVX2/O3 /arch:CORE-AVX2/O3 /QxHost/O3 /QxHost
I found that compiling with this option on Windows seems to unroll all loops? /QxHost

0 Kudos
15 Replies
NoorjahanSk_Intel
Moderator
1,545 Views

Hi,


Thanks for posting in Intel Communities.


Could you please provide us with the below details, so that we can investigate it from our end?

1. sample reproducer and detailed steps you have followed to build the sample code.

2. How you are able to visualize the output?

3. OS/Hardware details and compiler version being used.


Thanks & Regards,

Noorjahan.


0 Kudos
mochongli
Novice
1,512 Views

1:Use vs2022 to create a new project and then specify icx instead of using the command line.
Because the command line and ide have different default compilation options.
Code:

 

 

#include <string>
#include <algorithm>
#include <cstdlib>

int main()
{
    std::string text;
    for (int i = 0; i < 200000; ++i) text += std::to_string(i);
    size_t numChars = text.size();

    int* suffixes = new int[numChars];
    for (size_t i = 0; i < numChars; i++) suffixes[i] = i;

    std::sort(suffixes, suffixes + numChars,
        [&](int x, int y) {
            return std::lexicographical_compare(
                text.begin() + x,
                text.end(),
                text.begin() + y,
                text.end()); });

}

 

 

 Then add the compile option to compile.
2: IDA free f5
3:19044.2846/Intel(R) oneAPI DPC++/C++ Compiler 2023.1.0 (2023.1.0.20230320)

0 Kudos
NoorjahanSk_Intel
Moderator
1,452 Views

Hi,


Thanks for providing the details.


>>IDA free f5

Could you please confirm whether this is an analysis tool? If yes, please provide us with the detailed steps you have followed to visualize the output so that we can also try it from our end.


Also please provide the IDA free f5 version along with hardware details.

 

Thanks & Regards,

Noorjahan


0 Kudos
mochongli
Novice
1,409 Views

I confirm it is. After downloading and installing it, you can open the compiled file with it and press F5 to see.
https://hex-rays.com/ida-free/#download

0 Kudos
NoorjahanSk_Intel
Moderator
1,355 Views

Hi,

 

Thanks for providing the details.

 

We have tried with IDA-Free and When we try to press F5, Pseudocode-A Tab opens after loading the executable, so we cannot visualize a Graph.

Please refer to the below screenshot for more details:

NoorjahanSk_Intel_0-1683105855183.png

 

If we select one particular function, we can see the Graph.

Please refer to the below screenshot for more details:

NoorjahanSk_Intel_1-1683105908011.png

 

Could you please help us in reproducing the issue with detailed steps, so that we can investigate your issue at our end?

 

Thanks & Regards,

Noorjahan.

 

 

0 Kudos
mochongli
Novice
1,296 Views

do you compile with release configuration?
I was wrong before, you don't need to press F5, just use IDA to open the compiled program.
/O3 /arch:CORE-AVX2/O3 /arch:CORE-AVX2/O3 /QxHost/O3 /QxHost

0 Kudos
NoorjahanSk_Intel
Moderator
1,180 Views

Hi,


We are also able to reproduce the issue at our end. We have reported this issue to the concerned development team. They are looking into your issue.


Thanks & Regards,

Noorjahan.


0 Kudos
NoorjahanSk_Intel
Moderator
1,108 Views

Hi,


To unroll the loops, you can use the /Qunroll option with icx compiler.

Please refer to below link for more details:

https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/unroll-qunroll.html


Could you please let us know the exact issue you observed with /QxHost option?

Could you please let us know if you face any issues with the /Qunroll option?


Thanks & Regards,

Noorjahan.


0 Kudos
mochongli
Novice
1,099 Views

/Qunroll just sets the maximum number
I want /arch:CORE-AVX2 to use the same optimization as /QxHost
How do I know which option to use when compiling?

0 Kudos
NoorjahanSk_Intel
Moderator
1,040 Views

Hi,


Using /Qunroll without setting n will let the compiler decide the number of loops to unroll. 

Could you please try compiling with /arch:CORE-AVX2 and /Qunroll to see if it matches the behavior of /QxHost?


Thanks & Regards,

Noorjahan


0 Kudos
mochongli
Novice
1,031 Views

The compiler uses default heuristics when unrolling loops.

0 Kudos
mochongli
Novice
1,022 Views

I looked at the clang and icx documentation, why there is no option for Unroll all loops, like GCC's -funroll-all-loops. And only can be set to some value, which is hard for me to control, higher values the compile time will be very long. And /QxHost looks somewhat similar to -funroll-all-loops, so I want to know if there are any options to view which options were used during compilation.

0 Kudos
NoorjahanSk_Intel
Moderator
917 Views

Hi,

 

>>if there are any options to view which options were used during compilation.

 

You can use "-###" flag during compilation to see all the options being used under the hood.

You can add the flag under 

Properties>C/C++>Command Line> Additional Options.

 

You can also try "-###" flag to get all compilation options in oneAPI command prompt. 

Please find the below screenshot for more details:

NoorjahanSk_Intel_0-1686896739537.png

 

Thanks & Regards,

Noorjahan.

 

NoorjahanSk_Intel
Moderator
878 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks & Regards,

Noorjahan.


NoorjahanSk_Intel
Moderator
824 Views

Hi,


I have not heard back from you, so I will close this inquiry now. If you need further assistance, please post a new question.


Thanks & Regards,

Noorjahan.


Reply