MAGMA  magma-1.4.0
Matrix Algebra on GPU and Multicore Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
testings.h
Go to the documentation of this file.
1 #ifndef TESTINGS_H
2 #define TESTINGS_H
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7 
8 #include "magma.h"
9 
10 #ifndef min
11 #define min(a,b) (((a)<(b))?(a):(b))
12 #endif
13 
14 #ifndef max
15 #define max(a,b) (((a)<(b))?(b):(a))
16 #endif
17 
18 
19 #define TESTING_INIT() \
20  magma_init(); \
21  if( CUBLAS_STATUS_SUCCESS != cublasInit() ) { \
22  fprintf(stderr, "ERROR: cublasInit failed\n"); \
23  magma_finalize(); \
24  exit(-1); \
25  } \
26  magma_print_devices();
27 
28 
29 #define TESTING_FINALIZE() \
30  magma_finalize(); \
31  cublasShutdown();
32 
33 
34 #define TESTING_INIT_MGPU() \
35 { \
36  magma_init(); \
37  int ndevices; \
38  cudaGetDeviceCount( &ndevices ); \
39  for( int idevice = 0; idevice < ndevices; ++idevice ) { \
40  magma_setdevice( idevice ); \
41  if( CUBLAS_STATUS_SUCCESS != cublasInit() ) { \
42  fprintf(stderr, "ERROR: gpu %d: cublasInit failed\n", idevice);\
43  magma_finalize(); \
44  exit(-1); \
45  } \
46  } \
47  magma_setdevice(0); \
48  magma_print_devices(); \
49 }
50 
51 
52 #define TESTING_FINALIZE_MGPU() \
53 { \
54  magma_finalize(); \
55  int ndevices; \
56  cudaGetDeviceCount( &ndevices ); \
57  for( int idevice = 0; idevice < ndevices; ++idevice ) { \
58  magma_setdevice(idevice); \
59  cublasShutdown(); \
60  } \
61 }
62 
63 
64 #define TESTING_MALLOC( ptr, type, size ) \
65  if ( MAGMA_SUCCESS != \
66  magma_malloc_cpu( (void**) &ptr, (size)*sizeof(type) )) { \
67  fprintf( stderr, "!!!! malloc failed for: %s\n", #ptr ); \
68  magma_finalize(); \
69  exit(-1); \
70  }
71 
72 
73 #define TESTING_HOSTALLOC( ptr, type, size ) \
74  if ( MAGMA_SUCCESS != \
75  magma_malloc_pinned( (void**) &ptr, (size)*sizeof(type) )) { \
76  fprintf( stderr, "!!!! magma_malloc_pinned failed for: %s\n", #ptr ); \
77  magma_finalize(); \
78  exit(-1); \
79  }
80 
81 
82 #define TESTING_DEVALLOC( ptr, type, size ) \
83  if ( MAGMA_SUCCESS != \
84  magma_malloc( (void**) &ptr, (size)*sizeof(type) )) { \
85  fprintf( stderr, "!!!! magma_malloc failed for: %s\n", #ptr ); \
86  magma_finalize(); \
87  exit(-1); \
88  }
89 
90 
91 #define TESTING_FREE( ptr ) \
92  magma_free_cpu( ptr )
93 
94 
95 #define TESTING_HOSTFREE( ptr ) \
96  magma_free_pinned( ptr )
97 
98 
99 #define TESTING_DEVFREE( ptr ) \
100  magma_free( ptr )
101 
102 
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 
107 void magma_zmake_hermitian( magma_int_t N, magmaDoubleComplex* A, magma_int_t lda );
108 void magma_cmake_hermitian( magma_int_t N, magmaFloatComplex* A, magma_int_t lda );
109 void magma_dmake_symmetric( magma_int_t N, double* A, magma_int_t lda );
110 void magma_smake_symmetric( magma_int_t N, float* A, magma_int_t lda );
111 
112 void magma_zmake_hpd( magma_int_t N, magmaDoubleComplex* A, magma_int_t lda );
113 void magma_cmake_hpd( magma_int_t N, magmaFloatComplex* A, magma_int_t lda );
114 void magma_dmake_hpd( magma_int_t N, double* A, magma_int_t lda );
115 void magma_smake_hpd( magma_int_t N, float* A, magma_int_t lda );
116 
117 void magma_assert( bool condition, const char* msg, ... );
118 
119 #define MAX_NTEST 1000
120 
121 typedef struct magma_opts
122 {
123  // matrix size
131 
132  // scalars
140  magma_int_t itype; // hegvd: problem type
142  magma_int_t version; // hemm_mgpu, hetrd
143  double fraction; // hegvdx
144  double tolerance;
145 
146  // boolean arguments
147  int check;
148  int lapack;
149  int warmup;
150  int all;
151 
152  // lapack flags
158  magma_vec_t jobu; // gesvd: no left singular vectors
159  magma_vec_t jobvt; // gesvd: no right singular vectors
160  magma_vec_t jobz; // heev: no eigen vectors
161  magma_vec_t jobvr; // geev: no right eigen vectors
162  magma_vec_t jobvl; // geev: no left eigen vectors
163 } magma_opts;
164 
165 void parse_opts( int argc, char** argv, magma_opts *opts );
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* TESTINGS_H */
void parse_opts(int argc, char **argv, magma_opts *opts)
magma_vec_t jobvt
Definition: testings.h:159
magma_int_t ntest
Definition: testings.h:124
void magma_cmake_hpd(magma_int_t N, magmaFloatComplex *A, magma_int_t lda)
#define MAX_NTEST
Definition: testings.h:119
char magma_diag_t
Definition: magma_types.h:379
void magma_cmake_hermitian(magma_int_t N, magmaFloatComplex *A, magma_int_t lda)
magma_int_t nstream
Definition: testings.h:136
magma_diag_t diag
Definition: testings.h:157
magma_trans_t transA
Definition: testings.h:154
magma_int_t niter
Definition: testings.h:138
magma_vec_t jobz
Definition: testings.h:160
int magma_int_t
Definition: magmablas.h:12
struct magma_opts magma_opts
int warmup
Definition: testings.h:149
char magma_trans_t
Definition: magma_types.h:377
void magma_smake_hpd(magma_int_t N, float *A, magma_int_t lda)
magma_int_t svd_work
Definition: testings.h:141
void magma_zmake_hpd(magma_int_t N, magmaDoubleComplex *A, magma_int_t lda)
magma_vec_t jobvr
Definition: testings.h:161
char magma_side_t
Definition: magma_types.h:380
magma_int_t ngpu
Definition: testings.h:137
magma_int_t nrhs
Definition: testings.h:135
magma_int_t version
Definition: testings.h:142
int check
Definition: testings.h:147
magma_side_t side
Definition: testings.h:156
magma_vec_t jobvl
Definition: testings.h:162
double fraction
Definition: testings.h:143
char magma_vec_t
Definition: magma_types.h:384
void magma_dmake_hpd(magma_int_t N, double *A, magma_int_t lda)
magma_int_t nb
Definition: testings.h:134
magma_int_t nmax
Definition: testings.h:129
void magma_smake_symmetric(magma_int_t N, float *A, magma_int_t lda)
#define A(i, j)
Definition: cprint.cpp:16
void magma_dmake_symmetric(magma_int_t N, double *A, magma_int_t lda)
magma_int_t nsize[MAX_NTEST]
Definition: testings.h:126
magma_int_t nthread
Definition: testings.h:139
magma_int_t kmax
Definition: testings.h:130
char magma_uplo_t
Definition: magma_types.h:378
magma_int_t itype
Definition: testings.h:140
magma_int_t device
Definition: testings.h:133
magma_trans_t transB
Definition: testings.h:155
magma_int_t mmax
Definition: testings.h:128
magma_int_t ksize[MAX_NTEST]
Definition: testings.h:127
void magma_assert(bool condition, const char *msg,...)
magma_vec_t jobu
Definition: testings.h:158
magma_uplo_t uplo
Definition: testings.h:153
magma_int_t msize[MAX_NTEST]
Definition: testings.h:125
void magma_zmake_hermitian(magma_int_t N, magmaDoubleComplex *A, magma_int_t lda)
double tolerance
Definition: testings.h:144
int lapack
Definition: testings.h:148