了解 Fortran 90 的并行用法

发布于 2024-11-28 13:14:13 字数 371 浏览 0 评论 0原文

y(1:n-1) = a*y(2:n) + x(1:n-1)
y(n) = c

在上面的Fortran 90代码中,我想知道它在同步、通信和算术方面是如何执行的。

我的理解是:

沟通是不同任务之间需要相互沟通。例如,如果某个变量与其他变量有依赖关系。但上面的代码并没有显示出有一些通信。因为它似乎没有依赖性,对吗?

同步与通信有一定关系,但也涉及是否使用了某种障碍。但在上面的代码中没有任何障碍。因此,唯一涉及的同步是是否存在任何数据依赖性。

算术我对这一点一无所知,如果有人可以向我解释它,我会很高兴。

y(1:n-1) = a*y(2:n) + x(1:n-1)
y(n) = c

In the above Fortran 90 code I want to know how it is executed in term of synchronization, communication and arithmetic.

What I understand is:

Communication is the need for different task to communication with each other. E.g. if there's some variable that have dependencies with some other variable. But the above code doesn't show that there is some communication. As it seems to be no dependencies, am I right?

Synchronization is somewhat related to communication, but it also involves if there has been some use of barriers. But in the above code there is no barrier. Therefore the only synchronization that is involved is if there are any data dependencies.

Arithmetic I have no clue regarding this point, and would be gladly if someone could explain it to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

风月客 2024-12-05 13:14:13

Fortran 中的规则相当简单:在将结果分配给左侧之前,先对右侧进行完全求值。
因此,您可以声称在分配时存在通信(将结果发送到 y),这同时也是一个同步点。
右侧的实际求值可以由编译器进行矢量化/并行化,从而导致数组中所有条目的求值顺序任意,除了最后一个条目,它仅在第一次赋值后设置。
然而,除了流水线之外,常见编译器没有引入真正的并行性。

The rule in Fortran is fairly simple: the right hand side is completely evaluated before the result is assigned to the left.
Thus you could claim there is a communication upon assigning (sending the result to y), which is at the same time a synchronization point.
The actual evaluation of the right side could be vectorized/parallelized by the compiler, resulting in arbitrary orders of the evaluations for all entries in the array, except for the last one, which is only set after the first assignment.
However, except for pipelining, there is no real parallelism introduced here by common compilers.

岁吢 2024-12-05 13:14:13

如果没有在给定的片段上停止太多,看起来您可能会对例如 使用 OpenMP 书籍(演示文稿 此处)。这是对并行计算(共享内存)世界的一个很好的温和介绍。对于较大的系统,您最好用谷歌搜索“MPI”及其相关主题。关于这个问题确实有大量的材料(其中很多涉及 fortran+mpi / fortran+openmp),所以我将跳过这里给出的例子。

这就是你的目的吗?

Without stopping too much at the given snippet, it looks you could perhaps be interested (tell me if I'm wrong) at for example, Using OpenMP book (presentation here). It is a nice gentle introduction to the world of parallel computing (memory shared). For larger systems you would do well to google "MPI" and its related subjects. There is really a plethora of material on the matter (a lot of them deal with fortran+mpi / fortran+openmp) so I'll skip giving examples here.

Is this what you were aiming for?

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