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

📄 simple.h

📁 Conway s Game of life 算法程序
💻 H
字号:
#ifndef SIMPLE_H
#define SIMPLE_H

#include "mpi.h"

#define Datatype 	MPI_Datatype
#define BYTE 		MPI_BYTE
#define CHAR 		MPI_CHAR
#define DOUBLE 		MPI_DOUBLE
#define FLOAT 		MPI_FLOAT
#define INT 		MPI_INT
#define LONG 		MPI_LONG
#define LONG_LONG 	MPI_LONG_LONG_INT
#define LONG_DOUBLE 	MPI_LONG_DOUBLE
#define PACKED 		MPI_PACKED
#define SHORT 		MPI_SHORT
#define UNSIGNED_CHAR 	MPI_UNSIGNED_CHAR
#define UNSIGNED 	MPI_UNSIGNED
#define UNSIGNED_LONG 	MPI_UNSIGNED_LONG
#define UNSIGNED_SHORT 	MPI_UNSIGNED_SHORT
//#define BOOL		MPI_BOOL

#define ANY_SOURCE	MPI_ANY_SOURCE
#define Operation 	MPI_Op
#define MAXIMUM 	MPI_MAX
#define MINIMUM 	MPI_MIN
#define PRODUCT 	MPI_PROD
#define SUM 		MPI_SUM
#define LOGICAL_AND 	MPI_LAND
#define LOGICAL_OR 	MPI_LOR
#define LOGICAL_XOR 	MPI_LXOR
#define BITWISE_AND 	MPI_BAND
#define BITWISE_OR 	MPI_BOR
#define BITWISE_XOR 	MPI_BXOR

// void Init(void);
// Initializes the simplified message-passing environment.  This function 
// 	must be called by each process before any message-passing functions
//	are called
// Precondition:  No message passing routines have been used before this
// Postcondition: The message passing environment has been initialized
#define Init  MPI_Init

void Finalize(void);
// Each process must call Finalize() before it exits
// Precondition:  The process has no pending communication 
// Postcondition: The process can make no further message-passing calls. 
//	All resources needed by the message-passing environment are released 

int GetRank(void);
// Returns the process rank of the calling process
// Precondition:  The message-passing environment has been initialized
// Postcondition: The process rank is returned as a non-negative integer.  
//	The process rank is unique within the process group
 
int GetSize(void);
// Returns the number of processes in the process group
// Precondition:  The message-passing environment has been initialized
// Postcondition: The return value is the cardinality of the process group

void Send(Datatype type, void *buffer, int count, int dest);
// Sends a message to another process
// Preconditions:  The message-passing environment has been initialized.
//	buffer references an array large enough to contain count items of 
//	data type type.  dest is the rank of a process within the process group.
// Postcondition:  Upon return, the message has either been delivered or the 
//	data copied to a system buffer. 

void Recv(Datatype type, void *buffer, int count, int source);
// Receives a message from another process
// Preconditions:  The message-passing environment has been initialized.
//	buffer references an array large enough to contain count items of 
//	data type type.  source is the rank of a process within the process 
//	group.
// Postcondition:  Upon return, the message is available in the array referenced
//	by buffer. 

void Bcast(Datatype type, void *buffer, int count, int root);
// The contents of the send buffer are copied to all other processes 
// Preconditions:  The message-passing environment has been initialized.
//	buffer references an array large enough to contain count items of 
//	data type type.  root is the rank of the process within the process 
//	group which has the data which will be broadcast to all other processes.
// Postcondition:  Upon return, the message is available to all processes of 
//	the group in the array referenced by buffer. 

void Reduce(Datatype type, void *sourcebuffer, void *recvbuffer, int count, 
		Operation op, int root);
// Combines the elements stored in the source buffer of each process in 
//	the process group using the operation specifed in op, and returns the 
//	combined values in the receive buffer of the process with rank root.
// Preconditions:  The message-passing environment has been initialized.
//	sourcebuffer and recvbuffer reference arrays large enough to contain 
//	count items of data type type.  root is the process rank of a process
//	in the process group.  op is a valid identifier of the type Operation. 
// Postcondition:  Upon return, recvbuffer has the result which has been 
//	combined using the specified operation.  When count is more than one, 
//	the combine operation is applied element-wise on each entry in the 
//	buffer.

void Gather(Datatype type, void *sendbuffer, void *recvbuffer, 
	int count, int root);
// Each process, including the root process, sends the data in sendbuffer 
//	to the recvbuffer of the process with rank root.
// Preconditions:  The message-passing environment has been initialized.
//	sendbuffer references an array large enough to contain 
//	count items of data type type.  recvbuffer references an array large 
//	enough to contain N*count items, where N is the number of processes.
//	root is the process rank of a process in the process group.
// Postcondition:  Upon return, the data from the process with rank i 
//	is stored in recvbuffer starting a location i*count. 

void Scatter(Datatype type, void *sendbuffer, void *recvbuffer, 
	int count, int root);
// The process with rank root sends a different part of sendbuffer to each 
//	process (including itself.)  The received data is stored in the 
//	recvbuffer.  Process i receives count contiguous elements of 
//	data type type starting from the i*count position of root's sendbuffer  
//	to the recvbuffer of the process with rank root.
// Preconditions:  The message-passing environment has been initialized.
//	sendbuffer references an array large enough to contain 
//	N*count items of data type type, where N is the number of processes.  
//	recvbuffer references an array large enough to contain count items.
//	root is the process rank of a process in the process group.
// Postcondition:  Upon return, the data from the process with rank root 
//	is stored in recvbuffer. 

void Barrier(void);
// This function ensures synchronization of all the processes in the process
// group.
// Preconditions:  The message-passing environment has been initialized.
//	All processes have a call to Barrier() in their thread of execution.
// Postcondition:  Upon return, all the processes in the process group have
//	called this function.

#endif

⌨️ 快捷键说明

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