HiCMA
Hierarchical Computations on Manycore Architectures
codelet_zpotrf.c
Go to the documentation of this file.
1 
16 #include "coreblas/lapacke.h"
17 #include "morse.h"
18 #include "runtime/starpu/chameleon_starpu.h"
19 //#include "runtime/starpu/include/runtime_codelet_z.h"
20 #include "auxdescutil.h"
21 
22 #include <sys/time.h>
23 
24 #include "runtime/starpu/runtime_codelets.h"
25 ZCODELETS_HEADER(potrf_hcore)
26 
27 void HICMA_TASK_zpotrf(const MORSE_option_t *options,
28  MORSE_enum uplo, int n, int nb,
29  const MORSE_desc_t *A, int Am, int An, int lda,
30  int iinfo)
31 {
32  (void)nb;
33  struct starpu_codelet *codelet = &cl_zpotrf_hcore;
34  /*void (*callback)(void*) = options->profiling ? cl_zpotrf_callback : NULL;*/
35  void (*callback)(void*) = NULL;
36 
37  MORSE_BEGIN_ACCESS_DECLARATION;
38  MORSE_ACCESS_RW(A, Am, An);
39  MORSE_END_ACCESS_DECLARATION;
40  starpu_insert_task(
41  starpu_mpi_codelet(codelet),
42  STARPU_VALUE, &uplo, sizeof(MORSE_enum),
43  STARPU_VALUE, &n, sizeof(int),
44  STARPU_RW, RTBLKADDR(A, double, Am, An),
45  STARPU_VALUE, &lda, sizeof(int),
46  STARPU_VALUE, &iinfo, sizeof(int),
47  STARPU_VALUE, &Am, sizeof(int),
48  STARPU_VALUE, &An, sizeof(int),
49  /* STARPU_SCRATCH, options->ws_worker, */
50  STARPU_PRIORITY, options->priority,
51  STARPU_CALLBACK, callback,
52 #if defined(CHAMELEON_CODELETS_HAVE_NAME)
53  STARPU_NAME, "hcore_zpotrf",
54 #endif
55  0);
56 }
57 
58 #if !defined(CHAMELEON_SIMULATION)
59 static void cl_zpotrf_hcore_cpu_func(void *descr[], void *cl_arg)
60 {
61 #ifdef HICMA_DISABLE_ALL_COMPUTATIONS
62  return;
63 #endif
64  struct timeval tvalBefore, tvalAfter; // removed comma
65  gettimeofday (&tvalBefore, NULL);
66 
67  MORSE_enum uplo;
68  int n;
69  double *A;
70  int lda;
71  int iinfo;
72  int info = 0;
73  int Am;
74  int An;
75 
76  A = (double *)STARPU_MATRIX_GET_PTR(descr[0]);
77 
78  starpu_codelet_unpack_args(cl_arg, &uplo, &n, &lda, &iinfo, &Am, &An);
79  if(HICMA_get_print_index() == 1){
80  printf("%d+POTRF\t|AD(%d,%d)\n",MORSE_My_Mpi_Rank(), Am,An);
81  }
82  if(HICMA_get_print_mat() == 1){
83  printf("%d\tpotrf-input\n", __LINE__);
84  _printmat(A, n, n, lda);
85  }
86  //CORE_zpotrf(uplo, n, A, lda, &info);
87  info = LAPACKE_dpotrf_work(
88  LAPACK_COL_MAJOR,
89  morse_lapack_const(uplo),
90  n, A, lda);
91  if(HICMA_get_print_mat() == 1){
92  printf("%d\tpotrf-output\n", __LINE__);
93  _printmat(A, n, n, lda);
94  }
95  if(info != 0){
96  fprintf(stderr, "%s\t|%d\t|Error in LAPACK potrf. info:%d\n", __FILE__, __LINE__, info);
97  if(0) {
98  int p,q;
99  for(p=0; p<n;p++){
100  for(q=0; q<10;q++){
101  printf("%.2e ", A[q*lda+p]);
102  }
103  printf("\n");
104  }
105  //getc(stdin);
106  }
107  exit(1);
108  }
110  gettimeofday (&tvalAfter, NULL);
111  printf("%d-POTRF\t|AD(%d,%d) N:%d LD:%d\t\t\t\t\tPOTRF:%.4f\n",MORSE_My_Mpi_Rank(), Am, An,
112  n, lda,
113  (tvalAfter.tv_sec - tvalBefore.tv_sec)
114  +(tvalAfter.tv_usec - tvalBefore.tv_usec)/1000000.0
115  );
116  }
117  {
118  char datebuf_start[128];
119  time_t timer;
120  struct tm* tm_info;
121  struct tvalAfter;
122  gettimeofday (&tvalAfter, NULL);
123  time(&timer);
124  tm_info = localtime(&timer);
125  //strftime(datebuf_start, 26, "%Y-%m-%d %H:%M:%S",tm_info);
126  //fprintf(stderr, "%s::%d\t", datebuf_start, Am);
127  }
128 
129 }
130 
131 #ifdef CHAMELEON_USE_MAGMA
132 static void cl_zpotrf_hcore_cuda_func(void *descr[], void *cl_arg)
133 {
134  cudaStream_t stream[2], currentt_stream;
135  MORSE_enum uplo;
136  int n;
137  cuDoubleComplex *A;
138  /* cuDoubleComplex *hA; */
139  int lda;
140  int iinfo;
141  int info = 0;
142 
143  A = (cuDoubleComplex *)STARPU_MATRIX_GET_PTR(descr[0]);
144  starpu_codelet_unpack_args(cl_arg, &uplo, &n, &lda, &iinfo);
145 
146  /* /\* */
147  /* * hwork => nb*nb */
148  /* *\/ */
149  /* hA = (cuDoubleComplex *)STARPU_MATRIX_GET_PTR(descr[1]); */
150 
151 /* stream[0] = starpu_cuda_get_local_stream(); */
152 /* if ( cudaStreamCreate( stream+1 ) != CUDA_SUCCESS ){ */
153 /* fprintf(stderr, "Error while creating stream in codelet_zpotrf\n"); */
154 /* exit(-1); */
155 /* } */
156 
157  CUDA_zpotrf( uplo, n, A, lda, &info);
158 
159  cudaThreadSynchronize();
160 /* cudaStreamDestroy( stream[1] ); */
161 
162  return;
163 }
164 #endif
165 #endif /* !defined(CHAMELEON_SIMULATION) */
166 
167 /*
168  * Codelet definition
169  */
170 #if defined CHAMELEON_USE_MAGMA
171 CODELETS(zpotrf_hcore, 1, cl_zpotrf_hcore_cpu_func, cl_zpotrf_hcore_cuda_func, 0)
172 #else
173 CODELETS_CPU(zpotrf_hcore, 1, cl_zpotrf_hcore_cpu_func)
174 #endif
#define A(m, n)
Definition: pzgemm.c:56
time_t timer
struct tm * tm_info
void HICMA_TASK_zpotrf(const MORSE_option_t *options, MORSE_enum uplo, int n, int nb, const MORSE_desc_t *A, int Am, int An, int lda, int iinfo)
int HICMA_get_print_mat()
Definition: hicma_init.c:56
void _printmat(double *A, int m, int n, int ld)
int HICMA_get_print_index_end()
Definition: hicma_init.c:53
int uplo[2]
int HICMA_get_print_index()
Definition: hicma_init.c:50