source: CIVL/text/include/civlc.h@ d87ec9c

1.23 2.0 main test-branch
Last change on this file since d87ec9c was f6ecaae, checked in by Stephen Siegel <siegel@…>, 12 years ago

Cleaned up header files a little more.

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

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/* This header file defines standard types and provides
2 * functions and function prototypes used in the CIVL-C language.
3 * It includes civlc-common.h, and then completes many of the
4 * declarations in civlc-common.h.
5 */
6
7#ifdef __CIVLC__
8#else
9#define __CIVLC__
10#include<civlc-common.h>
11
12/* ******************************* Types ******************************* */
13
14/* A message formed by $message_pack. Completes the declaration
15 * of this structure type in civlc-common.h */
16struct __message__ {
17 int source;
18 int dest;
19 int tag;
20 $bundle data;
21 int size;
22};
23
24/* A datatype representing a queue of messages. All message
25 * data is encapsulated inside this value; no external allocation
26 * is used. Completes the declaration of this structure type in
27 * civlc-common.h */
28struct __queue__ {
29 int length;
30 $message messages[];
31};
32
33
34/* A global communicator datatype which must be operated by local communicators.
35 * This communicator type has the same meaning as the communicator type
36 * in MPI. Completes the declaration of this type in civlc-common.h */
37struct __gcomm__ {
38 int nprocs; // number of processes
39 _Bool isInit[]; // if the local comm has been initiated
40 $queue buf[][]; // message buffers
41};
42
43/* A datatype representing a local communicator which is used for
44 * operating global communicators. The local communicator type has
45 * a handle of a global communicator. This type represents for
46 * a set of processes which have ranks in common.
47 * Completes the declaration of this type in civlc-common.h.
48 */
49struct __comm__ {
50 int place;
51 $gcomm gcomm;
52};
53
54/* A datatype representing a global barrier which must be operated by local
55 * barriers. Completes the declaration of this type in civlc-common.h.
56 */
57struct __gbarrier__ {
58 int nprocs;
59 $proc proc_map[]; // initialized as all $proc_null.
60 _Bool in_barrier[]; // initialized as all false.
61 int num_in_barrier; // initialized as 0.
62};
63
64/* A datatype representing a global barrier which used for
65 * operating global barriers. The local barrier type has
66 * a handle of a global barrier.
67 * Completes the declaration of this type in civlc-common.h.
68 */
69struct __barrier__ {
70 int place;
71 $gbarrier gbarrier; // initialized as 0.
72};
73
74/* Completes the declaration of this type in civlc-common.h */
75struct __int_iter__ {
76 int size;
77 int content[];
78 int index; //initialized as 0
79};
80
81/* ***************************** Functions ***************************** */
82
83
84/* creates a new message, copying data from the specified buffer */
85$message $message_pack(int source, int dest, int tag,
86 void *data, int size) {
87 $message result;
88
89 result.source = source;
90 result.dest = dest;
91 result.tag = tag;
92 result.data = $bundle_pack(data, size);
93 result.size = size;
94 return result;
95}
96
97/* returns the message source */
98int $message_source($message message) {
99 return message.source;
100}
101
102/* returns the message tag */
103int $message_tag($message message) {
104 return message.tag;
105}
106
107/* returns the message destination */
108int $message_dest($message message) {
109 return message.dest;
110}
111
112/* returns the message size */
113int $message_size($message message) {
114 return message.size;
115}
116
117/* transfers message data to buf, throwing exception if message
118 * size exceeds specified size */
119void $message_unpack($message message, void *buf, int size) {
120 $bundle_unpack(message.data, buf);
121 $assert(message.size <= size,
122 "Message of size %d exceeds the specified size %d.", message.size, size);
123}
124
125/* Returns the place of the local communicator. This is the same as the
126 * place argument used to create the local communicator. */
127int $comm_place($comm comm){
128 return comm->place;
129}
130
131void $barrier_call($barrier barrier) {
132 $barrier_enter(barrier);
133 $barrier_exit(barrier);
134}
135
136#endif
Note: See TracBrowser for help on using the repository browser.