Search code examples
macosgccosx-mountain-lionavx

gcc doesn't want to use AVX on mac


So I have this brand new mac book pro with intel core I7 processor and sysctl machdep.cpu.features giving

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 xAPIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C

yet when I run gcc (4.7.2 macports), it doesn't #define __AVX__. What's wrong? (Mac OS X 10.8.2)


Solution

  • I depends on the compiler flags you are using wether __AVX__ and __SSEx__ will be defined.

    So if you are using g++ -march=corei7avx the macro will be defined. -march=native should also suffice, if gcc is able to detect you cpu correctly (it usually is).