MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
codelet_zpotrf.c
Go to the documentation of this file.
1 
17 #include "morse_starpu.h"
18 
19 /*
20  * Codelet CPU
21  */
22 static void cl_zpotrf_cpu_func(void *descr[], void *cl_arg)
23 {
24  PLASMA_enum uplo;
25  int N;
26  PLASMA_Complex64_t *A;
27  int LDA;
28  int INFO = 0;
29 
30  A = (PLASMA_Complex64_t *)STARPU_MATRIX_GET_PTR(descr[0]);
31 
32  starpu_unpack_cl_args(cl_arg, &uplo, &N, &LDA);
33  INFO = LAPACKE_zpotrf_work(LAPACK_COL_MAJOR, lapack_const(uplo), N, A, LDA);
34 }
35 
36 /*
37  * Codelet Multi-cores
38  */
39 #ifdef MORSE_USE_MULTICORE
40 static void cl_zpotrf_mc_func(void *descr[], void *cl_arg)
41 {
42  int uplo;
43  int N;
44  PLASMA_Complex64_t *A;
45  int LDA;
46  int INFO = 0;
47 
48  A = (PLASMA_Complex64_t *)STARPU_MATRIX_GET_PTR(descr[0]);
49 
50  starpu_unpack_cl_args(cl_arg, &uplo, &N, &LDA);
51  INFO = PLASMA_zpotrf_Lapack(uplo, N, A, LDA);
52 }
53 #else
54 #define cl_zpotrf_mc_func cl_zpotrf_cpu_func
55 #endif
56 
57 /*
58  * Codelet GPU
59  */
60 #ifdef MORSE_USE_CUDA
61 static void cl_zpotrf_cuda_func(void *descr[], void *cl_arg)
62 {
63  int uplo;
64  int N;
65  cuDoubleComplex *A;
66  int LDA;
67  int INFO = 0;
68  int ret;
69 
70  A = (cuDoubleComplex *)STARPU_MATRIX_GET_PTR(descr[0]);
71 
72  starpu_unpack_cl_args(cl_arg, &uplo, &N, &LDA);
73 
74  ret = magma_zpotrf_gpu(
75  plasma_lapack_constants[uplo][0],
76  N, A, LDA, &INFO);
77  if (ret != MAGMA_SUCCESS) {
78  fprintf(stderr, "Error in Magma: %d\n", ret);
79  exit(-1);
80  }
81  cudaThreadSynchronize();
82 }
83 #endif
84 
85 /*
86  * Codelet definition
87  */
88 CODELETS(zpotrf, 1, cl_zpotrf_cpu_func, cl_zpotrf_cuda_func, cl_zpotrf_mc_func)
89 
90 /*
91  * Wrapper
92  */
93 void MORSE_zpotrf( MorseOption_t *option,
94  PLASMA_enum uplo, int n,
95  magma_desc_t *A, int Am, int An, int iinfo)
96 {
97  starpu_codelet *zpotrf_codelet;
98  void (*callback)(void*) = option->profiling ? cl_zpotrf_callback : NULL;
99  int lda = BLKLDD( A, Am );
100 
101 #ifdef MORSE_USE_MULTICORE
102  zpotrf_codelet = option->parallel ? &cl_zpotrf_mc : &cl_zpotrf;
103 #else
104  zpotrf_codelet = &cl_zpotrf;
105 #endif
106 
107  starpu_Insert_Task(zpotrf_codelet,
108  VALUE, &uplo, sizeof(PLASMA_enum),
109  VALUE, &n, sizeof(int),
110  INOUT, BLKADDR( A, PLASMA_Complex64_t, Am, An ),
111  VALUE, &lda, sizeof(int),
112  PRIORITY, option->priority,
113  CALLBACK, callback, NULL,
114  0);
115 
116  /* TODO: take cancellation into account */
117  /* if ( *info != 0 ) */
118  /* return (*info + iinfo); */
119 }