Walter
Walter

Reputation: 45424

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)

Upvotes: 2

Views: 4299

Answers (2)

RJVB
RJVB

Reputation: 776

On my i7 MBP 13" (mid 2010) running 10.6.8, the current MacPorts gcc 4.7.3 and 4.8.2 do define AVX when -mavx is specified. They however crash compiling code using boost::simd (available via www.metascale.org). Macports clang-3.3 has no such issues, but takes way longer to compile (with or without -mavx, compared to gcc >= 4.7 WITHOUT -mavx).

Upvotes: 0

Gunther Piez
Gunther Piez

Reputation: 30439

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).

Upvotes: 2

Related Questions