• 大小: 5KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-01-06
  • 语言: 其他
  • 标签: C  language  MPI  

资源简介

在MPI编译环境下在C源代码的 基础上编写的并行程序:高斯消元法求解线性方程组。

资源截图

代码片段和文件信息


#include
#include
#include“mpi.h“
#include“stdio.h“
#include
const int rows = 8; /*the rows of matrix*/
const int cols = 8; /*the cols of matrix*/
int main(int argc char **argv)

{
int ijkmyidnumprocsanstag;
double  A[rows][cols]B[cols]X[rows]AB[rows][cols+1];
int masterpro;
double buf[cols+1];
double starttimeendtime;
double tmptotaltime;
srand((unsigned int)time(NULL));
MPI_Status status;
masterpro = 0;
MPI_Init(&argc&argv);
MPI_Comm_rank(MPI_COMM_WORLD&myid);
MPI_Comm_size(MPI_COMM_WORLD&numprocs);
if (myid==0)
    {
      starttime = MPI_Wtime();
      for(i=0;i         {
            B[i]=rand()%20;
            for(j=0;j                 {
                    A[j][i]=rand()%20;
               

评论

共有 条评论