⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcast.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
字号:
/* * This program performs some simple tests of the MPI_Bcast broadcast * functionality. */#include "test.h"#include "mpi.h"#include <stdlib.h>intmain( int argc, char **argv){    int rank, size, ret, passed, i, *test_array;    /* Set up MPI */    MPI_Init(&argc, &argv);    MPI_Comm_rank(MPI_COMM_WORLD, &rank);    MPI_Comm_size(MPI_COMM_WORLD, &size);    /* Setup the tests */    Test_Init("bcast", rank);    test_array = (int *)malloc(size*sizeof(int));    /* Perform the test - this operation should really be done       with an allgather, but it makes a good test... */    passed = 1;    for (i=0; i < size; i++) {	if (i == rank)	    test_array[i] = i;	MPI_Bcast(test_array, size, MPI_INT, i, MPI_COMM_WORLD);	if (test_array[i] != i)	    passed = 0;    }    if (!passed)	Test_Failed("Simple Broadcast test");    else {	if (rank == 0)	    Test_Passed("Simple Broadcast test");	}    /* Close down the tests */    free(test_array);    if (rank == 0)	ret = Summarize_Test_Results();    else	ret = 0;    Test_Finalize();    /* Close down MPI */    Test_Waitforall( );    MPI_Finalize();    return ret;}

⌨️ 快捷键说明

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