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

📄 qdemo.c

📁 fortran并行计算包
💻 C
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//*   *  (C) 2005 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include <stdio.h>#include "mpi.h"/* This is a program to enable testing and demonstration of the debugger   interface, particularly in terms of showing message queues.  To use   this, run with a few processes and attach with the debugger when the   program stops.  You can change the variable "hold" to 0 to allow the   program to complete. */int main( int argc, char *argv[] ){    int wsize, wrank;    int source, dest;    int buf1[10], buf2[10], buf3[10];    volatile int hold = 1;     MPI_Comm dupcomm;    MPI_Status status;    MPI_Init( &argc, &argv );    MPI_Comm_size( MPI_COMM_WORLD, &wsize );    MPI_Comm_rank( MPI_COMM_WORLD, &wrank );        /* Set the source and dest in a ring */    source = (wrank + 1) % wsize;    dest   = (wrank + wsize - 1) % wsize;    MPI_Comm_dup( MPI_COMM_WORLD, &dupcomm );    MPI_Comm_set_name( dupcomm, "Dup of comm world" );    MPI_Send( buf2, 8, MPI_INT, dest, 1, MPI_COMM_WORLD );    MPI_Send( buf3, 4, MPI_INT, dest, 2, dupcomm );        while (hold) ;    MPI_Recv( buf1, 10, MPI_INT, source, 1, MPI_COMM_WORLD, &status );    MPI_Recv( buf1, 10, MPI_INT, source, 1, dupcomm, &status );    MPI_Comm_free( &dupcomm );            MPI_Finalize();        return 0;}

⌨️ 快捷键说明

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