PaCO++  0.05
PC/DistributionBloc.h
Go to the documentation of this file.
1 #ifndef DISTRIBUTION_BLOC_1D_IS_DEFINED
2 #define DISTRIBUTION_BLOC_1D_IS_DEFINED
3 
4 #if defined(__cplusplus)
5 extern "C" {
6 #endif
7 
11 
12 
14 
15 // // vOut represents what localData/stopo have to send to nodes of dtopo (vOut[].rank is in dtopo space)
16 // void computeSendBlock1D(GlobalData_t* gd, LocalData_t *sd, Topology_t *stopo, Topology_t *dtopo,
17 // vector<LocalData_t>* vOut);
18 
19 // // vOut represents what localData/dtopo have to receive from nodes of stopo (vOut[].rank is in stopo space)
20 // void computeReceiveBlock1D(GlobalData_t* gd, LocalData_t *dd, Topology_t *stopo, Topology_t *dtopo,
21 // vector<LocalData_t>* vOut);
22 
23 // // vOut represents what localData/stopo have to send to nodes of dtopo (vOut[].rank is in dtopo space)
24 // void computeSendRemoteDataBlock1D(GlobalData_t* gd, LocalData_t *sd, Topology_t *stopo, Topology_t *dtopo,
25 // vector<LocalData_t>* vOut, vector<void*> pData, distLoc_t mode,
26 // void *sdata, void *ddata);
27 
28 
32 
33  // Definition of bloc: all but the last one have the same size. The last bloc size
34  // can be null !
35 
36  // Compute BlockSize
37  static inline unsigned blockSize(unsigned glen, unsigned total) {
38  return (glen+total-1)/total;
39  }
40 
41  // Compute the size of the block on the processor of rank rank ( == bsz but for the last one)
42  static inline unsigned localBlockLengthO(unsigned glen, unsigned rank, unsigned total, unsigned bsz) {
43  if (rank == total - 1) {
44  return glen - rank * bsz;
45  } else {
46  return bsz;
47  }
48  }
49  static inline unsigned localBlockLength(unsigned glen, unsigned rank, unsigned total) {
50  if (rank == total - 1) {
51  return glen - rank * blockSize(glen, total);
52  } else {
53  return blockSize(glen, total);
54  }
55  }
56 
57  // Compute the bounds low & high of the process of rank rank
58  static inline void computeBlockBoundsO(unsigned long *low, unsigned long *high, unsigned glen,
59  unsigned rank, unsigned bsz) {
60  unsigned long tmp = (rank+1) * bsz;
61  *low = rank * bsz;
62  *high = ((glen <= tmp)?glen:tmp); // min
63  }
64  static inline void computeBlockBounds(unsigned *low, unsigned *high, unsigned glen,
65  unsigned rank, unsigned total) {
66 
67  unsigned bsz = blockSize(glen, total);
68  unsigned tmp = (rank+1) * bsz;
69 
70  *low = rank * bsz;
71  *high = ((glen <= tmp)?glen:tmp); // min
72  }
73 
74  static inline unsigned computeBlockBoundInf0(unsigned bsz, unsigned rank) {
75  return rank * bsz;
76  }
77 
78  static inline unsigned computeBlockBoundInf(unsigned glen, unsigned rank, unsigned total) {
79  return computeBlockBoundInf0(rank,blockSize(glen, total));
80  }
81 
82  static inline unsigned computeBlockBoundSup0(unsigned glen, unsigned bsz, unsigned rank) {
83  unsigned tmp = (rank+1) * bsz;
84  return ((glen <= tmp)?glen:tmp); // min
85 
86  }
87 
88  static inline unsigned computeBlockBoundSup(unsigned glen, unsigned rank, unsigned total) {
89  unsigned bsz = blockSize(glen, total);
90  return computeBlockBoundSup0(glen, bsz, rank);
91  }
92 
93 #if defined(__cplusplus)
94 }
95 #endif
96 
97 #endif
static void computeBlockBoundsO(unsigned long *low, unsigned long *high, unsigned glen, unsigned rank, unsigned bsz)
static void computeBlockBounds(unsigned *low, unsigned *high, unsigned glen, unsigned rank, unsigned total)
static unsigned computeBlockBoundSup(unsigned glen, unsigned rank, unsigned total)
static unsigned computeBlockBoundSup0(unsigned glen, unsigned bsz, unsigned rank)
static unsigned blockSize(unsigned glen, unsigned total)
static unsigned localBlockLength(unsigned glen, unsigned rank, unsigned total)
static unsigned computeBlockBoundInf0(unsigned bsz, unsigned rank)
static unsigned localBlockLengthO(unsigned glen, unsigned rank, unsigned total, unsigned bsz)
static unsigned computeBlockBoundInf(unsigned glen, unsigned rank, unsigned total)