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, CeedTransposeMode tmode, 46 const double *dU, magma_int_t ustride, double *dV, magma_int_t vstride, 47 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, const double* dinterp1d, 51 const double *dgrad1d, CeedTransposeMode tmode, const double *dU, 52 magma_int_t ustride, double *dV, magma_int_t vstride, magma_int_t batchCount, 53 magma_int_t dim_ctr); 54 55 void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q, magma_int_t dim, 56 const double *dqweight1d, double *dV, magma_int_t vstride, 57 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, const CeedScalar *interp, const CeedScalar *grad, 68 const CeedScalar *qref, const CeedScalar *qweight, CeedBasis basis); 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #define CeedDebug(...) 75 //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__) 76 77 // comment the line below to use the default magma_is_devptr function 78 #define magma_is_devptr magma_isdevptr 79 80 // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value> 81 #ifndef MAGMA_BATCH_STRIDE 82 #define MAGMA_BATCH_STRIDE (1000) 83 #endif 84