并行循环:不安全依赖在哪里?

发布于 2024-10-20 23:25:40 字数 416 浏览 9 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猛虎独行 2024-10-27 23:25:40

由于 A_me2 是一个指针数组,因此编译器不知道(例如)A_me2[0]A_me2[1] 是否存在不重叠,导致对同一位置进行多次写入,需要正确排序。通常有一个编译器#pragma 会告诉编译器假设不存在依赖关系,从而覆盖自动安全机制。

Since A_me2 is an array of pointers, the compiler doesn't know (for example) that A_me2[0] and A_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文