| Version 24 (modified by , 3 years ago) ( diff ) |
|---|
Prev: Language Manual | Next: Command Line Interface
CIVL Libraries
In progress.
bundle
Header: bundle.cvh. Uses: op.
A bundle is a sequence of objects of the same type, wrapped into an atomic package.
A bundle is created using a function that specifies a region of memory.
One can create a bundle from an array of integers, and another bundle from an array of reals.
Both bundles have the same type, $bundle.
They can therefore be entered into an array of $bundle, for example.
Hence bundles are useful for mixing objects of different (even statically unknown) types into a single data structure.
Later, the contents of a bundle can be extracted with another function that specifies a region of memory into which to unpack the bundle;
if that memory does not have the right type to receive the contents of the bundle, a runtime error occurs.
Types
$bundle: the bundle type
Functions
$system int $bundle_size($bundle b)- Returns the size of the given bundle, i.e., the number of bytes consumed by all elements of the bundle. This is the product of the number of elements and the size of one element.
$system $bundle $bundle_pack(void *ptr, int size)- This function creates a bundle from the memory region specified by
ptrandsize(the total number of bytes to copy), copying the data into the new bundle. It returns the new bundle.
- This function creates a bundle from the memory region specified by
$system void $bundle_unpack($bundle b, void *ptr)- This function copies the data from the given bundle into the memory region starting at
ptr. The memory region extends for$bundle_size(b)bytes.
- This function copies the data from the given bundle into the memory region starting at
$atomic_f void $bundle_unpack_apply($bundle data, void *buf, $operation op, int count, void *result)- This function unpacks the bundle while applying the specified numeric operation. Parameter
opspecifies a binary operation. For each i in 0..count-1, the operation is applied to the i-th element ofbufand the i-th element of the bundle, and the result is stored in the i-th position ofresult. Parametercountis the number of elements in the bundle;bufandresultshould each point to a region of memory capable of holding at leastcountelements.
- This function unpacks the bundle while applying the specified numeric operation. Parameter
Example
#include <bundle.cvh>
int main() {
int n = 10;
int a[n], b[n], c[n];
for (int i=0; i<n; i++) a[i] = i;
$bundle bun = $bundle_pack(a, n*sizeof(int));
$assert($bundle_size(bun) == n*sizeof(int));
$bundle_unpack(bun, b);
$assert($forall (int i: 0..n-1) b[i]==a[i]);
$bundle_unpack_apply(bun, b, _SUM, n, c);
$assert($forall (int i: 0..n-1) c[i]==2*a[i]);
}
comm
Header: comm.cvh. Uses: bundle.
The comm library supports message-passing-style communication. It provides a number of basic data structures which can be used to implement specific message-passing interfaces, such as MPI.
Types
$message: A message consists of data and meta-data. The data is a finite sequence of objects, all of the same type. The meta-data consists of 3 integers: the source, destination, and tag. The source identifies the process that sent the message. The destination identifies the process to which the message is sent. Bothsourceanddestinationare "places", which are nonnegative integer IDs that abstract places from which messages are sent or received. Typically, a single place is associated to each process in a message-passing system, but this is not required. The tag is an additional nonnegative integer that can be used to represent anything the user wants; the receiving process may select a message based on the tag.$gcomm: This is an opaque handle to an object that stores the state of the message-passing system. In particular, the buffered messages (those that have been sent, but not yet received) are stored in the gcomm.$comm: Each place has its own comm, an opaque handle local to that place that is used to access all message-passing functions (e.g., sends and receives) at that place. It contains a reference to the gcomm.
Constants
$COMM_ANY_SOURCE: a constant that can be used as the source argument in a dequeue operation to indicate that a message may be taken from any source$COMM_ANY_TAG: a constant that can be used as the tag argument in a dequeue operation to indicate that a message with any tag may be selected$comm_null: a constant representing the absence of$comm
Functions
$atomic_f $message $message_pack(int source, int dest, int tag, const void *data, int size)- Creates a new message with the given meta-data, and the data taken from the memory region that begins at
dataand extends forsizebytes. The data is copied into the new message object. The source, destination, and tag must be nonnegative. The size may be 0.
- Creates a new message with the given meta-data, and the data taken from the memory region that begins at
$atomic_f int $message_source($message message)- Gets the source of the message.
$atomic_f int $message_tag($message message)- Gets the tag of the message.
$atomic_f int $message_dest($message message)- Gets the destination of the message.
$atomic_f int $message_size($message message)- Gets the size of the message data (in bytes).
$atomic_f void $message_unpack($message message, void *buf, int size)- Extracts the data from a message, storing it in the buffer that starts at
buf. The argumentsizemust be greater than or equal to the size of message, else an error occurs.
- Extracts the data from a message, storing it in the buffer that starts at
$atomic_f $gcomm $gcomm_create($scope scope, int size)- Allocates a new gcomm object that will be stored in the heap of the specified scope. The
sizeis the number of "places" that will be associated to this gcomm. The place IDs range from 0 tosize-1 (inclusive).
- Allocates a new gcomm object that will be stored in the heap of the specified scope. The
$atomic_f int $gcomm_destroy($gcomm gcomm, void * junkMsgs)- Destroys the gcomm, deallocating memory that was allocated for it. If
junkMsgsis not NULL it shall be a pointer to an array of indeterminate length of$message. This function will populate that array with all messages remaining the gcomm's buffers and return the number of such messages.
- Destroys the gcomm, deallocating memory that was allocated for it. If
$atomic_f void $gcomm_dup($comm comm, $comm newcomm)- Duplicates the communicator
comm. Thenewcommis initialized to have the same gcomm and place as the originalcomm.
- Duplicates the communicator
$atomic_f $comm $comm_create($scope scope, $gcomm gcomm, int place)- Creates a new
commassociated with the specifiedplaceingcomm. Ifplaceis less than 0, or greater than the size ofgcomm, or another process has already occupiedplaceingcomm, an error occurs. The new comm object is allocated in the heap of the given scope.
- Creates a new
$atomic_f void $comm_destroy($comm comm)- Deallocates the comm.
$atomic_f int $comm_size($comm comm)- Gets the size of the gcomm that owns
comm.
- Gets the size of the gcomm that owns
$atomic_f int $comm_place($comm comm)- Gets the place of the given
commin its gcomm object.
- Gets the place of the given
$system void $comm_enqueue($comm comm, $message message)- Enqueues a message in a FIFO channel in the gcomm. The message should have its source be the place of
comm. The message will enqueued on channel (i,j) in the gcomm, where i is the place of the source, and j is the place of the destination of the message.
- Enqueues a message in a FIFO channel in the gcomm. The message should have its source be the place of
$system $state_f _Bool $comm_probe($comm comm, int source, int tag)- Determines whether there exists a message with the given source and tag, and with destination the place of
comm, in the gcomm associated tocomm.sourcemay be$COMM_ANY_SOURCEandtagmay be$COMM_ANY_TAG.
- Determines whether there exists a message with the given source and tag, and with destination the place of
$system $message $comm_seek($comm comm, int source, int tag)- Returns the oldest message in the gcomm associated to
commthat matchessourceandtagwithout modifying gcomm.sourcemay be$COMM_ANY_SOURCEandtagmay be$COMM_ANY_TAG. If no such message found, returns a message with empty data and all meta-data being-1.
- Returns the oldest message in the gcomm associated to
$system $message $comm_dequeue($comm comm, int source, int tag)- Dequeues a message in a FIFO channel in the gcomm. The message should have its destination be the place of
comm. The message will be dequeued from channel (i,j) in the gcomm, where i is the place of the source, and j is the place of the destination of the message. A call to this function will not return until a matching message can be dequeued.
- Dequeues a message in a FIFO channel in the gcomm. The message should have its destination be the place of
$system $state_f _Bool $comm_empty_in($comm )- deprecated
$system $state_f _Bool $comm_empty_out($comm )- deprecated
concurrency
Header: concurrency.cvh. Uses: bundle.
Types
$gbarrier- A data type representing a handle to a global barrier object.
$barrier- A data type representing a process-local handle used to operate a global barrier
Functions
$atomic_f $gbarrier $gbarrier_create($scope scope, int size)- Creates a new global barrier object and returns a handle to it. The barrier has the specified
size. The new object will be allocated in the givenscope.
- Creates a new global barrier object and returns a handle to it. The barrier has the specified
$atomic_f void $gbarrier_destroy($gbarrier gbarrier)- Destroys the global barrier object referred by the handle
gbarrier
- Destroys the global barrier object referred by the handle
int $get_nprocs($gbarrier gbarrier)- Returns the size of the global barrier object
$atomic_f $barrier $barrier_create($scope scope, $gbarrier gbarrier, int place)- Creates a process-local handle for operating the global barrier referred by
gbarrier. Theplacemust be in [0,get_nprocs(gbarrier)-1]. It specifies the place in the global barrier that will be occupied by the local handle.
- Creates a process-local handle for operating the global barrier referred by
$atomic_f void $barrier_destroy($barrier barrier)- Destroys the local handle to a global barrier
void $barrier_call($barrier barrier)- Calls the barrier referred by
barrier
- Calls the barrier referred by
void $barrier_call_yield($barrier barrier)- Calls the barrier from within an atomic section: this will yield at the point where process is waiting to exit barrier.
void $barrier_call_subset($barrier barrier, int nprocs)- under construction
void $barrier_call_execute($barrier barrier, void foo(void))- under construction
domain
Header: domain.cvh. Uses: (nothing).
Types
$domain_strategy- An enumeration type used to specify how domains are decomposed. There are three options:
ALL,RANDOM, andROUND_ROBIN.
- An enumeration type used to specify how domains are decomposed. There are three options:
$domain_decomposition- A data structure representing the decomposition result of a domain.
Functions
$system $domain_decomposition $domain_partition($domain domain, $domain_strategy strategy, int n)- Takes a domain and some n>0 and returns some partition of the domain into n sub-domains, according to the decomposition strategy specified.
$system $range $range_of_rectangular_domain($domain dom, int index)- Returns the
index-th range of the given domaindom. Requiresindexto be between 1 and the dimension ofdomminus 1.
- Returns the
$system int $high_of_regular_range($range range)- Returns the upper bound of a regular range.
$system int $low_of_regular_range($range range)- Returns the lower bound of a regular range.
$system int $step_of_regular_range($range range)- Returns the step of a regular range
$system _Bool $is_rectangular_domain($domain domain)- Returns true if this
domainis a rectangular domain.
- Returns true if this
$system _Bool $is_regular_range($range range)- Returns true if this
rangeis a regular range, i.e., it is composed of a lower bound, a higher bound and a step.
- Returns true if this
$system int $dimension_of($domain domain)- Returns the dimension of the given domain.
mem
Header: mem.cvh. Uses: (nothing).
The mem library provides functions to manipulate objects of the CIVL-C built-in type---$mem. A $mem object represents a set of memory locations.
Functions
$system void $write_set_push()- Pushes a new entry (i.e. an empty
$mem) onto the write stack of the calling process. Each process maintains a write stack. A stack entry is a$memobject. A write to a memory location will cause the memory location being added to the top entry of the write stack, if the stack is non-empty.
- Pushes a new entry (i.e. an empty
$system $mem $write_set_pop()- Pops and returns the top entry of the write stack of the calling process.
$state_f $system $mem $write_set_peek()- Returns the top entry of the write stack of the calling process.
$system void $read_set_push()- Pushes a new entry (i.e. an empty
$mem) onto the read stack of the calling process. Each process maintains a read stack. A stack entry is a$memobject. Reading a memory location will cause the memory location being added to the top entry of the read stack, if the stack is non-empty.
- Pushes a new entry (i.e. an empty
$system $mem $read_set_pop()- Pops and returns the top entry of the read stack of the calling process.
$state_f $system $mem $read_set_peek()- Returns the top entry of the read stack of the calling process.
$atomic_f $system $mem $mem_empty()- Creates a new empty
$memobject.
- Creates a new empty
$atomic_f $system _Bool $mem_equals($mem m0, $mem m1)- Returns true iff
m0andm1are the identical set of memory locations.
- Returns true iff
$atomic_f $system _Bool $mem_contains($mem super, $mem sub)- Returns true iff
superis a super-set ofsub.
- Returns true iff
$atomic_f $system _Bool $mem_no_intersect($mem m0, $mem m1, $mem *out0, $mem *out1)- Returns true iff
m0andm1are two disjoint sets. Ifm0andm1overlap,out0andout1will be assigned two overlapping memory location sets, which are as small as the function can figure out fromm0andm1, respectively.
- Returns true iff
$atomic_f $system $mem $mem_union($mem mem0, $mem mem1)- Returns the union of the two sets of memory locations
mem0andmem1.
- Returns the union of the two sets of memory locations
$atomic_f $system $mem $mem_union_widening($mem, $mem)- Similar to the
$mem_unionfunction but may return an over-approximated super-set of the union set. The over-approximation is done by the model checker in order to make state space finite.
- Similar to the
$atomic_f $system void $mem_havoc($mem m)- Assigns arbitrary values to memory locations in
m
- Assigns arbitrary values to memory locations in
$atomic_f $system $mem $mem_unary_widening($mem m)- Returns an over-approximated super-set of
m. The over-approximation is done by the model checker in order to make state space finite.
- Returns an over-approximated super-set of
$atomic_f $system void $mem_assign_from($state s, $mem m)- deprecated
op
Header: op.h. Uses: (nothing).
Defines an enumerated type $operation with the following values:
| Constant | Description |
|---|---|
_NO_OP | no operation |
_MAX | maximum |
_MIN | minimun |
_SUM | sum |
_PROD | product |
_LAND | logical and |
_BAND | bit-wise and |
_LOR | logical or |
_BOR | bit-wise or |
_LXOR | logical exclusive or |
_BXOR | bit-wise exclusive or |
_MINLOC | min value and location |
_MAXLOC | max value and location |
_EQ | equal to |
_NEQ | not Equal to |
pointer
Header: pointer.cvh. Uses: op.
scope
Header: scope.cvh. Uses: (nothing).
seq
Header: seq.cvh. Uses: (nothing).
C Standard library
stdlib
stdio
string
Prev: Language Manual | Next: Command Line Interface
