xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma.h (revision 3513a71063a013a065fe70dec49cba820e0fc134)
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 
197f5b9731SStan Tomov #include <string.h>
20d863ab9bSjeremylt #include <ceed-backend.h>
215a9ca9adSVeselin Dobrev #include "magma.h"
225a9ca9adSVeselin Dobrev 
237f5b9731SStan Tomov typedef struct {
247f5b9731SStan Tomov   CeedScalar *dqref1d;
257f5b9731SStan Tomov   CeedScalar *dinterp1d;
267f5b9731SStan Tomov   CeedScalar *dgrad1d;
277f5b9731SStan Tomov   CeedScalar *dqweight1d;
287f5b9731SStan Tomov } CeedBasis_Magma;
297f5b9731SStan Tomov 
307f5b9731SStan Tomov typedef struct {
317f5b9731SStan Tomov   const CeedScalar **inputs;
327f5b9731SStan Tomov   CeedScalar **outputs;
337f5b9731SStan Tomov   bool setupdone;
347f5b9731SStan Tomov } CeedQFunction_Magma;
357f5b9731SStan Tomov 
3690104f39SStan Tomov #define USE_MAGMA_BATCH
3797ee337cSStan Tomov #define USE_MAGMA_BATCH2
387f5b9731SStan Tomov #define USE_MAGMA_BATCH3
397f5b9731SStan Tomov #define USE_MAGMA_BATCH4
4090104f39SStan Tomov 
41*3513a710Sjeremylt CEED_INTERN void magma_dtensor_contract(Ceed ceed, CeedInt A, CeedInt B,
42*3513a710Sjeremylt                                         CeedInt C, CeedInt J,
43*3513a710Sjeremylt                                         const CeedScalar *t,
44*3513a710Sjeremylt                                         CeedTransposeMode tmode,
45*3513a710Sjeremylt                                         const CeedInt Add, const CeedScalar *u,
46*3513a710Sjeremylt                                         CeedScalar *v);
47f68f2f01STzanio 
487f5b9731SStan Tomov #ifdef __cplusplus
497f5b9731SStan Tomov CEED_INTERN {
507f5b9731SStan Tomov #endif
51*3513a710Sjeremylt void magmablas_dbasis_apply_batched_eval_interp(magma_int_t P, magma_int_t Q,
52*3513a710Sjeremylt   magma_int_t dim, magma_int_t ncomp, const double *dT, CeedTransposeMode tmode,
53*3513a710Sjeremylt   const double *dU, magma_int_t ustride, double *dV, magma_int_t vstride,
547f5b9731SStan Tomov   magma_int_t batchCount);
557f5b9731SStan Tomov 
56*3513a710Sjeremylt void magmablas_dbasis_apply_batched_eval_grad(magma_int_t P, magma_int_t Q,
57*3513a710Sjeremylt   magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt, const double* dinterp1d,
58*3513a710Sjeremylt   const double *dgrad1d, CeedTransposeMode tmode, const double *dU,
59*3513a710Sjeremylt   magma_int_t ustride, double *dV, magma_int_t vstride, magma_int_t batchCount,
607f5b9731SStan Tomov   magma_int_t dim_ctr);
617f5b9731SStan Tomov 
62*3513a710Sjeremylt void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q, magma_int_t dim,
63*3513a710Sjeremylt   const double *dqweight1d, double *dV, magma_int_t vstride,
647f5b9731SStan Tomov   magma_int_t batchCount);
657f5b9731SStan Tomov 
667f5b9731SStan Tomov magma_int_t
677f5b9731SStan Tomov magma_isdevptr(const void *A);
687f5b9731SStan Tomov 
69*3513a710Sjeremylt CEED_INTERN int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P1d,
70*3513a710Sjeremylt   CeedInt Q1d, const CeedScalar *interp1d, const CeedScalar *grad1d,
71*3513a710Sjeremylt   const CeedScalar *qref1d, const CeedScalar *qweight1d, CeedBasis basis);
727f5b9731SStan Tomov 
73*3513a710Sjeremylt CEED_INTERN int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim,
74*3513a710Sjeremylt   CeedInt ndof, CeedInt nqpts, const CeedScalar *interp, const CeedScalar *grad,
75*3513a710Sjeremylt   const CeedScalar *qref, const CeedScalar *qweight, CeedBasis basis);
767f5b9731SStan Tomov 
777f5b9731SStan Tomov #ifdef __cplusplus
787f5b9731SStan Tomov }
797f5b9731SStan Tomov #endif
807f5b9731SStan Tomov 
81f68f2f01STzanio #define CeedDebug(...)
827f5b9731SStan Tomov //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
837f5b9731SStan Tomov 
847f5b9731SStan Tomov // comment the line below to use the default magma_is_devptr function
857f5b9731SStan Tomov #define magma_is_devptr magma_isdevptr
867f5b9731SStan Tomov 
877f5b9731SStan Tomov // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value>
887f5b9731SStan Tomov #ifndef MAGMA_BATCH_STRIDE
897f5b9731SStan Tomov #define MAGMA_BATCH_STRIDE (1000)
907f5b9731SStan Tomov #endif
91