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

📄 inactivereq.c

📁 mpi并行计算的c++代码 可用vc或gcc编译通过 可以用来搭建并行计算试验环境
💻 C
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* *  (C) 2005 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include "mpi.h"#include <stdio.h>#include <stdlib.h>#include "mpitest.h"/* This test program checks that the point-to-point completion routines   can be applied to an inactive persistent request, as required by the    MPI-1 standard. See section 3.7.3, for example,    One is allowed to call MPI TEST with a null or inactive request argument.    In such a case the operation returns with flag = true and empty status.*/int StatusEmpty( MPI_Status *s ){    int errs = 0;    int count = 10;    if (s->MPI_TAG != MPI_ANY_TAG) {	errs++;	printf( "MPI_TAG not MPI_ANY_TAG in status\n" );    }    if (s->MPI_SOURCE != MPI_ANY_SOURCE) {	errs++;	printf( "MPI_SOURCE not MPI_ANY_SOURCE in status\n" );    }    MPI_Get_count( s, MPI_INT, &count );    if (count != 0) {	errs++;	printf( "count in status is not 0\n" );    }    /* Return true only if status passed all tests */    return errs ? 0 : 1;}int main(int argc, char *argv[]){    MPI_Request r;    MPI_Status  s;    int errs = 0;    int flag;    int buf[10];    int tag = 27;    int dest = 0;    MTest_Init( &argc, &argv );    /* Create a persistent send request */    MPI_Send_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );    flag = 0;    s.MPI_TAG = 10;    s.MPI_SOURCE = 10;    MPI_Test( &r, &flag, &s );    if (!flag) {	errs++;	printf( "Flag not true after MPI_Test\n" );	printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );	MTest_Finalize( errs );	MPI_Finalize();	return 0;    }    if (!StatusEmpty( &s )) {	errs++;	printf( "Status not empty after MPI_Test\n" );    }    s.MPI_TAG = 10;    s.MPI_SOURCE = 10;    MPI_Wait( &r, &s );    if (!StatusEmpty( &s )) {	errs++;	printf( "Status not empty after MPI_Wait\n" );    }    MPI_Request_free( &r );    /* Create a persistent receive request */    MPI_Recv_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );    flag = 0;    s.MPI_TAG = 10;    s.MPI_SOURCE = 10;    MPI_Test( &r, &flag, &s );    if (!flag) {	errs++;	printf( "Flag not true after MPI_Test\n" );	printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );	MTest_Finalize( errs );	MPI_Finalize();	return 0;    }    if (!StatusEmpty( &s )) {	errs++;	printf( "Status not empty after MPI_Test\n" );    }    s.MPI_TAG = 10;    s.MPI_SOURCE = 10;    MPI_Wait( &r, &s );    if (!StatusEmpty( &s )) {	errs++;	printf( "Status not empty after MPI_Wait\n" );    }    MPI_Request_free( &r );        MTest_Finalize( errs );    MPI_Finalize();    return 0;}

⌨️ 快捷键说明

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