hpl_grid.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * -- High Performance Computing Linpack Benchmark (HPL)
  3. * HPL - 2.0 - September 10, 2008
  4. * Antoine P. Petitet
  5. * University of Tennessee, Knoxville
  6. * Innovative Computing Laboratory
  7. * (C) Copyright 2000-2008 All Rights Reserved
  8. *
  9. * -- Copyright notice and Licensing terms:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions, and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. *
  22. * 3. All advertising materials mentioning features or use of this
  23. * software must display the following acknowledgement:
  24. * This product includes software developed at the University of
  25. * Tennessee, Knoxville, Innovative Computing Laboratory.
  26. *
  27. * 4. The name of the University, the name of the Laboratory, or the
  28. * names of its contributors may not be used to endorse or promote
  29. * products derived from this software without specific written
  30. * permission.
  31. *
  32. * -- Disclaimer:
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  35. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  37. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
  38. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  41. * DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  43. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  44. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. */
  46. #ifndef HPL_GRID_H
  47. #define HPL_GRID_H
  48. /*
  49. * ---------------------------------------------------------------------
  50. * Include files
  51. * ---------------------------------------------------------------------
  52. */
  53. #include "hpl_pmisc.h"
  54. /*
  55. * ---------------------------------------------------------------------
  56. * #typedefs and data structures
  57. * ---------------------------------------------------------------------
  58. */
  59. typedef enum { HPL_INT = 100, HPL_DOUBLE = 101 } HPL_T_TYPE;
  60. typedef enum
  61. {
  62. HPL_ROW_MAJOR = 201,
  63. HPL_COLUMN_MAJOR = 202
  64. } HPL_T_ORDER;
  65. typedef struct HPL_S_grid
  66. {
  67. MPI_Comm all_comm; /* grid communicator */
  68. MPI_Comm row_comm; /* row communicator */
  69. MPI_Comm col_comm; /* column communicator */
  70. HPL_T_ORDER order; /* ordering of the procs in the grid */
  71. int iam; /* my rank in the grid */
  72. int myrow; /* my row number in the grid */
  73. int mycol; /* my column number in the grid */
  74. int nprow; /* the total # of rows in the grid */
  75. int npcol; /* the total # of columns in the grid */
  76. int nprocs; /* the total # of procs in the grid */
  77. int row_ip2; /* largest power of two <= nprow */
  78. int row_hdim; /* row_ip2 procs hypercube dimension */
  79. int row_ip2m1; /* largest power of two <= nprow-1 */
  80. int row_mask; /* row_ip2m1 procs hypercube mask */
  81. int col_ip2; /* largest power of two <= npcol */
  82. int col_hdim; /* col_ip2 procs hypercube dimension */
  83. int col_ip2m1; /* largest power of two <= npcol-1 */
  84. int col_mask; /* col_ip2m1 procs hypercube mask */
  85. } HPL_T_grid;
  86. /*
  87. * ---------------------------------------------------------------------
  88. * Data Structures
  89. * ---------------------------------------------------------------------
  90. */
  91. typedef void (*HPL_T_OP)
  92. ( const int, const void *, void *, const HPL_T_TYPE );
  93. /*
  94. * ---------------------------------------------------------------------
  95. * #define macros definitions
  96. * ---------------------------------------------------------------------
  97. */
  98. #define HPL_2_MPI_TYPE( typ ) \
  99. ( ( typ == HPL_INT ? MPI_INT : MPI_DOUBLE ) )
  100. /*
  101. * The following macros perform common modulo operations; All functions
  102. * except MPosMod assume arguments are < d (i.e., arguments are themsel-
  103. * ves within modulo range).
  104. */
  105. /* increment with mod */
  106. #define MModInc(I, d) if(++(I) == (d)) (I) = 0
  107. /* decrement with mod */
  108. #define MModDec(I, d) if(--(I) == -1) (I) = (d)-1
  109. /* positive modulo */
  110. #define MPosMod(I, d) ( (I) - ((I)/(d))*(d) )
  111. /* add two numbers */
  112. #define MModAdd(I1, I2, d) \
  113. ( ( (I1) + (I2) < (d) ) ? (I1) + (I2) : (I1) + (I2) - (d) )
  114. /* add 1 to # */
  115. #define MModAdd1(I, d) ( ((I) != (d)-1) ? (I) + 1 : 0 )
  116. /* subtract two numbers */
  117. #define MModSub(I1, I2, d) \
  118. ( ( (I1) < (I2) ) ? (d) + (I1) - (I2) : (I1) - (I2) )
  119. /* sub 1 from # */
  120. #define MModSub1(I, d) ( ((I)!=0) ? (I)-1 : (d)-1 )
  121. /*
  122. * ---------------------------------------------------------------------
  123. * grid function prototypes
  124. * ---------------------------------------------------------------------
  125. */
  126. int HPL_grid_init
  127. STDC_ARGS( (
  128. MPI_Comm,
  129. const HPL_T_ORDER,
  130. const int,
  131. const int,
  132. HPL_T_grid *
  133. ) );
  134. int HPL_grid_exit
  135. STDC_ARGS( (
  136. HPL_T_grid *
  137. ) );
  138. int HPL_grid_info
  139. STDC_ARGS( (
  140. const HPL_T_grid *,
  141. int *,
  142. int *,
  143. int *,
  144. int *
  145. ) );
  146. int HPL_pnum
  147. STDC_ARGS( (
  148. const HPL_T_grid *,
  149. const int,
  150. const int
  151. ) );
  152. int HPL_barrier
  153. STDC_ARGS( (
  154. MPI_Comm
  155. ) );
  156. int HPL_broadcast
  157. STDC_ARGS( (
  158. void *,
  159. const int,
  160. const HPL_T_TYPE,
  161. const int,
  162. MPI_Comm
  163. ) );
  164. int HPL_reduce
  165. STDC_ARGS( (
  166. void *,
  167. const int,
  168. const HPL_T_TYPE,
  169. const HPL_T_OP ,
  170. const int,
  171. MPI_Comm
  172. ) );
  173. int HPL_all_reduce
  174. STDC_ARGS( (
  175. void *,
  176. const int,
  177. const HPL_T_TYPE,
  178. const HPL_T_OP ,
  179. MPI_Comm
  180. ) );
  181. void HPL_max
  182. STDC_ARGS( (
  183. const int,
  184. const void *,
  185. void *,
  186. const HPL_T_TYPE
  187. ) );
  188. void HPL_min
  189. STDC_ARGS( (
  190. const int,
  191. const void *,
  192. void *,
  193. const HPL_T_TYPE
  194. ) );
  195. void HPL_sum
  196. STDC_ARGS( (
  197. const int,
  198. const void *,
  199. void *,
  200. const HPL_T_TYPE
  201. ) );
  202. #endif
  203. /*
  204. * End of hpl_grid.h
  205. */