source: CIVL/text/include/civlc.h@ 3cf40e5

1.23 2.0 main test-branch
Last change on this file since 3cf40e5 was c270dae, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added barrier function.

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

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/* This header file defines standard types and provides
2 * function prototypes used in the CIVL-C language.
3 */
4
5#ifdef __CIVLC__
6#else
7#include<civlc-common.h>
8#define __CIVLC__
9
10/* creates a new message, copying data from the specified buffer */
11$message $message_pack(int source, int dest, int tag,
12 void *data, int size) {
13 $message result;
14
15 result.source = source;
16 result.dest = dest;
17 result.tag = tag;
18 result.data = $bundle_pack(data, size);
19 result.size = size;
20 return result;
21}
22
23/* returns the message source */
24int $message_source($message message) {
25 return message.source;
26}
27
28/* returns the message tag */
29int $message_tag($message message) {
30 return message.tag;
31}
32
33/* returns the message destination */
34int $message_dest($message message) {
35 return message.dest;
36}
37
38/* returns the message size */
39int $message_size($message message) {
40 return message.size;
41}
42
43/* transfers message data to buf, throwing exception if message
44 * size exceeds specified size */
45void $message_unpack($message message, void *buf, int size) {
46 $bundle_unpack(message.data, buf);
47 $assert(message.size <= size,
48 "Message of size %d exceeds the specified size %d.", message.size, size);
49}
50
51/* Creates a new global communicator object and returns a handle to it.
52 * The global communicator will have size communication places. The
53 * global communicator defines a communication "universe" and encompasses
54 * message buffers and all other components of the state associated to
55 * message-passing. The new object will be allocated in the given scope. */
56$gcomm $gcomm_create($scope scope, int size) {
57 $gcomm result;
58
59 for (int i=0; i<size; i++) ;
60 result = $gcomm_create2(scope, size);
61 return result;
62}
63
64/* Returns the place of the local communicator. This is the same as the
65 * place argument used to create the local communicator. */
66int $comm_place($comm comm){
67 return comm->place;
68}
69
70void $barrier_call($barrier barrier) {
71 $barrier_enter(barrier);
72 $barrier_exit(barrier);
73}
74#endif
Note: See TracBrowser for help on using the repository browser.