PaCO++
0.05
|
00001 #ifndef DISTRIBUTION_BLOC_1D_IS_DEFINED 00002 #define DISTRIBUTION_BLOC_1D_IS_DEFINED 00003 00004 #if defined(__cplusplus) 00005 extern "C" { 00006 #endif 00007 00011 00012 00014 00015 // // vOut represents what localData/stopo have to send to nodes of dtopo (vOut[].rank is in dtopo space) 00016 // void computeSendBlock1D(GlobalData_t* gd, LocalData_t *sd, Topology_t *stopo, Topology_t *dtopo, 00017 // vector<LocalData_t>* vOut); 00018 00019 // // vOut represents what localData/dtopo have to receive from nodes of stopo (vOut[].rank is in stopo space) 00020 // void computeReceiveBlock1D(GlobalData_t* gd, LocalData_t *dd, Topology_t *stopo, Topology_t *dtopo, 00021 // vector<LocalData_t>* vOut); 00022 00023 // // vOut represents what localData/stopo have to send to nodes of dtopo (vOut[].rank is in dtopo space) 00024 // void computeSendRemoteDataBlock1D(GlobalData_t* gd, LocalData_t *sd, Topology_t *stopo, Topology_t *dtopo, 00025 // vector<LocalData_t>* vOut, vector<void*> pData, distLoc_t mode, 00026 // void *sdata, void *ddata); 00027 00028 00032 00033 // Definition of bloc: all but the last one have the same size. The last bloc size 00034 // can be null ! 00035 00036 // Compute BlockSize 00037 static inline unsigned blockSize(unsigned glen, unsigned total) { 00038 return (glen+total-1)/total; 00039 } 00040 00041 // Compute the size of the block on the processor of rank rank ( == bsz but for the last one) 00042 static inline unsigned localBlockLengthO(unsigned glen, unsigned rank, unsigned total, unsigned bsz) { 00043 if (rank == total - 1) { 00044 return glen - rank * bsz; 00045 } else { 00046 return bsz; 00047 } 00048 } 00049 static inline unsigned localBlockLength(unsigned glen, unsigned rank, unsigned total) { 00050 if (rank == total - 1) { 00051 return glen - rank * blockSize(glen, total); 00052 } else { 00053 return blockSize(glen, total); 00054 } 00055 } 00056 00057 // Compute the bounds low & high of the process of rank rank 00058 static inline void computeBlockBoundsO(unsigned long *low, unsigned long *high, unsigned glen, 00059 unsigned rank, unsigned bsz) { 00060 unsigned long tmp = (rank+1) * bsz; 00061 *low = rank * bsz; 00062 *high = ((glen <= tmp)?glen:tmp); // min 00063 } 00064 static inline void computeBlockBounds(unsigned *low, unsigned *high, unsigned glen, 00065 unsigned rank, unsigned total) { 00066 00067 unsigned bsz = blockSize(glen, total); 00068 unsigned tmp = (rank+1) * bsz; 00069 00070 *low = rank * bsz; 00071 *high = ((glen <= tmp)?glen:tmp); // min 00072 } 00073 00074 static inline unsigned computeBlockBoundInf0(unsigned bsz, unsigned rank) { 00075 return rank * bsz; 00076 } 00077 00078 static inline unsigned computeBlockBoundInf(unsigned glen, unsigned rank, unsigned total) { 00079 return computeBlockBoundInf0(rank,blockSize(glen, total)); 00080 } 00081 00082 static inline unsigned computeBlockBoundSup0(unsigned glen, unsigned bsz, unsigned rank) { 00083 unsigned tmp = (rank+1) * bsz; 00084 return ((glen <= tmp)?glen:tmp); // min 00085 00086 } 00087 00088 static inline unsigned computeBlockBoundSup(unsigned glen, unsigned rank, unsigned total) { 00089 unsigned bsz = blockSize(glen, total); 00090 return computeBlockBoundSup0(glen, bsz, rank); 00091 } 00092 00093 #if defined(__cplusplus) 00094 } 00095 #endif 00096 00097 #endif