xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma.h (revision d4f681533d27c003962cc7064bd4f4feca6d2274)
1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3 // reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 // magma functions specific to ceed
18 
19 #include <string.h>
20 #include <ceed-backend.h>
21 #include "magma.h"
22 
23 typedef struct {
24   CeedScalar *dqref1d;
25   CeedScalar *dinterp1d;
26   CeedScalar *dgrad1d;
27   CeedScalar *dqweight1d;
28 } CeedBasis_Magma;
29 
30 typedef struct {
31   const CeedScalar **inputs;
32   CeedScalar **outputs;
33   bool setupdone;
34 } CeedQFunction_Magma;
35 
36 #define USE_MAGMA_BATCH
37 #define USE_MAGMA_BATCH2
38 #define USE_MAGMA_BATCH3
39 #define USE_MAGMA_BATCH4
40 
41 #ifdef __cplusplus
42 CEED_INTERN {
43 #endif
44   void magmablas_dbasis_apply_batched_eval_interp(magma_int_t P, magma_int_t Q,
45       magma_int_t dim, magma_int_t ncomp, const double *dT,
46       CeedTransposeMode tmode, const double *dU, magma_int_t ustride,
47       double *dV, magma_int_t vstride, magma_int_t batchCount);
48 
49   void magmablas_dbasis_apply_batched_eval_grad(magma_int_t P, magma_int_t Q,
50       magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt,
51       const double* dinterp1d, const double *dgrad1d, CeedTransposeMode tmode,
52       const double *dU, magma_int_t ustride, double *dV, magma_int_t vstride,
53       magma_int_t batchCount, magma_int_t dim_ctr);
54 
55   void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q,
56       magma_int_t dim, const double *dqweight1d, double *dV,
57       magma_int_t vstride, magma_int_t batchCount);
58 
59   magma_int_t
60   magma_isdevptr(const void *A);
61 
62   CEED_INTERN int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P1d,
63       CeedInt Q1d, const CeedScalar *interp1d, const CeedScalar *grad1d,
64       const CeedScalar *qref1d, const CeedScalar *qweight1d, CeedBasis basis);
65 
66   CEED_INTERN int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim,
67                                           CeedInt ndof, CeedInt nqpts,
68                                           const CeedScalar *interp,
69                                           const CeedScalar *grad,
70                                           const CeedScalar *qref,
71                                           const CeedScalar *qweight,
72                                           CeedBasis basis);
73   #ifdef __cplusplus
74 }
75   #endif
76 
77 #define CeedDebug(...)
78 //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
79 
80 // comment the line below to use the default magma_is_devptr function
81 #define magma_is_devptr magma_isdevptr
82 
83 // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value>
84 #ifndef MAGMA_BATCH_STRIDE
85 #define MAGMA_BATCH_STRIDE (1000)
86 #endif
87