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

📄 pcp-slave.c

📁 The example for Boor USING MPI2
💻 C
字号:
/* pcp from the Scalable Unix Tools, in MPI */#include "mpi.h"#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#define BUFSIZE    256*1024#define CMDSIZE    80int main( int argc, char *argv[] ){    int   mystatus, allstatus, done, numread;    char  outfilename[128], controlmsg[80];    int   outfd;    char  buf[BUFSIZE];    MPI_Init( &argc, &argv );    MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD );    if ( strcmp( controlmsg, "exit" ) == 0 ) {        MPI_Finalize();	return -1;    }    MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD );    if ( (outfd = open( controlmsg, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU ) ) == -1 )         mystatus = -1;    else        mystatus = 0;    MPI_Allreduce( &mystatus, &allstatus, 1, MPI_INT, MPI_MIN,		   MPI_COMM_WORLD );    if ( allstatus == -1 ) {	MPI_Finalize();	return( -1 );    }    /* at this point all files have been successfully opened */        done = 0;    while ( !done ) {	MPI_Bcast( &numread, 1, MPI_INT, 0, MPI_COMM_WORLD );	if ( numread > 0 ) {	    MPI_Bcast( buf, numread, MPI_BYTE, 0, MPI_COMM_WORLD );	    write( outfd, buf, numread ); 	}	else {	  	    close( outfd );	    done = 1;	}    }    MPI_Finalize();}

⌨️ 快捷键说明

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