src/base/cs_all_to_all.c File Reference

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
cs_all_to_all.c File Reference
`#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 "cs_block_dist.h"`
`#include "cs_log.h"`
`#include "cs_order.h"`
`#include "cs_timer.h"`
`#include "cs_all_to_all.h"`
Include dependency graph for cs_all_to_all.c:

## Macros
#define | CS_ALL_TO_ALL_USE_GNUM (1 << 0)
#define | CS_ALL_TO_ALL_USE_DEST_ID (1 << 1)
#define | CS_ALL_TO_ALL_USE_SRC_ID (1 << 2)

## Functions
cs_all_to_all_t * | cs_all_to_all_create_s (size_t n_elts, int stride, cs_datatype_t datatype, void *elt, const int dest_rank[], MPI_Comm comm)
| Create an all-to-all distributor for strided data. More...
cs_all_to_all_t * | cs_all_to_all_create_with_ids_s (size_t n_elts, int stride, cs_datatype_t datatype, cs_datatype_t dest_id_datatype, bool add_src_id, void *elt, void *dest_id, const int dest_rank[], MPI_Comm comm)
| Create an all-to-all distributor for strided data with additional metadata. More...
cs_all_to_all_t * | cs_all_to_all_create_from_block_s (size_t n_elts, int stride, cs_datatype_t datatype, cs_datatype_t dest_id_datatype, bool add_src_id, void *elt, const cs_gnum_t *elt_gnum, cs_block_dist_info_t bi, MPI_Comm comm)
| Create an all-to-all distributor for strided data with additional metadata, with destination rank 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_exchange (cs_all_to_all_t *d)
| Exchange data with an all-to-all distributor. More...
void | cs_all_to_all_sort_by_source_rank (cs_all_to_all_t *d)
| Sort stride crystal router data by source rank. More...
cs_lnum_t | cs_all_to_all_n_elts (const cs_all_to_all_t *d)
| Get number of elements associated with all-to-all distributor. More...
void | cs_all_to_all_swap_src_dest (cs_all_to_all_t *d)
| Swap source and destination ranks of all-to-all distributor. More...
void | cs_all_to_all_get_data_pointer (cs_all_to_all_t *d, size_t *data_stride, unsigned char **data)
| Get pointer to data elements associated with an all-to-all distributor. More...
void | cs_all_to_all_get_rank_pointers (cs_all_to_all_t *d, size_t *rank_stride, int **src_rank, int **dest_rank)
| Get pointer to ranks of elements associated with an all-to-all distributor. More...
void | cs_all_to_all_get_id_pointers (cs_all_to_all_t *d, size_t *id_stride, cs_lnum_t **dest_id, cs_lnum_t **src_id)
| Get pointer to source or destination rank element ids associated with an all-to-all distributor. More...
void | cs_all_to_all_get_gnum_pointer (cs_all_to_all_t *d, size_t *gnum_stride, cs_gnum_t **gnum)
| Get pointer to element global numbers 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...

## Detailed Description

(end ignore by Doxygen)

      All-to-all parallel data exchange.

## Macro Definition Documentation

#define CS_ALL_TO_ALL_USE_DEST_ID (1 << 1)

#define CS_ALL_TO_ALL_USE_GNUM (1 << 0)

#define CS_ALL_TO_ALL_USE_SRC_ID (1 << 2)

## Function Documentation

cs_all_to_all_t* cs_all_to_all_create_from_block_s | ( | size_t | n_elts,
|  | int | stride,
|  | cs_datatype_t | datatype,
|  | cs_datatype_t | dest_id_datatype,
|  | bool | add_src_id,
|  | void * | elt,
|  | const cs_gnum_t * | elt_gnum,
|  | cs_block_dist_info_t | bi,
|  | MPI_Comm | comm
| ) |  |

Create an all-to-all distributor for strided data with additional metadata, with destination rank determined from global numbers and block distribution information.

This variant allows optional tracking of destination ids or global numbers associated with elements, as well as their source ids.

In cases where those arrays are required and already available, this may avoid the need for a specific element values buffer mixing actual data values and numbering metadata. It also makes extraction of the metadata easier using cs_all_to_all_get_id_pointers.

Parameters

  [in] | n_elts | number of elements
  [in] | stride | number of values per entity (interlaced)
  [in] | datatype | type of data considered
  [in] | dest_id_datatype | type of destination id (CS_GNUM_TYPE, CS_LNUM_TYPE or CS_DATATYPE_NULL depending on elt_id values)
  [in] | add_src_id | add source id metadata (id in elt array)
  [in] | elt | element values
  [in] | elt_gnum | global element numbers
  [in] | bi | destination block distribution info
  [in] | comm | associated MPI communicator

Returns
  pointer to new all-to-all distributor

cs_all_to_all_t* cs_all_to_all_create_s | ( | size_t | n_elts,
|  | int | stride,
|  | cs_datatype_t | datatype,
|  | void * | elt,
|  | const int | dest_rank[],
|  | MPI_Comm | comm
| ) |  |

Create an all-to-all distributor for strided data.

Parameters

  [in] | n_elts | number of elements
  [in] | stride | number of values per entity (interlaced)
  [in] | datatype | type of data considered
  [in] | elt | element values
  [in] | dest_rank | destination rank for each element
  [in] | comm | associated MPI communicator

Returns
  pointer to new all-to-all distributor

cs_all_to_all_t* cs_all_to_all_create_with_ids_s | ( | size_t | n_elts,
|  | int | stride,
|  | cs_datatype_t | datatype,
|  | cs_datatype_t | dest_id_datatype,
|  | bool | add_src_id,
|  | void * | elt,
|  | void * | dest_id,
|  | const int | dest_rank[],
|  | MPI_Comm | comm
| ) |  |

Create an all-to-all distributor for strided data with additional metadata.

This variant allows optional tracking of destination ids or global numbers associated with elements, as well as their source ids.

In cases where those arrays are required and already available, this may avoid the need for a specific element values buffer mixing actual data values and numbering metadata. It also makes extraction of the metadata easier using cs_all_to_all_get_id_pointers.

Parameters

  [in] | n_elts | number of elements
  [in] | stride | number of values per entity (interlaced)
  [in] | datatype | type of data considered
  [in] | dest_id_datatype | type of destination id (CS_GNUM_TYPE, CS_LNUM_TYPE or CS_DATATYPE_NULL depending on elt_id values)
  [in] | add_src_id | add source id metadata (id in elt array)
  [in] | elt | element values
  [in] | dest_id | element destination id, global number, or NULL
  [in] | dest_rank | destination rank for each element
  [in] | comm | associated MPI communicator

Returns
  pointer to new all-to-all distributor

void cs_all_to_all_destroy | ( | cs_all_to_all_t ** | d | ) |

Destroy an all-to-all distributor.

Parameters

  [in,out] | d | pointer to associated all-to-all distributor

void cs_all_to_all_exchange | ( | cs_all_to_all_t * | d | ) |

Exchange data with an all-to-all distributor.

Order of data from a same source rank is preserved.

Parameters

  [in,out] | d | pointer to associated all-to-all distributor

void cs_all_to_all_get_data_pointer | ( | cs_all_to_all_t * | d,
|  | size_t * | data_stride,
|  | unsigned char ** | data
| ) |  |

Get pointer to data elements associated with an all-to-all distributor.

This allows modification and/or extraction of those elements.

Note that depending on the distributor type used, the rank metadata and data may be interleaved, so the corresponding pointers point to strided, interleaved data.

Parameters

  [in] | d | pointer to associated all-to-all distributor
  [out] | data_stride | stride (in bytes) between data items
  [out] | data_ptr | pointer to data items

void cs_all_to_all_get_gnum_pointer | ( | cs_all_to_all_t * | d,
|  | size_t * | gnum_stride,
|  | cs_gnum_t ** | gnum
| ) |  |

Get pointer to element global numbers associated with an all-to-all distributor.

If this data is not available (depending on the all-to-all distributor creation function and options), the matching pointer will be set to NULL.

This allows modification and/or extraction of those numbers.

Note that depending on the distributor type used, the rank metadata and data may be interleaved, so the corresponding pointers point to strided, interleaved data.

Parameters

  [in] | d | pointer to associated all-to-all distributor
  [out] | gnum_stride | stride (in integers) between element global numbers
  [out] | gnum | pointer to global numbers

void cs_all_to_all_get_id_pointers | ( | cs_all_to_all_t * | d,
|  | size_t * | id_stride,
|  | cs_lnum_t ** | dest_id,
|  | cs_lnum_t ** | src_id
| ) |  |

Get pointer to source or destination rank element ids associated with an all-to-all distributor.

If a requested type of id is not available (depending on the all-to-all distributor creation function and options), the matching pointer will be set to NULL.

This allows modification and/or extraction of those ids, though it is intended primarily for identification.

Note that depending on the distributor type used, the rank metadata and data may be interleaved, so the corresponding pointers point to strided, interleaved data.

Parameters

  [in] | d | pointer to associated all-to-all distributor
  [out] | id_stride | stride (in integers) between id items
  [out] | dest_id | pointer to destination ids (or NULL)
  [out] | src_id | pointer to source ids (or NULL)

void cs_all_to_all_get_rank_pointers | ( | cs_all_to_all_t * | d,
|  | size_t * | rank_stride,
|  | int ** | src_rank,
|  | int ** | dest_rank
| ) |  |

Get pointer to ranks of elements associated with an all-to-all distributor.

This allows modification and/or extraction of those ranks.

Note that depending on the distributor type used, the rank metadata and data may be interleaved, so the corresponding pointers point to strided, interleaved data.

Parameters

  [in] | d | pointer to associated all-to-all distributor
  [out] | rank_stride | stride (in integers) between rank values
  [out] | src_rank | pointer to source rank values (or NULL)
  [out] | dest_rank | pointer to destination rank values (or NULL)

cs_all_to_all_type_t cs_all_to_all_get_type | ( | void |  | ) |

Get current type of all-to-all distributor algorithm choice.

Returns
  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 | ( | const 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.

Parameters

  [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.

Parameters

  t | type of all-to-all distributor algorithm choice to select

void cs_all_to_all_sort_by_source_rank | ( | cs_all_to_all_t * | d | ) |

Sort stride crystal router data by source rank.

Parameters

  [in,out] | d | pointer to associated all-to-all distributor

void cs_all_to_all_swap_src_dest | ( | cs_all_to_all_t * | d | ) |

Swap source and destination ranks of all-to-all distributor.

Parameters

  [in,out] | d | pointer to associated all-to-all distributor