MPI 训练之一

root@dcs-977baf93-0:/workspace/pthread# mpic++ t07.cpp -o 2.out

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 4 ./2.out

Hello World from process 1 of 4

Hello World from process 0 of 4

Hello World from process 2 of 4

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 6 ./2.out

Hello World from process 3 of 6

===================================================================================

= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES

= PID 235 RUNNING AT dcs-977baf93-0

= EXIT CODE: 9

= CLEANING UP REMAINING PROCESSES

= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES

===================================================================================

YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Killed (signal 9)

This typically refers to a problem with your application.

Please see the FAQ page for debugging suggestions

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 2 ./2.out

Hello World from process 1 of 2

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 1 ./2.out

Hello World from process 0 of 1

root@dcs-977baf93-0:/workspace/pthread# mpic++ t07.cpp -o 2.out

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 1 ./2.out

Hello World from process 0 of 1

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 3 ./2.out

Hello World from process 0 of 3

Hello World from process 1 of 3

Hello World from process 2 of 3

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 4 ./2.out

Hello World from process 2 of 4

Hello World from process 3 of 4

Hello World from process 1 of 4

Hello World from process 0 of 4

root@dcs-977baf93-0:/workspace/pthread# mpirun -n 2 ./2.out

Hello World from process 1 of 2

Hello World from process 0 of 2

root@dcs-977baf93-0:/workspace/pthread#

cpp 复制代码
#include <mpi.h>
#include <stdio.h>


int main(int argc, char** argv) {
    int process_Rank, size_Of_Cluster;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &size_Of_Cluster);
    MPI_Comm_rank(MPI_COMM_WORLD, &process_Rank);

    printf("Hello World from process %d of %d\n", process_Rank,
           size_Of_Cluster);
    MPI_Finalize();
    return 0;
}
相关推荐
若云止水21 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_preinit_modules 函数
linux·nginx·ubuntu
waicsdn_haha37 分钟前
Eclipse IDE 2025-03 最新版安装教程(官方下载+环境配置详解)
java·linux·开发语言·ide·windows·fpga开发·eclipse
安於宿命41 分钟前
【Linux】管道通信——命名管道
linux·服务器·c++·信息与通信
小白的白是白痴的白1 小时前
如何安装vm和centos
linux·运维·centos
xsh801442421 小时前
Centos中将UTC的时区改为CTS时区
linux·运维·centos
xing.yu.CTF1 小时前
Alice与Bob-素数分解密码学
算法·密码学
瓦力的狗腿子1 小时前
Starlink卫星动力学系统仿真建模第十讲-基于SMC和四元数的卫星姿态控制示例及Python实现
开发语言·python·算法
艾醒(AiXing-w)2 小时前
Linux系统管理(十七)——配置英伟达驱动、Cuda、cudnn、Conda、Pytorch、Pycharm等Python深度学习环境
linux·python·深度学习
闻缺陷则喜何志丹2 小时前
【二分查找】P11201 [JOIG 2024] たくさんの数字 / Many Digits|普及
c++·算法·二分查找·洛谷·字符·数字·需要
shinelord明2 小时前
【再谈设计模式】访问者模式~操作对象结构的新视角
开发语言·数据结构·算法·设计模式·软件工程