人们可以有基于CPU架构的条件code运行时?架构、条件、CPU、code

由网友(ζ????雅痞?)分享简介:我使用的.Net 4.5(preVIEW ... 4优良是为这一问题的目的)。我做穿线工作。I'm using .Net 4.5 (preview... 4 is fine for the purposes of this question). I'm doing threading work.根据我的研究,我知道...

我使用的.Net 4.5(preVIEW ... 4优良是为这一问题的目的)。我做穿线工作。

I'm using .Net 4.5 (preview... 4 is fine for the purposes of this question). I'm doing threading work.

根据我的研究,我知道,x86 CPU的有一个强大的内存模型,这意味着将无法重新排序写入。这使得释放锁的安全。这是不正确的安腾处理器,其具有存储模型弱。

Based on my studies, I know that x86 CPUs have a strong memory model, which means writes won't be reordered. This makes releasing locks safe. This is not true for Itanium CPUs, which have a weak memory model.

我明白波动,记忆力障碍,执行重新排序的原则。

I understand volatile, memory barriers, and execution reordering principles.

我需要的理想是插入的关键点如果的CPU是安腾记忆障碍,但如果它的x86。是否可以动态地做到这一点,在有运行时编译器指令的JIT进程?

What I need ideally is to insert memory barriers at key points if the CPU is Itanium, but not if it's x86. Is it possible to do this dynamically, as in have runtime compiler directives that the JIT processes?

如果没有,我知道我需要有两个平台的独立版本。在这种情况下,什么是最优雅的方式来做到这一点,而不必2台C#文件,而只是改变目标?

If not, I realise I will need to have separate builds for the two platforms. In that case, what is the most elegant way to do this without having 2 sets of C# files, but rather simply changing the target?

推荐答案

在回答你的主要问题;我不认为这是目前可能有CIL指令条件编译基于平台的机器指令(而不是什么被烤成的JIT编译器等)。

In answer to your main question; I don't think it's currently possible to have CIL instructions conditionally compiled to machine instructions based on platform (other than what's been baked into the JIT compiler).

创建两个(或更多)的主要工具从一组源的建立仍的 preprocessor指令的。

Your primary tool for creating two (or more) builds from one set of source is still preprocessor directives.

阅读全文

相关推荐

最新文章