testing_zauxiliary.c 9.97 KB
Newer Older
1
/**
2 3
 *
 * @file testing_zauxiliary.c
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
7 8
 * @copyright 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon CHAMELEON_Complex64_t auxiliary testings routines
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15 16 17 18 19
 * @author Mathieu Faverge
 * @author Cédric Castagnède
 * @date 2010-11-15
 * @precisions normal z -> c d s
 *
20
 */
21 22 23 24 25 26 27 28 29
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#else  /* Non-Windows */
#include <unistd.h>
#include <sys/resource.h>
#endif
Mathieu Faverge's avatar
Mathieu Faverge committed
30
#include <chameleon.h>
31 32 33 34 35
#include "testing_zauxiliary.h"

int   IONE     = 1;
int   ISEED[4] = {0,0,0,1};   /* initial seed for zlarnv() */

Mathieu Faverge's avatar
Mathieu Faverge committed
36 37 38 39 40 41 42 43
cham_storage_t  format[6] = { ChamCM, ChamRM, ChamCCRB, ChamCRRB, ChamRCRB, ChamRRRB };
cham_side_t     side[2]   = { ChamLeft,    ChamRight };
cham_uplo_t     uplo[2]   = { ChamUpper,   ChamLower };
cham_diag_t     diag[2]   = { ChamNonUnit, ChamUnit  };
cham_trans_t    trans[3]  = { ChamNoTrans, ChamTrans, ChamConjTrans };
int             itype[3]  = { 1, 2, 3 };
cham_store_t    storev[2] = { ChamRowwise, ChamColumnwise };
cham_normtype_t norm[4]   = { ChamMaxNorm, ChamOneNorm, ChamInfNorm, ChamFrobeniusNorm };
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

char *formatstr[6]= { "CM", "RM", "CCRB", "CRRB", "RCRB", "RRRB"};
char *sidestr[2]  = { "Left ", "Right" };
char *uplostr[2]  = { "Upper", "Lower" };
char *diagstr[2]  = { "NonUnit", "Unit   " };
char *transstr[3] = { "N", "T", "H" };
char *itypestr[3]  = { "inv(U')xAxinv(U) or inv(L)xAxinv(L')", "UxAxU' or L'xAxL", "UxAxU' or L'xAxL" };
char *storevstr[2] = { "Rowwise", "Columnwise" };
char *normstr[4]  = { "Max", "One", "Inf", "Fro" };

#define map_cm(m, n, i, j)   ((i) + (j) * (m))
#define map_rm(m, n, i, j)   ((i) * (n) + (j))

int map_CM(int m, int n, int mb, int nb, int i, int j)
{
    int hres = map_cm(m, n, i, j);
    (void)mb;
    (void)nb;
    (void)n;
    return hres;
}

int map_RM(int m, int n, int mb, int nb, int i, int j)
{
    int hres = map_rm(m, n, i, j);
    (void)mb;
    (void)nb;
    (void)m;
    return hres;
}

int map_CCRB(int m, int n, int mb, int nb, int i, int j) {
    int m0 = m - m%mb;
    int n0 = n - n%nb;
    if ( j < n0 )
        if (i < m0)
            /* Case in A11 */
            return ( map_cm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_cm( mb,   nb,   i%mb, j%nb) );
        else
            /* Case in A21 */
            return ( m0*n0 + ( (j/nb) * (nb*(m%mb)) )       + map_cm( m%mb, nb,   i%mb, j%nb) );
    else
        if (i < m0)
            /* Case in A12 */
            return ( m*n0  + ( (i/mb) * (mb*(n%nb)) )       + map_cm( mb,   n%nb, i%mb, j%nb) );
        else
            /* Case in A22 */
            return ( m*n0  + (n-n0)*m0                      + map_cm( m%mb, n%nb, i%mb, j%nb) );
}

int map_CRRB(int m, int n, int mb, int nb, int i, int j) {
    int m0 = m - m%mb;
    int n0 = n - n%nb;
    if ( j < n0 )
        if (i < m0)
            /* Case in A11 */
            return ( map_cm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_rm( mb,   nb,   i%mb, j%nb) );
        else
            /* Case in A21 */
            return ( m0*n0 + ( (j/nb) * (nb*(m%mb)) )       + map_rm( m%mb, nb,   i%mb, j%nb) );
    else
        if (i < m0)
            /* Case in A12 */
            return ( m*n0  + ( (i/mb) * (mb*(n%nb)) )       + map_rm( mb,   n%nb, i%mb, j%nb) );
        else
            /* Case in A22 */
            return ( m*n0  + (n-n0)*m0                      + map_rm( m%mb, n%nb, i%mb, j%nb) );
}

int map_RCRB(int m, int n, int mb, int nb, int i, int j) {
    int m0 = m - m%mb;
    int n0 = n - n%nb;
    if ( j < n0 )
        if (i < m0)
            /* Case in A11 */
            return ( map_rm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_cm( mb,   nb,   i%mb, j%nb) );
        else
            /* Case in A21 */
            return ( m0*n  + ( (j/nb) * (nb*(m%mb)) )       + map_cm( m%mb, nb,   i%mb, j%nb) );
    else
        if (i < m0)
            /* Case in A12 */
            return ( m0*n0 + ( (i/mb) * (mb*(n%nb)) )       + map_cm( mb,   n%nb, i%mb, j%nb) );
        else
            /* Case in A22 */
            return ( m*n0  + (n-n0)*m0                      + map_cm( m%mb, n%nb, i%mb, j%nb) );
}

int map_RRRB(int m, int n, int mb, int nb, int i, int j) {
    int m0 = m - m%mb;
    int n0 = n - n%nb;
    if ( j < n0 )
        if (i < m0)
            /* Case in A11 */
            return ( map_rm( m/mb, n/nb, i/mb, j/nb )*mb*nb + map_rm( mb,   nb,   i%mb, j%nb) );
        else
            /* Case in A21 */
            return ( m0*n  + ( (j/nb) * (nb*(m%mb)) )       + map_rm( m%mb, nb,   i%mb, j%nb) );
    else
        if (i < m0)
            /* Case in A12 */
            return ( m0*n0 + ( (i/mb) * (mb*(n%nb)) )       + map_rm( mb,   n%nb, i%mb, j%nb) );
        else
            /* Case in A22 */
            return ( m*n0  + (n-n0)*m0                      + map_rm( m%mb, n%nb, i%mb, j%nb) );
}

151
int (*formatmap[6])(int, int, int, int, int, int) = {  map_CM, map_RM, map_CCRB, map_CRRB, map_RCRB, map_RRRB };
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

int main (int argc, char **argv)
{
    int ncores, ngpus;
    int info = 0;
    char func[32];

    /* Check for number of arguments*/
    if ( argc < 4) {
        printf(" Proper Usage is : ./ztesting ncores ngpus FUNC ...\n"
               "   - ncores : number of cores\n"
               "   - ngpus  : number of GPUs\n"
               "   - FUNC   : name of function to test\n"
               "   - ... plus arguments depending on the testing function \n");
        exit(1);
    }

169 170 171
    sscanf( argv[1], "%d",   &ncores );
    sscanf( argv[2], "%d",   &ngpus  );
    sscanf( argv[3], "%31s",  func   );
172

Mathieu Faverge's avatar
Mathieu Faverge committed
173
    /* Initialize CHAMELEON */
174
    /*if(nthreads_per_worker)
Mathieu Faverge's avatar
Mathieu Faverge committed
175
     CHAMELEON_InitPar(ncores/nthreads_per_worker, ncudas, nthreads_per_worker);
176
     else*/
Mathieu Faverge's avatar
Mathieu Faverge committed
177 178 179 180
    CHAMELEON_Init( ncores, ngpus);
    CHAMELEON_Disable(CHAMELEON_AUTOTUNING);
    CHAMELEON_Set(CHAMELEON_TILE_SIZE,         32 );
    CHAMELEON_Set(CHAMELEON_INNER_BLOCK_SIZE,   5 );
181 182 183 184 185 186 187 188 189 190

    argc -= 4;
    argv += 4;
    info  = 0;

    /*
     * Norms
     */
    if ( strcmp(func, "LANGE") == 0 ) {
        info += testing_zlange( argc, argv );
191 192 193 194 195
    }
    /*
     * Blas Level 3
     */
    else if ( strcmp(func, "GEMM") == 0 ) {
196
        info += testing_zgemm( argc, argv );
197
    }
198
#if defined(PRECISION_z) || defined(PRECISION_c)
199
    else if ( strcmp(func, "HEMM") == 0 ) {
200
        info += testing_zhemm( argc, argv );
201 202
    }
    else if ( strcmp(func, "HERK") == 0 ) {
203
        info += testing_zherk( argc, argv );
204 205
    }
    else if ( strcmp(func, "HER2K") == 0 ) {
206
        info += testing_zher2k( argc, argv );
207
    }
208
#endif
209
    else if ( strcmp(func, "SYMM") == 0 ) {
210
        info += testing_zsymm( argc, argv );
211 212
    }
    else if ( strcmp(func, "SYRK") == 0 ) {
213
        info += testing_zsyrk( argc, argv );
214 215
    }
    else if ( strcmp(func, "SYR2K") == 0 ) {
216
        info += testing_zsyr2k( argc, argv );
217 218
    }
    else if ( strcmp(func, "TRMM") == 0 ) {
219
        info += testing_ztrmm( argc, argv );
220 221
    }
    else if ( strcmp(func, "TRSM") == 0 ) {
222
        info += testing_ztrsm( argc, argv );
223 224
    }
    else if ( strcmp(func, "PEMV") == 0 ) {
225
        info += testing_zpemv( argc, argv );
226 227
    }
    else if ( strcmp(func, "GEADD") == 0 ) {
228
        info = testing_zgeadd( argc, argv );
229 230 231 232 233
    }
    /*
     * Linear system
     */
    else if ( strcmp(func, "POSV") == 0 ) {
234
        info += testing_zposv( argc, argv );
235 236
    }
    else if ( strcmp(func, "GELS") == 0 ) {
237
        info += testing_zgels( argc, argv );
238 239
    }
    else if ( strcmp(func, "GESV_INCPIV") == 0 ) {
240
        info += testing_zgesv_incpiv( argc, argv );
241
    }
242 243 244 245 246 247
    else if ( strcmp(func, "GELS_HQR") == 0 ) {
        info += testing_zgels_hqr( argc, argv );
    }
    else if ( strcmp(func, "GELS_SYSTOLIC") == 0 ) {
        info += testing_zgels_systolic( argc, argv );
    }
248 249 250 251 252 253 254
    /* else if ( strcmp(func, "GESV") == 0 ) { */
    /*     info += testing_zgesv( argc, argv ); */
    /* } */
    /*
     * Matrix inversion
     */
    else if ( strcmp(func, "POTRI") == 0 ) {
255
        info += testing_zpotri( argc, argv );
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
    }
    /* else if ( strcmp(func, "GETRI") == 0 ) { */
    /*      info += testing_zgetri( argc, argv ); */
    /* } */
    /*
     * Eigenvalue Problems
     */
    /* else if ( strcmp(func, "HEEV") == 0 ) { */
    /*     info += testing_zheev( argc, argv ); */
    /* } */
    else if ( strcmp(func, "HEEVD") == 0 ) {
        info += testing_zheevd( argc, argv );
    }
    /* else if ( strcmp(func, "HEGV") == 0 ) { */
    /*     info += testing_zhegv( argc, argv ); */
    /* } */
    /* else if ( strcmp(func, "HEGVD") == 0 ) { */
    /*     info += testing_zhegv( argc, argv ); */
    /* } */
    /* else if ( strcmp(func, "HEGST") == 0 ) { */
    /*     info += testing_zhegst( argc, argv ); */
    /* } */
    /*
     * Singular Value Decomposition
     */
    else if ( strcmp(func, "GESVD") == 0 ) {
        info += testing_zgesvd( argc, argv );
    }
284
#ifdef DOUBLE
285 286 287 288 289 290 291 292 293 294 295 296
    /*
     * Mixed precision
     */
    /* else if ( strcmp(func, "CPOSV") == 0 ) { */
    /*     info += testing_zcposv( argc, argv ); */
    /* } */
    /* else if ( strcmp(func, "CGESV") == 0 ) { */
    /*     info += testing_zcgesv( argc, argv ); */
    /* } */
    /* else if ( strcmp(func, "CUNGESV") == 0 ) { */
    /*     info += testing_zcungesv( argc, argv ); */
    /* } */
297
#endif
298 299 300 301 302 303 304 305 306
    /*
     * Layout Transformation
     */
    /* else if ( strcmp(func, "GECFI") == 0 ) { */
    /*     info += testing_zgecfi( argc, argv ); */
    /* } */
    /* else if ( strcmp(func, "GETMI") == 0 ) { */
    /*     info += testing_zgetmi( argc, argv ); */
    /* } */
307 308 309
    else if ( strcmp(func, "GEQRF_QDWH") == 0 ) {
        info += testing_zgeqrf_qdwh( argc, argv );
    }
310
    else {
311 312 313 314 315 316 317 318 319
        fprintf(stderr, "Function unknown\n");
    }

    if ( info == -1 ) {
        printf( "TESTING %s FAILED : incorrect number of arguments\n", func);
    } else if ( info == -2 ) {
        printf( "TESTING %s FAILED : not enough memory\n", func);
    }

Mathieu Faverge's avatar
Mathieu Faverge committed
320
    CHAMELEON_Finalize();
321 322 323

    return info;
}