1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/*
* decomp.h
*
* Created on: Oct 2018
* Author: Norbert Podhorszki
*/
#ifndef DECOMP_H_
#define DECOMP_H_
#include <stddef.h> // size_t
/** Decompose M processes with N-dimensional decomposition in a Column major
* fashion.
* INPUT: ndim as N dimension
* rank as the MPI rank of the calling process
* decomp[] array for the number of processes in each dimension
* OUTPUT: pos[] array describes the position of this rank in each dimension
*
* Requirement: pos[] must be pre-allocated to hold ndim elements
*
* Examples:
* 1. 2-dim, 6 processes with 2x3 decomposition
* ndim = 2, decomp[]={2,3}
* decomposition calculated according to this table
* pos[1]
* 0 1 2
* ----------
* pos[0] 0 | 0 2 4
* 1 | 1 3 5
*
*/
void decompColumnMajor(const size_t ndim, const size_t rank, const size_t *decomp, size_t *pos);
/** Decompose M processes with N-dimensional decomposition in a Row major
* fashion.
* INPUT: ndim as N dimension
* rank as the MPI rank of the calling process
* decomp[] array for the number of processes in each dimension
* OUTPUT: pos[] array describes the position of this rank in each dimension
*
* Requirement: pos[] must be pre-allocated to hold ndim elements
*
* Examples:
* 1. 2-dim, 6 processes with 2x3 decomposition
* ndim = 2, decomp[]={2,3}
* decomposition calculated according to this table
* pos[1]
* 0 1 2
* ----------
* pos[0] 0 | 0 1 2
* 1 | 3 4 5
*
*/
void decompRowMajor(const size_t ndim, const size_t rank, const size_t *decomp, size_t *pos);
#endif /* DECOMP_H */
|