資源簡介
在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;
???????????????
- 上一篇:MSTAR官方數據集
- 下一篇:計算機組成原理期末復習題
評論
共有 條評論