Fortran 中的多任务处理

发布于 2024-11-05 05:33:16 字数 1436 浏览 0 评论 0原文

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

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

发布评论

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

评论(3

梦里梦着梦中梦 2024-11-12 05:33:16

需要阅读的主要标准是 OpenMP(共享内存多线程)和 MPI(消息传递)。两者都可以很好地与 Fortran(以及其他语言)配合使用,并且您可以在网上找到大量信息。

OpenMP 定义了一种在 Fortran/C/C++ 中进行并发(并行)处理编程的简单方法。该进程必须驻留在同一台计算机(节点)中。

OpenMP 3.0 最近引入了 $OMP TASK 指令,原则上该指令应该允许以通常的多线程方式完成多任务(即每个线程执行自己的任务)。对于 OpenMP,请参阅本教程:

https://computing.llnl.gov/tutorials/openMP/

或 < a href="http://www.openmp.org/">http://www.openmp.org/

我不会讨论进程间通信(IPC),因为我对此并不熟悉。我相信如果你想要的话,你可以进行 POSIX 函数调用。如果您的编译器支持某些 Fortran 2003 结构(例如 gfortran >= 4.4),那么您可以使用 ISO_C_BINDING 标准模块提供的良好的 C-Fortran 互操作性。然后,只要小心谨慎,您就可以调用可以提供 IPC 功能的 posix 函数。这是我的2c。

The main standards to read up on are OpenMP (shared memory multi-threading) and MPI (message passing). Both work well with Fortran (as well as other languages) and you will find a lot of information online.

OpenMP defines a simple way of programming concurrent (parallel) processing in Fortran/C/C++. The process must reside in a same computer (node).

OpenMP 3.0 recent introduces $OMP TASK directive which in principle should allow multitasking the way multithreading is usually done (that is, each thread does its own task). For OpenMP, see this tutorial:

https://computing.llnl.gov/tutorials/openMP/

or specs in http://www.openmp.org/

I won't address interprocess communication (IPC) since I am not familiar with this. I believe you can do POSIX function calls if that what you want. If your compiler supports some Fortran 2003 constructs (e.g. gfortran >= 4.4) then you can use the nice C-Fortran interoperability provided by ISO_C_BINDING standard module. Then with proper care you can call posix functions that can provide IPC functionalities. That's my 2c.

与风相奔跑 2024-11-12 05:33:16

Fortran2008 还具有 coarrays,它允许从语言本身内部进行分布式内存计算,并且执行并发,它允许类似于 OpenMP 并行 do 循环的功能。目前只有最新的intel编译器完全支持这些,g95有部分支持;然而,包括 gfortran 在内的其他编译器供应商正在积极开发它们。

Fortran2008 also has coarrays, which allows distributed-memory computing from within the language itself, and do concurrent, which allows for functionality similar to an OpenMP parallel do loop. Right now, only the newest intel compiler fully supports these, and g95 has partial support; however, they are actively being worked on by the other compiler vendors, including gfortran.

新一帅帅 2024-11-12 05:33:16

在 Fortran 中执行并发的方式与在任何其他语言中执行此操作的方式相同:生成 pthread、使用 OpenMP、使用 MPI、fork() ...任何最适合您需要的方式。

系统 API 通常采用 C 语言(参见 POSIX 和 Windows API),但无论您使用哪种编程语言,与 C 进行交互都是不争的事实。

即使在 2015 年,Fortran 2008 中的“并发”结构仍然没有很多编译器支持。

You do concurrency in Fortran in the same way you would do this in any other language: Spawn a pthread, use OpenMP, use MPI, fork() ... whatever suits your need best.

Systems APIs are often in C (cf. POSIX and Windows API), but interacting with C is a fact of life, regardless of which programming language you use.

The "do concurrent" contruct in Fortran 2008 still does not have a lot of compiler support, even in 2015.

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