Skip to content

Commit

Permalink
p4est_communication: white space
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Jul 11, 2024
1 parent f12d735 commit e4ab65c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 82 deletions.
72 changes: 36 additions & 36 deletions src/p4est_communication.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ p4est_transfer_items_end (p4est_transfer_context_t * tc)
typedef struct p4est_transfer_meta
{
/* in the following p refers to the local rank, and q any rank */

/* data used for sending */
/* number of points that p receives in this iteration */
size_t num_incoming;
Expand Down Expand Up @@ -1516,8 +1516,8 @@ init_transfer_meta (p4est_transfer_meta_t *meta)
meta->offsets = NULL;
}

static void
destroy_transfer_meta (p4est_transfer_meta_t *meta, int num_procs)
static void
destroy_transfer_meta (p4est_transfer_meta_t *meta, int num_procs)
{
/* destroy send data */
if (meta->receivers != NULL) {
Expand Down Expand Up @@ -1546,11 +1546,11 @@ destroy_transfer_meta (p4est_transfer_meta_t *meta, int num_procs)
}

/** Internal context for \ref p4est_transfer_search.
*
*
* Allows us to access the following variables in the point callback during
* \ref p4est_search_partition.
*/
typedef struct p4est_transfer_internal
typedef struct p4est_transfer_internal
{
/* point-quadrant intersection function */
p4est_intersect_t intersect;
Expand Down Expand Up @@ -1585,7 +1585,7 @@ p4est_transfer_internal_t;

/** Push point \a pi into the send buffer for \a receiver */
static void
push_to_send_buffer (p4est_transfer_meta_t *meta,
push_to_send_buffer (p4est_transfer_meta_t *meta,
p4est_transfer_search_t *c,
p4est_locidx_t pi, int receiver)
{
Expand All @@ -1602,8 +1602,8 @@ push_to_send_buffer (p4est_transfer_meta_t *meta,
point_size);
}

/** Point callback for \ref p4est_search_partition in compute_send_buffers
*
/** Point callback for \ref p4est_search_partition in compute_send_buffers
*
* \param[in,out] p4est We only use the user pointer which points to our
* internal context. This may be a fake p4est.
* \param[in] which_tree The tree containing the quadrant
Expand All @@ -1619,7 +1619,7 @@ static int
transfer_search_point (p4est_t *p4est, p4est_topidx_t which_tree,
p4est_quadrant_t *quadrant, int pfirst, int plast,
void *point_index)
{
{
int intersection_found;

/* context */
Expand Down Expand Up @@ -1668,7 +1668,7 @@ transfer_search_point (p4est_t *p4est, p4est_topidx_t which_tree,
return 0;
}

/* get last process whose domain we have already recorded as intersecting
/* get last process whose domain we have already recorded as intersecting
* this point
*/
last_proc = internal->last_procs[pi];
Expand Down Expand Up @@ -1703,7 +1703,7 @@ transfer_search_point (p4est_t *p4est, p4est_topidx_t which_tree,
}

/** Prepare outgoing buffers of points to propagate.
*
*
* \param[in, out] p4est_transfer_internal Internal context
* \param[in] num_procs number of MPI processes
*/
Expand Down Expand Up @@ -1757,7 +1757,7 @@ compute_send_buffers (p4est_transfer_internal_t *internal,
else {
/* We are running p4est_transfer_search_gfp */
/* Run search to add points to buffers */
p4est_search_partition_gfp (internal->gfp, internal->nmemb,
p4est_search_partition_gfp (internal->gfp, internal->nmemb,
internal->num_trees, 0, internal, NULL,
transfer_search_point, search_objects);
}
Expand All @@ -1777,23 +1777,23 @@ compute_send_buffers (p4est_transfer_internal_t *internal,
}

/** Update communication metadata with which processes p is sending points to
* and how many points are being sent to each of these.
*
* and how many points are being sent to each of these.
*
* The output is stored in the fields meta->receivers and meta->recvs_counts.
* We assume comm->send_buffers is already populated.
*
*
* \param[in,out] meta communication metadata
* \param[in] point_size byte size of points
* \param[in] num_procs number of mpi processes
* \param[in] rank rank of the local process
* \return 0 if no error occured. 1 if a message being sent is too large
*/
static int
compute_receivers (p4est_transfer_meta_t *meta,
compute_receivers (p4est_transfer_meta_t *meta,
size_t point_size, int num_procs, int rank)
{
int err = 0;

/* initialize receivers and receiver counts */
meta->receivers = sc_array_new (sizeof (int));
meta->recvs_counts = sc_array_new (sizeof (size_t));
Expand Down Expand Up @@ -1825,10 +1825,10 @@ compute_receivers (p4est_transfer_meta_t *meta,
}

/** Post non-blocking sends for points in the given communication data.
*
* To each rank q in meta->receivers we send the points stored at
*
* To each rank q in meta->receivers we send the points stored at
* meta->send_buffers[q]
*
*
* \param[in] meta communication data
* \param[in] mpicomm MPI communicator
* \param[out] req request storage of same length as comm->receivers
Expand Down Expand Up @@ -1864,13 +1864,13 @@ post_sends (p4est_transfer_meta_t *meta,
}
}

/** Update communication metadata with total number of incoming points, and
* offsets to receive incoming points at.
*
/** Update communication metadata with total number of incoming points, and
* offsets to receive incoming points at.
*
* The outputs are stored in the fields meta->num_incoming and meta->offsets.
* We assume that meta->senders and meta->senders_counts are already
* populated.
*
*
* \param[in,out] meta communication metadata.
*/
static void
Expand All @@ -1890,12 +1890,12 @@ compute_offsets_and_num_incoming (p4est_transfer_meta_t *meta, size_t point_size
/** Post non-blocking receives for senders in the given communication data.
* If there is a message for ourself then we copy it manually here rather
* than receiving it through MPI.
*
*
* We expect to receive points from each sender in meta->senders. The number
* of points each sender is sending is stored in meta->senders_counts (with
* corresponding indexing). We receive each message at the offset stored in
* meta->offsets (again with corresponding indexing).
*
*
* \param[in] meta communication data
* \param[in,out] recv_buffer points to array where received points are stored
* \param[out] req request storage of same length as meta->senders
Expand Down Expand Up @@ -1946,9 +1946,9 @@ post_receives (p4est_transfer_meta_t * meta,
}
}

/** Central execution pathway for p4est_transfer_search,
/** Central execution pathway for p4est_transfer_search,
* p4est_transfer_search_gfx and p4est_transfer_search_gfp.
*
*
* \param[in] p4est Value of NULL indicates we are running gfx or gfp.
* \param[in] gfq Value of NULL indicates we are running gfp.
* \param[in] nmemb Number of processors encoded in \a gfp (plus one).
Expand All @@ -1958,7 +1958,7 @@ static int
p4est_transfer_search_internal (p4est_transfer_internal_t *internal);

int
p4est_transfer_search (p4est_t *p4est, p4est_transfer_search_t *c,
p4est_transfer_search (p4est_t *p4est, p4est_transfer_search_t *c,
p4est_intersect_t intersect, int save_unowned)
{
int err;
Expand Down Expand Up @@ -1997,7 +1997,7 @@ p4est_transfer_search (p4est_t *p4est, p4est_transfer_search_t *c,
return err;
}

int
int
p4est_transfer_search_gfx (const p4est_gloidx_t *gfq,
const p4est_quadrant_t *gfp,
int nmemb, p4est_topidx_t num_trees,
Expand Down Expand Up @@ -2070,7 +2070,7 @@ p4est_transfer_search_gfp (const p4est_quadrant_t *gfp, int nmemb,
return p4est_transfer_search_internal (&internal);
}

int
int
p4est_transfer_search_internal (p4est_transfer_internal_t *internal)
{
int mpiret;
Expand Down Expand Up @@ -2105,13 +2105,13 @@ p4est_transfer_search_internal (p4est_transfer_internal_t *internal)
SC_CHECK_MPI (mpiret);
mpiret = sc_MPI_Comm_size (mpicomm, &num_procs);
SC_CHECK_MPI (mpiret);

/* use search_partition to put points in appropriate send buffers */
compute_send_buffers (internal, num_procs, rank);

/* record which processes p is sending points to and how many points each
process receives */
/* note: an error is recorded here if p is attempting to send more than
/* note: an error is recorded here if p is attempting to send more than
INT_MAX bytes in an own or resp message to another process. We defer
synchronising these errors until just before calling sc_notify_ext
to avoid creating an unnecessary synchronisation point */
Expand Down Expand Up @@ -2181,7 +2181,7 @@ p4est_transfer_search_internal (p4est_transfer_internal_t *internal)
"P4EST_LOCIDX_MAX\n",
rank, (long long) num_incoming);
}

/* synchronise possible error of a process receiving too many points */
mpiret =
sc_MPI_Allreduce (&errsend, &err, 1, sc_MPI_INT, sc_MPI_LOR, mpicomm);
Expand Down Expand Up @@ -2217,7 +2217,7 @@ p4est_transfer_search_internal (p4est_transfer_internal_t *internal)
post_receives (&resp, c->points->array, recv_req, mpicomm, point_size);
post_receives (&own,
c->points->array + resp.num_incoming * point_size,
recv_req + resp.senders->elem_count,
recv_req + resp.senders->elem_count,
mpicomm,
point_size);

Expand All @@ -2239,4 +2239,4 @@ p4est_transfer_search_internal (p4est_transfer_internal_t *internal)

/* return success */
return 0;
}
}
45 changes: 23 additions & 22 deletions src/p4est_communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void p4est_transfer_end (p4est_transfer_context_t * tc);

/** Callback function for \ref p4est_transfer_search, as well as its variants
* \ref p4est_transfer_search_gfx and \ref p4est_transfer_search_gfp.
*
*
* \param[in] p4est In the versions of transfer search not requiring an
* explicit p4est this is a dummy p4est where only the user
* pointer is initialized.
Expand All @@ -603,14 +603,14 @@ typedef int (*p4est_intersect_t) (p4est_t *p4est,
* are exactly the points which intersect its domain. Points are completely
* arbitrary and may for example represent geometric objects such as polyhedra
* or geodesics.
*
*
* The \a points array is subdivided into two sub-arrays. The first sub-array,
* consisting of the first \a num_resp consecutive elements, contains the
* points that this process is responsible for propagating during
* \ref p4est_transfer_search. The second sub-array, consisting of the
* remaining elements, contains the points known to this process that it is
* not responsible for propagating.
*
*
* This structure is intended to be initialised on each process, storing a
* disjoint subset of the global set of points. Initially, \a num_resp
* should be set to the length of \a points so that each each process is
Expand All @@ -619,47 +619,48 @@ typedef int (*p4est_intersect_t) (p4est_t *p4est,
* propagating a point then the point will be forgotten after calling
* \ref p4est_transfer_search, and similarly that if multiple processes are
* responsible for propagating a point then it will be duplicated.
*
*
* Calling \ref p4est_transfer_search performs the transfer of points and
* updates \a num_resp, while preserving the property that each point has
* exactly one process responsible for propagating it.
*
*
* Users may modify the points array between calls to
* \ref p4est_transfer_search. For example, point coordinates could
* be modified to represent movement of points as a simulation evolves through
* time. Care should be taken when adding or deleting points, and when
* modifying the order of \a points, to ensure that \a num_resp is updated
* and that the first \a num_resp points are still the points that the
* process should propagate.
*
* process should propagate.
*
* During the transfer of points in \ref p4est_transfer_search the \a points
* array is destroyed and reallocated. Thus users should not maintain pointers
* to it or its contents.
*/
typedef struct p4est_transfer_search
typedef struct p4est_transfer_search
{
sc_array_t *points; /**< All points known to this process. */
p4est_locidx_t num_resp; /**< The number of points this process is
responsible for propagating when
\ref p4est_transfer_search is called.
These points are stored in the first
\a num_resp positions of \a points. */
} p4est_transfer_search_t;
}
p4est_transfer_search_t;

/** Collective, point-to-point transfer for maintaining distributed
* collection of points. After communication, points are stored (only) on the
* processes whose domains they intersect. A return value of 0 indicates
* success. An nonzero value is returned to indicate error. Errors occurs when
* the number of bytes transferred in any single message would exceed
* the number of bytes transferred in any single message would exceed
* INT_MAX (2GB on most machines), or if any process would receive more than
* P4EST_LOCIDX_MAX points in total. Error/success is collective. If an error
* does occur then the contents of \a c are not modified.
*
*
* Points can be instances of an arbitrary struct. Point-quadrant intersection
* is specified by the user supplied callback \a intersect. A single point may
* intersect multiple process domains, and after communication will be known
* to each of these processes.
*
*
* Each process is responsible for propagating a subset of the points it
* knows. Before communication, exactly one process should be responsible for
* propagating each point. The intersecting processes for each point are
Expand All @@ -673,13 +674,13 @@ typedef struct p4est_transfer_search
* intersect the domain of any process. If this option is enabled then these
* points are remembered by the process that was responsible for propagating
* them.
*
*
* The points that a process is responsible for propagating are stored in a
* subarray of the array of known points, as described in
* subarray of the array of known points, as described in
* \ref p4est_transfer_search_t. Users should take care to maintain this
* subdivision if they modify the array of points between rounds of
* communication.
*
*
* \param [in] p4est The forest we search with. Its user_pointer is
* passed to the intersection callback.
* \param [in,out] c Points and propagation responsibilities. The
Expand All @@ -692,15 +693,15 @@ typedef struct p4est_transfer_search
* \return 0 if transfer was successful.
*/
int
p4est_transfer_search (p4est_t *p4est, p4est_transfer_search_t *c,
p4est_transfer_search (p4est_t *p4est, p4est_transfer_search_t *c,
p4est_intersect_t intersect, int save_unowned);

/** The same as \ref p4est_transfer_search, except that we search with a
* partition, rather than an explicit p4est. The partition can be that of any
* p4est, not necessarily known to the caller.
*
*
* This function is collective.
*
*
* \param [in] gfq Partition offsets to traverse. Length \a nmemb + 1.
* \param [in] gfp Partition position to traverse. Length \a nmemb + 1.
* \param [in] nmemb Number of processors encoded in \a gfq (plus one).
Expand Down Expand Up @@ -729,19 +730,19 @@ p4est_transfer_search_gfx (const p4est_gloidx_t *gfq,
/** The same as \ref p4est_transfer_search, except that we search with a
* partition, rather than an explicit p4est. The partition can be that of any
* p4est, not necessarily known to the caller.
*
*
* This function is similar to \ref p4est_transfer_search_gfx, but does not
* require the \ref p4est_gloidx_t array gfq. If gfq is available, using
* \ref p4est_transfer_search_gfx is recommended, because it is slightly
* faster.
*
*
* This function is collective.
*
*
* \param [in] gfp Partition position to traverse. Length \a nmemb + 1.
* \param [in] nmemb Number of processors encoded in \a gfq (plus one).
* \param [in] num_trees Tree number must match the contents of \a gfq.
* \param [in] user_pointer Passed to the intersection callback.
* \param [in] sc_MPI_Comm Function is collective over the communicator.
* \param [in] mpicomm Function is collective over the communicator.
* \param [in,out] c Points and propagation responsibilities. The
* array \a c.points is destroyed and reallocated,
* so pointers to it should not be referenced after
Expand Down
Loading

0 comments on commit e4ab65c

Please sign in to comment.