并行循环:不安全依赖在哪里?
我正在尝试使用 Solaris Studio Complier 中提供的自动并行化选项来并行化以下循环。
int max = A->m;
complex** A_me2;
complex fred;
for ( i = 0; i < max; i++ )
{
for ( j = 0; j < i-1; j++ )
{
A_me2[i][j] = fred;
A_me2[i][j] = fred;
}
}
然而,当我通过编译器运行这个循环时,我收到一条消息:“不是并行化,不安全的依赖”。不安全的依赖到底在哪里?两个赋值语句的输入和输出之间显然没有别名,并且 i 和 j 是每个线程私有的......我对为什么会发生这种情况感到非常困惑。任何指导将不胜感激!
I'm trying to parallelize the following loop using the automatic parallelization options present in the Solaris Studio Complier.
int max = A->m;
complex** A_me2;
complex fred;
for ( i = 0; i < max; i++ )
{
for ( j = 0; j < i-1; j++ )
{
A_me2[i][j] = fred;
A_me2[i][j] = fred;
}
}
However when I run this loop through the compiler I get a message saying: "not parallelized, unsafe dependence". Where exactly is the unsafe dependence? There is clearly no aliasing between the inputs and outputs of both assignment statements, and i and j are private to each thread... I'm extremely stumped as to why this is happening. Any guidance would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于
A_me2
是一个指针数组,因此编译器不知道(例如)A_me2[0]
和A_me2[1]
是否存在不重叠,导致对同一位置进行多次写入,需要正确排序。通常有一个编译器#pragma 会告诉编译器假设不存在依赖关系,从而覆盖自动安全机制。Since
A_me2
is an array of pointers, the compiler doesn't know (for example) thatA_me2[0]
andA_me2[1]
don't overlap, leading to multiple writes to the same location that need to be ordered correctly. There is often a compiler#pragma
that will tell the compiler to assume that there are no dependencies, overriding the automatic safety mechanisms.