My Project
programmer's documentation
|
#include "cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "cs_assert.h"
#include "cs_block_dist.h"
#include "cs_crystal_router.h"
#include "cs_log.h"
#include "cs_order.h"
#include "cs_timer.h"
#include "cs_all_to_all.h"
Functions | |
cs_all_to_all_t * | cs_all_to_all_create (size_t n_elts, int flags, const cs_lnum_t *dest_id, const int dest_rank[], MPI_Comm comm) |
Create an all-to-all distributor based on destination rank. More... | |
cs_all_to_all_t * | cs_all_to_all_create_from_block (size_t n_elts, int flags, const cs_gnum_t *src_gnum, cs_block_dist_info_t bi, MPI_Comm comm) |
Create an all-to-all distributor for elements whose destination rank is determined from global numbers and block distribution information. More... | |
void | cs_all_to_all_destroy (cs_all_to_all_t **d) |
Destroy an all-to-all distributor. More... | |
void | cs_all_to_all_transfer_dest_rank (cs_all_to_all_t *d, int **dest_rank) |
Transfer ownership of destination rank to an all-to-all distributor. More... | |
void | cs_all_to_all_transfer_dest_id (cs_all_to_all_t *d, cs_lnum_t **dest_id) |
Transfer ownership of destination ids to an all-to-all distributor. More... | |
cs_lnum_t | cs_all_to_all_n_elts_dest (cs_all_to_all_t *d) |
Get number of elements associated with all-to-all distributor. More... | |
void * | cs_all_to_all_copy_array (cs_all_to_all_t *d, cs_datatype_t datatype, int stride, bool reverse, const void *src_data, void *dest_data) |
Communicate array data using all-to-all distributor. More... | |
cs_lnum_t * | cs_all_to_all_copy_index (cs_all_to_all_t *d, bool reverse, const cs_lnum_t *src_index, cs_lnum_t *dest_index) |
Communicate local index using all-to-all distributor. More... | |
void * | cs_all_to_all_copy_indexed (cs_all_to_all_t *d, cs_datatype_t datatype, bool reverse, const cs_lnum_t *src_index, const void *src_data, const cs_lnum_t *dest_index, void *dest_data) |
Communicate local index using all-to-all distributor. More... | |
int * | cs_all_to_all_get_src_rank (cs_all_to_all_t *d) |
Get array of source element ranks associated with an all-to-all distributor. More... | |
cs_all_to_all_type_t | cs_all_to_all_get_type (void) |
Get current type of all-to-all distributor algorithm choice. More... | |
void | cs_all_to_all_set_type (cs_all_to_all_type_t t) |
Set current type of all-to-all distributor algorithm choice. More... | |
void | cs_all_to_all_log_finalize (void) |
Log performance information relative to instrumented all-to-all distribution. More... | |
All-to-all parallel data exchange.
void* cs_all_to_all_copy_array | ( | cs_all_to_all_t * | d, |
cs_datatype_t | datatype, | ||
int | stride, | ||
bool | reverse, | ||
const void * | src_data, | ||
void * | dest_data | ||
) |
Communicate array data using all-to-all distributor.
If a destination buffer is provided, it should be of sufficient size for the number of elements returned by cs_all_to_all_n_elts_dest (multiplied by stride and datatype size).
If no buffer is provided, one is allocated automatically, and transferred to the caller (who is responsible for freeing it when no longer needed).
If used in reverse mode, data is still communicated from src_data to dest_buffer or an internal buffer, but communication direction (i.e. source and destination ranks) are reversed.
This is obviously a collective operation, and all ranks must provide the same datatype, stride, and reverse values.
[in,out] | d | pointer to associated all-to-all distributor |
[in] | datatype | type of data considered |
[in] | stride | number of values per entity (interlaced), |
[in] | reverse | if true, communicate in reverse direction |
[in] | src_data | source data |
[out] | dest_data | pointer to destination data, or NULL |
cs_lnum_t* cs_all_to_all_copy_index | ( | cs_all_to_all_t * | d, |
bool | reverse, | ||
const cs_lnum_t * | src_index, | ||
cs_lnum_t * | dest_index | ||
) |
Communicate local index using all-to-all distributor.
If a destination buffer is provided, it should be of sufficient size for the number of elements returned by cs_all_to_all_n_elts_dest.
If no buffer is provided, one is allocated automatically, and transferred to the caller (who is responsible for freeing it when no longer needed).
If used in reverse mode, data is still communicated from src_index to dest_index or an internal buffer, but communication direction (i.e. source and destination ranks) are reversed.
This is obviously a collective operation, and all ranks must provide the same value for the reverse parameter.
[in,out] | d | pointer to associated all-to-all distributor |
[in] | reverse | if true, communicate in reverse direction |
[in] | src_index | source index |
[out] | dest_index | pointer to destination index, or NULL |
void* cs_all_to_all_copy_indexed | ( | cs_all_to_all_t * | d, |
cs_datatype_t | datatype, | ||
bool | reverse, | ||
const cs_lnum_t * | src_index, | ||
const void * | src_data, | ||
const cs_lnum_t * | dest_index, | ||
void * | dest_data | ||
) |
Communicate local index using all-to-all distributor.
If a destination buffer is provided, it should be of sufficient size for the number of elements indicated by dest_index[cs_all_to_all_n_elts_dest(d)];
If no buffer is provided, one is allocated automatically, and transferred to the caller (who is responsible for freeing it when no longer needed).
If used in reverse mode, data is still communicated from src_index to dest_index or an internal buffer, but communication direction (i.e. source and destination ranks) are reversed.
This is obviously a collective operation, and all ranks must provide the same value for the reverse parameter.
[in,out] | d | pointer to associated all-to-all distributor |
[in] | datatype | type of data considered |
[in] | reverse | if true, communicate in reverse direction |
[in] | src_index | source index |
[in] | src_data | source data |
[in] | dest_index | destination index |
[out] | dest_data | pointer to destination data, or NULL |
cs_all_to_all_t* cs_all_to_all_create | ( | size_t | n_elts, |
int | flags, | ||
const cs_lnum_t * | dest_id, | ||
const int | dest_rank[], | ||
MPI_Comm | comm | ||
) |
Create an all-to-all distributor based on destination rank.
This is a collective operation on communicator comm.
If the flags bit mask matches CS_ALL_TO_ALL_USE_DEST_ID, data exchanged will be ordered by the array passed to the dest_id
argument. For n
total values received on a rank (as given by cs_all_to_all_n_elts_dest), those destination ids must be in the range [0, n
[.
If the flags bit mask matches CS_ALL_TO_ALL_ORDER_BY_SRC_RANK, data exchanged will be ordered by source rank (this is incompatible with CS_ALL_TO_ALL_USE_DEST_ID.
dest_rank
and dest_id
arrays are only referenced by the distributor, not copied, and must remain available throughout the distributor's lifetime. They may be fully transferred to the structure if not needed elsewhere using the cs_all_to_all_transfer_dest_rank and cs_all_to_all_transfer_dest_id functions.[in] | n_elts | number of elements |
[in] | flags | sum of ordering and metadata flag constants |
[in] | dest_id | element destination id (required if flags contain CS_ALL_TO_ALL_USE_DEST_ID), or NULL |
[in] | dest_rank | destination rank for each element |
[in] | comm | associated MPI communicator |
cs_all_to_all_t* cs_all_to_all_create_from_block | ( | size_t | n_elts, |
int | flags, | ||
const cs_gnum_t * | src_gnum, | ||
cs_block_dist_info_t | bi, | ||
MPI_Comm | comm | ||
) |
Create an all-to-all distributor for elements whose destination rank is determined from global numbers and block distribution information.
This is a collective operation on communicator comm.
If the flags bit mask matches CS_ALL_TO_ALL_USE_DEST_ID, data exchanged will be ordered by global element number.
If the flags bit mask matches CS_ALL_TO_ALL_ORDER_BY_SRC_RANK, data exchanged will be ordered by source rank (this is incompatible with CS_ALL_TO_ALL_USE_DEST_ID.
[in] | n_elts | number of elements |
[in] | flags | sum of ordering and metadata flag constants |
[in] | src_gnum | global source element numbers |
[in] | bi | destination block distribution info |
[in] | comm | associated MPI communicator |
void cs_all_to_all_destroy | ( | cs_all_to_all_t ** | d | ) |
Destroy an all-to-all distributor.
[in,out] | d | pointer to associated all-to-all distributor |
int* cs_all_to_all_get_src_rank | ( | cs_all_to_all_t * | d | ) |
Get array of source element ranks associated with an all-to-all distributor.
This function should be called only after cs_all_to_all_copy_array, and allocates and returns an array of source element ranks matching the exchanged data elements.
It should also be called only if the distributor creation flags match CS_ALL_TO_ALL_NEED_SRC_RANK or CS_ALL_TO_ALL_ORDER_BY_SRC_RANK.
The returned data is owned by the caller, who is responsible for freeing it when no longer needed.
If source ranks are not available (depending on the distributor creation function and options), the matching pointer will be set to NULL.
[in] | d | pointer to associated all-to-all distributor |
cs_all_to_all_type_t cs_all_to_all_get_type | ( | void | ) |
Get current type of all-to-all distributor algorithm choice.
void cs_all_to_all_log_finalize | ( | void | ) |
Log performance information relative to instrumented all-to-all distribution.
cs_lnum_t cs_all_to_all_n_elts_dest | ( | cs_all_to_all_t * | d | ) |
Get number of elements associated with all-to-all distributor.
The number of elements is the number of elements received after exchange.
If no exchange has been done yet (depending on the communication protocol), metadata will be exchanged by this call, so it is a collective operation.
[in] | d | pointer to associated all-to-all distributor |
void cs_all_to_all_set_type | ( | cs_all_to_all_type_t | t | ) |
Set current type of all-to-all distributor algorithm choice.
t | type of all-to-all distributor algorithm choice to select |
void cs_all_to_all_transfer_dest_id | ( | cs_all_to_all_t * | d, |
cs_lnum_t ** | dest_id | ||
) |
Transfer ownership of destination ids to an all-to-all distributor.
The dest_id array should be the same as the one used for the creation of the distributor.
[in,out] | d | pointer to associated all-to-all distributor |
[in,out] | dest_id | pointer to element destination id |
void cs_all_to_all_transfer_dest_rank | ( | cs_all_to_all_t * | d, |
int ** | dest_rank | ||
) |
Transfer ownership of destination rank to an all-to-all distributor.
The dest_rank array should be the same as the one used for the creation of the distributor.
[in,out] | d | pointer to associated all-to-all distributor |
[in,out] | dest_rank | pointer to element destination rank |