xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma.h (revision d4f681533d27c003962cc7064bd4f4feca6d2274)
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 
417f5b9731SStan Tomov #ifdef __cplusplus
427f5b9731SStan Tomov CEED_INTERN {
437f5b9731SStan Tomov #endif
443513a710Sjeremylt   void magmablas_dbasis_apply_batched_eval_interp(magma_int_t P, magma_int_t Q,
45*d4f68153Sjeremylt       magma_int_t dim, magma_int_t ncomp, const double *dT,
46*d4f68153Sjeremylt       CeedTransposeMode tmode, const double *dU, magma_int_t ustride,
47*d4f68153Sjeremylt       double *dV, magma_int_t vstride, magma_int_t batchCount);
487f5b9731SStan Tomov 
493513a710Sjeremylt   void magmablas_dbasis_apply_batched_eval_grad(magma_int_t P, magma_int_t Q,
50*d4f68153Sjeremylt       magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt,
51*d4f68153Sjeremylt       const double* dinterp1d, const double *dgrad1d, CeedTransposeMode tmode,
52*d4f68153Sjeremylt       const double *dU, magma_int_t ustride, double *dV, magma_int_t vstride,
53*d4f68153Sjeremylt       magma_int_t batchCount, magma_int_t dim_ctr);
547f5b9731SStan Tomov 
55*d4f68153Sjeremylt   void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q,
56*d4f68153Sjeremylt       magma_int_t dim, const double *dqweight1d, double *dV,
57*d4f68153Sjeremylt       magma_int_t vstride, magma_int_t batchCount);
587f5b9731SStan Tomov 
597f5b9731SStan Tomov   magma_int_t
607f5b9731SStan Tomov   magma_isdevptr(const void *A);
617f5b9731SStan Tomov 
623513a710Sjeremylt   CEED_INTERN int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P1d,
633513a710Sjeremylt       CeedInt Q1d, const CeedScalar *interp1d, const CeedScalar *grad1d,
643513a710Sjeremylt       const CeedScalar *qref1d, const CeedScalar *qweight1d, CeedBasis basis);
657f5b9731SStan Tomov 
663513a710Sjeremylt   CEED_INTERN int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim,
67*d4f68153Sjeremylt                                           CeedInt ndof, CeedInt nqpts,
68*d4f68153Sjeremylt                                           const CeedScalar *interp,
69*d4f68153Sjeremylt                                           const CeedScalar *grad,
70*d4f68153Sjeremylt                                           const CeedScalar *qref,
71*d4f68153Sjeremylt                                           const CeedScalar *qweight,
72*d4f68153Sjeremylt                                           CeedBasis basis);
737f5b9731SStan Tomov   #ifdef __cplusplus
747f5b9731SStan Tomov }
757f5b9731SStan Tomov   #endif
767f5b9731SStan Tomov 
77f68f2f01STzanio #define CeedDebug(...)
787f5b9731SStan Tomov //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
797f5b9731SStan Tomov 
807f5b9731SStan Tomov // comment the line below to use the default magma_is_devptr function
817f5b9731SStan Tomov #define magma_is_devptr magma_isdevptr
827f5b9731SStan Tomov 
837f5b9731SStan Tomov // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value>
847f5b9731SStan Tomov #ifndef MAGMA_BATCH_STRIDE
857f5b9731SStan Tomov #define MAGMA_BATCH_STRIDE (1000)
867f5b9731SStan Tomov #endif
87