Search code examples
c++compilationcudanvcc

What is option -O3 for g++ and nvcc?


I'm new to nvcc and I've seen a library where compilation is done with option -O3, for g++ and nvcc.

CC=g++
CFLAGS=--std=c++11 -O3
NVCC=nvcc
NVCCFLAGS=--std=c++11 -arch sm_20 -O3

What is -O3 doing ?


Solution

  • It's optimization on level 3, basically a shortcut for
    several other options related to speed optimization etc. (see link below).

    I can't find any documentation on it.

    ... it is one of the best known options:

    https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

    http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#options-for-altering-compiler-linker-behavior