- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我尝试在 VS2013 中编译以下内容
template <class T>
void assignment(T* result, size_t sz, const T x)
{
for (size_t i = 0; i < sz; i++)
result[i] = x;
}
并且编译器无法使用以下消息对代码进行向量化。
info C5002: loop not vectorized due to reason '1104'
虽然下面的代码没问题
void discountFactor(double* result, const double* r, double t, size_t sz)
{
for (size_t i = 0; i < sz; i++)
result[i] = -r[i] * t;
for (size_t i = 0; i < sz; i++)
result[i] = exp(result[i]);
}
谁能给我解释一下1104的原因是什么?
最佳答案
正如其他人所说,这些类型的优化在 MSDN 上有很好的记录。 .事实上,那里有一个很好的例子。这是片段:
int code_1104(int *A, int *B)
{
// When it vectorizes a loop, the compiler must 'expand' scalar
// variables to a vector size such that they can fit in
// vector registers. Code 1104 is emitted when the compiler
// cannot 'expand' such scalars.
// In this example, we try to 'expand' x to be used in the
// vectorized loop. However, there is a use of 'x'
// beyond the loop body, which prohibits this expansion.
// To resolve this, try to limit scalars to be used only in
// the loop body and not beyond, and try to keep their types
// consistent with the loop types.
int x;
for (int i=0; i<1000; ++i)
{
x = B[i];
A[i] = A[i] + x;
}
return x;
}
我的解释(老实说,他们只是猜测):第二个示例之所以有效,是因为 result
是原始数据类型 (double *
),即使它在循环范围之外也可以轻松修改。
该示例在其注释中说明...
// When it vectorizes a loop, the compiler must 'expand' scalar
// variables to a vector size such that they can fit in
// vector registers.
根据您调用模板化函数assignment
的方式,第一个示例中的T
可能是任何。包括一个不适合寄存器的类型。因此,我假设编译器无法自动矢量化您的 for
循环。
关于c++ - Visual Studio 无法矢量化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30736758/
我正在尝试将字符串列表转换为字符向量的向量: import collection.breakOut def stringsToCharVectors(xs: List[String]) = x
我正在尝试使用 Pytorch 通过 2D 向量(嘈杂语音帧序列)的回归来预测 1D 向量(干净语音数据帧) data) - 之前已经完成过。帧序列为帧提供时间上下文,以更准确地预测干净帧。这些向量可
在尝试构建时,我收到此错误: Operator '+=' is ambiguous on operands of type 'Vector3' and 'Vector2' 这是问题出处的脚本代码: u
是否存在实现 FIFO 意义上的循环数组或向量的 R 包? 假设我们有这个数组: 2 4 7 1 当在位置 1 插入一个新的观察值(比如 3)时,我希望第 n 个元素被第 n-1 个元素替换: 3 2
我在游戏中有两个对象,为此可以将其视为 2d 平面上的点,但我使用 Vector3s,因为游戏本身是 3d。 我有一个游戏相机,我想将其与两个物体垂直(也在平面上)对齐,以便它们都在相机的视野中。由于
我做了一个Telegram robot ,它的工作之一是从音频文件创建样本。现在对于发送给它的大多数音频,样本都非常好;像这样: 但是,对于一些音频,样本看起来有点奇怪: 如您所见,此文件中的波形未显
由于对 JavaScript 非常陌生,我在使用 JQuery VectorMaps 时遇到了以下问题: 当我用这种语法突出显示一个国家时,一切都很完美: jQuery('#vmap').vector
我正在使用 ChartJS 在我的网站中包含一些 map ,但 ChartJS 库没有我想要的 map 。 我想知道这种类型的矢量 map 是否很容易在网上免费找到,还是必须从头开始构建? Chart
我需要创建一个函数。在此范围内,我需要发生以下事情: List 1: '(a 5 6) List 2: '(c 8 10) List 3: '(d 4 9) 以上是列表。我需要忽略每个列表的第一列(这
我在地球表面有一个点,我正在将其从地球中心转换为向量。 我有一个以度数表示的真北航向,描述了该点将在地球表面行进的路径。 我需要计算一个向量,该向量垂直于该点沿地球表面的路径所创建的平面。 我尝试
大家好,这是我的 JavaScript 代码,用于为矢量 map 制作 ip 标记以显示在线 ip.. 所有 ips 都有 3 个不同的端口,例如:ip1:1020 或 ip2:5050 或 ip3:
我正在使用 Three.js 透视相机,我需要了解相机所注视的点。 如何使用相机的矩阵/旋转向量计算它? 最佳答案 相机向下看它的内部负 z 轴。所以选择相机负 z 轴上的任意点,如下所示: var
重要提示:请注意这个问题是关于 VECTOR map 的。不是高度图。 我正在尝试在 Scenekit 中实现 Vector 位移,如 apple 演示文稿中所述: https://www.youtu
我正在处理一个稳定增长的语料库。我使用用 Python 实现的 Doc2Vec 来训练我的文档向量。 是否可以更新文档向量? 我想使用文档向量进行文档推荐。 最佳答案 单个向量可以更新,但是 gens
我正在努力寻找一种比较(测量)两个不同信号之间相似性的好方法。我不想找出一个信号到另一个信号的时间延迟,但我想看看它们之间有何相似之处。例如,我有以下两个信号,比如说 s1 ans s2。这两个信号看
我想绘制 y 与 x 线,然后在它上面我想绘制向量。我可以使用 matplotlib 的 plot 和 quiver 函数来做到这一点。但是,矢量将始终绘制在线的后面,而不是在线的顶部。也就是说,线将
包含复数的向量 a 的大小为 N×1。任务是找到乘法a * a^HA (N-by-N) >,其中 H 是 Hermitian 算子(共轭转置),因此矩阵 A 是 Hermitian。 有没有比 O(N
三天来,我一直在努力从我的响应中获取复杂类型(列表),但总是收到 ClassCastException D/SOAPEnvelope(1552): Error: java.lang.ClassCast
在我的 android 项目中,我想要离线 map 。使用图 block ,我的 map 占用 500 MB 的空间,我还想在 map 上离线搜索地址。我认为减小尺寸并使搜索成为可能的唯一方法是矢量
什么是 Android Compose 方法来平铺图像以用小图案填充我的背景? 没有旋转的位图的天真方法可能是这样的: @Composable fun TileImage() { val pa
我是一名优秀的程序员,十分优秀!