26 #include "matrixlapack_magma.hpp" 29 int diag_magma_cmp(
int xNsize, std::complex<double> **A,
30 std::complex<double> *r,std::complex<double> **vec,
int ngpu){
33 fprintf(stdout,
" Error: ngpu is less than or equal to 0. ngpu = %d\n", ngpu);
34 fprintf(stdout,
" exit in this function.\n\n");
44 magma_int_t n, lda, lwork, lrwork;
45 magma_int_t *iwork, liwork;
48 magmaDoubleComplex *a, *work;
52 magma_int_t maxngpu = 0;
53 magma_device_t *dummy;
54 magma_getdevices(dummy, 9999, &maxngpu);
56 fprintf(stdout,
" Warning: ngpu is beyond maxgpu. ngpu = %d, maxngpu = %d\n", ngpu, maxngpu);
57 fprintf(stdout,
" MAGMA library executes maxngpu.\n\n");
63 magmaDoubleComplex aux_work[1];
65 magma_int_t aux_iwork[1];
72 magma_zheevd(jobz, uplo,
79 lwork = (magma_int_t) MAGMA_Z_REAL(aux_work[0]);
80 lrwork = (magma_int_t) aux_rwork[0];
81 liwork = aux_iwork[0];
84 magma_zmalloc_cpu(&a, xNsize * xNsize);
85 magma_dmalloc_cpu(&w, xNsize);
86 magma_zmalloc_pinned(&work, lwork);
87 magma_dmalloc_cpu(&rwork, lrwork);
88 magma_imalloc_cpu(&iwork, liwork);
91 for(j=0;j<xNsize;j++){
92 for(i=0;i<xNsize;i++){
93 MAGMA_Z_REAL(a[k]) = real(A[i][j]);
94 MAGMA_Z_IMAG(a[k]) = imag(A[i][j]);
100 magma_zheevd_m(ngpu, jobz, uplo,
107 magma_free_cpu(iwork);
111 magma_free_pinned(work);
112 magma_free_cpu(rwork);
117 for(i=0;i<xNsize;i++){
118 for(j=0;j<xNsize;j++){
119 vec[i][j] = MAGMA_Z_REAL(a[k]) + MAGMA_Z_IMAG(a[k]) *
I;
124 for(k=0;k<xNsize;k++){
130 magma_free_pinned(work);
131 magma_free_cpu(rwork);
138 int diag_magma_real(
int xNsize,
double **A,
139 double *r,
double **vec,
int ngpu){
142 fprintf(stdout,
" Error: ngpu is less than or equal to 0. ngpu = %d\n", ngpu);
143 fprintf(stdout,
" exit in this function.\n\n");
153 magma_int_t n, lda, lwork;
154 magma_int_t *iwork, liwork;
160 magma_int_t maxngpu = 0;
161 magma_device_t *dummy;
162 magma_getdevices(dummy, 9999, &maxngpu);
164 fprintf(stdout,
" Warning: ngpu is beyond maxgpu. ngpu = %d, maxngpu = %d\n", ngpu, maxngpu);
165 fprintf(stdout,
" MAGMA library executes maxngpu.\n\n");
172 magma_int_t aux_iwork[1];
179 magma_dsyevd(jobz, uplo,
185 lwork = (magma_int_t) MAGMA_D_REAL(aux_work[0]);
186 liwork = aux_iwork[0];
189 magma_dmalloc_cpu(&a, xNsize * xNsize);
190 magma_dmalloc_cpu(&w, xNsize);
191 magma_dmalloc_pinned(&work, lwork);
192 magma_imalloc_cpu(&iwork, liwork);
195 for(j=0;j<xNsize;j++){
196 for(i=0;i<xNsize;i++){
203 magma_dsyevd_m(ngpu, jobz, uplo,
209 magma_free_cpu(iwork);
213 magma_free_pinned(work);
218 for(i=0;i<xNsize;i++){
219 for(j=0;j<xNsize;j++){
225 for(k=0;k<xNsize;k++){
231 magma_free_pinned(work);
std::complex< double > I(0.0, 1.0)