如何JitIntrinsicAttribute影响code一代? [英] How does JitIntrinsicAttribute affect code generation?

查看:180
本文介绍了如何JitIntrinsicAttribute影响code一代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览.NET源$ C ​​$ C,看到<一href="https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/JitIntrinsicAttribute.cs"相对=nofollow>这个属性。它说,

I was browsing .NET source code and saw this attribute. It says,

这可以附着到JIT固有方法的属性/特性

An attribute that can be attached to JIT Intrinsic methods/properties

和根据<一href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.isjitintrinsic(v=vs.100).aspx"相对=nofollow> MSDN :

表示一个修改的方法是其中所述的特性值   刚刚在实时(JIT)编译器可以执行特殊的code一代。本   类不能被继承。

Indicates that a modified method is an intrinsic value for which the just-in-time (JIT) compiler can perform special code generation. This class cannot be inherited.

但我有麻烦找的如何的。什么样的code将执行一个特殊的code一代?

but I had trouble to find how. On what kind of code it performs a special code generation?

我的主要的猜测是,它主要采用SIMD一样,像<处理器指令href="http://stackoverflow.com/questions/13244898/are-all-the-magic-methods-on-the-jvm-marked-as-native/13244964#13244964">Java JIT确实。这里是<一个href="https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/Vector.cs"相对=nofollow>一个例子的。我很好奇它的加速,我不知道,如果单做这件事。

My main guess is that it mainly uses processor instructions like SIMD, something like Java JIT does. Here is an example. I'm curious about the acceleration it does and I wonder if Mono does this too.

推荐答案

这是具体到<一个href="http://blogs.msdn.com/b/dotnet/archive/2013/09/30/ryujit-the-next-generation-jit-compiler.aspx"相对=nofollow> RyuJIT ,下一代64位抖动,微软目前正在开发。仍然在阿尔法(又名CTP),.NET和Visual Studio的下一个版本将于包含它。目前在.NET 4.6 preVIEW。

This is specific to RyuJIT, the next generation 64-bit jitter that Microsoft is currently working on. Still in alpha (aka CTP), the next version of .NET and Visual Studio is slated to include it. Currently available in the .NET 4.6 Preview.

在RyuJIT一个新的特点是它能够产生SIMD机code,趁着矢量指令的Intel / AMD处理器的能力。制作浮在阵列浮点运算高达4倍倍的速度。在[JitIntrisic]属性是一个标志为C#code表示RyuJIT有,它会生成SIMD版本的机器code,而不是正常的非量化版本特殊的内置知识。

One new feature in RyuJIT is its ability to generate SIMD machine code, taking advantage of vectorization instructions in Intel/AMD processors. Making floating point operations on arrays up to x4 times faster. The [JitIntrisic] attribute is a marker for C# code that RyuJIT has special built-in knowledge of, it will generate the SIMD version of the machine code instead of the normal non-vectorized version.

请记住,这仍然是一个百万英里远的那种code,目前的C和C ++编译器可以生成。 RyuJIT只能为它知道膏抹类型做到这一点。像System.Numerics.Vector2。 SIMD code有很强的调整要求,是有效的,对齐,以16 SSE2指令,以32 AVX指令。获得这样的排列在.NET程序将需要的CLR全面调整,但目前只能调整到8任意SIMD代将是.NET本机的功能,.NET的版本,可以使用C ++编译器的后端提前-的时间生成机器code。目前只能在Windows应用商店和手机应用程序。获取.NET原生工作的桌面应用程序将需要的.NET应用程序打包方式的一个非常显著大修。未来的音乐。

Do keep in mind that this is still a million miles away from the kind of code that current C and C++ compilers can generate. RyuJIT can only do this for anointed types that it knows about. Like System.Numerics.Vector2. SIMD code has very strong alignment requirements to be efficient, aligned to 16 for SSE2 instructions, to 32 for AVX instructions. Getting such alignment in a .NET program is going to require a complete overhaul of the CLR, it currently can only align to 8. Arbitrary SIMD generation is going to be a feature of .NET Native, the version of .NET that can use the C++ compiler's back-end to generate machine code ahead-of-time. Currently only possible in Windows Store and Phone apps. Getting .NET Native to work for desktop apps is going to require a very significant overhaul of the way .NET apps are packaged. Future music.

长话短说:在如何的你问的是抖动。单一直摆弄自己的SIMD支持,这似乎已经得到<一href="http://stackoverflow.com/questions/19519142/is-there-still-any-development-on-simd-in-mono">stuck 5年前。 .NET的核心是刚刚宣布要开放源码的非常宽松的MIT许可,我认为(但不知道一个事实,还),这是将包括源$ C ​​$下RyuJIT。 GitHub的项目进展中的工作,现在,非常不完整的。

Long story short: the how you are asking about is the jitter. Mono has been tinkering with its own SIMD support, it appears to have gotten stuck 5 years ago. .NET Core was just recently announced to go open source with the very liberal MIT license, I assume (but don't know for a fact yet) that this is going to include the source code for RyuJIT. The github project is work in progress right now and very incomplete.

更新:这使它成为.NET 4.6 RTM没有什么大的变化。 Vector.IsHardwareAccelerated现在是内部的。只有System.Numerics.Vector2,Vector3类型和的Vector4类型获得SIMD爱。

UPDATE: This made it into .NET 4.6 RTM without any major changes. Vector.IsHardwareAccelerated is now internal. Only the System.Numerics.Vector2, Vector3 and Vector4 types get the SIMD love.

这篇关于如何JitIntrinsicAttribute影响code一代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆