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
testing_cgecfi.c
Go to the documentation of this file.
1 
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <lapacke.h>
27 #include <plasma.h>
28 #include "testing_cmain.h"
29 
30 static int conversions[36][2] = {
31  /* No conversion */
32  { PlasmaCM, PlasmaCM },
37  { PlasmaRM, PlasmaRM },
38  /* One Conversion */
39  { PlasmaCM, PlasmaCCRB },
40  { PlasmaCCRB, PlasmaCM },
41  { PlasmaRM, PlasmaRRRB },
42  { PlasmaRRRB, PlasmaRM },
51  /* Two Conversions */
52  { PlasmaRM, PlasmaCRRB },
53  { PlasmaCRRB, PlasmaRM },
54  { PlasmaCM, PlasmaRCRB },
55  { PlasmaRCRB, PlasmaCM },
60  { PlasmaCM, PlasmaCRRB },
61  { PlasmaCRRB, PlasmaCM },
62  { PlasmaRCRB, PlasmaRM },
63  { PlasmaRM, PlasmaRCRB },
64  /* Three Conversions */
65  { PlasmaCM, PlasmaRRRB },
66  { PlasmaRRRB, PlasmaCM },
67  { PlasmaCCRB, PlasmaRM },
68  { PlasmaRM, PlasmaCCRB },
69  /* Three Conversions */
70  { PlasmaCM, PlasmaRM },
71  { PlasmaRM, PlasmaCM },
72 };
73 
74 static int check_solution(int m, int n, int mba, int nba, int mbb, int nbb,
76  int (*mapA)(int, int, int, int, int, int), int (*mapB)(int, int, int, int, int, int)) {
77  int i, j;
78 
79  for( j=0; j<n; j++) {
80  for (i=0; i<m; i++) {
81  if (A[ mapA(m, n, mba, nba, i, j) ] != B[ mapB(m, n, mbb, nbb, i, j) ] ) {
82  return -1;
83  }
84  }
85  }
86  return 0;
87 }
88 
89 int testing_cgecfi(int argc, char **argv){
90 
92  int m, n, mb, nb, mb2, nb2;
93  int i, ret, size;
94  int f1, f2;
95 
96  /* Check for number of arguments*/
97  if (argc != 6){
98  USAGE("GECFI", "M N MB NB with \n",
99  " - M : the number of rows of the matrix \n"
100  " - N : the number of columns of the matrix \n"
101  " - MB : the number of rows of each block \n"
102  " - NB : the number of columns of each block \n"
103  " - MB2 : the number of rows of each block \n"
104  " - NB2 : the number of columns of each block \n");
105  return -1;
106  }
107 
108  m = atoi(argv[0]);
109  n = atoi(argv[1]);
110  mb = atoi(argv[2]);
111  nb = atoi(argv[3]);
112  mb2 = atoi(argv[4]);
113  nb2 = atoi(argv[5]);
114 
115  /* Initialize Plasma */
116  size = m*n*sizeof(PLASMA_Complex32_t);
117  A = (PLASMA_Complex32_t *)malloc(size);
118  B = (PLASMA_Complex32_t *)malloc(size);
119  LAPACKE_clarnv_work(1, ISEED, m*n, A);
120 
121  for(i=0; i<36; i++) {
122  memcpy(B, A, size);
123 
124  f1 = conversions[i][0]-PlasmaCM;
125  f2 = conversions[i][1]-PlasmaCM;
126 
127  printf(" - TESTING CGECFI (%4s => %4s) ...", formatstr[f1], formatstr[f2] );
128 
129  ret = PLASMA_cgecfi(m, n, B, conversions[i][0], mb, nb, conversions[i][1], mb2, nb2);
130 
131  if (ret != PLASMA_SUCCESS) {
132  printf("Failed\n");
133  continue;
134  }
135 
136  if ( check_solution(m, n, mb, nb, mb2, nb2, A, B,
137  (int (*)(int, int, int, int, int, int))formatmap[f1],
138  (int (*)(int, int, int, int, int, int))formatmap[f2] ) == 0 )
139  printf("............ PASSED !\n");
140  else
141  printf("... FAILED !\n");
142 
143 #if 0
144  {
145  char cmd[256];
146 
147  PLASMA_Finalize();
148  sprintf(cmd, "mv $PWD/dot_dag_file.dot $PWD/cgecfi_%s_%s.dot", formatstr[f1], formatstr[f2]);
149  system(cmd);
150 
151  PLASMA_Init(0);
153  }
154 #endif
155  }
156 
157  free( A ); free( B );
158 
159  return 0;
160 }