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

📄 msg.h

📁 Parallel programming/Lou Baker, Bradley J.Smith .—New York:McGraw-Hill Book Co.
💻 H
字号:
/* static char sccs_id[] = "@(#) /home2/bsmith/src/psph/SCCS/s.msg.h 1.11 94/03/17"; */

/* Message passing library - generic
 * Bradley J Smith
 */

#ifdef MYMPI
/* My MPI Implementation */

/* Typedefs */
typedef int MPI_Datatype;
typedef int MPI_Comm;
typedef int MPI_Op;

typedef struct tagMPI_Status
	{
	int source, tag;
	int count;
	} MPI_Status;

typedef struct tagMPI_Request
	{
	MPI_Status status;
	MPI_Datatype datatype;
	int is_send;
	char *buf;
	int msgid;
	} MPI_Comm_request;

/* Defines */
#if defined(MYMPI)
#define MPI_CHAR 			(MPI_Datatype) 1
#define MPI_SHORT			(MPI_Datatype) 2
#define MPI_INT				(MPI_Datatype) 3
#define MPI_LONG			(MPI_Datatype) 4
#define MPI_UNSIGNED_CHAR 	(MPI_Datatype) 5
#define MPI_UNSIGNED_SHORT 	(MPI_Datatype) 6
#define MPI_UNSIGNED 		(MPI_Datatype) 7
#define MPI_UNSIGNED_LONG 	(MPI_Datatype) 8
#define MPI_FLOAT			(MPI_Datatype) 9
#define MPI_DOUBLE			(MPI_Datatype) 10
#ifndef PVM        	/* PVM LONG DOUBLE not supported */
#define MPI_LONG_DOUBLE		(MPI_Datatype) 11
#endif
#define MPI_BYTE			(MPI_Datatype) 12
#endif


/* Reduction operations - only a handful implemented under PVM */
#define MPI_MAX	(MPI_Op) 1
#define MPI_MIN	(MPI_Op) 2
#define MPI_SUM (MPI_Op) 3
#define MPI_PROD (MPI_Op) 4

#ifndef PVM
#define MPI_BAND (MPI_Op) 5
#endif
/* Note - other reduction opss are defined but we don't use them! */

/* Error returns */
#define MPI_SUCCESS 0
#define MPI_FAILURE -1

/* Random source/tags for receives */
#define MPI_PROCNULL	(-2)	/* No send */
#define MPI_ANY_SOURCE 	(-1)
#define MPI_ANY_TAG 	(-1)

#define MPI_SYS_TAG 16300
#define BARRIER_MSG_TAG (MPI_SYS_TAG+1)
#define REDUCE_MSG_TAG (MPI_SYS_TAG+2)

/* Default universal communications channel */
#define MPI_COMM_WORLD (MPI_Comm) 0


void _MPI_Op(void *b1, void *b2, int count,MPI_Datatype datatype, MPI_Op op);

/* Basic environment operations */
int MPI_Init(int* argc, char*** argv);
int MPI_Comm_size(MPI_Comm comm, int *size);
int MPI_Comm_rank(MPI_Comm comm, int *rank);
int MPI_Abort(MPI_Comm comm, int errcode);
int MPI_Finalize(void);

/* Basic send and receive */
int MPI_Send(void *buf, int count, MPI_Datatype datatype,
	int dest, int tag, MPI_Comm comm);
int MPI_Recv(void *buf, int count, MPI_Datatype datatype,int source,
	int tag, MPI_Comm comm, MPI_Status *status);

/* Non-blocking send and receive */
int MPI_Isend(void *buf, int count, MPI_Datatype datatype,
	int dest, int tag, MPI_Comm comm, MPI_Comm_request *request);
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
	int source, int tag, MPI_Comm comm, MPI_Comm_request *request);
int MPI_Wait(MPI_Comm_request *request, MPI_Status *status);
int MPI_Test(MPI_Comm_request *request, MPI_Status *status);

/* Probes */
int MPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag,
	MPI_Status *status);

/* Trivial comm status */
int MPI_Get_source(MPI_Status status, int *source);
int MPI_Get_tag(MPI_Status status, int *tag);
int MPI_Get_count(MPI_Status* status, MPI_Datatype datatype,
	int *count);

/* Fundamental Synchronization */
int MPI_Barrier(MPI_Comm comm);
int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
	MPI_Datatype datatype, MPI_Op op, int root,
    	MPI_Comm comm);


#ifdef PVM

#include "pvm3.h"

/* MPI - to PVM interface */
#define PVM_SOURCE(source) ((source==MPI_ANY_SOURCE)?-1:PVM_tid[source])

int PVM_Init(char *name, int n);	/* Spawns n processes */
int PVM_Nproc(void);					/* Returns number of processors */
int PVM_Rank(void);						/* Returns this proc's id */
void PVM_Abort(int errcode);		/* Prints message and kills everyone */
int PVM_Send(void *buf, int count, MPI_Datatype data_type, int *dests, int ndest,
	int tag);						/* Generic blocking send */
int PVM_Receive(void *buf, int count, MPI_Datatype data_type, int source,
	int tag, MPI_Status *status, int *bufid);	/* Generic blocking receive */
int PVM_Unpack(int buf_id,void *buf, int count, MPI_Datatype data_type,int source,
	MPI_Status *status);			/* Unpacks PVM buffer */
int PVM_Pack(void *buf, int count, MPI_Datatype data_type);
void PVM_GetStatus(int buf_id,  int count, MPI_Datatype datatype, int source,
	 MPI_Status *status);			/* Grab status on buffer */
int PVM_Isend(void *buf, int count, MPI_Datatype data_type, int dest,
	int tag, MPI_Comm_request *request); /* Non blocking send (fake) */
int PVM_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
	int tag, MPI_Comm_request *request);
int PVM_Wait(MPI_Comm_request *request, MPI_Status *status);
int PVM_Test(MPI_Comm_request *request, MPI_Status *status);
int PVM_Probe(int source, int tag, int *flag, MPI_Status *status);
int PVM_SizeDataType(MPI_Datatype dt);

#endif /* PVM */

#ifdef PGON_MSG
/* Paragon message passing calls (native) */
/* Initialize n copies of the named process */
int PGON_Init(int n, int argc, char **argv);
int PGON_Rank();
int PVM_Nproc();
void PGON_Abort(int errcode);
int PGON_Send(void *buf, int count, MPI_Datatype data_type, 
	int *dest, int ndest, int tag);
int PGON_Receive(void *buf, int count, int data_type, int source,
	int tag, MPI_Status *status);
int PGON_Isend(void *buf, int count, MPI_Datatype data_type, int dest,
	int tag, MPI_Comm_request *request);
int PGON_Irecv(void *buf, int count, MPI_Datatype data_type, int source,
	int tag, MPI_Comm_request *request);
int PGON_Wait(MPI_Comm_request *request, MPI_Status *status);
int PGON_Test(MPI_Comm_request *request, MPI_Status *status);
int PGON_Probe(int source, int tag, int *flag, MPI_Status *status);
#endif /* PGON_MSG */

#ifdef MPL_MSG
/* Paragon message passing calls (native) */
/* Initialize n copies of the named process */
int MPL_Init(int n, int argc, char **argv);
int MPL_Rank();
int PVM_Nproc();
void MPL_Abort(int errcode);
int MPL_Send(void *buf, int count, MPI_Datatype data_type, 
	int *dest, int ndest, int tag);
int MPL_Receive(void *buf, int count, int data_type, int source,
	int tag, MPI_Status *status);
int MPL_Isend(void *buf, int count, MPI_Datatype data_type, int dest,
	int tag, MPI_Comm_request *request);
int MPL_Irecv(void *buf, int count, MPI_Datatype data_type, int source,
	int tag, MPI_Comm_request *request);
int MPL_Wait(MPI_Comm_request *request, MPI_Status *status);
int MPL_Test(MPI_Comm_request *request, MPI_Status *status);
int MPL_Probe(int source, int tag, int *flag, MPI_Status *status);
#endif /* MPL_MSG */

#else  /* MYMPI */

  #include "mpi.h"
  #define MPI_Comm_request MPI_Request

#endif /* MYMPI */

⌨️ 快捷键说明

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