Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/p4est.c
Original file line number Diff line number Diff line change
Expand Up @@ -4265,3 +4265,15 @@ p4est_source_ext (sc_io_source_t * src, sc_MPI_Comm mpicomm, size_t data_size,

return p4est;
}

/* definitions for inline functions */
p4est_tree_t *p4est_tree_array_index (sc_array_t * array,
p4est_topidx_t it);
p4est_quadrant_t *p4est_quadrant_array_index (sc_array_t * array,
size_t it);
p4est_quadrant_t *p4est_quadrant_array_push_copy (sc_array_t * array,
const p4est_quadrant_t *
qsrc);
p4est_quadrant_t *p4est_quadrant_array_push (sc_array_t * array);
p4est_quadrant_t *p4est_quadrant_mempool_alloc (sc_mempool_t * mempool);
p4est_quadrant_t *p4est_quadrant_list_pop (sc_list_t * list);
21 changes: 9 additions & 12 deletions src/p4est.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ p4est_t *p4est_load (const char *filename, sc_MPI_Comm mpicomm,
p4est_connectivity_t ** connectivity);

/** Return a pointer to an array element indexed by a p4est_topidx_t.
* \param [in] index needs to be in [0]..[elem_count-1].
* \param [in] it needs to be in [0]..[elem_count-1].
* \param [in] array Valid array, commonly the trees array of a
* p4est.
*/
/*@unused@*/
static inline p4est_tree_t *
inline p4est_tree_t *
p4est_tree_array_index (sc_array_t * array, p4est_topidx_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_tree_t));
Expand All @@ -487,8 +488,7 @@ p4est_tree_array_index (sc_array_t * array, p4est_topidx_t it)
}

/** Return a pointer to a quadrant array element indexed by a size_t. */
/*@unused@*/
static inline p4est_quadrant_t *
inline p4est_quadrant_t *
p4est_quadrant_array_index (sc_array_t * array, size_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_quadrant_t));
Expand All @@ -505,7 +505,7 @@ p4est_quadrant_array_index (sc_array_t * array, size_t it)
* This serves to make the function clean for valgrind.
* \return Newly allocated quadrant with contents of \a qsrc.
*/
static inline p4est_quadrant_t *
inline p4est_quadrant_t *
p4est_quadrant_array_push_copy (sc_array_t * array,
const p4est_quadrant_t *qsrc)
{
Expand All @@ -524,8 +524,7 @@ p4est_quadrant_array_push_copy (sc_array_t * array,
* In this case, we're writing to all bits of it.
* This serves to make the quadrant clean for valgrind.
*/
/*@unused@*/
static inline p4est_quadrant_t *
inline p4est_quadrant_t *
p4est_quadrant_array_push (sc_array_t * array)
{
p4est_quadrant_t *q;
Expand All @@ -538,8 +537,7 @@ p4est_quadrant_array_push (sc_array_t * array)
}

/** Call sc_mempool_alloc for a mempool creating quadrants. */
/*@unused@*/
static inline p4est_quadrant_t *
inline p4est_quadrant_t *
p4est_quadrant_mempool_alloc (sc_mempool_t * mempool)
{
P4EST_ASSERT (mempool->elem_size == sizeof (p4est_quadrant_t));
Expand All @@ -548,8 +546,7 @@ p4est_quadrant_mempool_alloc (sc_mempool_t * mempool)
}

/** Call sc_list pop for a quadrant array. */
/*@unused@*/
static inline p4est_quadrant_t *
inline p4est_quadrant_t *
p4est_quadrant_list_pop (sc_list_t * list)
{
return (p4est_quadrant_t *) sc_list_pop (list);
Expand Down
13 changes: 13 additions & 0 deletions src/p4est_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,16 @@ p4est_version_minor (void)
/* In rare cases SC_VERSION_MAJOR may be a non-numerical string */
return sc_atoi (SC_TOSTRING (P4EST_VERSION_MINOR));
}

/* definitions for inline functions */
void p4est_log_indent_push (void);
void p4est_log_indent_pop (void);
unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt);
unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt);
unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt);
int p4est_topidx_is_sorted (p4est_topidx_t * t, int length);
void p4est_topidx_bsort (p4est_topidx_t * t, int length);
uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p,
int num_procs);
p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num,
int p, int num_procs);
55 changes: 38 additions & 17 deletions src/p4est_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,15 @@ void P4EST_LERRORF (const char *fmt, ...)
*/
extern SC_DLL_PUBLIC int p4est_package_id;

static inline void
/** Add one space to the start of p4est's default log format. */
inline void
p4est_log_indent_push (void)
{
sc_log_indent_push_count (p4est_package_id, 1);
}

static inline void
/** Remove one space from the start of p4est's default log format. */
inline void
p4est_log_indent_pop (void)
{
sc_log_indent_pop_count (p4est_package_id, 1);
Expand Down Expand Up @@ -377,8 +379,7 @@ int p4est_get_package_id (void);
* \param [in] tt Array of (at least) two values.
* \return An unsigned hash value.
*/
/*@unused@*/
static inline unsigned
inline unsigned
p4est_topidx_hash2 (const p4est_topidx_t * tt)
{
uint32_t a, b, c;
Expand All @@ -403,8 +404,7 @@ p4est_topidx_hash2 (const p4est_topidx_t * tt)
* \param [in] tt Array of (at least) three values.
* \return An unsigned hash value.
*/
/*@unused@*/
static inline unsigned
inline unsigned
p4est_topidx_hash3 (const p4est_topidx_t * tt)
{
uint32_t a, b, c;
Expand All @@ -431,8 +431,7 @@ p4est_topidx_hash3 (const p4est_topidx_t * tt)
* \param [in] tt Array of (at least) four values.
* \return An unsigned hash value.
*/
/*@unused@*/
static inline unsigned
inline unsigned
p4est_topidx_hash4 (const p4est_topidx_t * tt)
{
uint32_t a, b, c;
Expand Down Expand Up @@ -460,8 +459,11 @@ p4est_topidx_hash4 (const p4est_topidx_t * tt)
return (unsigned) c;
}

/*@unused@*/
static inline int
/** Check if an array of p4est_topidx_t is sorted from lowest to highest.
* \param [in] t Array of p4est_topidx_t.
* \param [in] length The length of array \a t.
* \return True, iff the array is correctly sorted. */
inline int
p4est_topidx_is_sorted (p4est_topidx_t * t, int length)
{
int i;
Expand All @@ -474,9 +476,11 @@ p4est_topidx_is_sorted (p4est_topidx_t * t, int length)
return 1;
}

/*@unused@*/
static inline void
p4est_topidx_bsort (p4est_topidx_t * t, int length)
/** Sort an array of p4est_topidx_t from lowest to highest using bubble sort.
* \param [in] t Array of p4est_topidx_t.
* \param [in] length The length of array \a t. */
inline void
p4est_topidx_bsort (p4est_topidx_t *t, int length)
{
int i, j;
p4est_topidx_t tswap;
Expand All @@ -495,8 +499,16 @@ p4est_topidx_bsort (p4est_topidx_t * t, int length)
P4EST_ASSERT (p4est_topidx_is_sorted (t, length));
}

/*@unused@*/
static inline uint64_t
/** For a uint64_t global number of elements return the offset of rank p in
* their uniform partition.
* \param [in] global_num The global number of elements to partition.
* \param [in] p The rank in [0, \a num_procs] for which we compute the
* offset.
* \param [in] num_procs The total number of processes.
* \return The index of the first element local to rank \a p in
* in the uniform partition of the range
* [0, \a global_num - 1]. */
inline uint64_t
p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs)
{
uint64_t result;
Expand All @@ -522,8 +534,17 @@ p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs)
return result;
}

/*@unused@*/
static inline p4est_gloidx_t
/** For a p4est_gloidxs_t global number of elements return the offset of rank p
* in their uniform partition.
* \param [in] global_num The global number of elements to partition.
* \param [in] p The rank in [0, \a num_procs] for which we compute the
* offset.
* \param [in] num_procs The total number of processes.
* \return The index of the first element local to rank \a p in
* in the uniform partition of the range
* [0, \a global_num - 1]. */

inline p4est_gloidx_t
p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs)
{
p4est_gloidx_t result;
Expand Down
4 changes: 4 additions & 0 deletions src/p4est_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -5945,3 +5945,7 @@ p4est_connectivity_coordinates_canonicalize (p4est_connectivity_t *conn,
P4EST_ASSERT (*treeid_out < treeid ||
p4est_coordinates_compare (coords_out, coords) <= 0);
}

/* definitions for inline functions */
p4est_corner_transform_t *p4est_corner_array_index (sc_array_t * array,
size_t it);
3 changes: 1 addition & 2 deletions src/p4est_connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,7 @@ int p4est_connectivity_is_equivalent (p4est_connectivity_t *
conn2);

/** Return a pointer to a p4est_corner_transform_t array element. */
/*@unused@*/
static inline p4est_corner_transform_t *
inline p4est_corner_transform_t *
p4est_corner_array_index (sc_array_t * array, size_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_corner_transform_t));
Expand Down
10 changes: 10 additions & 0 deletions src/p4est_iterate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3326,3 +3326,13 @@ p4est_iterate (p4est_t * p4est, p4est_ghost_t * Ghost_layer, void *user_data,
#endif
iter_corner, 0);
}

/* definitions for inline functions */
p4est_iter_corner_side_t *p4est_iter_cside_array_index_int (sc_array_t *
array, int it);
p4est_iter_corner_side_t *p4est_iter_cside_array_index (sc_array_t * array,
size_t it);
p4est_iter_face_side_t *p4est_iter_fside_array_index_int (sc_array_t * array,
int it);
p4est_iter_face_side_t *p4est_iter_fside_array_index (sc_array_t * array,
size_t it);
12 changes: 4 additions & 8 deletions src/p4est_iterate.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ void p4est_iterate (p4est_t * p4est,

/** Return a pointer to a iter_corner_side array element indexed by a int.
*/
/*@unused@*/
static inline p4est_iter_corner_side_t *
inline p4est_iter_corner_side_t *
p4est_iter_cside_array_index_int (sc_array_t * array, int it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
Expand All @@ -259,8 +258,7 @@ p4est_iter_cside_array_index_int (sc_array_t * array, int it)

/** Return a pointer to a iter_corner_side array element indexed by a size_t.
*/
/*@unused@*/
static inline p4est_iter_corner_side_t *
inline p4est_iter_corner_side_t *
p4est_iter_cside_array_index (sc_array_t * array, size_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
Expand All @@ -272,8 +270,7 @@ p4est_iter_cside_array_index (sc_array_t * array, size_t it)

/** Return a pointer to a iter_face_side array element indexed by a int.
*/
/*@unused@*/
static inline p4est_iter_face_side_t *
inline p4est_iter_face_side_t *
p4est_iter_fside_array_index_int (sc_array_t * array, int it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));
Expand All @@ -285,8 +282,7 @@ p4est_iter_fside_array_index_int (sc_array_t * array, int it)

/** Return a pointer to a iter_face_side array element indexed by a size_t.
*/
/*@unused@*/
static inline p4est_iter_face_side_t *
inline p4est_iter_face_side_t *
p4est_iter_fside_array_index (sc_array_t * array, size_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));
Expand Down
16 changes: 16 additions & 0 deletions src/p4est_lnodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3719,3 +3719,19 @@ p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t * buffer)
}
P4EST_FREE (buffer);
}

/* definitions for inline functions */
#ifndef P4_TO_P8
int p4est_lnodes_decode (p4est_lnodes_code_t face_code,
int hanging_face[4]);
#else
int p8est_lnodes_decode (p8est_lnodes_code_t face_code,
int hanging_face[6],
int hanging_edge[12]);
#endif
p4est_lnodes_rank_t *p4est_lnodes_rank_array_index_int (sc_array_t * array,
int it);
p4est_lnodes_rank_t *p4est_lnodes_rank_array_index (sc_array_t * array,
size_t it);
p4est_gloidx_t p4est_lnodes_global_index (p4est_lnodes_t * lnodes,
p4est_locidx_t lidx);
35 changes: 21 additions & 14 deletions src/p4est_lnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ p4est_lnodes_rank_t;
* note: not touched if there are no hanging faces.
* \return true if any face is hanging, false otherwise.
*/
static inline int
inline int
p4est_lnodes_decode (p4est_lnodes_code_t face_code, int hanging_face[4])
{
P4EST_ASSERT (face_code >= 0);
Expand Down Expand Up @@ -335,12 +335,16 @@ p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
p4est_lnodes_t *
lnodes);

/** p4est_lnodes_shared_owned_end
*
* Complete sharing of the owned node data between processes as initiated in
* \ref p4est_lnodes_share_owned_begin. */
void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
buffer);

/** Equivalent to calling p4est_lnodes_share_owned_end directly after
* p4est_lnodes_share_owned_begin. Use if there is no local work that can be
* done to mask the communication cost.
/** Equivalent to calling \ref p4est_lnodes_share_owned_end directly after
* \ref p4est_lnodes_share_owned_begin. Use if there is no local work that can
* be done to mask the communication cost.
*/
void p4est_lnodes_share_owned (sc_array_t * node_data,
p4est_lnodes_t * lnodes);
Expand All @@ -354,7 +358,7 @@ void p4est_lnodes_share_owned (sc_array_t * node_data,
* \a buffer->recv_buffers entry as described above. The user can then perform
* some arbitrary work that requires the data from all processes that share a
* node (such as reduce, max, min, etc.). When the work concludes, the
* \a buffer should be destroyed with p4est_lnodes_buffer_destroy.
* \a buffer should be destroyed with \ref p4est_lnodes_buffer_destroy.
*
* Values of \a node_data are not guaranteed to be sent, and
* \a buffer->recv_buffer entries are not guaranteed to be received until
Expand All @@ -364,26 +368,31 @@ void p4est_lnodes_share_owned (sc_array_t * node_data,
p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
p4est_lnodes_t * lnodes);

/** p4est_lnodes_shared_all_end
*
* Complete sharing of the node data between all relevant processes as initiated
* in \ref p4est_lnodes_share_all_begin. */
void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
buffer);

/** Equivalent to calling p4est_lnodes_share_all_end directly after
* p4est_lnodes_share_all_begin. Use if there is no local work that can be
/** Equivalent to calling \ref p4est_lnodes_share_all_end directly after
* \ref p4est_lnodes_share_all_begin. Use if there is no local work that can be
* done to mask the communication cost.
* \return A fully initialized buffer that contains the received data.
* After processing this data, the buffer must be freed with
* p4est_lnodes_buffer_destroy.
* \ref p4est_lnodes_buffer_destroy.
*/
p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
p4est_lnodes_t * lnodes);

/** Destroy the buffer filled with node data during a call to
* \ref p4est_lnodes_share_all_end or \ref p4est_lnodes_share_all.*/
void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
buffer);

/** Return a pointer to a lnodes_rank array element indexed by a int.
*/
/*@unused@*/
static inline p4est_lnodes_rank_t *
inline p4est_lnodes_rank_t *
p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
Expand All @@ -395,8 +404,7 @@ p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)

/** Return a pointer to a lnodes_rank array element indexed by a size_t.
*/
/*@unused@*/
static inline p4est_lnodes_rank_t *
inline p4est_lnodes_rank_t *
p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
{
P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
Expand All @@ -407,8 +415,7 @@ p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
}

/** Compute the global number of a local node number */
/*@unused@*/
static inline p4est_gloidx_t
inline p4est_gloidx_t
p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
{
p4est_locidx_t owned = lnodes->owned_count;
Expand Down
Loading
Loading