Schnellen Code mit GNU Compiler erzeugen



  • Hallo Forum,

    ich habe einen Source den ich möglichst schnell ausführen lassen möchte. Mit welchen Optionen kompiliere ich ihn? Der Rechner ist ein Intel Core2 Duo (http://de.wikipedia.org/wiki/Intel_Core_2) Processor 1,8GHz. In den Compiler Optionen ist das einzige was passen könnte: "Intel Pentium Nocona (MMX, SSE, SSE2, SSE3, 64 bit extension)". Aber wenn ich es do kompiliere gibt es keinen Geschwindigkeitsvorteil. Heißt das nun das mein Programm nicht optimiert werden konnte? Oder bringen diese Technologien (SSE, MMX) nicht allzuviel bei cryptographischen Berechnungen? (Viel MD5 und SHA256 Rechnungen, ...)

    Und bei diesen Optimierungen O1 bis O3: Muß ich da alle 3 anklicken oder reicht nur O3?

    Vielen Dank

    A



  • Der Link zu den Compiler options:
    http://www.network-theory.co.uk/docs/gccintro/gccintro_49.html

    -O1 or -O
    This level turns on the most common forms of optimization that do not require any speed-space tradeoffs. With this option the resulting executables should be smaller and faster than with -O0. The more expensive optimizations, such as instruction scheduling, are not used at this level. Compiling with the option -O1 can often take less time than compiling with -O0, due to the reduced amounts of data that need to be processed after simple optimizations.
    -O2
    This option turns on further optimizations, in addition to those used by -O1. These additional optimizations include instruction scheduling. Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages.
    -O3
    This option turns on more expensive optimizations, such as function inlining, in addition to all the optimizations of the lower levels -O2 and -O1. The -O3 optimization level may increase the speed of the resulting executable, but can also increase its size. Under some circumstances where these optimizations are not favorable, this option might actually make a program slower.



  • -03 und -mtune=core2

    Falls dies kein Leistungszuwach erbingt, dann tut es mir leid xD

    UPDATE: Korrekt mtune parameter 😉



  • nimm den intel-compiler.





  • Hört sich gut an, und werde "-m core2" gleich mal zusätzlich setzen. Leider habe ich mein prj gerade vollkommen auseinander genommen... werde es vor dem Feierabend nicht testen können.



  • Wenn dein GCC aktuell genug ist kannst du auch einfach -march=native angeben, dann sucht sich GCC schon das passende aus 🙂


Anmelden zum Antworten