t8  1.2.0
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
Macros | Typedefs | Functions
t8_shmem.h File Reference

We define basic shared memory routines. More...

#include <t8.h>
#include <sc_shmem.h>

Go to the source code of this file.

Macros

#define T8_SHMEM_BEST_TYPE   SC_SHMEM_BASIC
 Defines the shared memory type that is best suited for t8code and the current machine. More...
 

Typedefs

typedef struct t8_shmem_arrayt8_shmem_array_t
 

Functions

void t8_shmem_init (sc_MPI_Comm comm)
 Initialize shared memory usage for a communicator. More...
 
void t8_shmem_finalize (sc_MPI_Comm comm)
 Finalize shared memory usage for a communicator. More...
 
void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type)
 Set a shared memory type of a communicator. More...
 
void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm)
 Initialize and allocate a shared memory array structure. More...
 
int t8_shmem_array_start_writing (t8_shmem_array_t array)
 Enable writing mode for a shmem array. More...
 
void t8_shmem_array_end_writing (t8_shmem_array_t array)
 Disable writing mode for a shmem array. More...
 
void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value)
 Set an entry of a t8_shmem array that is used to store t8_gloidx_t. More...
 
void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source)
 Copy the contents of one t8_shmem array into another. More...
 
void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype)
 Fill a t8_shmem array with an allgather. More...
 
sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array)
 Return the MPI communicator associated with a shmem array. More...
 
size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array)
 Get the element size of a t8_shmem_array. More...
 
size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array)
 Get the number of elements of a t8_shmem_array. More...
 
const t8_gloidx_tt8_shmem_array_get_gloidx_array (t8_shmem_array_t array)
 Return a read-only pointer to the data of a shared memory array interpreted as an t8_gloidx_t array. More...
 
t8_gloidx_tt8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array)
 Return a pointer to the data of a shared memory array interpreted as an t8_gloidx_t array. More...
 
t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index)
 Return an entry of a shared memory array that stores t8_gloidx_t. More...
 
const void * t8_shmem_array_get_array (t8_shmem_array_t array)
 Return a pointer to the data array of a t8_shmem_array. More...
 
const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index)
 Return a read-only pointer to an element in a t8_shmem_array. More...
 
void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index)
 Return a pointer to an element in a t8_shmem_array in writing mode. More...
 
int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b)
 
void t8_shmem_array_destroy (t8_shmem_array_t *parray)
 Free all memory associated with a t8_shmem_array. More...
 

Detailed Description

We define basic shared memory routines.

Macro Definition Documentation

◆ T8_SHMEM_BEST_TYPE

#define T8_SHMEM_BEST_TYPE   SC_SHMEM_BASIC

Defines the shared memory type that is best suited for t8code and the current machine.

See also
sc_shmem.h

Function Documentation

◆ t8_shmem_array_allgather()

void t8_shmem_array_allgather ( const void *  sendbuf,
int  sendcount,
sc_MPI_Datatype  sendtype,
t8_shmem_array_t  recvarray,
int  recvcount,
sc_MPI_Datatype  recvtype 
)

Fill a t8_shmem array with an allgather.

Parameters
[in]sendbufthe source from this process
[in]sendcountthe number of items to allgather
[in]sendtypethe type of items to allgather
[in,out]recvbufthe destination shmem array
[in]recvcountthe number of items to allgather
[in]recvtypethe type of items to allgather
Note
Writing mode must be disabled for recvarray.

◆ t8_shmem_array_copy()

void t8_shmem_array_copy ( t8_shmem_array_t  dest,
t8_shmem_array_t  source 
)

Copy the contents of one t8_shmem array into another.

Parameters
[in,out]destThe array in which source should be copied.
[in]sourceThe array to copy.
Note
dest must be initialized and match in element size and element count to source.
dest must have writing mode disabled.

◆ t8_shmem_array_destroy()

void t8_shmem_array_destroy ( t8_shmem_array_t parray)

Free all memory associated with a t8_shmem_array.

Parameters
[in,out]parrayOn input a pointer to a valid t8_shmem_array. This array is freed and parray is set to NULL on return.

◆ t8_shmem_array_end_writing()

void t8_shmem_array_end_writing ( t8_shmem_array_t  array)

Disable writing mode for a shmem array.

Parameters
[in,out]arrayInitialized with writing mode enabled.
See also
t8_shmem_array_start_writing.
Note
This function is MPI collective.

◆ t8_shmem_array_get_array()

const void* t8_shmem_array_get_array ( t8_shmem_array_t  array)

Return a pointer to the data array of a t8_shmem_array.

Parameters
[in]arrayThe t8_shmem_array.
Returns
A pointer to the data array of array.
Note
Writing mode must be disabled for array.

◆ t8_shmem_array_get_comm()

sc_MPI_Comm t8_shmem_array_get_comm ( t8_shmem_array_t  array)

Return the MPI communicator associated with a shmem array.

Parameters
[in]arrayThe shmem_array to be queried.
Returns
The MPI communicator stored at array.

◆ t8_shmem_array_get_elem_count()

size_t t8_shmem_array_get_elem_count ( t8_shmem_array_t  array)

Get the number of elements of a t8_shmem_array.

Parameters
[in]arrayThe array.
Returns
The number of elements in array.

◆ t8_shmem_array_get_elem_size()

size_t t8_shmem_array_get_elem_size ( t8_shmem_array_t  array)

Get the element size of a t8_shmem_array.

Parameters
[in]arrayThe array.
Returns
The element size of array's elements.

◆ t8_shmem_array_get_gloidx()

t8_gloidx_t t8_shmem_array_get_gloidx ( t8_shmem_array_t  array,
int  index 
)

Return an entry of a shared memory array that stores t8_gloidx_t.

Parameters
[in]arrayThe t8_shmem_array
[in]indexThe index of the entry to be queried.
Returns
The index-th entry of array as t8_gloidx_t.
Note
Writing mode must be disabled for array.

◆ t8_shmem_array_get_gloidx_array()

const t8_gloidx_t* t8_shmem_array_get_gloidx_array ( t8_shmem_array_t  array)

Return a read-only pointer to the data of a shared memory array interpreted as an t8_gloidx_t array.

Parameters
[in]arrayThe t8_shmem_array
Returns
The data of array as t8_gloidx_t pointer.
Note
Writing mode must be disabled for array.

◆ t8_shmem_array_get_gloidx_array_for_writing()

t8_gloidx_t* t8_shmem_array_get_gloidx_array_for_writing ( t8_shmem_array_t  array)

Return a pointer to the data of a shared memory array interpreted as an t8_gloidx_t array.

The array must have writing enabled t8_shmem_array_start_writing and you should not write into the memory after t8_shmem_array_end_writing was called.

Parameters
[in]arrayThe t8_shmem_array
Returns
The data of array as t8_gloidx_t pointer.

◆ t8_shmem_array_index()

const void* t8_shmem_array_index ( t8_shmem_array_t  array,
size_t  index 
)

Return a read-only pointer to an element in a t8_shmem_array.

Parameters
[in]arrayThe t8_shmem_array.
[in]indexThe index of an element.
Returns
A pointer to the element at index in array.
Note
You should not modify the value.
Writing mode must be disabled for array.

◆ t8_shmem_array_index_for_writing()

void* t8_shmem_array_index_for_writing ( t8_shmem_array_t  array,
size_t  index 
)

Return a pointer to an element in a t8_shmem_array in writing mode.

Parameters
[in]arrayThe t8_shmem_array.
[in]indexThe index of an element.
Returns
A pointer to the element at index in array.
Note
You can modify the value before the next call to t8_shmem_array_end_writing.
Writing mode must be enabled for array.

◆ t8_shmem_array_init()

void t8_shmem_array_init ( t8_shmem_array_t parray,
size_t  elem_size,
size_t  elem_count,
sc_MPI_Comm  comm 
)

Initialize and allocate a shared memory array structure.

Parameters
[in,out]parrayOn input this pointer must be non-NULL. On return this pointer is set to the new t8_shmem_array.
[in]elem_sizeThe size in bytes of an array element.
[in]elem_countThe total number of elements to allocate.
[in]commThe MPI communicator to be associated with the shmem_array. If not set, the shared memory type will be set to T8_SHMEM_BEST_TYPE.

◆ t8_shmem_array_set_gloidx()

void t8_shmem_array_set_gloidx ( t8_shmem_array_t  array,
int  index,
t8_gloidx_t  value 
)

Set an entry of a t8_shmem array that is used to store t8_gloidx_t.

The array must have writing mode enabled t8_shmem_array_start_writing.

Parameters
[in,out]arrayThe array to be mofified.
[in]indexThe array entry to be modified.
[in]valueThe new value to be set.

◆ t8_shmem_array_start_writing()

int t8_shmem_array_start_writing ( t8_shmem_array_t  array)

Enable writing mode for a shmem array.

Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero.

Parameters
[in,out]arrayInitialized array. Writing will be enabled on certain processes.
Returns
True if the calling process can write into the array.
Note
This function is MPI collective.

◆ t8_shmem_finalize()

void t8_shmem_finalize ( sc_MPI_Comm  comm)

Finalize shared memory usage for a communicator.

This destroys the intra- and internode communicators.

Parameters
[in]commThe MPI Communicator.
Note
Call this function if you initialized the communicator for shared memory usage and you are sure that you will not use it for shared memory again.
Calling this function multiple times with the same communicator is safe and does not change the behaviour.

◆ t8_shmem_init()

void t8_shmem_init ( sc_MPI_Comm  comm)

Initialize shared memory usage for a communicator.

This sets up the intra- and internode communicators.

Parameters
[in]commThe MPI Communicator.
Note
This function needs to be called to enable shared memory usage for a communicator.
Calling this function multiple times with the same communicator is safe and does not change the behaviour.

◆ t8_shmem_set_type()

void t8_shmem_set_type ( sc_MPI_Comm  comm,
sc_shmem_type_t  type 
)

Set a shared memory type of a communicator.

If the type was already set it is overwritten.

Parameters
[in,out]commThe MPI Communicator
[in]typeA shared memory type.