日期:2014-05-17  浏览次数:20506 次

关于64位应用程序
请教大家一个问题啊,如果想让程序真正在64位环境下面运行,是否发布程序时,一定要选择x64而不能是Any Cpu ?

据说64位比32位猛很多,大家能否把自己升级为64位应用的经验告知一二...
小弟感激不尽!

------解决方案--------------------
一般的数据类型问题不大,反而是有一些必须以x86形式编译,比如某个第三方控件只有32位的,那么编译时就要选择x86编译,运行时强制以32位运行,比如silverlight组件
------解决方案--------------------
AnyCPU will compile your assembly to run on any platform. DLLs and EXEs compiled with AnyCPU option will behave with sutle difference. On a 64-bit Windows operating system, EXEs compiled with this option will execute on the 64 bit CLR, while DLLs compiled with this option will execute on the same CLR as the process into which it is being loaded. So, if a 32bit EXE load a DLL that is compiled with this option, the process is 32bit so the DLL will run on the 32bit CLR.
x86 option compiles your assembly to be run by the 32-bit, x86-compatible common language runtime. On 32bit platform, the EXEs will run as 32bit process. On 64bit platform, the EXEs will run under WOW64 mode.
x64 option compiles your assembly to be run by the 64-bit common language runtime on a computer that supports the AMD64 or EM64T instruction set.
Also please take a look at: How to: Optimize an Application for a Specific CPU Type
------解决方案--------------------
VS编译目标platform有3个选择:AnyCPU,x86和x64.其中AnyCPU是最不常用的,换句话说,AnyCPU编译的case是最为罕见的,但操蛋的微软是把这个最罕见的case设置为默认值。
如果一个程序被编译成AnyCPU,那么该程序将包含2套相同逻辑的程序,一套在32OS上用,一套在64OS上用。这下问题就来了,譬如某coder在他的32位OS上用AnyCPU变异了他的code,他的code调用32位COM,这一调用不会有任何问题,因为AnyCPU的程序在32OS以32位方式运行,32位APP调用32COM,没有问题。但如果某客户使用64OS,那么该程序将以64位方式运行,64位APP调用32COM,error out!
------解决方案--------------------
探讨
VS编译目标platform有3个选择:AnyCPU,x86和x64.其中AnyCPU是最不常用的,换句话说,AnyCPU编译的case是最为罕见的,但操蛋的微软是把这个最罕见的case设置为默认值。
如果一个程序被编译成AnyCPU,那么该程序将包含2套相同逻辑的程序,一套在32OS上用,一套在64OS上用。这下问题就来了,譬如某coder在他的32位OS上用AnyCPU变异了他的code……

------解决方案--------------------
而且,如果也不有“anycpu包含两套代码”这种事情的,.net是虚拟机语言,运行时编译的,msil代码是跨平台的,而且“any=2”本身也有问题吧,世界上并不只有intel x86/x64平台

x64平台对于普通代码来说,能够提升性能的地方一个是减少了堆栈的使用,x64寄存器多,能加少栈的倒腾,而现在多级存储体系之间差距越来越大,所以“查表快于计算”很多时候已经不是事实了;另一个是能利用更大的内存,如SQL Server,更大的缓存意味着更高的效率

要真正发挥x64的优势的,得将算法字长都改为64位,字长加倍,循环减半,而在64位机器上实际的计算量并不增加,这样便能够提升一倍效率

至于指望jit能把代码编译成sse等高级指令基本是妄想,高级语言考虑通用性,缺乏直接的SIMD支持,所以现在那些号称能利用SSE指令的编译器实际效果都不好