source: CIVL/mods/dev.civl.abc/examples/link/comm/comm.cvh

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/* This header file contains the data types and function prototypes for
2 * communication.
3 */
4
5#ifdef __COMM__
6#else
7#define __COMM__
8
9/* includes civlc.cvh because this library references $scope */
10#include <civlc.cvh>
11#include <bundle.cvh>
12
13/* *********************** Constants *********************** */
14
15/* Like MPI_ANY_SOURCE, can be used in probe, seek, dequeue
16 * to match a message with any source */
17#define $COMM_ANY_SOURCE -1
18
19/* Like $COMM_ANY_SOURCE above, except for tags */
20#define $COMM_ANY_TAG -2
21
22/* ********************************* Types ********************************* */
23
24/* The message type, declared here as an incomplete
25 * struct type, which is all you need for constructing
26 * the AST. For the complete version, see the CIVL
27 * project.
28 */
29typedef struct __message__ {
30 int source;
31 int dest;
32 int tag;
33 $bundle data;
34 int size;
35} $message;
36
37/* A datatype representing a queue of messages. All message
38 * data is encapsulated inside this value; no external allocation
39 * is used. */
40typedef struct __queue__ $queue;
41
42/* A global communicator datatype which must be operated by local communicators.
43 * This communicator type has the same meaning as the communicator type in MPI
44 * standards*/
45typedef struct __gcomm__ * $gcomm;
46
47/* A datatype representing a local communicator which is used for
48 * operating global communicators. The local communicator type has
49 * a handle of a global communicator. This type represents for
50 * a set of processes which have ranks in common.
51 */
52typedef struct __comm__ * $comm;
53
54/* ************************* Functions of Message ************************** */
55
56/* creates a new message, copying data from the specified buffer */
57$message $message_pack(int source, int dest, int tag, void *data, int size);
58
59/* returns the message source */
60int $message_source($message message);
61
62/* returns the message tag */
63int $message_tag($message message) ;
64
65/* returns the message destination */
66int $message_dest($message message) ;
67
68/* returns the message size */
69int $message_size($message message);
70
71/* transfers message data to buf, throwing exception if message
72 * size exceeds specified size */
73void $message_unpack($message message, void *buf, int size);
74
75/* ************************** Functions of $gcomm ************************** */
76
77/* Creates a new global communicator object and returns a handle to it.
78 * The global communicator will have size communication places. The
79 * global communicator defines a communication "universe" and encompasses
80 * message buffers and all other components of the state associated to
81 * message-passing. The new object will be allocated in the given scope. */
82$gcomm $gcomm_create($scope scope, int size);
83
84/* De-allocation a __gcomm__ object */
85void $gcomm_destroy($gcomm gcomm);
86
87/* Returns $true iff gcomm points to a valid object. */
88_Bool $gcomm_defined($gcomm gcomm);
89
90/* *************************** Functions of $comm ************************** */
91
92/* Creates a new local communicator object and returns a handle to it.
93 * The new communicator will be affiliated with the specified global
94 * communicator. This local communicator handle will be used as an
95 * argument in most message-passing functions. The place must be in
96 * [0,size-1] and specifies the place in the global communication universe
97 * that will be occupied by the local communicator. The local communicator
98 * handle may be used by more than one process, but all of those
99 * processes will be viewed as occupying the same place.
100 * Only one call to $comm_create may occur for each gcomm-place pair.
101 * The new object will be allocated in the given scope. */
102$comm $comm_create($scope scope, $gcomm gcomm, int place);
103
104/* De-allocation a __comm__ object */
105void $comm_destroy($comm comm);
106
107/* Returns the size (number of places) in the global communicator associated
108 * to the given comm. */
109int $comm_size($comm comm);
110
111/* Returns the place of the local communicator. This is the same as the
112 * place argument used to create the local communicator. */
113int $comm_place($comm comm);
114
115/* Adds the message to the appropriate message queue in the communication
116 * universe specified by the comm. The source of the message must equal
117 * the place of the comm. */
118void $comm_enqueue($comm comm, $message message);
119
120/* Returns true iff a matching message exists in the communication universe
121 * specified by the comm. A message matches the arguments if the destination
122 * of the message is the place of the comm, and the sources and tags match. */
123_Bool $comm_probe($comm comm, int source, int tag);
124
125/* Finds the first matching message and returns it without modifying
126 * the communication universe. If no matching message exists, returns a message
127 * with source, dest, and tag all negative. */
128$message $comm_seek($comm comm, int source, int tag);
129
130/* Finds the first matching message, removes it from the communicator,
131 * and returns the message */
132$message $comm_dequeue($comm comm, int source, int tag);
133
134/* Returns $true iff comm points to a valid object. */
135_Bool $comm_defined($comm comm);
136
137#endif
Note: See TracBrowser for help on using the repository browser.