allredmany.c

来自「刚才是说明 现在是安装程序在 LINUX环境下进行编程的MPICH安装文件」· C语言 代码 · 共 30 行

C
30
字号
#include <stdio.h>#include "mpi.h"/* * This example should be run with 2 processes and tests the ability of the * implementation to handle a flood of one-way messages. */int main( int argc, char **argv ){  double wscale = 10.0, scale;  int numprocs, myid,i;  MPI_Init(&argc,&argv);  MPI_Comm_size(MPI_COMM_WORLD,&numprocs);  MPI_Comm_rank(MPI_COMM_WORLD,&myid);  for ( i=0; i<10000; i++) {    MPI_Allreduce(&wscale,&scale,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);  }  if (myid == 0) {      /* If we get here at all, we're ok */      printf( " No Errors\n" );  }  MPI_Finalize();    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?