MPI 多机并行
来源:互联网 发布:ios推荐游戏2017 知乎 编辑:程序博客网 时间:2024/05/20 06:52
主要涉及到的指令如下:
$mpdallexit
$mpdtrace -l
$mpdboot -n 5 -f ~/mpd.hosts /*5表示启动的结点的个数,该参数的值≤numprocs*/
Example:
//testMultiCompuParallel.c
/*求PI值*/
#include <stdio.h>
#include "mpi.h"
#define N 10000000
int main ( int argc, char *argv[] ) {
int myid, numprocs;
int i;
double t,mypi,pi;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init ( &argc, &argv );
MPI_Comm_rank ( MPI_COMM_WORLD, &myid );
MPI_Comm_size ( MPI_COMM_WORLD, &numprocs);
MPI_Get_processor_name( processor_name,&namelen);
printf("Process %d of %d on %s\n",myid,numprocs,processor_name);
for (i=myid + 1; i <= N ; i += numprocs){
t = (double)(i-0.5)/N;
mypi += (double) 4 / ( t*t + 1 );
}
MPI_Reduce ( &mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD );
if(myid==0){
pi *= (double)1/N;
printf("The pi is %lf\n",pi);
}
MPI_Finalize();
return 0;
}
-----------------------------------------------------------------------------------------------------------
[qq@node1 test_MultiCompuParallel]$ mpdallexit
[qq@node1 test_MultiCompuParallel]$ mpdtrace -l
mpdtrace: cannot connect to local mpd (/tmp/mpd2.console_qq); possible causes:
1. no mpd is running on this host
2. an mpd is running but was started without a "console" (-n option)
[qq@node1 test_MultiCompuParallel]$ mpdboot -n 5 -f ~/mpd.hosts
[qq@node1 test_MultiCompuParallel]$ mpdtrace -l
node1_48739 (10.3.1.152)
node4_39991 (10.3.1.155)
node3_57325 (10.3.1.154)
node2_38906 (10.3.1.153)
node0_35575 (10.3.1.151)
[qq@node1 test_MultiCompuParallel]$ mpicc -o testMultiCompuParallel testMultiCompuParallel.c
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 1 testMultiCompuParallel
Process 0 of 1 on node0
The pi is 3.141593
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 2 testMultiCompuParallel
Process 0 of 2 on node0
Process 1 of 2 on node1
The pi is 3.141593
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 3 testMultiCompuParallel
Process 1 of 3 on node1
Process 0 of 3 on node0
Process 2 of 3 on node2
The pi is 3.141593
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 4 testMultiCompuParallel
Process 2 of 4 on node2
Process 1 of 4 on node1
Process 0 of 4 on node0
Process 3 of 4 on node3
The pi is 3.141593
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 5 testMultiCompuParallel
Process 3 of 5 on node3
Process 2 of 5 on node2
Process 1 of 5 on node1
Process 0 of 5 on node0
Process 4 of 5 on node4
The pi is 3.141593
[qq@node1 test_MultiCompuParallel]$ mpirun -machinefile ~/mpd.hosts -np 6 testMultiCompuParallel
too few entries in machinefile
- MPI 多机并行
- Ubuntu(14.04.1)配置MPI多机并行环境(虚拟机)详细步骤
- 并行计算MPI研究
- 并行计算mpi [ PI ]
- MPI 并行解方程
- MPI并行程序设计实例教程
- 并行计算 & HPC & MPI
- MPI—并行求和
- 并行程序设计---MPI
- MPI并行编程
- MPI多进程并行计算矩阵乘法实现
- 并行编程实战记录----多线程与MPI多进程
- 并行计算MPI(一):MPI入门
- 并行计算MPI(二):MPI阻塞通信
- MPI的并行hello程序
- mpi并行程序设计 启动 mpdboot
- 并行计算MPI [ 简单例子 ]
- 并行处理 mpi矩阵乘法
- 电脑不小心删掉内容的恢复方法
- 常用知识总结——信号量
- opencms静态到处配置详解
- Spark初级入门详解
- window 窗口
- MPI 多机并行
- HashMap和Hashtable的区别
- ios基础之关闭输入框的几种常见方法集锦
- JAVA命令行开发工具Apache Cli
- 初始Hive —— 深入浅出学Hive
- linux下如何添加一个用户并且让用户获得root权限
- java并发学习博客
- 接口隔离原则(ISP--Interface Segregation Principle)
- 芯片测试