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

In this file we collect function that deal with the cmesh partition offset. More...

#include <t8.h>
#include <t8_cmesh.h>

Go to the source code of this file.

Functions

t8_gloidx_t t8_offset_first (int proc, const t8_gloidx_t *offset)
 Return the global id of the first local tree of a given process in a partition. More...
 
t8_gloidx_t t8_offset_first_tree_to_entry (t8_gloidx_t first_tree, int shared)
 Given the global tree id of the first local tree of a process and the flag whether it is shared or not, compute the entry in the offset array. More...
 
t8_gloidx_t t8_offset_num_trees (int proc, const t8_gloidx_t *offset)
 The number of trees of a given process in a partition. More...
 
t8_gloidx_t t8_offset_last (int proc, const t8_gloidx_t *offset)
 Return the last local tree of a given process in a partition. More...
 
int t8_offset_empty (int proc, const t8_gloidx_t *offset)
 Check whether a given process has no local trees in a given partition. More...
 
int t8_offset_next_nonempty_rank (int rank, int mpisize, const t8_gloidx_t *offset)
 Find the next higher rank that is not empty. More...
 
int t8_offset_in_range (t8_gloidx_t tree_id, int proc, const t8_gloidx_t *offset)
 Determine whether a given global tree id is a local tree of a given process in a certain partition. More...
 
int t8_offset_any_owner_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset)
 Find any process that has a given tree as local tree. More...
 
int t8_offset_first_owner_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner)
 Find the smallest process that has a given tree as local tree. More...
 
int t8_offset_last_owner_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner)
 Find the biggest process that has a given tree as local tree. More...
 
int t8_offset_next_owner_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner)
 Given a process current_owner that has the tree gtree as local tree, find the next bigger rank that also has this tree as local tree. More...
 
int t8_offset_prev_owner_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner)
 Given a process current_owner that has the tree gtree as local tree, find the next smaller rank that also has this tree as local tree. More...
 
void t8_offset_all_owners_of_tree (int mpisize, t8_gloidx_t gtree, const t8_gloidx_t *offset, sc_array_t *owners)
 Compute a list of all processes that own a specific tree.n offset minus 1. More...
 
int t8_offset_nosend (int proc, int mpisize, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to)
 Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself) More...
 
int t8_offset_sendsto (int proca, int procb, const t8_gloidx_t *t8_offset_from, const t8_gloidx_t *t8_offset_to)
 Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process. More...
 
int t8_offset_sendstree (int proc_send, int proc_to, t8_gloidx_t gtree, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to)
 Query whether in a repartitioning setting, a given process sends a given tree to a second process. More...
 
int t8_offset_range_send (int start, int end, int mpirank, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to)
 Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting. More...
 
void t8_offset_print (t8_shmem_array_t offset, sc_MPI_Comm comm)
 Print an offset array. More...
 

Detailed Description

In this file we collect function that deal with the cmesh partition offset.

TODO: document this file

Function Documentation

◆ t8_offset_all_owners_of_tree()

void t8_offset_all_owners_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset,
sc_array_t *  owners 
)

Compute a list of all processes that own a specific tree.n offset minus 1.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global index of a tree.
[in]offsetThe partition to be considered.
[in,out]ownersOn input an initialized sc_array with integer entries and zero elements. On output a sorted list of all MPI ranks that have gtree as a local tree in offset.

◆ t8_offset_any_owner_of_tree()

int t8_offset_any_owner_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset 
)

Find any process that has a given tree as local tree.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global id of a tree.
[in]offsetThe partition to be considered.
Returns
An MPI rank that has gtree as a local tree.

◆ t8_offset_empty()

int t8_offset_empty ( int  proc,
const t8_gloidx_t offset 
)

Check whether a given process has no local trees in a given partition.

Parameters
[in]procA mpi rank.
[in]offsetA partition table.
Returns
nonzero if proc does not have local trees in offset. 0 otherwise.

◆ t8_offset_first()

t8_gloidx_t t8_offset_first ( int  proc,
const t8_gloidx_t offset 
)

Return the global id of the first local tree of a given process in a partition.

Parameters
[in]procThe rank of the process.
[in]offsetThe partition table.
Returns
The global id of the first local tree of proc in the partition offset.

◆ t8_offset_first_owner_of_tree()

int t8_offset_first_owner_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset,
int *  some_owner 
)

Find the smallest process that has a given tree as local tree.

To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global id of a tree.
[in]offsetThe partition to be considered.
[in]some_ownerIf >= 0 considered as input: a process that has gtree as local tree. If < 0 on output a process that has gtree as local tree. Specifying some_owner increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree.
Returns
The smallest rank that has gtree as a local tree.

◆ t8_offset_first_tree_to_entry()

t8_gloidx_t t8_offset_first_tree_to_entry ( t8_gloidx_t  first_tree,
int  shared 
)

Given the global tree id of the first local tree of a process and the flag whether it is shared or not, compute the entry in the offset array.

This entry is the first_tree if it is not shared and -first_tree - 1 if it is shared.

Parameters
[in]first_treeThe global tree id of a process's first tree.
[in]shared0 if first_tree is not shared with a smaller rank, 1 if it is.
Returns
The entry that represents the process in an offset array. first_tree if shared == 0
  • first_tree - 1 if shared != 0

◆ t8_offset_in_range()

int t8_offset_in_range ( t8_gloidx_t  tree_id,
int  proc,
const t8_gloidx_t offset 
)

Determine whether a given global tree id is a local tree of a given process in a certain partition.

Parameters
[in]tree_idA global tree id.
[in]procA mpi rank.
[in]offsetA partition table.
Returns
nonzero if tree_id is a local tree of proc in offset. 0 if it is not.

◆ t8_offset_last()

t8_gloidx_t t8_offset_last ( int  proc,
const t8_gloidx_t offset 
)

Return the last local tree of a given process in a partition.

Parameters
[in]procA mpi rank.
[in]offsetA partition table.
Returns
The global tree id of the last local tree of proc in offset.

◆ t8_offset_last_owner_of_tree()

int t8_offset_last_owner_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset,
int *  some_owner 
)

Find the biggest process that has a given tree as local tree.

To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global id of a tree.
[in]offsetThe partition to be considered.
[in,out]some_ownerIf >= 0 considered as input: a process that has gtree as local tree. If < 0 on output a process that has gtree as local tree. Specifying some_owner increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree.
Returns
The biggest rank that has gtree as a local tree.

◆ t8_offset_next_nonempty_rank()

int t8_offset_next_nonempty_rank ( int  rank,
int  mpisize,
const t8_gloidx_t offset 
)

Find the next higher rank that is not empty.

returns mpisize if this rank does not exist.

Parameters
[in]procAn MPI rank.
[in]mpisizeThe number of total MPI ranks.
[in]offsetAn array with at least mpisize + 1 entries.
Returns
A rank p such that p > rank and t8_offset_empty (p, offset) is True and t8_offset_empty (q, offset) is False for all rank < q < p. If no such q exists, mpisize is returned.

◆ t8_offset_next_owner_of_tree()

int t8_offset_next_owner_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset,
int  current_owner 
)

Given a process current_owner that has the tree gtree as local tree, find the next bigger rank that also has this tree as local tree.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global id of a tree.
[in]offsetThe partition to be considered.
[in]current_ownerA process that has gtree as local tree.
Returns
The MPI rank of the next bigger rank than current_owner that has gtree as local tree. -1 if non such rank exists.

◆ t8_offset_nosend()

int t8_offset_nosend ( int  proc,
int  mpisize,
const t8_gloidx_t offset_from,
const t8_gloidx_t offset_to 
)

Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself)

Parameters
[in]procA mpi rank.
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]offset_fromThe partition table of the current partition.
[in]offset_toThe partition table of the next partition.
Returns
nonzero if proc will not send any local trees if we repartition from offset_from to offset_to 0 if it does send local trees.

◆ t8_offset_num_trees()

t8_gloidx_t t8_offset_num_trees ( int  proc,
const t8_gloidx_t offset 
)

The number of trees of a given process in a partition.

Parameters
[in]procA mpi rank.
[in]offsetA partition table.
Returns
The number of local trees of proc in the partition offset.

◆ t8_offset_prev_owner_of_tree()

int t8_offset_prev_owner_of_tree ( int  mpisize,
t8_gloidx_t  gtree,
const t8_gloidx_t offset,
int  current_owner 
)

Given a process current_owner that has the tree gtree as local tree, find the next smaller rank that also has this tree as local tree.

Parameters
[in]mpisizeThe number of MPI ranks, also the number of entries in offset minus 1.
[in]gtreeThe global id of a tree.
[in]offsetThe partition to be considered.
[in]current_ownerA process that has gtree as local tree.
Returns
The MPI rank of the next smaller rank than current_owner that has gtree as local tree. -1 if non such rank exists.

◆ t8_offset_print()

void t8_offset_print ( t8_shmem_array_t  offset,
sc_MPI_Comm  comm 
)

Print an offset array.

Useful for debugging.

Parameters
[in]offsetThe offset to print
[in]commAn mpi communicator matching the offset size.

◆ t8_offset_range_send()

int t8_offset_range_send ( int  start,
int  end,
int  mpirank,
const t8_gloidx_t offset_from,
const t8_gloidx_t offset_to 
)

Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting.

Parameters
[in]startThe first mpi rank to be considered as sender.
[in]endThe last mpi rank to be considered as sender.
[in]mpirankThe mpirank to be considered as receiver.
[in]offset_fromThe partition table of the current partition.
[in]offset_toThe partition table of the next partition.
Returns
The number of processes p, such that start <= p <= end and p does send local trees (and possibly ghosts) to mpirank.

◆ t8_offset_sendsto()

int t8_offset_sendsto ( int  proca,
int  procb,
const t8_gloidx_t t8_offset_from,
const t8_gloidx_t t8_offset_to 
)

Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process.

Parameters
[in]procaMpi rank of the possible sending process.
[in]procbMpi rank of the possible receiver.
[in]offset_fromThe partition table of the current partition.
[in]offset_toThe partition table of the next partition.
Returns
nonzero if proca does send local trees to procb when we repartition from offset_from to offset_to. 0 else.

◆ t8_offset_sendstree()

int t8_offset_sendstree ( int  proc_send,
int  proc_to,
t8_gloidx_t  gtree,
const t8_gloidx_t offset_from,
const t8_gloidx_t offset_to 
)

Query whether in a repartitioning setting, a given process sends a given tree to a second process.

Parameters
[in]proc_sendMpi rank of the possible sending process.
[in]proc_recvMpi rank of the possible receiver.
[in]gtreeA global tree id.
[in]offset_fromThe partition table of the current partition.
[in]offset_toThe partition table of the next partition.
Returns
nonzero if proc_send will send the tree gtree to proc_recv. 0 else. When calling, gtree must not be a local tree of proc_send in offset_from. In this case, 0 is always returned.