Hi all,
I've written aprogram that uses reflection to give a list of relevant
methods in the Mono.Simd, and reports whether they are accelerated or
not (see below). This small program might be of interest to others, to
see how well their processor behave.
There are methods that have overloaded, for which I should give the
signature, but I'm a bit lost in how this signature should look like.
I tried to convert the ParameterInfo[] of the methods to Type[], as
required by the IsMethodAccelerated method, but this gives erroneous
results. Is it only the parameters list, or is there more to it?
I thought of removing the overloaded methods (see list), but I guess I
might risk to remove relevant methods as well. The overloaded methods
are mainly op_Explicit, LoadAligned, StoreAligned, and the PrefetchXxx
methods. Are these relevant to show up in such a list?
Anyway, I'm quite thrilled to see that almost all of the methods are
accelerated :-).
Bart
using System;
using Mono.Simd;
using System.Reflection;
namespace AcceleratedMethods
{
class MainClass
{
public static void Main(string[] args)
{
// Change to your location of Mono.Simd
string monoSimdLocation = @"/Users/masschel/local/mono/
lib/mono/2.0/Mono.Simd.dll";
Assembly assembly = Assembly.LoadFile(monoSimdLocation);
foreach(Type type in assembly.GetTypes())
{
string typeName = type.Name;
if (typeName.Length>=6 && typeName.Substring(0,6) ==
"Vector")
{
Console.WriteLine("Type {0}", type.Name);
foreach(MethodInfo mi in type.GetMethods())
{
string methodName = mi.Name;
bool ctu = methodName != "Equals"
&& methodName != "GetHashCode"
&& methodName != "ToString"
&& methodName != "GetType"
&& (methodName.Length>=4
&& methodName.Substring(0, 4) !=
"get_"
&& methodName.Substring(0, 4) !=
"set_");
if (ctu)
{
try
{
Console.WriteLine(" Method {0}
{1}", mi.Name, SimdRuntime.IsMethodAccelerated(type, mi.Name));
}
// Overloaded methods
catch
(System.Reflection.AmbiguousMatchException amme)
{
Type[] types = new
Type[mi.GetParameters().Length];
for(int i = 0; i <
mi.GetParameters().Length; i++)
{
types[i] = mi.GetParameters()
[i].GetType();
}
Console.WriteLine("
AmbiguousMatchException for method {0} {1}", mi.Name,
SimdRuntime.IsMethodAccelerated(type, mi.Name, types));
}
}
}
}
}
}
}
}