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;
}
相关推荐
_OP_CHEN6 小时前
算法基础篇:(十九)吃透 BFS!从原理到实战,解锁宽度优先搜索的核心玩法
算法·蓝桥杯·bfs·宽度优先·算法竞赛·acm/icpc
大柏怎么被偷了6 小时前
【Linux】进程替换
linux·运维·服务器
小猪咪piggy6 小时前
【算法】day 20 leetcode 贪心
算法·leetcode·职场和发展
Xの哲學6 小时前
Linux 指针工作原理深入解析
linux·服务器·网络·架构·边缘计算
forestsea6 小时前
现代 JavaScript 加密技术详解:Web Crypto API 与常见算法实践
前端·javascript·算法
乌萨奇也要立志学C++6 小时前
【Linux】进程信号(二)信号保存与捕捉全解析、可重入函数、volatile
linux·服务器
张洪权6 小时前
bcrypt 加密
算法
快手技术7 小时前
视频理解霸榜!快手 Keye-VL 旗舰模型重磅开源,多模态视频感知领头羊
算法
无垠的广袤7 小时前
【工业树莓派 CM0 NANO 单板计算机】本地部署 EMQX
linux·python·嵌入式硬件·物联网·树莓派·emqx·工业物联网
骑自行车的码农8 小时前
🍂 React DOM树的构建原理和算法
javascript·算法·react.js