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;
}
相关推荐
颇有几分姿色几秒前
深入理解 Linux 内存管理:free 命令详解
linux·运维·服务器
yannan201903136 分钟前
【算法】(Python)动态规划
python·算法·动态规划
埃菲尔铁塔_CV算法7 分钟前
人工智能图像算法:开启视觉新时代的钥匙
人工智能·算法
EasyCVR8 分钟前
EHOME视频平台EasyCVR视频融合平台使用OBS进行RTMP推流,WebRTC播放出现抖动、卡顿如何解决?
人工智能·算法·ffmpeg·音视频·webrtc·监控视频接入
linsa_pursuer9 分钟前
快乐数算法
算法·leetcode·职场和发展
小芒果_0110 分钟前
P11229 [CSP-J 2024] 小木棍
c++·算法·信息学奥赛
qq_4340859012 分钟前
Day 52 || 739. 每日温度 、 496.下一个更大元素 I 、503.下一个更大元素II
算法
Beau_Will12 分钟前
ZISUOJ 2024算法基础公选课练习一(2)
算法
XuanRanDev15 分钟前
【每日一题】LeetCode - 三数之和
数据结构·算法·leetcode·1024程序员节
gkdpjj16 分钟前
C++优选算法十 哈希表
c++·算法·散列表