You can write a program that checks CPUID and use the output of that program while compiling:
gcc $(cpuid_test) my_prog.c
where cpuid_test returns '-march=bdver1'
or -DXOP_SUPPORT=1
سؤال
I have next problem:
I have some tests related to xop check with using some Bulldozer (xop)
instructions.
And I must run this tests only on Bulldozer
processors.
How can I check that my processor supports xop
instruction at compile-time?
Language: C
, Os: Linux
;
لا يوجد حل صحيح
نصائح أخرى
You can write a program that checks CPUID and use the output of that program while compiling:
gcc $(cpuid_test) my_prog.c
where cpuid_test returns '-march=bdver1'
or -DXOP_SUPPORT=1
You cannot test at compile time, but you can compile for AMD Bulldozer using:
$ gcc -march=bdver1 -mtune=bdver1 ...
See: http://gcc.gnu.org/gcc-4.6/changes.html
If your build machine is your target machine, look into /proc/cpuinfo
.
If a source is compiled with -march=bdver1
(which enables XOP support among other things), the preprocessor macro __XOP__
will be defined to 1.
You can test at compile time for XOP with
#ifdef __XOP__
...XOP code path here...
#else
...non XOP code here...
#endif