PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
core_zplghe.c
Go to the documentation of this file.
1 
17 #include "common.h"
18 
19 #define COMPLEX
20 #undef REAL
21 
22 /*
23  Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
24  generating threads only read Rnd64seed. It is safe to set Rnd64seed before
25  and after any calls to create_tile(). The only problem can be caused if
26  Rnd64seed is changed during the matrix generation time.
27  */
28 
29 //static unsigned long long int Rnd64seed = 100;
30 #define Rnd64_A 6364136223846793005ULL
31 #define Rnd64_C 1ULL
32 #define RndF_Mul 5.4210108624275222e-20f
33 #define RndD_Mul 5.4210108624275222e-20
34 
35 #ifdef COMPLEX
36 #define NBELEM 2
37 #else
38 #define NBELEM 1
39 #endif
40 
41 static unsigned long long int
42 Rnd64_jump(unsigned long long int n, unsigned long long int seed ) {
43  unsigned long long int a_k, c_k, ran;
44  int i;
45 
46  a_k = Rnd64_A;
47  c_k = Rnd64_C;
48 
49  ran = seed;
50  for (i = 0; n; n >>= 1, i++) {
51  if (n & 1)
52  ran = a_k * ran + c_k;
53  c_k *= (a_k + 1);
54  a_k *= a_k;
55  }
56 
57  return ran;
58 }
59 
60 #if defined(PLASMA_HAVE_WEAK)
61 #pragma weak CORE_zplghe = PCORE_zplghe
62 #define CORE_zplghe PCORE_zplghe
63 #endif
64 void CORE_zplghe( double bump, int m, int n, PLASMA_Complex64_t *A, int lda,
65  int bigM, int m0, int n0, unsigned long long int seed )
66 {
67  PLASMA_Complex64_t *tmp = A;
68  int64_t i, j;
69  unsigned long long int ran, jump;
70 
71  jump = m0 + n0 * bigM;
72 
73  /*
74  * Tile diagonal
75  */
76  if ( m0 == n0 ) {
77  for (j = 0; j < n; j++) {
78  ran = Rnd64_jump( NBELEM * jump, seed );
79 
80  for (i = j; i < m; i++) {
81  *tmp = 0.5f - ran * RndF_Mul;
82  ran = Rnd64_A * ran + Rnd64_C;
83 #ifdef COMPLEX
84  *tmp += I*(0.5f - ran * RndF_Mul);
85  ran = Rnd64_A * ran + Rnd64_C;
86 #endif
87  tmp++;
88  }
89  tmp += (lda - i + j + 1);
90  jump += bigM + j;
91  }
92 
93  for (j = 0; j < n; j++) {
94 #ifdef COMPLEX
95  A[j+j*lda] += bump - I*cimag( A[j+j*lda] );
96 #else
97  A[j+j*lda] += bump;
98 #endif
99 
100  for (i=0; i<j; i++) {
101  A[lda*j+i] = conj( A[lda*i+j] );
102  }
103  }
104  }
105  /*
106  * Lower part
107  */
108  else if ( m0 > n0 ) {
109  for (j = 0; j < n; j++) {
110  ran = Rnd64_jump( NBELEM * jump, seed );
111 
112  for (i = 0; i < m; i++) {
113  *tmp = 0.5f - ran * RndF_Mul;
114  ran = Rnd64_A * ran + Rnd64_C;
115 #ifdef COMPLEX
116  *tmp += I*(0.5f - ran * RndF_Mul);
117  ran = Rnd64_A * ran + Rnd64_C;
118 #endif
119  tmp++;
120  }
121  tmp += (lda - i);
122  jump += bigM;
123  }
124  }
125  /*
126  * Upper part
127  */
128  else if ( m0 < n0 ) {
129  /* Overwrite jump */
130  jump = n0 + m0 * bigM;
131 
132  for (i = 0; i < m; i++) {
133  ran = Rnd64_jump( NBELEM * jump, seed );
134 
135  for (j = 0; j < n; j++) {
136  A[j*lda+i] = 0.5f - ran * RndF_Mul;
137  ran = Rnd64_A * ran + Rnd64_C;
138 #ifdef COMPLEX
139  A[j*lda+i] -= I*(0.5f - ran * RndF_Mul);
140  ran = Rnd64_A * ran + Rnd64_C;
141 #endif
142  }
143  jump += bigM;
144  }
145  }
146 }
147 
148 /***************************************************************************/
151 void QUARK_CORE_zplghe( Quark *quark, Quark_Task_Flags *task_flags,
152  double bump, int m, int n, PLASMA_Complex64_t *A, int lda,
153  int bigM, int m0, int n0, unsigned long long int seed )
154 {
156  QUARK_Insert_Task(quark, CORE_zplghe_quark, task_flags,
157  sizeof(double), &bump, VALUE,
158  sizeof(int), &m, VALUE,
159  sizeof(int), &n, VALUE,
160  sizeof(PLASMA_Complex64_t)*lda*n, A, OUTPUT,
161  sizeof(int), &lda, VALUE,
162  sizeof(int), &bigM, VALUE,
163  sizeof(int), &m0, VALUE,
164  sizeof(int), &n0, VALUE,
165  sizeof(unsigned long long int), &seed, VALUE,
166  0);
167 }
168 
169 /***************************************************************************/
172 #if defined(PLASMA_HAVE_WEAK)
173 #pragma weak CORE_zplghe_quark = PCORE_zplghe_quark
174 #define CORE_zplghe_quark PCORE_zplghe_quark
175 #endif
177 {
178  double bump;
179  int m;
180  int n;
182  int lda;
183  int bigM;
184  int m0;
185  int n0;
186  unsigned long long int seed;
187 
188  quark_unpack_args_9( quark, bump, m, n, A, lda, bigM, m0, n0, seed );
189  CORE_zplghe( bump, m, n, A, lda, bigM, m0, n0, seed );
190 }
191