【问题标题】:parallel computing? openmp or mpi [closed]并行计算? openmp 或 mpi [关闭]
【发布时间】:2022-01-19 08:40:15
【问题描述】:

一条长长的地下隧道已经建成,穿过一座山。由于困难重重 地形,隧道必须很窄,宽度刚好能容纳一个人 车辆。此外,由于隧道的某些部分在非常深的峡谷上有桥梁,因此决定 任何时候都只让一辆车进入隧道。隧道的每一端都有一个控制器

规范进入隧道并跟踪车辆从隧道的出口。写一个多 线程程序来模仿这个系统。假设,任何时候都有随机数量的车辆

出现在入口处。

混淆是使用openmp或mpi,如果可能的话,如果有人可以请提供解决方案

【问题讨论】:

  • 过度简化:多线程 = OpenMP,分布式进程 = MPI。话虽如此,恕我直言,pthreads 在这里可能比 OpenMP 更适合。
  • 但我只能使用这两个中的任何一个
  • StackOverflow 不是代码编写服务。请展示自己的努力。谢谢。
  • 对不起,但我不是反对这些答案的人
  • 我也没有投反对票 ????‍♂️ 我的意见是投反对票的人应该诚实并解释为什么他们知道得更好,但它似乎并没有那样工作,

标签: parallel-processing mpi openmp


【解决方案1】:

MPI 专为大规模、多节点应用程序而设计。因此,在我看来,您的问题不足以保证使用 MPI。此外,与 MPI 中的进程相比,使用线程(可以在 OpenMP 等模型中动态创建)更好地表达它的性质。

最后,OpenMP 主要面向“工作共享”:将一些批量任务分配给可用线程/内核。您的应用程序感觉有些不同。虽然它可以通过 OpenMP 任务实现,但 pthread 或 C++ 线程等线程模型可能更合适。

【讨论】:

    【解决方案2】:

    现在由你决定,我查了他们两个,这是我找到的解释:

    OpenMP

    OpenMP is typically used for loop-level parallelism, but it also supports function-level parallelism. 
    This mechanism is called OpenMP sections. 
    The structure of sections is straightforward and can be useful in many instances. 
    Consider one of the most important algorithms in computer science, the quicksort.
    

    OpenMPI

    Open MPI (based on Message Passing Interface) is also a programming platform, but instead provides one the ability to parallelize code over a (non-)homogenous distributed system (e.g., a supercomputer). 
    For instance, it's possible to parallelize an entire program over a network of computers, or nodes, which communicate over the same network. 
    Since these nodes are essentially computers, they have their own memory layout and their own set of cores (see OpenMP description). 
    Communication between nodes, when compared to shared memory systems, can be difficult and is usually expensive.
    

    您可以在此处阅读更多信息Difference OpenMP vs OpenMPI

    据我所知,您应该选择 OpenMP,因为他们说通信更容易。

    【讨论】:

    • 请注意,OpenMP 是一种语言标准,OpenMPI 只是 MPI 标准的一种实现。所以比较 OpenMP(一个文档)和 OpenMPI(一个文档的实现)是一个类别错误:-)
    • 如果您向我提供代码将非常有帮助
    猜你喜欢
    • 2021-09-20
    • 2018-05-25
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 1970-01-01
    相关资源
    最近更新 更多