HiCMA
Hierarchical Computations on Manycore Architectures
testing_zauxiliary.c
Go to the documentation of this file.
1 
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #if defined( _WIN32 ) || defined( _WIN64 )
30 #include <windows.h>
31 #else /* Non-Windows */
32 #include <unistd.h>
33 #include <sys/resource.h>
34 #endif
35 #include <morse.h>
36 #undef REAL
37 #define COMPLEX
38 #undef SINGLE
39 #define DOUBLE
40 #include "testing_zauxiliary.h"
41 
42 int IONE = 1;
43 int ISEED[4] = {0,0,0,1}; /* initial seed for zlarnv() */
44 
45 int format[6]= { MorseCM, MorseRM, MorseCCRB, MorseCRRB, MorseRCRB, MorseRRRB };
46 int side[2] = { MorseLeft, MorseRight };
47 int uplo[2] = { MorseUpper, MorseLower };
48 int diag[2] = { MorseNonUnit, MorseUnit };
49 int trans[3] = { MorseNoTrans, MorseTrans, MorseConjTrans };
50 int itype[3] = { 1, 2, 3 };
51 int storev[2] = { MorseRowwise, MorseColumnwise };
52 int norm[4] = { MorseMaxNorm, MorseOneNorm, MorseInfNorm, MorseFrobeniusNorm };
53 
54 char *formatstr[6]= { "CM", "RM", "CCRB", "CRRB", "RCRB", "RRRB"};
55 char *sidestr[2] = { "Left ", "Right" };
56 char *uplostr[2] = { "Upper", "Lower" };
57 char *diagstr[2] = { "NonUnit", "Unit " };
58 char *transstr[3] = { "N", "T", "H" };
59 char *itypestr[3] = { "inv(U')xAxinv(U) or inv(L)xAxinv(L')", "UxAxU' or L'xAxL", "UxAxU' or L'xAxL" };
60 char *storevstr[2] = { "Rowwise", "Columnwise" };
61 char *normstr[4] = { "Max", "One", "Inf", "Fro" };
62 
63 #define map_cm(m, n, i, j) ((i) + (j) * (m))
64 #define map_rm(m, n, i, j) ((i) * (n) + (j))
65 
66 int map_CM(int m, int n, int mb, int nb, int i, int j)
67 {
68  int hres = map_cm(m, n, i, j);
69  (void)mb;
70  (void)nb;
71  (void)n;
72  return hres;
73 }
74 
75 int map_RM(int m, int n, int mb, int nb, int i, int j)
76 {
77  int hres = map_rm(m, n, i, j);
78  (void)mb;
79  (void)nb;
80  (void)m;
81  return hres;
82 }
83 
84 int map_CCRB(int m, int n, int mb, int nb, int i, int j) {
85  int m0 = m - m%mb;
86  int n0 = n - n%nb;
87  if ( j < n0 )
88  if (i < m0)
89  /* Case in A11 */
90  return ( map_cm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_cm( mb, nb, i%mb, j%nb) );
91  else
92  /* Case in A21 */
93  return ( m0*n0 + ( (j/nb) * (nb*(m%mb)) ) + map_cm( m%mb, nb, i%mb, j%nb) );
94  else
95  if (i < m0)
96  /* Case in A12 */
97  return ( m*n0 + ( (i/mb) * (mb*(n%nb)) ) + map_cm( mb, n%nb, i%mb, j%nb) );
98  else
99  /* Case in A22 */
100  return ( m*n0 + (n-n0)*m0 + map_cm( m%mb, n%nb, i%mb, j%nb) );
101 }
102 
103 int map_CRRB(int m, int n, int mb, int nb, int i, int j) {
104  int m0 = m - m%mb;
105  int n0 = n - n%nb;
106  if ( j < n0 )
107  if (i < m0)
108  /* Case in A11 */
109  return ( map_cm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_rm( mb, nb, i%mb, j%nb) );
110  else
111  /* Case in A21 */
112  return ( m0*n0 + ( (j/nb) * (nb*(m%mb)) ) + map_rm( m%mb, nb, i%mb, j%nb) );
113  else
114  if (i < m0)
115  /* Case in A12 */
116  return ( m*n0 + ( (i/mb) * (mb*(n%nb)) ) + map_rm( mb, n%nb, i%mb, j%nb) );
117  else
118  /* Case in A22 */
119  return ( m*n0 + (n-n0)*m0 + map_rm( m%mb, n%nb, i%mb, j%nb) );
120 }
121 
122 int map_RCRB(int m, int n, int mb, int nb, int i, int j) {
123  int m0 = m - m%mb;
124  int n0 = n - n%nb;
125  if ( j < n0 )
126  if (i < m0)
127  /* Case in A11 */
128  return ( map_rm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_cm( mb, nb, i%mb, j%nb) );
129  else
130  /* Case in A21 */
131  return ( m0*n + ( (j/nb) * (nb*(m%mb)) ) + map_cm( m%mb, nb, i%mb, j%nb) );
132  else
133  if (i < m0)
134  /* Case in A12 */
135  return ( m0*n0 + ( (i/mb) * (mb*(n%nb)) ) + map_cm( mb, n%nb, i%mb, j%nb) );
136  else
137  /* Case in A22 */
138  return ( m*n0 + (n-n0)*m0 + map_cm( m%mb, n%nb, i%mb, j%nb) );
139 }
140 
141 int map_RRRB(int m, int n, int mb, int nb, int i, int j) {
142  int m0 = m - m%mb;
143  int n0 = n - n%nb;
144  if ( j < n0 )
145  if (i < m0)
146  /* Case in A11 */
147  return ( map_rm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_rm( mb, nb, i%mb, j%nb) );
148  else
149  /* Case in A21 */
150  return ( m0*n + ( (j/nb) * (nb*(m%mb)) ) + map_rm( m%mb, nb, i%mb, j%nb) );
151  else
152  if (i < m0)
153  /* Case in A12 */
154  return ( m0*n0 + ( (i/mb) * (mb*(n%nb)) ) + map_rm( mb, n%nb, i%mb, j%nb) );
155  else
156  /* Case in A22 */
157  return ( m*n0 + (n-n0)*m0 + map_rm( m%mb, n%nb, i%mb, j%nb) );
158 }
159 
160 int (*formatmap[6])(int, int, int, int, int, int) = { map_CM, map_RM, map_CCRB, map_CRRB, map_RCRB, map_RRRB };
161 
162 int main (int argc, char **argv)
163 {
164  int ncores, ngpus;
165  int info = 0;
166  char func[32];
167 
168  /* Check for number of arguments*/
169  if ( argc < 4) {
170  printf(" Proper Usage is : ./ztesting ncores ngpus FUNC ...\n"
171  " - ncores : number of cores\n"
172  " - ngpus : number of GPUs\n"
173  " - FUNC : name of function to test\n"
174  " - ... plus arguments depending on the testing function \n");
175  exit(1);
176  }
177 
178  sscanf( argv[1], "%d", &ncores );
179  sscanf( argv[2], "%d", &ngpus );
180  sscanf( argv[3], "%31s", func );
181 
182  /* Initialize MORSE */
183  /*if(nthreads_per_worker)
184  MORSE_InitPar(ncores/nthreads_per_worker, ncudas, nthreads_per_worker);
185  else*/
186  MORSE_Init( ncores, ngpus);
187  MORSE_Disable(MORSE_AUTOTUNING);
188  MORSE_Set(MORSE_TILE_SIZE, 32 );
189  MORSE_Set(MORSE_INNER_BLOCK_SIZE, 5 );
190 
191  argc -= 4;
192  argv += 4;
193  info = 0;
194 
195  /*
196  * Linear system
197  */
198  if ( strcmp(func, "posv") == 0 ) {
199  info += testing_dposv( argc, argv );
200  }
201  else if ( strcmp(func, "trsmd") == 0 ) {
202  info += testing_dtrsmd( argc, argv );
203  }
204  else {
205  fprintf(stderr, "Function unknown\n");
206  }
207 
208  if ( info == -1 ) {
209  printf( "TESTING %s FAILED : incorrect number of arguments\n", func);
210  } else if ( info == -2 ) {
211  printf( "TESTING %s FAILED : not enough memory\n", func);
212  }
213 
214  MORSE_Finalize();
215 
216  return info;
217 }
int map_CRRB(int m, int n, int mb, int nb, int i, int j)
int map_RRRB(int m, int n, int mb, int nb, int i, int j)
int itype[3]
#define map_cm(m, n, i, j)
char * transstr[3]
char * formatstr[6]
int norm[4]
char * normstr[4]
char * diagstr[2]
int format[6]
int main(int argc, char **argv)
int map_RCRB(int m, int n, int mb, int nb, int i, int j)
int map_RM(int m, int n, int mb, int nb, int i, int j)
int storev[2]
char * uplostr[2]
int side[2]
int(* formatmap[6])(int, int, int, int, int, int)
int IONE
int diag[2]
char * storevstr[2]
int testing_dtrsmd(int argc, char **argv)
char * sidestr[2]
char * itypestr[3]
#define map_rm(m, n, i, j)
int trans[3]
int map_CM(int m, int n, int mb, int nb, int i, int j)
int uplo[2]
int map_CCRB(int m, int n, int mb, int nb, int i, int j)
int testing_dposv(int argc, char **argv)
int ISEED[4]