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 CeedScalar *dqref; 32 CeedScalar *dinterp; 33 CeedScalar *dgrad; 34 CeedScalar *dqweight; 35 } CeedBasisNonTensor_Magma; 36 37 typedef struct { 38 CeedInt *offsets; 39 CeedInt *doffsets; 40 int own_; 41 int down_; // cover a case where we own Device memory 42 } CeedElemRestriction_Magma; 43 44 typedef struct { 45 const CeedScalar **inputs; 46 CeedScalar **outputs; 47 bool setupdone; 48 } CeedQFunction_Magma; 49 50 #define USE_MAGMA_BATCH 51 #define USE_MAGMA_BATCH2 52 #define USE_MAGMA_BATCH3 53 #define USE_MAGMA_BATCH4 54 55 #ifdef __cplusplus 56 CEED_INTERN { 57 #endif 58 void magmablas_dbasis_apply_batched_eval_interp(magma_int_t P, magma_int_t Q, 59 magma_int_t dim, magma_int_t ncomp, 60 const double *dT, CeedTransposeMode tmode, 61 const double *dU, magma_int_t u_elemstride, 62 magma_int_t u_compstride, 63 double *dV, magma_int_t v_elemstride, 64 magma_int_t v_compstride, 65 magma_int_t nelem); 66 67 void magmablas_dbasis_apply_batched_eval_grad(magma_int_t P, magma_int_t Q, 68 magma_int_t dim, magma_int_t ncomp, 69 magma_int_t nqpt, const double* dinterp1d, 70 const double *dgrad1d, CeedTransposeMode tmode, 71 const double *dU, magma_int_t u_elemstride, 72 magma_int_t u_compstride, magma_int_t u_dimstride, 73 double *dV, magma_int_t v_elemstride, 74 magma_int_t v_compstride, magma_int_t v_dimstride, 75 magma_int_t dim_id, magma_int_t nelem); 76 77 void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q, magma_int_t dim, 78 const double *dqweight1d, double *dV, 79 magma_int_t v_elemstride, 80 magma_int_t nelem); 81 82 void magma_weight(magma_int_t grid, magma_int_t threads, magma_int_t nelem, 83 magma_int_t Q, 84 double *dqweight, double *dv); 85 86 void magma_readDofsOffset(const magma_int_t NCOMP, 87 const magma_int_t compstride, 88 const magma_int_t esize, const magma_int_t nelem, 89 magma_int_t *offsets, const double *du, double *dv); 90 91 void magma_readDofsStrided(const magma_int_t NCOMP, const magma_int_t esize, 92 const magma_int_t nelem, magma_int_t *strides, 93 const double *du, double *dv); 94 95 void magma_writeDofsOffset(const magma_int_t NCOMP, 96 const magma_int_t compstride, 97 const magma_int_t esize, const magma_int_t nelem, 98 magma_int_t *offsets,const double *du, double *dv); 99 100 void magma_writeDofsStrided(const magma_int_t NCOMP, const magma_int_t esize, 101 const magma_int_t nelem, magma_int_t *strides, 102 const double *du, double *dv); 103 104 magma_int_t 105 magma_isdevptr(const void *A); 106 107 int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P1d, 108 CeedInt Q1d, 109 const CeedScalar *interp1d, 110 const CeedScalar *grad1d, 111 const CeedScalar *qref1d, 112 const CeedScalar *qweight1d, 113 CeedBasis basis); 114 115 int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim, 116 CeedInt ndof, CeedInt nqpts, 117 const CeedScalar *interp, 118 const CeedScalar *grad, 119 const CeedScalar *qref, 120 const CeedScalar *qweight, 121 CeedBasis basis); 122 123 int CeedElemRestrictionCreate_Magma(CeedMemType mtype, 124 CeedCopyMode cmode, 125 const CeedInt *offsets, 126 CeedElemRestriction r); 127 128 int CeedElemRestrictionCreateBlocked_Magma(const CeedMemType mtype, 129 const CeedCopyMode cmode, 130 const CeedInt *offsets, 131 const CeedElemRestriction res); 132 133 int CeedOperatorCreate_Magma(CeedOperator op); 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #define CeedDebug(...) 140 //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__) 141 142 // comment the line below to use the default magma_is_devptr function 143 #define magma_is_devptr magma_isdevptr 144 145 // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value> 146 #ifndef MAGMA_BATCH_STRIDE 147 #define MAGMA_BATCH_STRIDE (1000) 148 #endif 149