#include "utils.h"
#include "exchangeinfo.h"
Go to the source code of this file.
Classes | |
struct | INFODIM |
Information about one dimension of the array. More... | |
struct | RARR |
Array type. More... | |
Typedefs | |
typedef int( | RA_CREATE_FUN )(RARR *arr, IPNT v1, IPNT v2) |
typedef int( | RA_SET_FUN )(RARR *arr, const IPNT v1, const IPNT v2) |
Functions | |
int | ra_getdim (IPNT s, IPNT e) |
Helper function - returns dimension based on principle: dimension = largest index for which start, end indices differ = loop limit for loop over axes - not necessarily actual dimension of subarray. | |
int | ra_setnull (RARR *arr) |
Set all fields in an array to zeros (NO DEALLOCATION). | |
int | ra_create_s (RARR *arr, IPNT gs, IPNT n) |
Create array (given gs and n). | |
int | ra_create_e (RARR *arr, IPNT ge, IPNT n) |
Create array (given ge and n). | |
int | ra_create (RARR *arr, IPNT gs, IPNT ge) |
Create array (given gs and ge). | |
int | ra_declare_s (RARR *arr, IPNT gs, IPNT n) |
Declare array (given gs and n). | |
int | ra_declare_e (RARR *arr, IPNT ge, IPNT n) |
Declare array (given gs and n). | |
int | ra_declare (RARR *arr, IPNT gs, IPNT ge) |
Declare array (given gs and n). | |
int | ra_allocate (RARR *arr) |
Allocate array. | |
int | ra_destroy (RARR *arr) |
Destroy array (STORAGE DEALLOCATION). | |
int | ra_greset_s (RARR *arr, const IPNT gs, const IPNT n) |
Reset the working (computational virtual) array (given gs and n) (NO STORAGE ALLOCATION). | |
int | ra_greset_e (RARR *arr, const IPNT ge, const IPNT n) |
Reset the working (computational virtual) array (given ge and n) (NO STORAGE ALLOCATION). | |
int | ra_greset (RARR *arr, const IPNT gs, const IPNT ge) |
Reset the working (computational virtual) array (given gs and ge) (NO STORAGE ALLOCATION). | |
int | ra_offset_s (RARR *arr, const IPNT os, const IPNT n) |
Reset the working (computational virtual) array (given os and n) (NO STORAGE ALLOCATION). | |
int | ra_offset_e (RARR *arr, const IPNT oe, const IPNT n) |
Reset the working (computational virtual) array (given oe and n) (NO STORAGE ALLOCATION). | |
int | ra_offset (RARR *arr, const IPNT os, const IPNT oe) |
Reset the working (computational virtual) array (given oe and n) (NO STORAGE ALLOCATION). | |
int | ra_dump (const RARR *arr, FILE *stream) |
Dump array information. | |
int | ra_print (RARR *arr, FILE *stream) |
Output the working (computational virtual) array to stream. | |
int | ra_fprint (RARR *arr, const char *path) |
Output the working (computational virtual) array to a file. | |
int | ra_write (RARR *arr, FILE *stream) |
Output the working (computational virtual) array to stream. | |
int | ra_fwrite (RARR *arr, const char *path) |
Output the working (computational virtual) array to a file. | |
int | ra_read (RARR *arr, FILE *stream) |
read the working (computational virtual) array from a binary stream | |
int | ra_fread (RARR *arr, const char *path) |
read the working (computational virtual) array from a binary file | |
int | ra_printslice (RARR *arr, FILE *stream, int idim, int islice) |
Output a slice of the working (computational virtual) array to a stream. | |
int | ra_fprintslice (RARR *arr, const char *path, int idim, int islice) |
Output a slice of the working (computational virtual) array to a stream. | |
int | ra_writeslice (RARR *arr, FILE *stream, int idim, int islice) |
Output a slice of the working (computational virtual) array to a file. | |
int | ra_fwriteslice (RARR *arr, const char *path, int idim, int islice) |
Output a slice of the working (computational virtual) array to a file. | |
ireal | ra_get (const RARR *arr, IPNT li) |
Get value at a local index relative to gs. | |
ireal | ra_gget (const RARR *arr, IPNT gi) |
Get value at a global index. | |
void | ra_set (RARR *arr, IPNT li, ireal r) |
Set value at a local index relative to gs. | |
void | ra_gset (RARR *arr, IPNT gi, ireal r) |
Set value at a global index. | |
int | ra_size (const RARR *arr, IPNT n) |
Get axis lengths of the working (computational virtual) array. | |
int | ra_datasize (const RARR *arr, size_t *n) |
Get size of the working (computational virtual) array. | |
int | ra_a_size (const RARR *arr, IPNT n) |
Get axis lengths of the allocated array. | |
int | ra_a_datasize (const RARR *arr, size_t *n) |
Get size of the allocated array. | |
int | ra_gse (const RARR *arr, IPNT gs, IPNT ge) |
Get the global start and end indices of the working (computational virtual) array. | |
int | ra_gse (const RARR *arr1, const RARR *arr2, IPNT gs, IPNT ge) |
int | ra_se (const RARR *arr, IPNT s, IPNT e) |
Get the start and end indices of the working (computational virtual) array RELATIVE to the allocated array. | |
int | ra_a_gse (const RARR *arr, IPNT gs, IPNT ge) |
Get the start and end indices of the allocated array. | |
int | ra_ds (const RARR *tgt, const RARR *src, IPNT ds) |
Relative index shift from source rarray to target array. | |
int | ra_checkbound (const RARR *arr, int idim, int li) |
Check if a local index relative to gs (and idim) is within bounds of the allocated array. | |
int | ra_gcheckbound (const RARR *arr, int idim, int gi) |
Check if a gloabal index (and idim) is within bounds of the allocated array. | |
int | ra_ndim (const RARR *arr, int *ndim) |
Get number of dimensions. | |
int | ra_empty (RARR *arr, int *empty) |
Array empty query. | |
int | ra_setempty (RARR *arr) |
Set the working (computational virtual) array empty. | |
int | ra_setexchangeinfo (RARR *arr, EXCHANGEINFO *einfo) |
Populates exchange info. | |
int | ra_overlap (RARR *arr1, RARR *arr2, int *overlap) |
Checks if the two working (computational virtual) arrays of arr1 and arr2 overlap. | |
int | ra_setoverlap (RARR *arr1, RARR *arr2) |
Set the working (computational virtual) array's dimension info of arr1 to be that of the overlap part of arr1 and arr2. | |
int | ra_zero (RARR *arr) |
Set the entries of the computational array all zero. | |
int | ra_a_zero (RARR *arr) |
Set the entries of the allocated array all zero. | |
int | ra_ghost_zero (RARR *arr) |
Set the entries of the ghost cells or halo (complement of computational array in allocated array) to zero. | |
int | ra_deepcopy (RARR const *src, RARR *tgt) |
Copy all of the members of the source struct to the target struct. | |
int | ra_copy (RARR *arr_des, RARR *arr_src) |
Copy the contents of the source VIRTUAL array to the destination VIRTUAL array. | |
int | ra_a_copy (RARR *arr_des, RARR *arr_src) |
Copy the contents of the source ALLOCATED arry to the destination ALLOCATED array. | |
int | ra_a_scale (RARR *tgt, ireal fac) |
scale ALLOCATED array elements | |
int | ra_a_inner (RARR const *arr1, RARR const *arr2, ireal *ip) |
part of infrastructure to give RDOM minimal DataContainer characteristics | |
int | ra_axpy (RARR *arry, RARR const *arrx, ireal a) |
part of infrastructure to give RDOM minimal DataContainer characteristics | |
int | ra_compare_meta (const RARR *a, const RARR *b) |
comparison function - required to make RARR behave like a proper metadata object |
Functions:
Notes:
Definition in file rarray.h.
typedef int( RA_SET_FUN)(RARR *arr, const IPNT v1, const IPNT v2) |
Helper function - returns dimension based on principle: dimension = largest index for which start, end indices differ = loop limit for loop over axes - not necessarily actual dimension of subarray.
[in] | s | - start indices |
[in] | e | - end indices |
int ra_setnull | ( | RARR * | arr | ) |
Create array (given gs and n).
Declaration + allocation. Set n=n0, gs=gs0, ge=ge0 and _s=_s0.
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the array in all dimensions |
[in] | n | - (IPNT) sizes of the array in all dimensions |
Create array (given ge and n).
Declaration + allocation. Set n=n0, gs=gs0, ge=ge0 and _s=_s0.
[out] | arr | - (RARR *) |
[in] | ge | - (IPNT) global end indices of the array in all dimensions |
[in] | n | - (IPNT) sizes of the array in all dimensions |
Create array (given gs and ge).
Declaration + allocation. Set n=n0, gs=gs0, ge=ge0 and _s=_s0.
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the array in all dimensions |
[in] | ge | - (IPNT) global end indices of the array in all dimensions |
Declare array (given gs and n).
Works like create, but does not allocate memory. Also set n=n0, gs=gs0, ge=ge0. Use ra_allocate to allocate memory.
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the array in all dimensions |
[in] | n | - (IPNT) sizes of the arr as in base/include/utils.h. |
Declare array (given gs and n).
Works like create, but does not allocate memory. Also set n=n0, gs=gs0, ge=ge0. Use ra_allocate to allocate memory.
[out] | arr | - (RARR *) |
[in] | ge | - (IPNT) global end indices of the array in all dimensions |
[in] | n | - (IPNT) sizes of the array in all dimensions |
Declare array (given gs and n).
Works like create, but does not allocate memory. Also set n=n0, gs=gs0, ge=ge0. Use ra_allocate to allocate memory.
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the array in all dimensions |
[in] | ge | - (IPNT) global end indices of the array in all dimensions |
int ra_allocate | ( | RARR * | arr | ) |
Allocate array.
Allocate memory. Set _s=_s0.
[out] | arr | - (RARR *) |
int ra_destroy | ( | RARR * | arr | ) |
Destroy array (STORAGE DEALLOCATION).
Free the allocated memory pointed by _s0
[out] | arr | - (RARR *) |
Reset the working (computational virtual) array (given gs and n) (NO STORAGE ALLOCATION).
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the working (computational virtual) array in all dimensions |
[in] | n | - (IPNT) sizes of the working (computational virtual) array in all dimensions |
Reset the working (computational virtual) array (given ge and n) (NO STORAGE ALLOCATION).
[out] | arr | - (RARR *) |
[in] | ge | - (IPNT) global end indices of the working (computational virtual) array in all dimensions |
[in] | n | - (IPNT) sizes of the working (computational virtual) array in all dimensions |
Reset the working (computational virtual) array (given gs and ge) (NO STORAGE ALLOCATION).
[out] | arr | - (RARR *) |
[in] | gs | - (IPNT) global start indices of the working (computational virtual) array in all dimensions. |
[in] | ge | - (IPNT) global end indices of the working (computational virtual) array in all dimensions. |
Reset the working (computational virtual) array (given os and n) (NO STORAGE ALLOCATION).
new_gs = gs + os, new_ge = ge - oe.
[out] | arr | - (RARR *) |
[in] | os | - (IPNT) start index offsets (forward) of the working (computational virtual) array in all dimensions. |
[in] | n | - (IPNT) sizes of the working (computational virtual) array in all dimensions |
Reset the working (computational virtual) array (given oe and n) (NO STORAGE ALLOCATION).
[out] | arr | - (RARR *) |
[in] | oe | - (IPNT) end index offsets (backward) of the working (computational virtual) array in all dimensions. |
[in] | n | - (IPNT) sizes of the working (computational virtual) array in all dimensions |
Reset the working (computational virtual) array (given oe and n) (NO STORAGE ALLOCATION).
[out] | arr | - (RARR *) |
[in] | os | - (IPNT) start index offsets (forward) of the working (computational virtual) array in all dimensions. |
[in] | oe | - (IPNT) end index offsets (backward) of the working (computational virtual) array in all dimensions. |
int ra_dump | ( | const RARR * | arr, | |
FILE * | stream | |||
) |
Dump array information.
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
int ra_print | ( | RARR * | arr, | |
FILE * | stream | |||
) |
Output the working (computational virtual) array to stream.
Format: formatted ASCII.
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
int ra_fprint | ( | RARR * | arr, | |
const char * | path | |||
) |
Output the working (computational virtual) array to a file.
Format: formatted ASCII
[in] | arr | - (RARR *) |
[in] | path | - (const char *) file name |
int ra_write | ( | RARR * | arr, | |
FILE * | stream | |||
) |
Output the working (computational virtual) array to stream.
Format: binary
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
int ra_fwrite | ( | RARR * | arr, | |
const char * | path | |||
) |
Output the working (computational virtual) array to a file.
Format: binary
[in] | arr | - (RARR *) |
[in] | path | - (const char *) file name |
int ra_read | ( | RARR * | arr, | |
FILE * | stream | |||
) |
read the working (computational virtual) array from a binary stream
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
int ra_fread | ( | RARR * | arr, | |
const char * | path | |||
) |
read the working (computational virtual) array from a binary file
[in] | arr | - (RARR *) |
[in] | path | - (const char *) file name |
int ra_printslice | ( | RARR * | arr, | |
FILE * | stream, | |||
int | idim, | |||
int | islice | |||
) |
Output a slice of the working (computational virtual) array to a stream.
Format: formatted ASCII.
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
[in] | idim | - (int) dimension number. the idim'th index is fixed |
[in] | islice | - (int) the fixed index |
int ra_fprintslice | ( | RARR * | arr, | |
const char * | path, | |||
int | idim, | |||
int | islice | |||
) |
Output a slice of the working (computational virtual) array to a stream.
Format: formatted ASCII.
[in] | arr | - (RARR *) |
[in] | path | - (const char *) file name |
[in] | idim | - (int) dimension number. the idim'th index is fixed |
[in] | islice | - (int) the fixed index |
int ra_writeslice | ( | RARR * | arr, | |
FILE * | stream, | |||
int | idim, | |||
int | islice | |||
) |
Output a slice of the working (computational virtual) array to a file.
Format: binary.
[in] | arr | - (RARR *) |
[in] | stream | - (FILE *) |
[in] | idim | - (int) dimension number. the idim'th index is fixed |
[in] | islice | - (int) the fixed index |
int ra_fwriteslice | ( | RARR * | arr, | |
const char * | path, | |||
int | idim, | |||
int | islice | |||
) |
Output a slice of the working (computational virtual) array to a file.
Format: binary.
[in] | arr | - (RARR *) |
[in] | path | - (const char *) file name |
[in] | idim | - (int) dimension number. the idim'th index is fixed |
[in] | islice | - (int) the fixed index |
Get value at a local index relative to gs.
[No difference with ra_gget, since gs is alway 0]
[in] | arr | - (RARR *) |
[in] | li | - (IPNT) local index relative to gs |
Get value at a global index.
[in] | arr | - (RARR *) |
[in] | gi | - (IPNT) global index |
Set value at a local index relative to gs.
[No difference with ra_gset, since gs is alway 0]
[out] | arr | - (RARR *) |
[in] | li | - (IPNT) local index relative to gs |
[in] | r | - (ireal) the value to be set |
Set value at a global index.
[out] | arr | - (RARR *) |
[in] | gi | - (IPNT) global index |
[in] | r | - (ireal) the value to be set |
Get axis lengths of the working (computational virtual) array.
[in] | arr | - (RARR *) |
[out] | n | - (IPNT) |
int ra_datasize | ( | const RARR * | arr, | |
size_t * | n | |||
) |
Get size of the working (computational virtual) array.
[in] | arr | - arg |
[out] | n | - size of array = prod of axis lengths |
Get axis lengths of the allocated array.
[in] | arr | - (RARR *) |
[out] | n | - (IPNT) |
0 on successful completion, else error code as in base/include/utils.h.
int ra_a_datasize | ( | const RARR * | arr, | |
size_t * | n | |||
) |
Get size of the allocated array.
[in] | arr | - (RARR *) |
[out] | n | - size of array = prod of axis lengths |
0 on successful completion, else error code as in base/include/utils.h.
Get the global start and end indices of the working (computational virtual) array.
[in] | arr | - (RARR *) |
[out] | gs | - (IPNT) start indices |
[out] | ge | - (IPNT) end indices |
Get the start and end indices of the working (computational virtual) array RELATIVE to the allocated array.
That is, return s = gs-gs0, e = ge-gs0. These are the correct index limits to loop over the computational array by indexing into the multidimensinal array representation of the allocated array. For example, if a is 2D, then you can assign to its computational part by the nested loop
ra_se(&a,s,e); for (i[1]=s[1];i[1]<=e[1];i[1]++) for (i[0]=s[0];i[0]<=e[0];i[0]++) a._s02[i[1]][i[0]] = ...
[in] | arr | - (RARR *) |
[out] | s | - (IPNT) start indices |
[out] | e | - (IPNT) end indices |
Get the start and end indices of the allocated array.
[in] | arr | - (RARR *) |
[out] | gs | - (IPNT) start indices |
[out] | ge | - (IPNT) end indices |
Relative index shift from source rarray to target array.
Used to align multidimensional index references: for example, if ds is retrieved by
ra_ds(&tgt,&src,ds)
and tgt, src are 3D rarrays, then
tgt._s3[i[2]+ds[2]][i[1]+ds[1]][i[0]+ds[0]]
and
src._s3[i[2]][i[1]][i[0]]
refer to values at the same global grid location
[in] | tgt | - (RARR *) target rarray (shifted indices) |
[in] | src | - (RARR *) source rarray (unshifted indices) |
[out] | ds | - (IPNT) index shift from source to target |
int ra_checkbound | ( | const RARR * | arr, | |
int | idim, | |||
int | li | |||
) |
Check if a local index relative to gs (and idim) is within bounds of the allocated array.
[in] | arr | - (RARR *) |
[in] | idim | - (int) dimension number. |
[in] | li | - local index relative to gs |
int ra_gcheckbound | ( | const RARR * | arr, | |
int | idim, | |||
int | gi | |||
) |
Check if a gloabal index (and idim) is within bounds of the allocated array.
[in] | arr | - (RARR *) |
[in] | idim | - (int) dimension number. |
[in] | gi | - global index |
int ra_ndim | ( | const RARR * | arr, | |
int * | ndim | |||
) |
Get number of dimensions.
[in] | arr | - (RARR *) |
[out] | ndim | - (int *) number of dimensions |
int ra_empty | ( | RARR * | arr, | |
int * | empty | |||
) |
Array empty query.
[in] | arr | - (RARR *) |
[out] | empty | - (int *) 0: nonempty, 1: empty |
int ra_setempty | ( | RARR * | arr | ) |
Set the working (computational virtual) array empty.
[in] | arr | - (RARR *) |
int ra_setexchangeinfo | ( | RARR * | arr, | |
EXCHANGEINFO * | einfo | |||
) |
Populates exchange info.
Creates MPI_Datatype inside - do not forget to destoy.
[in] | arr | - (RARR *) |
[out] | einfo | - (EXCHANGEINFO *) |
Checks if the two working (computational virtual) arrays of arr1 and arr2 overlap.
[in] | arr1,arr2 | - (RARR *) |
[out] | overlap | - (int *) 0: not overlap, 1: overlap |
Set the working (computational virtual) array's dimension info of arr1 to be that of the overlap part of arr1 and arr2.
int ra_zero | ( | RARR * | arr | ) |
Set the entries of the computational array all zero.
[in] | arr | - (RARR *) |
int ra_a_zero | ( | RARR * | arr | ) |
Set the entries of the allocated array all zero.
[in] | arr | - (RARR *) |
int ra_ghost_zero | ( | RARR * | arr | ) |
Set the entries of the ghost cells or halo (complement of computational array in allocated array) to zero.
[in] | arr | - (RARR *) |
Copy all of the members of the source struct to the target struct.
No allocation occurs. tgt works as a reference of src.
[in] | src | - (RARR const *) src cannot be pointed to other array, but one can change the array pointed by it |
[out] | tgt | - (RARR *) |
Copy the contents of the source VIRTUAL array to the destination VIRTUAL array.
Both arrays must have the same structure and be allocated.
Copy the contents of the source ALLOCATED arry to the destination ALLOCATED array.
Both arrays must have the same structure and be allocated.
scale ALLOCATED array elements
[in] | tgt | - (RARR *) target data |
[in] | fac | - (ireal) scale factor |
part of infrastructure to give RDOM minimal DataContainer characteristics
note that inner product is over entire ALLOCATED array, not just virtual array
[in] | arr1 | - (RARR const *) input array 1 |
[in] | arr2 | - (RARR const *) input array 2 |
[out] | ip | - (ireal) inner product - unscaled l2 |
part of infrastructure to give RDOM minimal DataContainer characteristics
saxpy for virtual arrays
[in] | arrx | - (RARR const *) input array |
[in] | arry | - (RARR *) input/output array = y <- ax+y |
[in] | a | - (ireal) multiplier |
comparison function - required to make RARR behave like a proper metadata object