xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma.h (revision 7f5b97318525f14c2c6b9e4eb41d4a37b3a25b45)
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 CEED_INTERN void magma_dtensor_contract(Ceed ceed,
42                             CeedInt A, CeedInt B, CeedInt C, CeedInt J,
43                             const CeedScalar *t, CeedTransposeMode tmode,
44                             const CeedInt Add,
45                             const CeedScalar *u, CeedScalar *v);
46 
47 #ifdef __cplusplus
48 CEED_INTERN {
49 #endif
50 void
51 magmablas_dbasis_apply_batched_eval_interp(
52     magma_int_t P, magma_int_t Q,
53     magma_int_t dim, magma_int_t ncomp,
54     const double *dT, CeedTransposeMode tmode,
55     const double *dU, magma_int_t ustride,
56           double *dV, magma_int_t vstride,
57     magma_int_t batchCount );
58 
59 void
60 magmablas_dbasis_apply_batched_eval_grad(
61     magma_int_t P, magma_int_t Q,
62     magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt,
63     const double* dinterp1d, const double *dgrad1d, CeedTransposeMode tmode,
64     const double *dU, magma_int_t ustride,
65           double *dV, magma_int_t vstride,
66       magma_int_t batchCount,
67       magma_int_t dim_ctr );
68 
69 void
70 magmablas_dbasis_apply_batched_eval_weight(
71     magma_int_t Q, magma_int_t dim,
72     const double *dqweight1d,
73     double *dV, magma_int_t vstride,
74     magma_int_t batchCount );
75 
76 magma_int_t
77 magma_isdevptr( const void* A );
78 
79 CEED_INTERN
80 int CeedBasisCreateTensorH1_Magma(
81     CeedInt dim, CeedInt P1d,
82     CeedInt Q1d, const CeedScalar *interp1d,
83     const CeedScalar *grad1d,
84     const CeedScalar *qref1d,
85     const CeedScalar *qweight1d,
86     CeedBasis basis);
87 
88 CEED_INTERN
89 int CeedBasisCreateH1_Magma(
90     CeedElemTopology topo,
91     CeedInt dim, CeedInt ndof,
92     CeedInt nqpts, const CeedScalar *interp,
93     const CeedScalar *grad,
94     const CeedScalar *qref,
95     const CeedScalar *qweight,
96     CeedBasis basis);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #define CeedDebug(...)
103 //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
104 
105 // comment the line below to use the default magma_is_devptr function
106 #define magma_is_devptr magma_isdevptr
107 
108 // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value>
109 #ifndef MAGMA_BATCH_STRIDE
110 #define MAGMA_BATCH_STRIDE (1000)
111 #endif
112 
113