FORM
4.3
|
#include <mpi.h>
Go to the source code of this file.
Data Structures | |
struct | PF_BUFFER |
struct | ParallelVars |
Macros | |
#define | MASTER 0 |
#define | PF_RESET 0 |
#define | PF_TIME 1 |
#define | PF_TERM_MSGTAG 10 /* master -> slave: sending terms */ |
#define | PF_ENDSORT_MSGTAG 11 /* master -> slave: no more terms to be distributed, slave -> master: after EndSort() */ |
#define | PF_DOLLAR_MSGTAG 12 /* slave -> master: sending $-variables */ |
#define | PF_BUFFER_MSGTAG 20 /* slave -> master: sending sorted terms, or in PF_SendFile()/PF_RecvFile() */ |
#define | PF_ENDBUFFER_MSGTAG 21 /* same as PF_BUFFER_MSGTAG, but indicates the end of operation */ |
#define | PF_READY_MSGTAG 30 /* slave -> master: slave is idle and can accept terms */ |
#define | PF_DATA_MSGTAG 50 /* InParallel, DoCheckpoint() */ |
#define | PF_EMPTY_MSGTAG 52 /* InParallel, DoCheckpoint(), PF_SendFile(), PF_RecvFile() */ |
#define | PF_STDOUT_MSGTAG 60 /* slave -> master: sending text to the stdout */ |
#define | PF_LOG_MSGTAG 61 /* slave -> master: sending text to the log file */ |
#define | PF_OPT_MCTS_MSGTAG 70 /* master <-> slave: optimization */ |
#define | PF_OPT_HORNER_MSGTAG 71 /* master <-> slave: optimization */ |
#define | PF_OPT_COLLECT_MSGTAG 72 /* slave -> master: optimization */ |
#define | PF_MISC_MSGTAG 100 |
#define | GNUC_PREREQ(major, minor, patchlevel) 0 |
#define | indices ((INDICES)(AC.IndexList.lijst)) |
#define | PF_ANY_SOURCE MPI_ANY_SOURCE |
#define | PF_ANY_MSGTAG MPI_ANY_TAG |
#define | PF_COMM MPI_COMM_WORLD |
#define | PF_BYTE MPI_BYTE |
#define | PF_INT MPI_INT |
#define | PF_LongMultiPack(buffer, count, type) PF_LongMultiPackImpl(buffer, count, sizeof_datatype(type), type) |
#define | PF_LongMultiUnpack(buffer, count, type) PF_LongMultiUnpackImpl(buffer, count, sizeof_datatype(type), type) |
Typedefs | |
typedef struct ParallelVars | PARALLELVARS |
Functions | |
int | PF_ISendSbuf (int, int) |
int | PF_Bcast (void *buffer, int count) |
int | PF_RawSend (int, void *, LONG, int) |
LONG | PF_RawRecv (int *, void *, LONG, int *) |
int | PF_PreparePack (void) |
int | PF_Pack (const void *buffer, size_t count, MPI_Datatype type) |
int | PF_Unpack (void *buffer, size_t count, MPI_Datatype type) |
int | PF_PackString (const UBYTE *str) |
int | PF_UnpackString (UBYTE *str) |
int | PF_Send (int to, int tag) |
int | PF_Receive (int src, int tag, int *psrc, int *ptag) |
int | PF_Broadcast (void) |
int | PF_PrepareLongSinglePack (void) |
int | PF_LongSinglePack (const void *buffer, size_t count, MPI_Datatype type) |
int | PF_LongSingleUnpack (void *buffer, size_t count, MPI_Datatype type) |
int | PF_LongSingleSend (int to, int tag) |
int | PF_LongSingleReceive (int src, int tag, int *psrc, int *ptag) |
int | PF_PrepareLongMultiPack (void) |
int | PF_LongMultiPackImpl (const void *buffer, size_t count, size_t eSize, MPI_Datatype type) |
int | PF_LongMultiUnpackImpl (void *buffer, size_t count, size_t eSize, MPI_Datatype type) |
int | PF_LongMultiBroadcast (void) |
int | PF_EndSort (void) |
WORD | PF_Deferred (WORD *, WORD) |
int | PF_Processor (EXPRESSIONS, WORD, WORD) |
int | PF_Init (int *, char ***) |
int | PF_Terminate (int) |
LONG | PF_GetSlaveTimes (void) |
LONG | PF_BroadcastNumber (LONG) |
void | PF_BroadcastBuffer (WORD **buffer, LONG *length) |
int | PF_BroadcastString (UBYTE *) |
int | PF_BroadcastPreDollar (WORD **, LONG *, int *) |
int | PF_CollectModifiedDollars (void) |
int | PF_BroadcastModifiedDollars (void) |
int | PF_BroadcastRedefinedPreVars (void) |
int | PF_BroadcastCBuf (int bufnum) |
int | PF_BroadcastExpFlags (void) |
int | PF_StoreInsideInfo (void) |
int | PF_RestoreInsideInfo (void) |
int | PF_BroadcastExpr (EXPRESSIONS e, FILEHANDLE *file) |
int | PF_BroadcastRHS (void) |
int | PF_InParallelProcessor (void) |
int | PF_SendFile (int to, FILE *fd) |
int | PF_RecvFile (int from, FILE *fd) |
void | PF_MLock (void) |
void | PF_MUnlock (void) |
LONG | PF_WriteFileToFile (int, UBYTE *, LONG) |
void | PF_FlushStdOutBuffer (void) |
Variables | |
PARALLELVARS | PF |
LONG | PF_maxDollarChunkSize |
Header file with things relevant to ParForm.
Definition in file parallel.h.
int PF_ISendSbuf | ( | int | to, |
int | tag | ||
) |
Nonblocking send operation. It sends everything from buff
to fill
of the active buffer. Depending on tag it also can do waiting for other sends to finish or set the active buffer to the next one.
to | the destination process number. |
tag | the message tag. |
int PF_Bcast | ( | void * | buffer, |
int | count | ||
) |
Broadcasts a message from the master to slaves.
[in,out] | buffer | the starting address of buffer. The contents in this buffer on the master will be transferred to those on the slaves. |
count | the length of the buffer in bytes. |
int PF_RawSend | ( | int | dest, |
void * | buf, | ||
LONG | l, | ||
int | tag | ||
) |
LONG PF_RawRecv | ( | int * | src, |
void * | buf, | ||
LONG | thesize, | ||
int * | tag | ||
) |
Receives not more than thesize bytes from src, returns the actual number of received bytes, or -1 on failure.
[in,out] | src | the source process number. In output, that of the actual received message. |
[out] | buf | the receive buffer. |
thesize | the size of the receive buffer in bytes. | |
[out] | tag | the message tag of the actual received message. |
int PF_PreparePack | ( | void | ) |
int PF_Pack | ( | const void * | buffer, |
size_t | count, | ||
MPI_Datatype | type | ||
) |
int PF_Unpack | ( | void * | buffer, |
size_t | count, | ||
MPI_Datatype | type | ||
) |
int PF_PackString | ( | const UBYTE * | str | ) |
Packs a string str into the packed buffer PF_packbuf, including the trailing zero.
The first element (PF_INT) is the length of the packed portion of the string. If the string does not fit to the buffer PF_packbuf, the function packs only the initial portion. It returns the number of packed bytes, so if (str[length-1]=='\0') then the whole string fits to the buffer, if not, then the rest (str+length) bust be packed and send again. On error, the function returns the negative error code.
One exception: the string "\0!\0" is used as an image of the NULL, so all 3 characters will be packed.
str | a string to be packed. |
int PF_UnpackString | ( | UBYTE * | str | ) |
Unpacks a string to str from the packed buffer PF_packbuf, including the trailing zero.
It returns the number of unpacked bytes, so if (str[length-1]=='\0') then the whole string was unpacked, if not, then the rest must be appended to (str+length). On error, the function returns the negative error code.
[out] | str | the buffer to store the unpacked string |
int PF_Send | ( | int | to, |
int | tag | ||
) |
Sends the contents in the pack buffer to the process specified by to.
Example:
to | the destination process number. |
tag | the message tag. |
int PF_Receive | ( | int | src, |
int | tag, | ||
int * | psrc, | ||
int * | ptag | ||
) |
Receives data into the pack buffer from the process specified by src. This function allows &src == psrc or &tag == ptag. Either psrc or ptag can be NULL.
See the example of PF_Send().
src | the source process number (can be PF_ANY_SOURCE). | |
tag | the source message tag (can be PF_ANY_TAG). | |
[out] | psrc | the actual source process number of received message. |
[out] | ptag | the received message tag. |
int PF_Broadcast | ( | void | ) |
Broadcasts the contents in the pack buffer on the master to those on the slaves.
Example:
int PF_PrepareLongSinglePack | ( | void | ) |
int PF_LongSinglePack | ( | const void * | buffer, |
size_t | count, | ||
MPI_Datatype | type | ||
) |
int PF_LongSingleUnpack | ( | void * | buffer, |
size_t | count, | ||
MPI_Datatype | type | ||
) |
Retrieves the next data in the "long single" pack buffer.
[out] | buffer | the pointer to the buffer to store the unpacked data. |
count | the number of elements of data to be received. | |
type | the data type of elements of data to be received. |
int PF_LongSingleSend | ( | int | to, |
int | tag | ||
) |
Sends the contents in the "long single" pack buffer to the process specified by to.
Example:
to | the destination process number. |
tag | the message tag. |
int PF_LongSingleReceive | ( | int | src, |
int | tag, | ||
int * | psrc, | ||
int * | ptag | ||
) |
Receives data into the "long single" pack buffer from the process specified by src. This function allows &src == psrc or &tag == ptag. Either psrc or ptag can be NULL.
See the example of PF_LongSingleSend().
src | the source process number (can be PF_ANY_SOURCE). | |
tag | the source message tag (can be PF_ANY_TAG). | |
[out] | psrc | the actual source process number of received message. |
[out] | ptag | the received message tag. |
int PF_PrepareLongMultiPack | ( | void | ) |
int PF_LongMultiPackImpl | ( | const void * | buffer, |
size_t | count, | ||
size_t | eSize, | ||
MPI_Datatype | type | ||
) |
Adds data into the "long multi" pack buffer.
buffer | the pointer to the buffer storing the data to be packed. |
count | the number of elements in the buffer. |
eSize | the byte size of each element of data. |
type | the data type of elements in the buffer. |
int PF_LongMultiUnpackImpl | ( | void * | buffer, |
size_t | count, | ||
size_t | eSize, | ||
MPI_Datatype | type | ||
) |
Retrieves the next data in the "long multi" pack buffer.
[out] | buffer | the pointer to the buffer to store the unpacked data. |
count | the number of elements of data to be received. | |
eSize | the byte size of each element of data. | |
type | the data type of elements of data to be received. |
int PF_LongMultiBroadcast | ( | void | ) |
Broadcasts the contents in the "long multi" pack buffer on the master to those on the slaves.
Example:
int PF_EndSort | ( | void | ) |
Finishes a master sorting with collecting terms from slaves. Called by EndSort().
If this is not the masterprocess, just initialize the sendbuffers and return 0, else PF_EndSort() sends the rest of the terms in the sendbuffer to the next slave and a dummy message to all slaves with tag PF_ENDSORT_MSGTAG. Then it receives the sorted terms, sorts them using a recursive 'tree of losers' (PF_GetLoser()) and writes them to the outputfile.
Definition at line 864 of file parallel.c.
WORD PF_Deferred | ( | WORD * | term, |
WORD | level | ||
) |
Replaces Deferred() on the slaves.
term | the term that must be multiplied by the contents of the current bracket. |
level | the compiler level. |
Definition at line 1208 of file parallel.c.
int PF_Processor | ( | EXPRESSIONS | e, |
WORD | i, | ||
WORD | LastExpression | ||
) |
Replaces parts of Processor() on the masters and slaves. On the master PF_Processor() is responsible for proper distribution of terms from the input file to the slaves. On the slaves it calls Generator() for all the terms that this process gets, but PF_GetTerm() gets terms from the master (not directly from infile).
e | The pointer to the current expression. |
i | The index for the current expression. |
LastExpression | The flag indicating whether it is the last expression. |
Definition at line 1540 of file parallel.c.
int PF_Init | ( | int * | argc, |
char *** | argv | ||
) |
All the library independent stuff. PF_LibInit() should do all library dependent initializations.
argc | pointer to the number of arguments. |
argv | pointer to the arguments. |
Definition at line 1953 of file parallel.c.
int PF_Terminate | ( | int | errorcode | ) |
Performs the finalization of ParFORM. To be called by Terminate().
error | an error code. |
Definition at line 2047 of file parallel.c.
References PF_LibTerminate().
LONG PF_GetSlaveTimes | ( | void | ) |
Returns the total CPU time of all slaves together. This function must be called on the master and all slaves.
Definition at line 2063 of file parallel.c.
LONG PF_BroadcastNumber | ( | LONG | x | ) |
Broadcasts a LONG value from the master to the all slaves.
x | the number to be broadcast (set on the master). |
Definition at line 2083 of file parallel.c.
void PF_BroadcastBuffer | ( | WORD ** | buffer, |
LONG * | length | ||
) |
Broadcasts a buffer from the master to all the slaves.
[in,out] | buffer | on the master, the buffer to be broadcast. On the slaves, the buffer will be allocated if the length is greater than 0. The caller must free it. |
[in,out] | length | on the master, the length of the buffer to be broadcast. On the slaves, it receives the length of transfered buffer. The actual transfer occurs only if the length is greater than 0. |
Definition at line 2110 of file parallel.c.
int PF_BroadcastString | ( | UBYTE * | str | ) |
Broadcasts a string from the master to all slaves.
[in,out] | str | The pointer to a null-terminated string. |
Definition at line 2152 of file parallel.c.
int PF_BroadcastPreDollar | ( | WORD ** | dbuffer, |
LONG * | newsize, | ||
int * | numterms | ||
) |
Broadcasts dollar variables set as a preprocessor variables. Only the master is able to make an assignment like #$a=g; where g is an expression: only the master has an access to the expression. So, the master broadcasts the result to slaves.
The result is in *dbuffer of the size is *newsize (in number of WORDs), +1 for trailing zero. For slave newsize and numterms are output parameters.
[in,out] | dbuffer | the buffer for a dollar variable. |
[in,out] | newsize | the size of the dollar variable in WORDs. |
[in,out] | numterms | the number of terms in the dollar variable. |
Definition at line 2207 of file parallel.c.
int PF_CollectModifiedDollars | ( | void | ) |
Combines modified dollar variables on the all slaves, and store them into those on the master.
The potentially modified dollar variables are given in PotModdollars, and the number of them is given by NumPotModdollars.
The current module could be executed in parallel only if all potentially modified variables are listed in ModOptdollars, otherwise the module was switched to the sequential mode.
Definition at line 2495 of file parallel.c.
int PF_BroadcastModifiedDollars | ( | void | ) |
Broadcasts modified dollar variables on the master to the all slaves.
The potentially modified dollar variables are given in PotModdollars, and the number of them is given by NumPotModdollars.
The current module could be executed in parallel only if all potentially modified variables are listed in ModOptdollars, otherwise the module was switched to the sequential mode. In either cases, we need to broadcast them.
Definition at line 2774 of file parallel.c.
int PF_BroadcastRedefinedPreVars | ( | void | ) |
Broadcasts preprocessor variables, which were changed by the Redefine statements in the current module, from the master to the all slaves.
The potentially redefined preprocessor variables are given in AC.pfirstnum, and the number of them is given by AC.numpfirstnum. For an actually redefined variable, the corresponding value in AC.inputnumbers is non-negative.
Definition at line 2991 of file parallel.c.
int PF_BroadcastCBuf | ( | int | bufnum | ) |
Broadcasts a compiler buffer specified by bufnum from the master to the all slaves.
bufnum | The index of the compiler buffer to be broadcast. |
Definition at line 3133 of file parallel.c.
int PF_BroadcastExpFlags | ( | void | ) |
Broadcasts AR.expflags and several properties of each expression, e.g., e->vflags, from the master to all slaves.
Definition at line 3244 of file parallel.c.
int PF_BroadcastExpr | ( | EXPRESSIONS | e, |
FILEHANDLE * | file | ||
) |
Broadcasts an expression from the master to the all slaves.
e | The expression to be broadcast. |
file | The file in which the expression is sitting. |
Definition at line 3536 of file parallel.c.
int PF_BroadcastRHS | ( | void | ) |
Broadcasts expressions appearing in the right-hand side from the master to the all slaves.
Definition at line 3564 of file parallel.c.
int PF_InParallelProcessor | ( | void | ) |
Processes expressions in the InParallel mode, i.e., dividing expressions marked by partodo over the slaves.
Definition at line 3611 of file parallel.c.
int PF_SendFile | ( | int | to, |
FILE * | fd | ||
) |
Sends a file to the process specified by to.
to | the destination process number. |
fd | the file to be sent. |
Definition at line 4207 of file parallel.c.
References PF_RawSend().
int PF_RecvFile | ( | int | from, |
FILE * | fd | ||
) |
Receives a file from the process specified by from.
from | the source process number. |
fd | the file to save the received data. |
Definition at line 4245 of file parallel.c.
void PF_MLock | ( | void | ) |
A function called by MLOCK(ErrorMessageLock) for slaves.
Definition at line 4326 of file parallel.c.
void PF_MUnlock | ( | void | ) |
A function called by MUNLOCK(ErrorMessageLock) for slaves.
Definition at line 4342 of file parallel.c.
LONG PF_WriteFileToFile | ( | int | handle, |
UBYTE * | buffer, | ||
LONG | size | ||
) |
Replaces WriteFileToFile() on the master and slaves.
It copies the given buffer into internal buffers if called between MLOCK(ErrorMessageLock) and MUNLOCK(ErrorMessageLock) for slaves and handle is StdOut or LogHandle, otherwise calls WriteFileToFile().
handle | a file handle that specifies the output. |
buffer | a pointer to the source buffer containing the data to be written. |
size | the size of data to be written in bytes. |
Definition at line 4371 of file parallel.c.
void PF_FlushStdOutBuffer | ( | void | ) |
Explicitly Flushes the buffer for the standard output on the master, which is used if PF_ENABLE_STDOUT_BUFFERING is defined.
Definition at line 4465 of file parallel.c.