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

📄 zero-blklen-vector.c

📁 mpi并行计算的c++代码 可用vc或gcc编译通过 可以用来搭建并行计算试验环境
💻 C
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * *  (C) 2003 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */     #include <mpi.h>#include <stdio.h>int main(int argc, char* argv[]){	int iam, np;	int m = 2, n = 0, lda = 1;	double A[2];	MPI_Comm comm = MPI_COMM_WORLD;	MPI_Datatype type = MPI_DOUBLE, vtype;	MPI_Init(&argc,&argv);	MPI_Comm_size(comm, &np);	MPI_Comm_rank(comm, &iam);	if (np < 2) {		printf( "Should be at least 2 processes for the test\n");        } else {		MPI_Type_vector(n, m, lda, type, &vtype);		MPI_Type_commit(&vtype);		A[0] = -1.0-0.1*iam;		A[1] = 0.5+0.1*iam;		printf("In process %i of %i before Bcast: A = %f,%f\n",		       iam, np, A[0], A[1] );		MPI_Bcast(A, 1, vtype, 0, comm);		printf("In process %i of %i after Bcast: A = %f,%f\n",		       iam, np, A[0], A[1]);		MPI_Type_free(&vtype);	}	MPI_Finalize();}

⌨️ 快捷键说明

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