2

We are having problem with Lapack compiled on a MacBook Pro Late 2013. The compiler complains about unsupported vector instructions when compiled with -march=native:

no such instruction: `vmovss (%rdx), %xmm0'

With -march=core2 everything is fine.

The problem is: How to detect the processor architecture in ? Currently, waf is aware of running on a machine with the Darwin OS, but the problem is not related to the OS but the processor, so this doesn't help.

I'm not asking how to get the assembler error fixed! I'm asking how to have waf detect the processor architecture.

PVitt
  • 11,500
  • 5
  • 51
  • 85
  • You may need to fix assembler as outlines in this answer: http://stackoverflow.com/questions/9840207/how-to-use-avx-pclmulqdq-on-mac-os-x-lion – ArtemB Apr 24 '14 at 17:52
  • 2
    In Linux you can just check `/proc/cpuinfo` and see if AVX is there. Sadly, it seems Mac does not provide that feature. – Davidmh Jun 04 '14 at 13:07

2 Answers2

1

This can help to identify the INTEL processor family. Run this piece of code

#include "stdio.h"
int main () {

  int ebx = 0, ecx = 0, edx = 0, eax = 1;
  __asm__ ("cpuid": "=b" (ebx), "=c" (ecx), "=d" (edx), "=a" (eax):"a" (eax));

  int model = (eax & 0x0FF) >> 4;
  int extended_model = (eax & 0xF0000) >> 12;
  int family_code = (eax & 0xF00) >> 8;
  int extended_family_code = (eax & 0xFF00000) >> 16;

  printf (" model %x\n extended_model %x\n family_code %x\n extended_family_code %x \n", eax, ebx, ecx, edx);
  printf ("CPUID: %02x %x\n", extended_family_code | family_code, extended_model | model);
  return 0;
}

Then look into the table given here processor arch. You will get to know your processor family.

sourabhxiii
  • 132
  • 2
  • 8
  • Thanks for the answer. But this is unfortunately C code. Waf is written in Python. Sorry for not mentioning that beforehand. – PVitt Jun 04 '14 at 12:52
1

Waf currently has no builtin feature for detecting CPU extensions. The vmovss instruction is part of the AVX instruction set. In a C file, you can check if AVX is available using the __AVX__ preprocessor macro:

int blah() {
    #ifdef __AVX__
         avx code here
    #else
         something else
    #endif
}

This would be my preferred solution to solve your problem. Then you wouldn't need to involve the build tool. Though you can ofcourse execute the same check with WAF:

def configure(ctx):
    ctx.check(msg = 'Checking for AVX support',
              execute = True,
              fragment='''int main() {
              #ifdef __AVX__
              return 0;
              #else
              return 1;
              #endif
              }\n''')

This requires that you use the -march=native option, otherwise your compiler is unlikely to enable AVX.

Björn Lindqvist
  • 19,221
  • 20
  • 87
  • 122