Optimization and Debugging info

What is the default optimization level for the compiler ?
Does it be true to gain more performance with higher level optimization ?


Interesting problem would be, when I didn’t add any -O option, the program gave
correct answer. However when I used -O0, wrong answer generate.
Also, same issue with -g option.

What is the default optimization level for the compiler?

By default, i.e. when the user does not specify any optimization flag on the command line, the compiler will use “-O”. This is essentially “-O2” but without auto-vectorization and a few others.

Does it be true to gain more performance with higher level optimization ?

There are rare cases where “-O1” is just as fast as “-O2”, but or the vast majority of codes, yes, higher opt levels with give better performance than low opt levels.

Interesting problem would be, when I didn’t add any -O option, the program gave
correct answer. However when I used -O0, wrong answer generate.
Also, same issue with -g option.

I need some context. Is this for sequential CPU code or are you talking about when you use OpenACC? What are you comparing to and if it is against a known output, how was the output generated? Finally, how “wrong” are the results? Fairly close? Completely different?