source: CIVL/include/headers/comm2.cvh@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

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