Comparison of Clang and GCC

Comparison is extremely informal, using non-vectorized Zakharov 1-D ionospheric plasma kinetics simulation code that does a lot of multiply/divide/exponent/add. Note, each line has

-lboost_system -lboost_filesystem -lboost_program_options

at the end, omitted for clarity.

Summary of Clang / g++ comparison

using

-march=native -mllvm -vectorize-loops clang++ 3.2 on Ubuntu 13.04 was the fastest by about 25% advantage over g++ 4.6 on Ubuntu 12.04, same CPU type

Both PCs used Core i7 Sandy Bridge. PC1: Ubuntu 12.04, Clang 3.0, g++ 4.6.3 compiled using:

clang++ -O3 -std=c++0x zakh.cpp -lncurses -lm normalized time to run compiled code: 1.0 (using this as PC1 reference)

compiled using

g++ -O3 -std=c++0x zakh.cpp -lncurses -lm normalized time to run compiled code: 1.0 approximately (not a noticeable change)

compiled using

g++ -O3 -march=native -std=c++0xzakh.cpp -lncurses -lm normalized time to run compiled code: 0.95 approximately (slightly better)

PC2: Ubuntu 13.04, Clang 3.2, g++ 4.7.3 (first running the executable copied from PC1) – use as PC2 reference: 1.0

compiled using:

clang++ -O3 -std=c++11 zakh.cpp -lncurses -lm normalized time to run compiled code: 0.95 (slightly faster)

compiled using:

g++ -O3 -std=c++11zakh.cpp -lncurses -lm normalized time to run compiled code: 0.95 (slightly faster)

compiled using

g++ -O3 -march=native -std=c++11 zakh.cpp -lncurses -lm normalized time to run compiled code: **0.9 (faster than same options used on Ubuntu 12.04 PC)**

compiled using

clang++ -O3 -march=native -mllvm -vectorize-loops -std=c++11 zakh.cpp -lncurses -lm normalized time to run compiled code: 0.8 (a lot faster than Clang 3.0 (no loop vectorization))

Tags:

Categories:

Updated:

Leave a Comment