wiki:Libraries

Version 15 (modified by siegel, 3 years ago) ( diff )

--

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 ptr and size (the total number of bytes to copy), copying the data into the new bundle. It returns the new bundle.
  • $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.
  • $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 op specifies a binary operation. For each i in 0..count-1, the operation is applied to the i-th element of buf and the i-th element of the bundle, and the result is stored in the i-th position of result. Parameter count is the number of elements in the bundle; buf and result should each point to a region of memory capable of holding at least count elements.

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
  • $gcomm
  • $comm

Constants

  • $COMM_ANY_SOURCE
  • $COMM_ANY_TAG

Functions

  • $atomic_f $message $message_pack(int source, int dest, int tag, const void *data, int size)
  • $atomic_f int $message_source($message message)
  • $atomic_f int $message_tag($message message)
  • $atomic_f int $message_dest($message message)
  • $atomic_f int $message_size($message message)
  • $atomic_f void $message_unpack($message message, void *buf, int size)
  • $atomic_f $gcomm $gcomm_create($scope scope, int size)
  • $atomic_f int $gcomm_destroy($gcomm gcomm, void * junkMsgs)
  • $atomic_f void $gcomm_dup($comm comm, $comm newcomm)
  • $atomic_f $comm $comm_create($scope scope, $gcomm gcomm, int place)
  • $atomic_f void $comm_destroy($comm comm)
  • $atomic_f int $comm_size($comm comm)
  • $atomic_f int $comm_place($comm comm)
  • $system void $comm_enqueue($comm comm, $message message)
  • $system $state_f _Bool $comm_probe($comm comm, int source, int tag)
  • $system $message $comm_seek($comm comm, int source, int tag)
  • $system $message $comm_dequeue($comm comm, int source, int tag)
  • $system $state_f _Bool $comm_empty_in($comm )
  • $system $state_f _Bool $comm_empty_out($comm )

concurrency

Header: concurrency.cvh. Uses: bundle.

domain

Header: domain.cvh. Uses: (nothing).

mem

Header: mem.cvh. Uses: (nothing).

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

Note: See TracWiki for help on using the wiki.