MPI 并行解上三角矩阵表示的方程组
来源:互联网 发布:软件工程项目报告 编辑:程序博客网 时间:2024/05/16 19:36
最基本的回代法实现
#include "mpi.h"#include <stdio.h>#include <stdlib.h>#define ROOT 0#define TAG 0int main(int argc,char *argv[]) {float matrix[][4]={{2,3,4,5},//the upper trangular matrix representing a equation set{0,2,3,4},{0,0,2,3}};int xcnt=3;//cout of xint self,size,tag=0;MPI_Init(&argc,&argv);MPI_Comm_rank(MPI_COMM_WORLD,&self);MPI_Comm_size(MPI_COMM_WORLD,&size);MPI_Request r;MPI_Status s;MPI_Datatype MPI_VEC;MPI_Type_vector(xcnt+1,1,1,MPI_FLOAT,&MPI_VEC);MPI_Type_commit(&MPI_VEC);float* equation=(float*)malloc((xcnt+1)*sizeof(float));float xs,xr;if(0==self) {//send each process the correspond equation//parellel send and copyMPI_Issend(matrix[1],1,MPI_VEC,1,TAG,MPI_COMM_WORLD,&r);for(int i=0;i<=xcnt;++i) {equation[i]=matrix[0][i];}MPI_Wait(&r,&s);for(int i=2;i<size;++i) {MPI_Ssend(matrix[i],1,MPI_VEC,i,TAG,MPI_COMM_WORLD);}} else {MPI_Recv(equation,1,MPI_VEC,ROOT,TAG,MPI_COMM_WORLD,&s);}for(int i=xcnt-1;i>=0;--i) {if(i==self) {xs=equation[xcnt]/equation[i];printf("x%d = %f \n",self,xs);MPI_Bcast(&xs,1,MPI_FLOAT,i,MPI_COMM_WORLD);} else {MPI_Bcast(&xs,1,MPI_FLOAT,i,MPI_COMM_WORLD);if(i>self) {equation[xcnt]-=equation[i]*xs;}}}free(equation);MPI_Finalize();return 0;}
- MPI 并行解上三角矩阵表示的方程组
- 矩阵乘的MPI并行程序
- 矩阵乘法的MPI并行计算
- 矩阵乘的MPI并行程序 MPI主从模式
- 并行处理 mpi矩阵乘法
- MPI 并行解方程
- MPI并行计算与矩阵1
- MPI并行计算与矩阵(2)
- triu--上三角矩阵的抽取
- 1125: 上三角矩阵的判断
- numpy 返回函数的上三角矩阵
- 1125: 上三角矩阵的判断
- OJ1125: 上三角矩阵的判断
- 上三角矩阵下三角矩阵
- 判断上三角矩阵
- 矩阵上三角打印
- 上三角蛇形矩阵
- 判断上三角矩阵
- linux tail 命令
- xcode 4 制作静态库详解
- 保护眼睛的电脑颜色配置
- 在SurfaceView中添加组件!!!!并且相互交互数据!!!!
- listview加载性能优化ViewHolder
- MPI 并行解上三角矩阵表示的方程组
- zoj1730
- struts2 ognl <s:property value="[0]">
- POJ3625—Prim实现
- POJ3155-最大密度子图
- 二进制相加
- 关于道士打架的一些看法
- wavion关于wireless mode的介绍
- 激情感受与升级