Author: post
Date: 2011-03-06 10:00:15 +0100 (Sun, 06 Mar 2011)
New Revision: 3837
Modified:
trunk/librawstudio/rs-utils.c
trunk/librawstudio/x86-cpu.h
Log:
Detect AVX extensions and OS support.
Modified: trunk/librawstudio/rs-utils.c
===================================================================
--- trunk/librawstudio/rs-utils.c 2011-02-27 23:46:47 UTC (rev 3836)
+++ trunk/librawstudio/rs-utils.c 2011-03-06 09:00:15 UTC (rev 3837)
@@ -198,6 +198,9 @@
#if defined (__i386__) || defined (__x86_64__)
+#define xgetbv(index,eax,edx) \
+ __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
+
/**
* Detect cpu features
* @return A bitmask of @RSCpuFlags
@@ -280,7 +283,13 @@
if (ecx & 0x00080000)
cpuflags |= RS_CPU_FLAG_SSE4_1;
if (ecx & 0x00100000)
- cpuflags |= RS_CPU_FLAG_SSE4_2;
+ cpuflags |= RS_CPU_FLAG_SSE4_2;
+ if ((ecx & 0x18000000) == 0x18000000)
+ {
+ xgetbv(0, eax, edx);
+ if ((eax & 0x6) == 0x6)
+ cpuflags |=
RS_CPU_FLAG_AVX;
+ }
}
/* Is there extensions */
@@ -319,6 +328,7 @@
report("SSSE3",RS_CPU_FLAG_SSSE3);
report("SSE4.1",RS_CPU_FLAG_SSE4_1);
report("SSE4.2",RS_CPU_FLAG_SSE4_2);
+ report("AVX",RS_CPU_FLAG_AVX);
#undef report
return(stored_cpuflags);
Modified: trunk/librawstudio/x86-cpu.h
===================================================================
--- trunk/librawstudio/x86-cpu.h 2011-02-27 23:46:47 UTC (rev 3836)
+++ trunk/librawstudio/x86-cpu.h 2011-03-06 09:00:15 UTC (rev 3837)
@@ -12,7 +12,8 @@
RS_CPU_FLAG_SSE3 = 1<<7,
RS_CPU_FLAG_SSSE3 = 1<<8,
RS_CPU_FLAG_SSE4_1 = 1<<9,
- RS_CPU_FLAG_SSE4_2 = 1<<10
+ RS_CPU_FLAG_SSE4_2 = 1<<10,
+ RS_CPU_FLAG_AVX = 1<<11
} RSCpuFlags;
#if defined(__x86_64__)
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit