lol! I have been known to do things like that! *shakes head at self.*
Here it is!
Sorry.
Hope you enjoy it. Got one request though, like someone with an AMD
machine with sse4a to try it out and tell me what they got.
Alex Shulgin wrote:
> Jerry Maine - KF5ADY wrote:
>> Here is the patch I wrote to detect sse4a, it is released under MIT/X11.
>>
>> Comments questions? [Yes, I tested it the best I could on my AMD machine
>> which doesn't support sse4a.]
>
> Obviously, you forgot the patch itself.
>
Index: mono/mini/mini-amd64.c
===================================================================
--- mono/mini/mini-amd64.c (revision 144855)
+++ mono/mini/mini-amd64.c (working copy)
@@ -939,7 +939,6 @@
*
* Returns a bitmask corresponding to all supported versions.
*
- * TODO detect other versions like SSE4a.
*/
guint32
mono_arch_cpu_enumerate_simd_versions (void)
@@ -961,6 +960,19 @@
if (ecx & (1 << 20))
sse_opts |= 1 << SIMD_VERSION_SSE42;
}
+
+ /* Yes, all this needs to be done to check for sse4a.
+ See: "Amd: CPUID Specification"
+ */
+ if (cpuid (0x80000000, &eax, &ebx, &ecx, &edx)) {
+ /* eax greater or equal than 0x80000001, ebx = 'htuA', ecx = DMAc', edx = 'itne'*/
+ if ((((unsigned int) eax) >= 0x80000001) && (ebx == 0x68747541) && (ecx == 0x444D4163) && (edx == 0x69746E65)) {
+ cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
+ if (ecx & (1 << 6))
+ sse_opts |= 1 << SIMD_VERSION_SSE4a;
+ }
+ }
+
return sse_opts;
}
Index: mono/mini/basic-simd.cs
===================================================================
--- mono/mini/basic-simd.cs (revision 144855)
+++ mono/mini/basic-simd.cs (working copy)
@@ -3123,6 +3123,7 @@
}
public static int Main (String[] args) {
+ Console.WriteLine(SimdRuntime.AccelMode);
return TestDriver.RunTests (typeof (SimdTests), args);
}
}
Index: mono/mini/mini-x86.c
===================================================================
--- mono/mini/mini-x86.c (revision 144855)
+++ mono/mini/mini-x86.c (working copy)
@@ -698,7 +698,6 @@
*
* Returns a bitmask corresponding to all supported versions.
*
- * TODO detect other versions like SSE4a.
*/
guint32
mono_arch_cpu_enumerate_simd_versions (void)
@@ -720,6 +719,20 @@
if (ecx & (1 << 20))
sse_opts |= 1 << SIMD_VERSION_SSE42;
}
+
+ /* Yes, all this needs to be done to check for sse4a.
+ See: "Amd: CPUID Specification"
+ */
+ if (cpuid (0x80000000, &eax, &ebx, &ecx, &edx)) {
+ /* eax greater or equal than 0x80000001, ebx = 'htuA', ecx = DMAc', edx = 'itne'*/
+ if ((((unsigned int) eax) >= 0x80000001) && (ebx == 0x68747541) && (ecx == 0x444D4163) && (edx == 0x69746E65)) {
+ cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
+ if (ecx & (1 << 6))
+ sse_opts |= 1 << SIMD_VERSION_SSE4a;
+ }
+ }
+
+
return sse_opts;
}
_______________________________________________
Mono-devel-list mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-devel-list