HPL_xjumpm.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. */
  47. /*
  48. * Include files
  49. */
  50. #include "hpl.h"
  51. #ifdef STDC_HEADERS
  52. void HPL_xjumpm
  53. (
  54. const int JUMPM,
  55. int * MULT,
  56. int * IADD,
  57. int * IRANN,
  58. int * IRANM,
  59. int * IAM,
  60. int * ICM
  61. )
  62. #else
  63. void HPL_xjumpm
  64. ( JUMPM, MULT, IADD, IRANN, IRANM, IAM, ICM )
  65. const int JUMPM;
  66. int * MULT;
  67. int * IADD;
  68. int * IRANN;
  69. int * IRANM;
  70. int * IAM;
  71. int * ICM;
  72. #endif
  73. {
  74. /*
  75. * Purpose
  76. * =======
  77. *
  78. * HPL_xjumpm computes the constants A and C to jump JUMPM numbers in
  79. * the random sequence: X(n+JUMPM) = A*X(n)+C. The constants encoded in
  80. * MULT and IADD specify how to jump from one entry in the sequence to
  81. * the next.
  82. *
  83. * Arguments
  84. * =========
  85. *
  86. * JUMPM (local input) const int
  87. * On entry, JUMPM specifies the number of entries in the
  88. * sequence to jump over. When JUMPM is less or equal than zero,
  89. * A and C are not computed, IRANM is set to IRANN corresponding
  90. * to a jump of size zero.
  91. *
  92. * MULT (local input) int *
  93. * On entry, MULT is an array of dimension 2, that contains the
  94. * 16-lower and 15-higher bits of the constant a to jump from
  95. * X(n) to X(n+1) = a*X(n) + c in the random sequence.
  96. *
  97. * IADD (local input) int *
  98. * On entry, IADD is an array of dimension 2, that contains the
  99. * 16-lower and 15-higher bits of the constant c to jump from
  100. * X(n) to X(n+1) = a*X(n) + c in the random sequence.
  101. *
  102. * IRANN (local input) int *
  103. * On entry, IRANN is an array of dimension 2. that contains the
  104. * 16-lower and 15-higher bits of the encoding of X(n).
  105. *
  106. * IRANM (local output) int *
  107. * On entry, IRANM is an array of dimension 2. On exit, this
  108. * array contains respectively the 16-lower and 15-higher bits
  109. * of the encoding of X(n+JUMPM).
  110. *
  111. * IAM (local output) int *
  112. * On entry, IAM is an array of dimension 2. On exit, when JUMPM
  113. * is greater than zero, this array contains the encoded
  114. * constant A to jump from X(n) to X(n+JUMPM) in the random
  115. * sequence. IAM(0:1) contains respectively the 16-lower and
  116. * 15-higher bits of this constant A. When JUMPM is less or
  117. * equal than zero, this array is not referenced.
  118. *
  119. * ICM (local output) int *
  120. * On entry, ICM is an array of dimension 2. On exit, when JUMPM
  121. * is greater than zero, this array contains the encoded
  122. * constant C to jump from X(n) to X(n+JUMPM) in the random
  123. * sequence. ICM(0:1) contains respectively the 16-lower and
  124. * 15-higher bits of this constant C. When JUMPM is less or
  125. * equal than zero, this array is not referenced.
  126. *
  127. * ---------------------------------------------------------------------
  128. */
  129. /*
  130. * .. Local Variables ..
  131. */
  132. int j[2], k;
  133. /* ..
  134. * .. Executable Statements ..
  135. */
  136. if( JUMPM > 0 )
  137. {
  138. IAM[0] = MULT[0]; IAM[1] = MULT[1]; /* IAM = MULT; */
  139. ICM[0] = IADD[0]; ICM[1] = IADD[1]; /* ICM = IADD; */
  140. for( k = 1; k <= JUMPM-1; k++ )
  141. {
  142. HPL_lmul( IAM, MULT, j ); /* j = IAM * MULT; */
  143. IAM[0] = j[0]; IAM[1] = j[1]; /* IAM = j; */
  144. HPL_lmul( ICM, MULT, j ); /* j = ICM * MULT; */
  145. HPL_ladd( IADD, j, ICM ); /* ICM = IADD + j; */
  146. }
  147. HPL_lmul( IRANN, IAM, j ); /* j = IRANN * IAM; */
  148. HPL_ladd( j, ICM, IRANM ); /* IRANM = j + ICM; */
  149. }
  150. else
  151. { /* IRANM = IRANN */
  152. IRANM[0] = IRANN[0]; IRANM[1] = IRANN[1];
  153. }
  154. /*
  155. * End of HPL_xjumpm
  156. */
  157. }