[英]OpenMP - index variable in OpenMP 'for' statement must have signed integral type
I'm new to OpenMP. 我是OpenMP的新手。 I'm trying to use multiple cores for a for loop but I get this compiling error:
我正在尝试将多个内核用于for循环,但出现此编译错误:
"error C3016: 'x' : index variable in OpenMP 'for' statement must have signed integral type". “错误C3016:'x':OpenMP'for'语句中的索引变量必须具有带符号的整数类型”。
I know OpenMP 2.0, which is standard with Microsoft Visual Studio 2010 ( what I'm using ), does not support unsigned data types for some reason but I don't believe I have any unsigned data types being used in this loop. 我知道OpenMP 2.0是Microsoft Visual Studio 2010(我正在使用的标准)的标准组件,由于某种原因它不支持未签名的数据类型,但是我不相信在此循环中使用任何未签名的数据类型。
Here is how my code looks like: 这是我的代码的样子:
Variable Declerations: 可变小数:
struct Vertex
{
float x, y;
};
FractalGenerator::Vertex FractalGenerator::_fracStart;
FractalGenerator::Vertex FractalGenerator::_fracEnd;
float FractalGenerator::_pointPrecision = 0.008f;
float FractalGenerator::_scaleFactor = 1;
For Loop: 对于循环:
float _fracStep = _pointPrecision / _scaleFactor;
#pragma omp parallel for
for (float x = _fracStart.x; x < _fracEnd.x; x += _fracStep)
{
for (float y = _fracStart.y; y < _fracEnd.y; y += _fracStep)
{
Looks like OpenMP doesn't support non-integral types as the index in a for
loop. 看起来OpenMP不支持非整数类型,因为它是
for
循环中的索引。 You have float x
, and while float
is an arithmetic type, it's not an integral type. 您有
float x
,虽然float
是算术类型,但不是整数类型。
An integral type is one of: bool
, char
, char16_t
, char32_t
, wchar_t
, and any of the signed and unsigned integer types ( char
, short
, int
, long
, and long long
). 整数类型是以下类型之一:
bool
, char
, char16_t
, char32_t
, wchar_t
以及任何有符号和无符号整数类型( char
, short
, int
, long
和long long
)。
You'll need to convert your algorithm to use one of these for the index of your for
loop. 您需要转换算法以将其中一种用于
for
循环的索引。 This might work: 这可能起作用:
int iEnd = (_fracEnd.x - _fracStart.x) / _fracStep;
int jEnd = (_fracEnd.y - _fracStart.y) / _fracStep;
for (int i = 0; i < iEnd; i++)
{
float x = _fracStart.x + i * _fracStep;
for (int j = 0; j < jEnd; j++)
{
float y = _fracStart.y + j * _fracStep;
// ...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.