I have learned that some Intel/AMD CPUs can do simultanous multiply and add with SSE/AVX: FLOPS per cycle for sandy-bridge and haswell SSE2/AVX/AVX2. I like to know how to do this best in code and I also want to know how it's done internally in the CPU. I mean with the super-scalar architecture. Let's say I want to do a long sum such as the following in SSE: //sum = a1*b1 + a2*b2 +
我了解到一些英特尔/ AMD处理器可以同时进行乘法运算并添加SSE / AVX: 沙桥和haswell SSE2 / AVX / AVX2每个周期FLOPS。 我想知道如何在代码中做到最好,我也想知道它是如何在CPU内部完成的。 我的意思是超级标量架构。 假设我想在SSE做一笔如下的长期支出: //sum = a1*b1 + a2*b2 + a3*b3 +... where a is a scalar and b is a SIMD vector (e.g. from matrix multiplication) sum = _mm_set1_ps(0.0f); a1 = _mm_set1
In various contexts, for example for the argument reduction for mathematical functions, one needs to compute (a - K) / (a + K) , where a is a positive variable argument and K is a constant. In many cases, K is a power of two, which is the use case relevant to my work. I am looking for efficient ways to compute this quotient more accurately than can be accomplished with the straightforward divis
在各种情况下,例如为了减少数学函数的参数,需要计算(a - K) / (a + K) ,其中a是正变量参数, K是常数。 在许多情况下, K是2的幂,这是与我的工作相关的用例。 我正在寻找更有效的方法来计算这个商数,而不是用直接的分割来完成。 可以假定硬件支持融合乘法 - 加法(FMA),因为此操作目前由所有主要的CPU和GPU架构提供,并且可以通过函数fma()和fmaf()在C / C ++中提供。 为了便于探索,我正在试验float运算。 由于我
The error function is closely related to the standard normal distribution and occurs frequently in the natural sciences as well as other fields. It is used in finance when pricing options, for example. While support for it was added first to ISO C99 and subsequently to C++ in the form of the functions erf() , erff() , it was until recently absent from at least one popular C/C+ toolchain. Many
误差函数与标准正态分布密切相关,在自然科学以及其他领域中经常出现。 例如,它在定价选项中用于财务。 虽然对它的支持首先添加到ISO C99,然后以函数erf() , erff()的形式添加到C ++,但直到最近还没有从至少一个流行的C / C +工具链中缺失。 许多项目仍然使用自己的错误函数实现,通常基于旧文献的近似值,如Abramowitz和Stegun,后者又回到 Cecil Hastings Jr,“数字计算机的近似值”。 普林斯顿大学出版社,1955年
For the simple and efficient implementation of fast math functions with reasonable accuracy, polynomial minimax approximations are often the method of choice. Minimax approximations are typically generated with a variant of the Remez algorithm. Various widely available tools such as Maple and Mathematica have built-in functionality for this. The generated coefficients are typically computed us
为了简单高效地实现具有合理精度的快速数学函数,多项式极大极小近似常常是选择的方法。 Minimax近似值通常由Remez算法的变体生成。 各种广泛使用的工具,如Maple和Mathematica都有内置的功能。 所生成的系数通常使用高精度算术来计算。 众所周知,简单地将这些系数舍入到机器精度会导致最终实现中的次最佳精度。 相反,人们搜索紧密相关的系数集合,这些系数可以精确地表示为机器编号,以生成机器优化的近似值。 两篇相
I was wondering about what makes the primary Java compiler (javac by sun) so fast at compilation? ..as well as the C# .NET compiler from Microsoft. I am comparing them with C++ compilers (such as G++), so maybe my question should have been, what makes C++ compilers so slow :) That question was nicely answered in this one: Why does C++ compilation take so long? (as jalf pointed out in the c
我想知道是什么让主编译器(sun编译的javac)如此快速地编译? ..以及Microsoft的C#.NET编译器。 我将它们与C ++编译器(如G ++)进行比较,所以也许我的问题应该是C ++编译器太慢了:) 这个问题很好地回答了这个问题:为什么C ++编译需要这么长时间? (正如贾尔夫在评论部分指出的那样) 基本上它是C ++缺少的模块概念,以及编译器所做的积极优化。 我认为最困难的部分不是编译头文件(除非它们真的很大,但在这种
Possible Duplicate: Why does C++ compilation take so long? Coming from C# background, I can't help but notice that the speed of compilation for C++ and C# code differs a lot-- C# is very fast to compile, but C++ is comparatively slow-- very slow, in fact. Why is this so? Two big reasons: C++ has to go and #include and parse all the header files (which means reading text files and in
可能重复: 为什么C ++编译需要这么长时间? 从C#背景来看,我不禁注意到编译C ++和C#代码的速度差异很大--C#编译速度非常快,但C ++相对较慢 - 事实上非常慢。 这是为什么? 两大原因: C ++必须去#include和解析所有头文件(这意味着读取文本文件并解释它们 - 包括模板 - 然后将它们直接展开到代码中),而C#在程序集DLL中使用预编译信息。 潜在的C ++优化方式比C#优化方式更加深远; 他们很容易将C#吹出水
I notice on the same machine, it takes C# much less time than C++ to compile. Why? NOTE1: I have not done any scientific benchmark. NOTE2: Before anyone says this isn't programming related, I am implementing a parser, I am finding what I can do from the get go to increase compile speed. NOTE3: I have a similar question Why do compilations take so long?. This question is asking on the
我注意到在同一台机器上,它比C ++花费的时间少得多。 为什么? 注1:我还没有做过任何科学基准。 注2:在任何人说这不是编程相关的,我正在实现一个解析器,我发现我可以从得到去增加编译速度。 注3:我有类似的问题编辑为什么需要这么长时间? 这个问题是关于从C / C ++到C#的具体差异。 很显然,一种简单的语言比一种复杂的语言编译起来更快,但C和C#都是复杂的语言。 我的外卖:1)C / C ++从预处理器和头文件
Right, so I have an enumerable and wish to get distinct values from it. Using System.Linq , there's of course an extension method called Distinct . In the simple case, it can be used with no parameters, like: var distinctValues = myStringList.Distinct(); Well and good, but if I have an enumerable of objects for which I need to specify equality, the only available overload is: var distin
对,所以我有一个枚举并希望从中获得不同的值。 使用System.Linq ,当然有一个名为Distinct的扩展方法。 在简单情况下,它可以不带参数使用,如: var distinctValues = myStringList.Distinct(); 那么好,但如果我有一个我需要指定相等的对象的枚举,唯一可用的重载是: var distinctValues = myCustomerList.Distinct(someEqualityComparer); 相等比较器参数必须是IEqualityComparer<T>的实例。 当然,我可以做
How to write a comment in a mvc view, that won't be transmitted to the final html (ie,to browser, to response). One can make a comment with <!--<a href="/">My comment</a> --> But it is visible in the page source code in browser. Is it possible to leave comments in cshtml files only for internal use? Note that in general, IDE's like Visual Studio will markup a comm
如何在mvc视图中编写评论,不会传输到最终的html(即浏览器,回复)。 人们可以发表评论 <!--<a href="/">My comment</a> --> 但它在浏览器的页面源代码中可见。 是否可以在cshtml文件中留下评论仅供内部使用? 请注意,通常,IDE的Visual Studio将通过选择要转换为注释的文本,然后使用ctrl-k ctrl-c快捷方式或在使用Resharper / Intelli-J风格快捷键,然后Ctrl / 。 服务器端评论: 剃刀.cshtml
I'm writing a screensaver in WPF. I have the screensaver working, however, it only displays on my main monitor. Is there a way to "black out" or draw graphics to additional monitors when the user has multiple displays? I've done some searching around, but haven't found anything relevant. UPDATE From ananthonline's answer below, I was able to accomplish the "b
我正在WPF中编写一个屏幕保护程序。 我有屏幕保护程序工作,但是,它只显示在我的主显示器上。 当用户有多个显示器时,是否有办法“禁用”或将图形绘制到其他显示器上? 我已经做了一些探索,但没有发现任何相关的东西。 UPDATE 从下面的ananthonline的回答中,我可以使用以下窗口在非主显示器上实现“黑屏”效果: <Window x:Class="ScreenSaver.BlackOut" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/