DistDir
backend.h
Go to the documentation of this file.
1 /*
2  * @file backend.h
3  *
4  * @copyright Copyright (C) 2024 Enrico Degregori <enrico.degregori@gmail.com>
5  *
6  * @author Enrico Degregori <enrico.degregori@gmail.com>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10 
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13 
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17 
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include "mpi.h"
35 
36 typedef void (*sort_fn) (int *, int, int);
37 typedef void (*sort_with_idx_fn) (int *, int *, int, int);
38 typedef void (*sort_with_idx2_fn) (int *, int *, int *, int, int);
39 
50 
61 
72 
88 void assign_idxlist_elements_to_buckets( int *bucket_idxlist,
89  const int *idxlist ,
90  int bucket_min_size,
91  int idxlist_size ,
92  int nbuckets );
93 
112 void assign_idxlist_elements_to_buckets2( int *bucket_idxlist,
113  const int *idxlist ,
114  int bucket_min_size,
115  int idxlist_size ,
116  int nbuckets ,
117  int bucket_stride );
118 
134 int num_procs_send_to_each_bucket(const int *bucket_idxlist,
135  int nbuckets ,
136  int idxlist_size ,
137  MPI_Comm comm );
138 
152 void num_indices_to_send_to_each_bucket( int *n_idx_each_bucket,
153  const int *bucket_idxlist ,
154  int idxlist_size ,
155  int nbuckets );
156 
176  const int *n_idx_each_bucket ,
177  int n_procs_sending_to_bucket,
178  int bucket_max_size ,
179  int idxlist_size ,
180  MPI_Comm comm ,
181  sort_fn sort );
182 
200 void num_indices_to_bucket_from_each_rank( int *bucket_msg_size_senders ,
201  const int *n_idx_each_bucket ,
202  const int *senders_to_bucket ,
203  int n_procs_sending_to_bucket,
204  int bucket_max_size ,
205  int idxlist_size ,
206  MPI_Comm comm );
207 
226 void bucket_idxlist_procs( int *bucket_ranks ,
227  const int *n_idx_each_bucket ,
228  const int *bucket_msg_size_senders ,
229  const int *senders_to_bucket ,
230  int n_procs_sending_to_bucket,
231  int bucket_max_size ,
232  int idxlist_size ,
233  MPI_Comm comm );
234 
255 void bucket_idxlist_elements( int *bucket_indices ,
256  const int *original_idxlist_sorted ,
257  const int *n_idx_each_bucket ,
258  const int *bucket_msg_size_senders ,
259  const int *senders_to_bucket ,
260  int n_procs_sending_to_bucket,
261  int bucket_max_size ,
262  int idxlist_size ,
263  MPI_Comm comm );
264 
void(* sort_with_idx2_fn)(int *, int *, int *, int, int)
Definition: backend.h:38
void(* sort_with_idx_fn)(int *, int *, int, int)
Definition: backend.h:37
void(* sort_fn)(int *, int, int)
Definition: backend.h:36
sort_fn get_sort_function()
Return sorting function.
void assign_idxlist_elements_to_buckets2(int *bucket_idxlist, const int *idxlist, int bucket_min_size, int idxlist_size, int nbuckets, int bucket_stride)
Assign each element of a given index list to a bucket.
void assign_idxlist_elements_to_buckets(int *bucket_idxlist, const int *idxlist, int bucket_min_size, int idxlist_size, int nbuckets)
Assign each element of a given index list to a bucket.
sort_with_idx_fn get_sort_with_idx_function()
Return sorting function with associated indices.
void bucket_idxlist_procs(int *bucket_ranks, const int *n_idx_each_bucket, const int *bucket_msg_size_senders, const int *senders_to_bucket, int n_procs_sending_to_bucket, int bucket_max_size, int idxlist_size, MPI_Comm comm)
Each bucket receives an array of size n_procs_sending_to_bucket with the MPI processes owning the ind...
void bucket_idxlist_elements(int *bucket_indices, const int *original_idxlist_sorted, const int *n_idx_each_bucket, const int *bucket_msg_size_senders, const int *senders_to_bucket, int n_procs_sending_to_bucket, int bucket_max_size, int idxlist_size, MPI_Comm comm)
Each bucket receives an array of size n_procs_sending_to_bucket with the indices of the original deco...
sort_with_idx2_fn get_sort_with_idx2_function()
Return sorting function with two associated indices.
void num_indices_to_bucket_from_each_rank(int *bucket_msg_size_senders, const int *n_idx_each_bucket, const int *senders_to_bucket, int n_procs_sending_to_bucket, int bucket_max_size, int idxlist_size, MPI_Comm comm)
Each bucket receives an array of size n_procs_sending_to_bucket with the number of indices that each ...
void num_indices_to_send_to_each_bucket(int *n_idx_each_bucket, const int *bucket_idxlist, int idxlist_size, int nbuckets)
Each process compute the number of indices to send to each bucket.
void senders_to_bucket(int *senders_to_bucket, const int *n_idx_each_bucket, int n_procs_sending_to_bucket, int bucket_max_size, int idxlist_size, MPI_Comm comm, sort_fn sort)
Each bucket receives an array of size n_procs_sending_to_bucket with the rank ID which send indices t...
int num_procs_send_to_each_bucket(const int *bucket_idxlist, int nbuckets, int idxlist_size, MPI_Comm comm)
Return the number of processes that send information to this bucket.
#define nbuckets
Definition: num_indices_to_send_to_each_bucket_tests.c:42
#define idxlist_size
Definition: num_indices_to_send_to_each_bucket_tests.c:43