xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma.h (revision 7f5b97318525f14c2c6b9e4eb41d4a37b3a25b45)
14444f328STzanio // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
24444f328STzanio // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
34444f328STzanio // reserved. See files LICENSE and NOTICE for details.
44444f328STzanio //
54444f328STzanio // This file is part of CEED, a collection of benchmarks, miniapps, software
64444f328STzanio // libraries and APIs for efficient high-order finite element and spectral
74444f328STzanio // element discretizations for exascale applications. For more information and
84444f328STzanio // source code availability see http://github.com/ceed.
94444f328STzanio //
104444f328STzanio // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
114444f328STzanio // a collaborative effort of two U.S. Department of Energy organizations (Office
124444f328STzanio // of Science and the National Nuclear Security Administration) responsible for
134444f328STzanio // the planning and preparation of a capable exascale ecosystem, including
144444f328STzanio // software, applications, hardware, advanced system engineering and early
154444f328STzanio // testbed platforms, in support of the nation's exascale computing imperative.
164444f328STzanio 
1790104f39SStan Tomov // magma functions specific to ceed
1890104f39SStan Tomov 
19*7f5b9731SStan Tomov #include <string.h>
20d863ab9bSjeremylt #include <ceed-backend.h>
215a9ca9adSVeselin Dobrev #include "magma.h"
225a9ca9adSVeselin Dobrev 
23*7f5b9731SStan Tomov typedef struct {
24*7f5b9731SStan Tomov     CeedScalar *dqref1d;
25*7f5b9731SStan Tomov     CeedScalar *dinterp1d;
26*7f5b9731SStan Tomov     CeedScalar *dgrad1d;
27*7f5b9731SStan Tomov     CeedScalar *dqweight1d;
28*7f5b9731SStan Tomov } CeedBasis_Magma;
29*7f5b9731SStan Tomov 
30*7f5b9731SStan Tomov typedef struct {
31*7f5b9731SStan Tomov   const CeedScalar **inputs;
32*7f5b9731SStan Tomov   CeedScalar **outputs;
33*7f5b9731SStan Tomov   bool setupdone;
34*7f5b9731SStan Tomov } CeedQFunction_Magma;
35*7f5b9731SStan Tomov 
3690104f39SStan Tomov #define USE_MAGMA_BATCH
3797ee337cSStan Tomov #define USE_MAGMA_BATCH2
38*7f5b9731SStan Tomov #define USE_MAGMA_BATCH3
39*7f5b9731SStan Tomov #define USE_MAGMA_BATCH4
4090104f39SStan Tomov 
41*7f5b9731SStan Tomov CEED_INTERN void magma_dtensor_contract(Ceed ceed,
4290104f39SStan Tomov                             CeedInt A, CeedInt B, CeedInt C, CeedInt J,
4390104f39SStan Tomov                             const CeedScalar *t, CeedTransposeMode tmode,
4490104f39SStan Tomov                             const CeedInt Add,
4590104f39SStan Tomov                             const CeedScalar *u, CeedScalar *v);
46f68f2f01STzanio 
47*7f5b9731SStan Tomov #ifdef __cplusplus
48*7f5b9731SStan Tomov CEED_INTERN {
49*7f5b9731SStan Tomov #endif
50*7f5b9731SStan Tomov void
51*7f5b9731SStan Tomov magmablas_dbasis_apply_batched_eval_interp(
52*7f5b9731SStan Tomov     magma_int_t P, magma_int_t Q,
53*7f5b9731SStan Tomov     magma_int_t dim, magma_int_t ncomp,
54*7f5b9731SStan Tomov     const double *dT, CeedTransposeMode tmode,
55*7f5b9731SStan Tomov     const double *dU, magma_int_t ustride,
56*7f5b9731SStan Tomov           double *dV, magma_int_t vstride,
57*7f5b9731SStan Tomov     magma_int_t batchCount );
58*7f5b9731SStan Tomov 
59*7f5b9731SStan Tomov void
60*7f5b9731SStan Tomov magmablas_dbasis_apply_batched_eval_grad(
61*7f5b9731SStan Tomov     magma_int_t P, magma_int_t Q,
62*7f5b9731SStan Tomov     magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt,
63*7f5b9731SStan Tomov     const double* dinterp1d, const double *dgrad1d, CeedTransposeMode tmode,
64*7f5b9731SStan Tomov     const double *dU, magma_int_t ustride,
65*7f5b9731SStan Tomov           double *dV, magma_int_t vstride,
66*7f5b9731SStan Tomov       magma_int_t batchCount,
67*7f5b9731SStan Tomov       magma_int_t dim_ctr );
68*7f5b9731SStan Tomov 
69*7f5b9731SStan Tomov void
70*7f5b9731SStan Tomov magmablas_dbasis_apply_batched_eval_weight(
71*7f5b9731SStan Tomov     magma_int_t Q, magma_int_t dim,
72*7f5b9731SStan Tomov     const double *dqweight1d,
73*7f5b9731SStan Tomov     double *dV, magma_int_t vstride,
74*7f5b9731SStan Tomov     magma_int_t batchCount );
75*7f5b9731SStan Tomov 
76*7f5b9731SStan Tomov magma_int_t
77*7f5b9731SStan Tomov magma_isdevptr( const void* A );
78*7f5b9731SStan Tomov 
79*7f5b9731SStan Tomov CEED_INTERN
80*7f5b9731SStan Tomov int CeedBasisCreateTensorH1_Magma(
81*7f5b9731SStan Tomov     CeedInt dim, CeedInt P1d,
82*7f5b9731SStan Tomov     CeedInt Q1d, const CeedScalar *interp1d,
83*7f5b9731SStan Tomov     const CeedScalar *grad1d,
84*7f5b9731SStan Tomov     const CeedScalar *qref1d,
85*7f5b9731SStan Tomov     const CeedScalar *qweight1d,
86*7f5b9731SStan Tomov     CeedBasis basis);
87*7f5b9731SStan Tomov 
88*7f5b9731SStan Tomov CEED_INTERN
89*7f5b9731SStan Tomov int CeedBasisCreateH1_Magma(
90*7f5b9731SStan Tomov     CeedElemTopology topo,
91*7f5b9731SStan Tomov     CeedInt dim, CeedInt ndof,
92*7f5b9731SStan Tomov     CeedInt nqpts, const CeedScalar *interp,
93*7f5b9731SStan Tomov     const CeedScalar *grad,
94*7f5b9731SStan Tomov     const CeedScalar *qref,
95*7f5b9731SStan Tomov     const CeedScalar *qweight,
96*7f5b9731SStan Tomov     CeedBasis basis);
97*7f5b9731SStan Tomov 
98*7f5b9731SStan Tomov #ifdef __cplusplus
99*7f5b9731SStan Tomov }
100*7f5b9731SStan Tomov #endif
101*7f5b9731SStan Tomov 
102f68f2f01STzanio #define CeedDebug(...)
103*7f5b9731SStan Tomov //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
104*7f5b9731SStan Tomov 
105*7f5b9731SStan Tomov // comment the line below to use the default magma_is_devptr function
106*7f5b9731SStan Tomov #define magma_is_devptr magma_isdevptr
107*7f5b9731SStan Tomov 
108*7f5b9731SStan Tomov // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value>
109*7f5b9731SStan Tomov #ifndef MAGMA_BATCH_STRIDE
110*7f5b9731SStan Tomov #define MAGMA_BATCH_STRIDE (1000)
111*7f5b9731SStan Tomov #endif
112*7f5b9731SStan Tomov 
113