HiCMA
Hierarchical Computations on Manycore Architectures
hcore_zhagcm.c
Go to the documentation of this file.
1 
16 //#include "hcore/include/hcore.h"
17 #include "morse.h"
18 #include "hcore_z.h"
19 #include <assert.h>
20 #include <stdio.h>
21 #include <sys/time.h>//FIXME for gettimeofday
22 
23 #include "hicma.h"
24 #include "hicma_common.h"
25 
26 #include "starsh.h"
27 #include "starsh-spatial.h"
28 #include "starsh-randtlr.h"
29 #ifdef LAPACKE_UTILS
30 #include <lapacke_utils.h>
31 #endif
32 #include "coreblas/coreblas.h"
33 #include "coreblas/lapacke.h"
34 
35 extern void _printmat(double * A, int m, int n, int ld);
36 
37 void HCORE_zhagcm( int m, int n, /*dimension of squareAD*/
38  double *AU,
39  double *AV,
40  double *Ark,
41  int ldu,
42  int ldv,
43  int tile_row_index, int tile_column_index,
44  int maxrank, double tol)
45 {
46  int ii = tile_row_index;
47  int jj = tile_column_index;
48  int64_t i, j;
49  int lda = ldu; //FIXME ASSUMPTION
50  struct timeval tvalBefore, tvalAfter; // removed comma
51  gettimeofday (&tvalBefore, NULL);
52  if(HICMA_get_print_index() == 1 ){
53  fprintf(stderr, "%d+HAGcM\t|(%d,%d) m:%d n:%d lda:%d ldu:%d ldv:%d\n",MORSE_My_Mpi_Rank(), ii, jj, m, n, lda, ldu, ldv);
54  }
55 
56  int shape[2];
57  int rank = 0;
58  int oversample = 10;
59  double *work;
60  int *iwork;
61  STARSH_cluster *RC = HICMA_get_starsh_format()->row_cluster, *CC = RC;
62  void *RD = RC->data, *CD = RD;
63  double *AD;
64  AD = malloc(sizeof(double) * lda * n);
65  //starsh_blrf_get_block(HICMA_get_starsh_format(), ii, jj, shape, &AD);
66 
67  HICMA_get_starsh_format()->problem->kernel(m, n, RC->pivot+RC->start[ii], CC->pivot+CC->start[jj],
68  RD, CD, AD, lda);
69  int mn = m;
70  int mn2 = maxrank+oversample;
71  if(mn2 > mn)
72  mn2 = mn;
73  // Get size of temporary arrays
74  size_t lwork = n, lwork_sdd = (4*mn2+7)*mn2;
75  if(lwork_sdd > lwork)
76  lwork = lwork_sdd;
77  lwork += (size_t)mn2*(2*n+m+mn2+1);
78  size_t liwork = 8*mn2;
79  // Allocate temporary arrays
80  //STARSH_MALLOC(iwork, liwork);
81  iwork = malloc(sizeof(*iwork) * liwork);
82  if(iwork == NULL) {
83  fprintf(stderr, "%s %s %d:\t Allocation failed. No memory! liwork:%d", __FILE__, __func__, __LINE__, liwork);
84  exit(-1);
85  }
86  //STARSH_MALLOC(work, lwork);
87  work = malloc(sizeof(*work) * lwork);
88  if(work == NULL) {
89  fprintf(stderr, "%s %s %d:\t Allocation failed. No memory! lwork:%d", __FILE__, __func__, __LINE__, lwork);
90  exit(-1);
91  }
92  starsh_dense_dlrrsdd(m, n, AD, lda, AU, ldu, AV, ldv, &rank, maxrank, oversample, tol, work, lwork, iwork);
93 
94  Ark[0] = rank;
95  if(HICMA_get_always_fixed_rank() == 1) {
97  }
98  if(HICMA_get_print_mat() == 1){
99  printf("%d\thagcm-UV-output\n", __LINE__);
100  _printmat(AD, m, n, lda);
101  _printmat(AU, m, rank, ldu);
102  _printmat(AV, ldv, rank, ldv);
103  }
104 
105  free(work);
106  free(iwork);
107  if(HICMA_get_print_index_end() == 1 ||
108  HICMA_get_print_index() == 1 ){
109  gettimeofday (&tvalAfter, NULL);
110  fprintf(stderr, "%d-HAGcM\t|(%d,%d) rk:%g m:%d n:%d lda:%d ldu:%d ldv:%d\t\t\t\t\tHAGcM: %.4f\n",MORSE_My_Mpi_Rank(),ii,jj,Ark[0],m, n, lda, ldu, ldv,
111  (tvalAfter.tv_sec - tvalBefore.tv_sec)
112  +(tvalAfter.tv_usec - tvalBefore.tv_usec)/1000000.0
113  );
114  }
115 }
116 
117 
118 
#define A(m, n)
Definition: pzgemm.c:56
void _printmat(double *A, int m, int n, int ld)
void HCORE_zhagcm(int m, int n, double *AU, double *AV, double *Ark, int ldu, int ldv, int tile_row_index, int tile_column_index, int maxrank, double tol)
Definition: hcore_zhagcm.c:37
int HICMA_get_print_mat()
Definition: hicma_init.c:56
int HICMA_set_fixed_rank(int rank)
Definition: hicma_init.c:46
int HICMA_get_print_index_end()
Definition: hicma_init.c:53
int HICMA_get_print_index()
Definition: hicma_init.c:50
STARSH_blrf * HICMA_get_starsh_format()
Definition: hicma_init.c:37
int HICMA_get_always_fixed_rank()
Definition: hicma_init.c:40