c++ - 为什么循环变量必须并行签名?

标签 c++ c parallel-processing openmp signed

我只是通过在线教程和资源学习 OpenMP。我想使用 parallel for 循环对矩阵进行平方(将其与自身相乘)。在 IBM compiler documentation ,我发现了“迭代变量必须是有符号整数”的要求。在 GCC 实现中也是如此吗?它是否在 OpenMP 标准中指定?如果是这样,是否有此要求的原因?

(这并不重要,因为预期的尺寸远小于 INT_MAX,但它确实花费了我一些转换。)

最佳答案

引自Why aren't unsigned OpenMP index variables allowed? :

According to the OpenMP 2.0 C/C++ API specification (pdf), section 2.4.1, that's one of the restrictions of the for loop. No reason is given for it, but I suspect it's just to simplify the assumptions that the code and compiler have to make, since there's special code to ensure that the range doesn't overflow the maximum value of the type.

OpenMP 3.0 apparently allows for unsigned types too, but I haven't seen it in action yet.

简而言之,它是标准的一部分,下一个版本将允许无符号整数。

关于c++ - 为什么循环变量必须并行签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3988470/

相关文章:

c++ - 如何在 cpp 源文件中链接静态库?

c - 如何解析接收到的可变长度数据

c - 在 PHP 扩展中将数组添加到类中

c++ - 错误 C2308 : concatenating mismatched strings

c - 在运行令人尴尬的并行作业时,避免并行文件系统过载的最佳方法是什么?

C++ 常量静态 char* 数组

c++ - 如何将变量与 vector 中包含的对象的成员变量进行比较

c++ - 不理解左值的双重转发 - 按值传递时

c++ - 使用 C++ 和 OpenMP 处理文件

bash - 易于并行化